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.
-
-
04/23/2021 at 3:35 PM #167903
Hello, this week was very bad for 5.5l in the short market in live mode. One should perhaps stick to a long and short variant. I am testing the 1min NAS 7.5 again, in any case 5.5l does not work if the market turns short in the long term, which is starting soon or is already there. nice weekend
04/26/2021 at 10:19 AM #168042this week was very bad for 5.5l
Hi, the “L” of V5.5L is for “Long” trade. So it means it’s a good code for long trade only. You can backtest it to observe the results for short and long rates.
1 user thanked author for this post.
04/26/2021 at 3:53 PM #168079Hello, yes i know it’s very good code. I just wanted to say that when the market goes short, what I think will happen soon, the code shouldn’t be used anymore. If you switch the code to long and short, short runs at a loss. Maybe someone has an idea how to get this under control?
05/01/2021 at 9:09 AM #168502Here’s the itf
Hello Noetheless,
I would like to know how you manage the optimization of a code. I mean you can’t walk forward all variable same time with large min / max variable so i would like to know how you manage it.
Thanks
05/01/2021 at 11:36 AM #168504I optimize 2 or 3 variables at a time, at first with large steps for a rough cut, then finer steps once I know what the range is going to be. Or I’ll do 4 – 6 at once, around 3000 iterations and let it run overnight.
I would usually do a rough cut on 100% of data so I can see and compare the results, but I don’t always take the top line (highest gain). If profit is similar I’d rather have a higher % win of more trades, or lower drawdown. Then I run a 70/30 WF with finer steps.
Hope this helps!
4 users thanked author for this post.
05/03/2021 at 11:26 AM #168664Thanks for your answer,
What about when there are MTF ? Do you test lower TF and add higher TF step by step ? There are often too much variables with these sorts of code.
What is “WF” in : Then I run a 70/30 WF with finer steps.
You use 100% data so you mean 1M barres ?
Thanks, it helps a lot in the way to test codes
05/03/2021 at 12:51 PM #168669What about when there are MTF ? Do you test lower TF and add higher TF step by step ?
———When I first developed it I optimized the higher TFs separately to get a longer backtest, but now that I’m fairly confident that it works I do everything on the 2min TF, about 6 years backtest.
What is “WF” in : Then I run a 70/30 WF with finer steps. You use 100% data so you mean 1M barres ?
———WF meaning Walk Forward, but just using one repetition, about 18 months out of sample. Yes, 100% means 1m bars.
1 user thanked author for this post.
05/03/2021 at 5:15 PM #168705Thanks for your answers 🙂
05/10/2021 at 9:17 AM #169230Good morning everyone,
I am running NAS Hull SAR v5.5L in demo and I’ve noticed that it opened positions on may 5th and 6th, but when the positions became positive enough to activate de TS, it did not trigger so I stopped the orders manually, did someone have the same issue?
Moreover, I also tried to BT and it does not return any operation since april 6th (see image attached), does someone have an explanation for that? I also try to BT 10k bars and PRT says its out of date and does not perform the BT.
Thanks everyone in advance!
05/10/2021 at 9:42 AM #16923805/10/2021 at 9:48 AM #16924205/10/2021 at 10:17 AM #16924705/10/2021 at 1:32 PM #169281tss = trailingpercentshort
as this is running long only, it’s irrelevant.
1 user thanked author for this post.
05/13/2021 at 5:59 PM #169602Hiya everyone, today the system opened a position without setting stop loss/take profit. I’m trying to figure out why but am quite clueless.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257/ Main code : NAS 2m HULL-SAR v5.5 L//-------------------------------------------------------------------------// Definition of code parametersDEFPARAM CumulateOrders = true // Cumulating positions activatedDEFPARAM preloadbars = 5000//Money Management NASMM = 1 // = 0 for optimizationif MM = 0 thenpositionsize= 1ENDIFONCE acc = 0.028ONCE acc2 = 0.022ONCE e = 0.025ONCE e1 = 0.02ONCE e2 = 0.02ONCE f = 8ONCE lr = 5.0ONCE ls = 4.0ONCE mp = 5.0ONCE p1 = 170.0ONCE p2 = 17.0ONCE p3 = 5.0ONCE pm = 2.0ONCE q = 0.01ONCE q1 = 0.025ONCE q2 = 0.005ONCE sd = 2.0ONCE sk = 8.0ONCE sl = 1.6ONCE tp = 2.3ONCE tss = 0.2ONCE tst = 0.29ONCE w = 0.015ONCE w1 = 0.005ONCE w2 = 0.005if MM = 1 thenONCE startpositionsize = 0.5ONCE factor = f // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etcONCE margin = (close*.05) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE margin2 = (close*.05)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE tier1 = 200 // IG first tier margin limitONCE maxpositionsize = 2000 // IG tier 2 margin limitONCE minpositionsize = 0.5 // 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 limitENDIFENDIFENDIFENDIFonce tradetype = 2 // [1] long/short [2]long [3]shortonce closeonreversal = 0 // active when tradetype=2 or tradetype=3MaxPos = (pm*positionsize)MaxPos2 = (mp*positionsize)Ctime = time >=143000 and time <210000//UK time//Ctime = time >=153000 and time <220000//Euro timeTIMEFRAME(12 minutes)Perioda= p1innera = 2*weightedaverage[round( Perioda/2)](typicalprice)-weightedaverage[Perioda](typicalprice)HULLa = weightedaverage[round(sqrt(Perioda))](innera)c1 = HULLa > HULLa[1]c2 = HULLa < HULLa[1]ST1 = SAR[q,w,e]c1a = (close > ST1)c2a = (close < ST1)TIMEFRAME(6 minutes)Periodb= p2innerb = 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[q1,w1,e1]c3a = (close > ST2)c4a = (close < ST2)//Stochastic RSI | indicatorlengthRSI = lr //RSI periodlengthStoch = ls //Stochastic periodsmoothK = sk //Smooth signal of stochastic RSIsmoothD = sd //Smooth signal of smoothed stochastic RSImyRSI = 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= p3innerc = 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[q2,w2,e2]c5a = (close > ST3)c6a = (close < ST3)CB = Ctime and c1 and c1a AND C3a and c3b and c3c AND C5a and c5bCB2 = c1 and c1a and c3 and c3a and c5 AND C5aCS = Ctime and c2 and c2a AND C4a and c4b and c4c AND C6a and c6CS2 = c2 and c2a and c4 and c4a and c6 AND C6aIF Not OnMarket THENFlag = 1Flag1 = 1Flag2 = 1Flag3 = 1ENDIF// Conditions to enter long positionsif tradetype=1 or tradetype=2 thenIF not longonmarket and CB and Flag THENBUY positionsize CONTRACT AT MARKETelsif Ctime and longonmarket and CB2 and COUNTOFLONGSHARES < MaxPos and Flag thenBUY positionsize CONTRACT AT MARKETFlag = 0elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag1 thenBUY positionsize CONTRACT AT MARKETFlag1 = 0elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag2 thenBUY positionsize CONTRACT AT MARKETFlag2 = 0elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag3 thenBUY positionsize CONTRACT AT MARKETFlag3 = 0SET STOP %LOSS slSET TARGET %PROFIT tpENDIFENDIFif closeonreversal and tradetype=2 and CS thensell at marketendif// Conditions to enter short positionsif tradetype=1 or tradetype=3 thenIF not shortonmarket and CS THENsellshort positionsize CONTRACT AT MARKETelsif Ctime and shortonmarket and CS2 and COUNTOFSHORTSHARES < MaxPos thensellshort positionsize CONTRACT AT MARKETSET STOP %LOSS 0.6SET TARGET %PROFIT 2.3ENDIFENDIF// %trailing stop function incl. cumulative positionsonce trailingstoptype1= 1if trailingstoptype1 then//====================trailingpercentlong = tst // %trailingpercentshort = tss // %once acceleratorlong = acc // [1] default; always > 0 (i.e. 0.5-3)once acceleratorshort= acc2 // 1 = default; always > 0 (i.e. 0.5-3)ts2sensitivity = 2 // 1 = close 2 = High/Low 3 = Low/High 4 = typicalprice (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*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 = positionpriceendif05/13/2021 at 8:48 PM #169629Try commenting out lines 150-151, then adding these lines at line 154:
1234If not OnMarket thenSET STOP %LOSS slSET TARGET %PROFIT tpEndif4 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on