trailing stop based on higher lows
- This topic has 5 replies, 4 voices, and was last updated 3 years ago by .
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
Similar topics:
Forums › ProRealTime English forum › ProOrder support › trailing stop based on higher lows
hi! Need a little help for an individual stoploss. let’s take a simple setup for an entry condition:
|
1
2
3
4
|
PatternToday = range > 5*PipSize //range = high – low
IF high > high[1] AND PatternToday[1] AND Not OnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
|
now I would like to build a simple, but effective trailing stoploss just like in the image:
any help is much appreciated. Thank you.
There you go:
|
1 2 3 4 5 6 7 8 9 10 11 |
IF Not OnMarket THEN MySL = 0 ENDIF IF MyLongConditions THEN BUY 1 CONTRACT AT Market MySL = low ENDIF IF MySL > 0 THEN MySL = max(MySL,low) SELL AT MySL STOP ENDIF |
Link to code above saved as Log 317 here …
Hi,
Chanced upon this idea and found it to be really useful. I wanted to make some tweaks to it and would greatly appreciate some help to double check if I’ve coded it correctly. If i wanted the stop loss to be at the lows/highs of the previous candle instead of the entry candle and for subsequent candles, to be at the lows/highs of the previous candles as well, is this the correct code for it?
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
IF Not OnMarket THEN MySLl = 0 MySLs = 0 ENDIF IF LONGONMARKET THEN MySLl = low[1] ENDIF IF MySLl > 0 THEN MySLl = max(MySLl,low[1]) SELL AT MySLl STOP ENDIF IF SHORTONMARKET THEN MySLs = high[1] ENDIF IF MySLs > 0 THEN MySLs = min(MySLs,high[1]) BUY AT MySLs STOP ENDIF |
Thanks in advance!
I changed it this way:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
IF Not OnMarket THEN MySLl = 0 MySLs = 999999 ENDIF IF LONGONMARKET AND (close > low[1]) THEN MySLl = max(low[1],MySLl) ENDIF IF MySLl > 0 THEN SELL AT MySLl STOP ENDIF IF SHORTONMARKET AND (close < high[1]) THEN MySLs = min(MySLs,high[1]) ENDIF IF MySLs > 0 THEN BUY AT MySLs STOP ENDIF |
Link to above added as Log 331 here …
Find exclusive trading pro-tools on