MIH8
- ago
Hi all.

I am sure there is a simple solution to what I want to do. Maybe someone can give me the right approach.

After I find an entry, I want to set the TP and SL relative to the entry price. For example, on the ATR of the entry bar like:

TP = PriceEntryBar + 2 x ATR_EntryBar
SL = PriceEntryBar - 1 x ATR_EntryBar

To do this, I would need to know the ATR and the price of the entry bar in the exit block. How can I implement this without coding?
The ATR is used only as an example, so it has not the focus.

I have seen that in the powerpack "Price Compare to Entry Bar" is available as a block, however I have not been able to do it with it.
I also thought of, to work with bar-n informations, but i was not able to find a solution so far.

More general, how can I set a price range for selling with the Blockstrategy that is not only based on points or percentages
(and reference the entry bar) ?


I am sure i miss something :-), thank you in advance.

0
565
Solved
14 Replies

Reply

Bookmark

Sort
- ago
#1
Hi,

You cannot accomplish this with the "Price compare..." condition (it works with a list of predefined Price conditions only). Neither Qualifiers like "N Bars Ago" applied to an Indicator comparison condition would do since the period varies. But it's easily possible to do with C# code.
0
Cone8
 ( 4.98% )
- ago
#3
Actually, I think you can do that with the rules I added to the Power Pack recently. Check the Power Pack rules in the "Exits" section:
Cover/Sell at Limit or Stop At Indicator Value and pick 0 for "Bars before entry".
0
MIH8
- ago
#5
Should it work like that?, because the numebers i can see are not what i would expect.

0
Cone8
 ( 4.98% )
- ago
#6
Has it ever occurred that sometimes what you don't expect is correct?
Please provide an example with a symbol and some numbers, and then I can take a look.
0
Cone8
 ( 4.98% )
- ago
#7
Strike that, I ran an example, and I definitely see something that I don't expect either. We'll work on this one too!

Edit -
Okay, the rule you used threw me off. You need to configure it so that the indicator actually returns the value that you want to exit at. Your rule is just return 2x ATR(5), but that needs to be added to the Close at the Entry bar. We should be able to configure that...
0
Cone8
 ( 4.98% )
- ago
#8
This one comes close, but doesn't have the 2x ATR - it's just ATR(5).



I tried using MathIndOpValue for Indicator2 in MathIndOp, but it seems we run into a limitation nesting those MathIndOp's.
0
Best Answer
MIH8
- ago
#9
Hi Cone, thanks for looking into this. I was expecting that I did something wrong, that's why I asked.

But please let me add one thing. I am confident in your sofware and service. Just great.
This is why I invest time with the software in the first place.

You and probably everyone in your team has been using and programming this software for more than 10 years. You have deep knowledge.

I, on the other hand, have only been working with the software for a few weeks in my spare time, trying to explore all possible corners.
(My wife is not so happy about that ;-)).

I test the software and the functions just extensively and my lack of experience is for this purpose rather advantageous. A handful of topics is certainly not much when exploring this software with all its features. Nevertheless, the discussions raised so far also led to something useful. As long as this is so, both sides have something from it.

So please, take it as it is. Thank you.
0
- ago
#10
As an untested idea for a potential workaround, maybe you could create custom indicators for the ATR multiples using the "New Custom Indicator (C#)" and then get them picked up by the Indicator chooser field in Blocks.
0
MIH8
- ago
#11
Thank you. I will give it a try. But apart from the technical question that came up, I am still interested in how to set price ranges in a general context? Or will this be the general way to handle it?
0
Cone8
 ( 4.98% )
- ago
#12
Blocks are versatile, but have limitations. You can do unlimited customization by editing the C# code.
0
MIH8
- ago
#13
As I said, I am just getting to know the framework. I find it super documented and C# is easy to use in this frame (so far).

Following the content of the thread the question was, how to get the ATRP from entry.
Here is what i did and it seems to work correct. (snippets)

CODE:
private ATRP atrp; public override void Initialize(BarHistory bars) { ...          indicatorATRP = atrp = new ATRP(bars, 1); ...          }


CODE:
    // close positions else {             Position lp = LastPosition;                       // double dbl_atrp = new ATRP(bars,1).Value[0] - how to compute and hold a single value after position opening?             double target_tp = 1.0 + 2.0 * atrp.Values[lp.EntryBar] / 100; //+2%             double target_sl = 1.0 - 1.0 * atrp.Values[lp.EntryBar] / 100; //-1%             double price_tp = target_tp * lp.EntryPrice;             double price_sl = target_sl * lp.EntryPrice;             ClosePosition(lp, OrderType.Limit, price_tp, "Sell at profit target");             ClosePosition(lp, OrderType.Stop, price_sl,"Sell at stop loss"); }


The code contains a comment. Could this also be coded in a more resource friendly way. After all, you only need a value that you have to hold somehow when opening the position. To hold the ATRP values for each index is easy but really necessary?

Actually I wanted to get along without programming. I am sure now there is no way back :-) (as usual)
0
- ago
#14
The series has already been created in Initialize so resources are allocated. But it may be possible to calculate an indicator's value (not all indicators support this method) at entry and assign to some Transaction's property like Tag to be queried later.
0

Reply

Bookmark

Sort