Can anyone please help me with the code/formula to trail my stop into profit along with the SuperTrend line.
I was hoping that ProRealtime would allow me to specify a level for my stop, (i.e. set stop loss 17000), but it looks like that isn’t possible.
Regards
Steve
Of course it is already possible to set a trailing stop on an indicator line, just like the SuperTrend. You have to define the distance between the Close and the indicator to reflect the new stop at each bar, like a dynamic stoploss.
Example :
defparam cumulateorders=false
//indi
st = SuperTrend[3,10]
// case BUY
IF close>st THEN
BUY 1 LOT AT MARKET
ENDIF
SET STOP TRAILING Close-st
As you can see on the picture attached, the stoploss of the buy order is moving correctly with the supertrend line. Hope it helps.
Thanks Nicolas, I’ve tried that, I get an error from the system that the trading system has to be stopped because it tried to put the stop at a negative level (but or sell both give the same error) Any ideas?
If I make an indicator to show the position of the stop loss it will show the correct position, but if I try to use set stop trailing SuperTrend[3,10] then it sets the stop 7200 pips away, so it seems like the system is using some other value for SuperTrend?
Regards
Steve
If Close is above the supertrend and you are in buying conditions, this code should do the trick. But if you are using the same one for short orders, you’ll have negative values indeed! Because SuperTrend is above the price when you sell the instrument. You should use these lines instead in your code :
IF LONGONMARKET THEN
SET STOP TRAILING Close-st
ENDIF
IF SHORTONMARKET THEN
SET STOP TRAILING st-Close
ENDIF
SebParticipant
Average
Unfortunately this method of trailing stop is not effective when I try it:
defparam cumulateorders=false
st = SuperTrend[3,10]
IF close crosses over st THEN
BUY 1 LOT AT MARKET
ENDIF
IF LONGONMARKET THEN
SET STOP TRAILING Close - st
ENDIF
IF close crosses under st THEN
Sellshort 1 LOT AT MARKET
ENDIF
IF SHORTONMARKET THEN
SET STOP TRAILING st - Close
ENDIF