trailing stop based on higher lows
Forums › ProRealTime English forum › ProOrder support › trailing stop based on higher lows
- This topic has 5 replies, 4 voices, and was last updated 1 year ago by GraHal.
-
-
04/04/2022 at 11:33 AM #191155
hi! Need a little help for an individual stoploss. let’s take a simple setup for an entry condition:
1234PatternToday = range > 5*PipSize //range = high – lowIF high > high[1] AND PatternToday[1] AND Not OnMarket THENBUY 1 CONTRACT AT MARKETENDIFnow I would like to build a simple, but effective trailing stoploss just like in the image:
- after the entry, the first stop will be the low of the entry bar
- if the next bar’s low is higher, then this will become the new stoploss level
- if the next bar’s low is not higher, either the old stoploss level will remain, or like in the graphic, it will trigger a sell order
any help is much appreciated. Thank you.
04/04/2022 at 3:54 PM #191186There you go:
1234567891011IF Not OnMarket THENMySL = 0ENDIFIF MyLongConditions THENBUY 1 CONTRACT AT MarketMySL = lowENDIFIF MySL > 0 THENMySL = max(MySL,low)SELL AT MySL STOPENDIF3 users thanked author for this post.
04/04/2022 at 6:54 PM #191196Link to code above saved as Log 317 here …
2 users thanked author for this post.
07/21/2022 at 7:01 PM #197655Hi,
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?
12345678910111213141516171819202122IF Not OnMarket THENMySLl = 0MySLs = 0ENDIFIF LONGONMARKET THENMySLl = low[1]ENDIFIF MySLl > 0 THENMySLl = max(MySLl,low[1])SELL AT MySLl STOPENDIFIF SHORTONMARKET THENMySLs = high[1]ENDIFIF MySLs > 0 THENMySLs = min(MySLs,high[1])BUY AT MySLs STOPENDIFThanks in advance!
07/22/2022 at 12:14 PM #197711I changed it this way:
1234567891011121314151617181920IF Not OnMarket THENMySLl = 0MySLs = 999999ENDIFIF LONGONMARKET AND (close > low[1]) THENMySLl = max(low[1],MySLl)ENDIFIF MySLl > 0 THENSELL AT MySLl STOPENDIFIF SHORTONMARKET AND (close < high[1]) THENMySLs = min(MySLs,high[1])ENDIFIF MySLs > 0 THENBUY AT MySLs STOPENDIF2 users thanked author for this post.
07/22/2022 at 3:20 PM #197718Link to above added as Log 331 here …
2 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on