Trailing distance and start
Forums › ProRealTime English forum › ProOrder support › Trailing distance and start
- This topic has 15 replies, 2 voices, and was last updated 4 years ago by
murre87.
-
-
10/20/2021 at 2:48 PM #18002010/20/2021 at 4:07 PM #180024
You can find one here https://www.prorealcode.com/topic/trailing-stop-and-breakeven-codes/#post-129187, but if you search the forum you can find more snippets.
Look also at the snippet library suggested by Vonasi and regularly updated by GraHal https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit#gid=0.
10/20/2021 at 6:09 PM #18003210/20/2021 at 7:00 PM #180036What distance is it?
10/20/2021 at 7:12 PM #18003710/20/2021 at 8:42 PM #180040Highest compared to what?
10/20/2021 at 8:53 PM #180041Highest closed candle after trailing was started.
Long: Start trailing when 0,1% in profit. Efter this sl moves (trails) with 0,04 % distance to highest price/bar/candle
Short: Start trailing when 0,1% in profit. Efter this sl moves (trails) with 0,04 % distance to lowest price/bar/candle
10/20/2021 at 9:26 PM #180043EMA/RSI123456789101112131415161718192021222324// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = ExponentialAverage[50](high)c1 = (low CROSSES OVER indicator1)Timeframe(4h)filter=RSI[14](close)timeframe(default)IF c1 AND filter<70 THENBUY 1 CONTRACT AT MARKETSET STOP %LOSS 0.05ENDIF//Help with trail//TrailStart = 0.1% //0.1 Start trailing when 0,1% in profit//Trailing distance = 0.04% //0.04 stoploss resets and is placed 0,04 % distance to highest price/bar/candle//Long: Start trailing when 0,1% in profit. Efter this sl moves (trails) with 0,04 % distance to highest price/bar/candle//Short: Start trailing when 0,1% in profit. Efter this sl moves (trails) with 0,04 % distance to lowest price/bar/candle10/21/2021 at 9:12 AM #18005810/21/2021 at 5:34 PM #180114What are the rules why both the green and red rectangle are drawn there?
Which is the highest candle you want to refer to?
0.04% needs to be calculated from which point? up to… ?
10/21/2021 at 6:16 PM #180119This might be better?
TP: set up 0.1% from entryWork with SL: If the trend continues and the trade exceeds 0.06%, SL is moved up / down by 0.04% for at least the breakeven.If the trend continues and breaks TP 0.1, TP is moved 0.1%, so new TP becomes 0.2% from original entry and SL is moved up to 0.1%.After that, work with trailing SL 0.1% up / down until it is broken and then you take a profit.Clarification: only candle close so that you do not let go of wicks.10/23/2021 at 8:27 AM #18020910/23/2021 at 8:47 AM #180211Yes, I’ll make it asap.
10/23/2021 at 10:37 AM #18021510/23/2021 at 11:19 AM #180226There you go:
123456789101112131415161718192021222324252627282930313233343536IF Not OnMarket THENMyStop = 0Entry = 0ENDIFIF close crosses over average[100,0](close) AND Not OnMarket THENBUY 1 CONTRACT AT MARKETSET STOP %LOSS 1.0Entry = closeENDIFTP = 1.0 / 100 //1.0%TrailStart = 0.6 / 100 //0.6%Trailingdistance = 0.2 / 100 //0.2%IF OnMarket AND Not OnMarket[1] THENEntry = TradePriceENDIFIF OnMarket THENIF MyStop = 0 THENIF close >= (Entry + (Entry * TrailStart)) THENMyStop = Entry + (Entry * Trailingdistance)ENDIFELSEIF close >= (MyStop + (Entry * TP)) THENMyStop = MyStop + (Entry * TP)ENDIFENDIFIF MyStop > 0 THENSELL AT MyStop STOPENDIFENDIFgraphonprice Entrygraphonprice Entry + (Entry * TP) coloured(0,0,255,255)graphonprice MyStop coloured(255,0,0,255)I tested it on DAX, 15min.
I changed percentages a little bit to ber able to test it better. -
AuthorPosts
Find exclusive trading pro-tools on