NAS 2m HULL-SAR trading system
Forums › ProRealTime English forum › ProOrder support › NAS 2m HULL-SAR trading system
- This topic has 343 replies, 42 voices, and was last updated 1 year ago by bege.
-
-
08/15/2021 at 6:34 PM #17539808/15/2021 at 7:03 PM #175399
DJ 1m HULL-SAR v7.5 L
DJ 1m HULL-SAR v7.5 L123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215//-------------------------------------------------------------------------// Main code : DJ 1m HULL-SAR v7.5 L//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Main code : DJ 1m HULL-SAR v7.5 L//-------------------------------------------------------------------------// Definition of code parametersDEFPARAM CumulateOrders = true // Cumulating positions deactivatedDEFPARAM preloadbars = 5000//Money Management DJONCE p1 = 80.0ONCE st11 = 0.005ONCE st12 = 0.01ONCE st13 = 0.01ONCE p2 = 14.0ONCE st21 = 0.005ONCE st22 = 0.015ONCE st23 = 0.005ONCE rsip = 14.0ONCE stp = 17.0ONCE stk = 7.0ONCE p3 = 4.0ONCE st31 = 0.02ONCE st32 = 0.015ONCE st33 = 0.015MM = 0 // = 0 for optimizationif MM = 0 thenpositionsize=0.3ENDIFif MM = 1 thenONCE startpositionsize = .2ONCE factor = 20 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etcONCE margin = (close*.008) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE margin2 = (close*.01)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE tier1 = 55 // IG first tier margin limitONCE maxpositionsize = 550 // IG tier 2 margin limitONCE minpositionsize = .2 // enter minimum position allowedIF StrategyProfit <> StrategyProfit[1] THENpositionsize = startpositionsize + Strategyprofit/(factor*margin)ENDIFIF StrategyProfit <> StrategyProfit[1] THENIF startpositionsize + Strategyprofit/(factor*margin) > tier1 thenpositionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 //incorporating tier 2 marginENDIFIF StrategyProfit <> StrategyProfit[1] THENif startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THENpositionsize = minpositionsize //keeps positionsize from going below allowed minimumENDIFIF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 > maxpositionsize thenpositionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limitENDIFENDIFENDIFENDIFCtime = time >=153000 and time <220000TIMEFRAME(15 minutes)Period= p1 //105inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice)HULLa = weightedaverage[round(sqrt(Period))](inner)c1 = HULLa > HULLa[1] or HULLb > HULLac2 = HULLa < HULLa[1] or HULLb < HULLaST1 = SAR[st11,st12,st13] //0.01, 0.015, 0.015c1a = (close > ST1)c2a = (close < ST1)TIMEFRAME(5 minutes)Periodb= p2 //20innerb = 2*weightedaverage[round( Periodb/2)](typicalprice)-weightedaverage[Periodb](typicalprice)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c3 = HULLb > HULLb[1]c4 = HULLb < HULLb[1]c3b = HULLb > HULLb[1] and HULLb[1] < HULLb[2]c4b = HULLb < HULLb[1] and HULLb[1] > HULLb[2]ST2 = SAR[st21,st22,st23] // 0.005, 0.015, 0.005c3a = (close > ST2)c4a = (close < ST2)//Stochastic RSI | indicatorlengthRSI = rsip //RSI period 15lengthStoch = stp //Stochastic period 14smoothK = stk //Smooth signal of stochastic RSI 7smoothD = std //Smooth signal of smoothed stochastic RSI 3myRSI = RSI[lengthRSI](close)MinRSI = lowest[lengthStoch](myrsi)MaxRSI = highest[lengthStoch](myrsi)StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)K = average[smoothK](stochrsi)*100D = average[smoothD](K)c3c = K>Dc4c = K<DTIMEFRAME(default)Periodc= p3 //4innerc = 2*weightedaverage[round( Periodc/2)](typicalprice)-weightedaverage[Periodc](typicalprice)HULLc = weightedaverage[round(sqrt(Periodc))](innerc)c5 = HULLc > HULLc[1] and HULLc[1] < HULLc[2]c6 = HULLc < HULLc[1] and HULLc[1] > HULLc[2]c5b = HULLc > HULLc[1]c6b = HULLc < HULLc[1]ST3 = SAR[st31,st32,st33] //0.02, 0.015, 0.015c5a = (close > ST3)c6a = (close < ST3)Once MaxPositionsAllowed = 1*positionsize// Conditions to enter long positionsIF not longonmarket and Ctime and c1 and c1a AND C3a and c3b and c3c AND C5a and c5b THENBUY positionsize CONTRACT AT MARKETelsif longonmarket and Ctime and c1 and c1a and c3 and c3a and c5 and COUNTOFLONGSHARES < MaxPositionsAllowed thenBUY positionsize CONTRACT AT MARKETSET STOP %LOSS 1.1SET TARGET %PROFIT 1.6ENDIF// Conditions to enter short positionsIF not shortonmarket and Ctime and c2 and c2a AND C4a and c4b and c4c AND C6a and c6b THENsellshort positionsize*0 CONTRACT AT MARKETelsif shortonmarket and Ctime and c2 and c2a and c4 and c4a and c6 and COUNTOFSHORTSHARES < MaxPositionsAllowed thensellshort positionsize*0 CONTRACT AT MARKETSET STOP %LOSS 1SET TARGET %PROFIT 1.4ENDIF// %trailing stop function incl. cumulative positionsonce trailingstoptype = 1if trailingstoptype then//====================once trailingpercentlong = 0.35 // %once trailingpercentshort = 0.38 // %once accelerator = 0.03 // 1 = default; always > 0 (i.e. 0.5-3)once accelerator2 = 0.1 // 1 = default; always > 0 (i.e. 0.5-3)once ts2sensitivity = 0 // [0]close;[1]high/low;[2]low;high//====================once steppercentlong = (trailingpercentlong/10)*acceleratoronce steppercentshort = (trailingpercentshort/10)*accelerator2if onmarket thentrailingstartlong = positionprice[1]*(trailingpercentlong/100)trailingstartshort = positionprice[1]*(trailingpercentshort/100)trailingsteplong = positionprice[1]*(steppercentlong/100)trailingstepshort = positionprice[1]*(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=hights2sensitivityshort=lowelsif ts2sensitivity=2 thents2sensitivitylong=lowts2sensitivityshort=highelsets2sensitivitylong=closets2sensitivityshort=closeendifif 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*pipsizeendifendifif 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 marketendifendifendifendifmypositionprice = positionpriceendif08/15/2021 at 7:31 PM #17540308/15/2021 at 11:12 PM #17541508/16/2021 at 7:26 AM #17542408/16/2021 at 9:31 AM #17543908/16/2021 at 9:40 AM #175442I dont remeber witch one i started but choose one on DJ-1.. from “View all attachments”
08/16/2021 at 10:20 AM #175447We assumed the version you posted the full code for above is the version that works for you (in ProOrder) with no errors … are you now saying this is not the case?
Have you got DJ 1m HULL-SAR v7.5 L runnng in ProOrder murre87?
08/16/2021 at 10:28 AM #175448this is the 1m bar backtest of DJ 1m HULL-SAR v7.5 Lg (as posted here Free profitable strategies )
It looks like a variation of a code that i built in v10.3 on a 200k backtest but rejected after v11 came along. Then someone else made alterations to it and errors have been introduced.
I’ll have a look at it when I get a chance but frankly it looks like a dog to me and probably not worth it.
The code that Murre87 has posted above as DJ 1m HULL-SAR v7.5 L looks like a re-optimisation with max positions = 1
Does that also give errors?
2 users thanked author for this post.
08/16/2021 at 11:22 AM #175451Murre87 has posted above as DJ 1m HULL-SAR v7.5 L
Yes the above version gives a Line 24 error (but doubt it is LIne 24, see my screenshot above) when trying to start on ProOrder.
08/16/2021 at 11:44 AM #175460Ok, one problem I just noticed is in the stochasticRSI:
1smoothD = std //Smooth signal of smoothed stochastic RSI 3std is a reserved term for standard deviation (also sexually transmitted disease), so can’t be used as a variable. Try changing this to sd (or anything else) and re-run the optimisation. Using std there will completely warp the results.
2 users thanked author for this post.
08/16/2021 at 1:37 PM #175466problem number 2
12345678// Conditions to enter long positionsIF not longonmarket and Ctime and c1 and c1a AND C3a and c3b and c3c AND C5a and c5b THENBUY positionsize CONTRACT AT MARKETelsif longonmarket and Ctime and c1 and c1a and c3 and c3a and c5 and COUNTOFLONGSHARES < MaxPositionsAllowed thenBUY positionsize CONTRACT AT MARKETSET STOP %LOSS 1.1SET TARGET %PROFIT 1.6ENDIFThe stop and target are in the elsif command for additional positions, but because MaxPositionsAllowed = 1 the elsif never happens, so the stop never registers. This is why it appears to be so successful, positions just stay open until they get into profit – sometimes for months with massive drawdown. If you want to run it with MaxPositionsAllowed = 1 (or CumulateOrders = false) then the elsif should be removed, or try:
1234567891011// Conditions to enter long positionsIF not longonmarket and Ctime and c1 and c1a AND C3a and c3b and c3c AND C5a and c5b THENBUY positionsize CONTRACT AT MARKETelsif longonmarket and Ctime and c1 and c1a and c3 and c3a and c5 and COUNTOFLONGSHARES < MaxPositionsAllowed thenBUY positionsize CONTRACT AT MARKETENDIFIF longonmarket thenSET STOP %LOSS 1.1SET TARGET %PROFIT 1.6endif2 users thanked author for this post.
08/17/2021 at 11:33 AM #17553101/09/2023 at 9:54 PM #207136 -
AuthorPosts
Find exclusive trading pro-tools on