New strategy template
Forums › ProRealTime English forum › ProOrder support › New strategy template
- This topic has 35 replies, 10 voices, and was last updated 3 years ago by
Chrisinobi.
-
-
05/17/2021 at 1:44 PM #169896
Hi palettofix, thanks for that – your suggestion makes perfect sense. In fact I recently tried making that same change, but it gave me an unexpected result in tests so I left it with the full calculation each time – even though it looks like it should be unnecessary.
01/19/2022 at 9:20 AM #185900nonetheless
Good morning Nonetheless, Thank you very much for this valuable contribution. I’m wondering is line 139 shouldn’t read “>=” rather than “<=”
Thanks
01/19/2022 at 12:39 PM #185909yes, you’re right, that looks like a typo – sorry!
This is the version of that snippet I now use – sets a max number of bars whether the position is winning or losing.
12345678910//EXIT ZOMBIE TRADEEZT = 1if EZT thenIF (longonmarket and barindex-tradeindex(1)>= b1 and positionperf>0) or (longonmarket and barindex-tradeindex(1)>= b2 and positionperf<0) thensell at marketendifIF (shortonmarket and barindex-tradeindex(1)>= b3 and positionperf>0) or (shortonmarket and barindex-tradeindex(1)>= b4 and positionperf<0) thenexitshort at marketendifendif1 user thanked author for this post.
01/19/2022 at 1:04 PM #18591301/19/2022 at 1:21 PM #185916Actually that was already corrected in the later versions – v5 for example.
but looking at that template, the main thing I would change is the Money Management. This is the one I’m now using, although there are many others in the Snippet library.
1234567891011121314151617181920//MONEY MANAGEMENT DAX IIMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize = 0.5ENDIFif MM thenMinSize = 0.5 // IG minimum position size allowedMaxSize = 1050 // IG tier 2 margin limitProfitAccrued = 0 // when restarting strategy, enter profit or loss to date in instrument currencyDD = dd //MinSize drawdown in instrument currencyMultiplier = 3 //drawdown multiplierCapital = DD * MultiplierEquity = Capital + ProfitAccrued + StrategyProfitPositionSize = Max(MinSize, Equity * (MinSize/Capital))if positionsize > MaxSize thenpositionsize = MaxSizeendifPositionSize = Round(PositionSize*100)PositionSize = PositionSize/100ENDIF2 users thanked author for this post.
01/19/2022 at 1:23 PM #18591801/21/2022 at 1:09 PM #186179Hi nonetheless,
I’m running tests on this simple strategy to better get grasp on how your BE/TrailingStop work. The code is below. It’s tested on DJ on 1 min chart (10k). The issue I’ve is after multiple runs of optimization, there are a few trades where the actual performance is way below the MFE, a few other reach a decent positive MFE and then end up negative.
I wonder if you can give me some advice on how to reduce the difference between MFE and actual performance and how to avoid finishing red after making 30pts positive. Do you use in your live systems a sort of staged parameters for each level of profit for example (eg. if positionperf >30 and <100 then tsl = x1 and tss=y1 // if positionperf >100 and <200 then tsl = x2 and tss=y2, etc.)?
Thanks
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242//-------------------------------------------------------------------------// Code principal : MonSystème(136)//-------------------------------------------------------------------------DEFPARAM CUMULATEORDERS = FALSEDEFPARAM PRELOADBARS = 2000ONCE SL = 0.6ONCE TPL = 0.6ONCE TPS = 1.4ONCE acceleratorlong = 0.3ONCE acceleratorshort = 0.24ONCE besensitivity = 1.0ONCE besg = 0.01ONCE besl = 0.01ONCE ts2sensitivity = 3.0ONCE tsl = 0.13ONCE tss = 0.06TIMEFRAME(60 minutes)TrendUpH1 = close>open and close>close[1]TrendDnH1 = close<open and close<close[1]TIMEFRAME(5 minutes, UPDATEONCLOSE)ca=0cv=0TrendUpM15 = close>open and close>close[1]TrendDnM15 = close<open and close<close[1]p = 12q = 26r = 9z1=DEMA[p](close)z2 =dema[q](close)e= z1 - z2z3=DEMA[r](e)f=z3g=e-fca1 = e < 0 and g>0cv1 = e > 0 and g<0ca = TrendUpM15 and TrendUpH1 and ca1cv = TrendDnM15 and TrendDnH1 and cv1TIMEFRAME(DEFAULT)nLots = 1IF NOT LongOnMarket AND ca THENBUY nLots CONTRACTS AT MARKETENDIFIF NOT ShortOnMarket AND cv THENSELLSHORT nLots CONTRACTS AT MARKETENDIFIf LongOnMarket AND (cv) THENSELL AT MARKETSELLSHORT nLots CONTRACTS AT MARKETENDIFIF ShortOnMarket AND (ca) THENEXITSHORT AT MARKETBUY nLots CONTRACTS AT MARKETENDIF/////////////////////////////////Breakeven 2///////////////////////////////////if POSITIONPERF>=(100)*pipsize thenenableBreakEven =1// break even stop incl. cumulative positionsif enableBreakEven then//====================//once besg = be //% break even stop gain//once besl = bes //% break even stop level (+ or -)//besensitivity = 2 // 1 = close 2 = High/Low 3 = Low/High 4 = typicalprice (do not use once)//====================if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thenbenewsl=0mypositionpricebe = 0endifpositioncountbe = abs(countofposition)if benewsl > 0 thenif positioncountbe > positioncountbe[1] thenif longonmarket thenbenewsl = max(benewsl,positionprice * benewsl / mypositionpricebe)elsebenewsl = min(benewsl,positionprice * benewsl / mypositionpricebe)endifendifendifif besensitivity=1 thenbesensitivitylong=closebesensitivityshort=closeelsif besensitivity=2 thenbesensitivitylong=highbesensitivityshort=lowelsif besensitivity=3 thenbesensitivitylong=lowbesensitivityshort=highendifif longonmarket thenif besensitivitylong-positionprice>=((positionprice/100)*besg)*pointsize thenbenewsl=positionprice+((positionprice/100)*besl)*pointsizeendifendifif shortonmarket thenif positionprice-besensitivityshort>=((positionprice/100)*besg)*pointsize thenbenewsl=positionprice-((positionprice/100)*besl)*pointsizeendifendifendifmypositionpricebe = positionpriceif barindex-tradeindex>1 thenif longonmarket thenif benewsl>0 thensell at benewsl stopendifif benewsl>0 thenif low crosses under benewsl thensell at marketendifendifendifif shortonmarket thenif benewsl>0 thenexitshort at benewsl stopendifif benewsl>0 thenif high crosses over benewsl thenexitshort at marketendifendifendifendifendif/////////////////////////////////Trailing Stop///////////////////////////////////trailingstopPC = 1//endif// Percentage trailing stop function incl. cumulative positionsif trailingstopPC thentrailingpercentlong = tsl // %trailingpercentshort = tss // %//once acceleratorlong = tsl/10 //a1 // always > 0 (typically TSL/10)//once acceleratorshort= tss/10 //a2 // always > 0 (typically TSS/10)//ts2sensitivity = 2 // 1 = close 2 = High/Low 3 = Low/High 4 = typicalprice (do not use once)//====================once steppercentlong = (trailingpercentlong/10)*acceleratorlongonce steppercentshort = (trailingpercentshort/10)*acceleratorshortif onmarket thentrailingstartlong = positionprice*(trailingpercentlong/100)trailingstartshort = positionprice*(trailingpercentshort/100)trailingsteplong = positionprice*(steppercentlong/100)trailingstepshort = positionprice*(steppercentshort/100)endifif not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thennewsl = 0mypositionprice = 0endifpositioncount = abs(countofposition)if newsl > 0 thenif positioncount > positioncount[1] thenif longonmarket thennewsl = max(newsl,positionprice * newsl / mypositionprice)elsenewsl = min(newsl,positionprice * newsl / mypositionprice)endifendifendifif ts2sensitivity=1 thents2sensitivitylong=closets2sensitivityshort=closeelsif ts2sensitivity=2 thents2sensitivitylong=hights2sensitivityshort=lowelsif ts2sensitivity=3 thents2sensitivitylong=lowts2sensitivityshort=highelsif ts2sensitivity=4 thents2sensitivitylong=typicalpricets2sensitivityshort=typicalpriceendifif longonmarket thenif newsl=0 and ts2sensitivitylong-positionprice>=trailingstartlong*pipsize thennewsl = positionprice+trailingsteplong*pipsizeendifif newsl>0 and ts2sensitivitylong-newsl>=trailingsteplong*pipsize thennewsl = newsl+trailingsteplong*pipsizeendifendifif shortonmarket thenif newsl=0 and positionprice-ts2sensitivityshort>=trailingstartshort*pipsize thennewsl = positionprice-trailingstepshort*pipsizeendifif newsl>0 and newsl-ts2sensitivityshort>=trailingstepshort*pipsize thennewsl = newsl-trailingstepshort*pipsizeendifendifmypositionprice = positionpriceendifif barindex-tradeindex>1 thenif longonmarket thenif newsl>0 thensell at newsl stopendifif newsl>0 thenif low crosses under newsl thensell at marketendifendifendifif shortonmarket thenif newsl>0 thenexitshort at newsl stopendifif newsl>0 thenif high crosses over newsl thenexitshort at marketendifendifendifendifif longonmarket thenSET TARGET %PROFIT TPLelsif shortonmarket thenSET TARGET %PROFIT TPSendifSET STOP %LOSS SL01/21/2022 at 1:52 PM #186187Hi Khaled, without looking at the actual strategy, the first thing i notice is that using breakeven with that trail is an odd choice as the % trail already has a breakeven
(compare lines 108-115 with lines 195 – 200)
I only use the breakeven code in conjunction with the ATR trail, which does not have that component.
But even in that case, using besg = 0.01 would be impossible on the DJ as that would be only 3.5 points. The IG minimum is 10.
Lastly, ts2sensitivity = 3 is also an odd choice as that means that the low of the candle has to be above the breakeven level (when long). This is the hardest combination to achieve, esp with your settings means a v long wait for the trail to start. I normally use 2, (high/low)
1 user thanked author for this post.
01/21/2022 at 2:02 PM #186188esp with your settings means a v long wait for the trail to start
actually when i wrote that, I had mistaken your tpl/tps values for tsl/tss … but I would still recommend using ts2sensitivity = 2 (without the breakeven)
1 user thanked author for this post.
01/21/2022 at 2:10 PM #18618901/21/2022 at 2:17 PM #186190sensitivity = 3 was the result of the backtest
you mean you optimized it, with values 1 – 4 ?
01/21/2022 at 2:20 PM #18619101/27/2022 at 2:13 PM #186731@nonetheless , I am learning and developing a few strategies and robertogozzi, Nicolas, GraHal have been helping me over the last few weeks. Very keen to get my strategy working on PRT and I hope to go through your template and adopt the code where relevant, test them and feedback. I appreciate that you are sharing this template to help new members.
1 user thanked author for this post.
01/28/2022 at 5:12 PM #18686201/28/2022 at 6:53 PM #186874@micquan, As I mentioned in my previous post, it was a test to check and understand how the Trailing Stop shared by nonetheless works. I didn’t update this particular “simple” strategy, as I’ll not use it. If you don’t get the same results, may be you didn’t use same TF or not same dates (start/end) or may be you picked the Dow 1pound, while I used Dow 1 euro. The idea behind my post was to understand why there is a big gap between actual performance and MFE and nonetheless explained that I was using two times breakeven system together with inappropriate choice of ts2sensitivity option.
Happy to discuss further and/or to help testing an idea.
-
AuthorPosts
Find exclusive trading pro-tools on