How to set SL same as TP? Without using MM?
2 replies
Julianrob
9 years ago #113080
Hi.
I’ve been using a formula to get my stop loss which works well.
But I’d like to copy that distance in pips for my TP, however I can’t see how to do it. I tried using MM but had some trouble. I also tried for example for long trades;
TP; ((Order open price (1000) – Order stop loss (1000)) + (Order open price (1000)))
Any help would be appreciated, thanks
Julian
Mark Fric
9 years ago #128251
Julian, it wouldn’t work like this. The problem is that functions OrderOpenPrice() and OrderStopLoss() will return correct values only after the order is already opened.
But you call them as the order is opening, they’ll return zeroes.
But it can be easily made using variables.
Define a new double type variable which you’ll use to compute SL.
In THEN action first use Assign Variable to compute SL value and then store it into this variable.
Then add new Enter at Market/Stop/Limit action and use this variable (or formula based on it) for SL and PT.
Mark
StrategyQuant architect
Julianrob
9 years ago #128261
Thanks Mark.
I think I get what you’re saying. I found someone else in the forum with a similar issue, in which you described a possible solution, so I adapted it myself and came up with this which works well:
For long trades: PT= (open (0)) – (Min(low[2],low[1])) + ((ConvertToRealPips) (TakeProfitBuffer))
Where TakeProfitBuffer is a variable I created, default set to 2, or same value as stop loss buffer, 2 pips away from the lowest of the last 2 lows.
The same kind of thing can also be used to compute activate trailing stop value, works well 🙂
Viewing 2 replies - 1 through 2 (of 2 total)