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/14/2021 at 3:09 PM #167063
It may be that the code needs an extra Endif adding as the last line of the code?
Thanks, i will try.
That’s curious it works on backtest but not in autotrading.
I will tell back
04/14/2021 at 3:13 PM #167065You can’t launch the system in autotrading because there are variables in the optimization boxes; you have first to define the values through the code, delete the optimization boxes and then you can run it.
I don’t think i have to do it with the last version of prorealtime V11.
The problem doesn’t come from it in my opinion
I have v11 and can’t run it for the problem i mentioned you
04/14/2021 at 3:39 PM #167067NIK 1m Hull-SAR
Hello everyone
Thank you very much for this good basic strategy. I ask for your indulgence and understanding, because I am still a beginner, do not speak English and work with a translator!
I do a test and optimization with Nikkei, with good results (see appendix). It doesn’t run live for very long and keeps getting error messages (see appendix). During the American trading hours it runs for 4 to 5 hours and a profit trade has already been achieved, but I need your help. How to get the algorithm stable, without error message and shutdown. On Nasdaq, things are going better but not perfect either, with 2 to 3 errors a week (always live).
– Error 1: Division by zero – what protections are there? That’s why I use MTF 5min over 7min to 22min total runs on 1min.
– Error 2: Historical data is not sufficient?
Ask for your help. I think the algorithm has potential. What is your opinion on this?
One more general question at the end. Can algorithms, after hundreds of hours of invested work, win in the long run? When will the marketplace come? ( I have at the moment 10 Algo live, of which 5 for rent )
Once again, pay tribute to your work!
Here are the .itf and pictures.
Thank you for your comment and help.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194// Definition of code parametersDEFPARAM CumulateOrders = true // Cumulating positions deactivatedDEFPARAM preloadbars = 10000//Money Management NASMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize=0.5ENDIFif MM = 1 thenONCE startpositionsize = 0.5ONCE factor = 6 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etcONCE margin = (close*.005) // 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 = 200 // IG first tier margin limitONCE maxpositionsize = 2000 // IG tier 2 margin limitONCE minpositionsize = .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 limitENDIFENDIFENDIFENDIFCtime = time >=103000 and time <211400TIMEFRAME(22 minutes)Period= 80inner = 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[0.02,0.015,0.025]c1a = (close > ST1)c2a = (close < ST1)TIMEFRAME(7 minutes)Periodb= 17innerb = 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[0.015,0.015,0.02]c3a = (close > ST2)c4a = (close < ST2)//Stochastic RSI | indicatorlengthRSI = 3 //RSI periodlengthStoch = 3 //Stochastic periodsmoothK = 6 //Smooth signal of stochastic RSIsmoothD = 4 //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(5 minutes)Periodc= 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[0.005,0.015,0.015]c5a = (close > ST3)c6a = (close < ST3)TIMEFRAME(default)Once MaxPositionsAllowed = 5*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.6SET TARGET %PROFIT 1.4ENDIF// 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 CONTRACT AT MARKETelsif shortonmarket and Ctime and c2 and c2a and c4 and c4a and c6 and COUNTOFSHORTSHARES < MaxPositionsAllowed thensellshort positionsize CONTRACT AT MARKETSET STOP %LOSS 1.2SET TARGET %PROFIT 1.7ENDIF// %trailing stop function incl. cumulative positionsonce trailingstoptype = 1if trailingstoptype then//====================once trailingpercentlong = 0.47 // %once trailingpercentshort = 0.56 // %once accelerator = 0.095 // 1 = default; always > 0 (i.e. 0.5-3)once accelerator2 = 0.31 // 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 = positionpriceendif1 user thanked author for this post.
04/14/2021 at 5:48 PM #167078You can’t launch the system in autotrading because there are variables in the optimization boxes; you have first to define the values through the code, delete the optimization boxes and then you can run it.
In v11 you can launch it like this (or should be able to do that). PRT changed my values to 17 decimal places as described in #165505. I have made a copy with fixed values in the code instead but then I get “Division by zero”.
04/14/2021 at 5:49 PM #167079You can’t launch the system in autotrading because there are variables in the optimization boxes; you have first to define the values through the code, delete the optimization boxes and then you can run it.
I don’t think i have to do it with the last version of prorealtime V11.
The problem doesn’t come from it in my opinion
I have v11 and can’t run it for the problem i mentioned you
The problem is line 2. There must not exist any blank lines before the defparam lines. Remove the line or put // into it.
The error message is confusing.
04/14/2021 at 5:51 PM #167080Hi, thanks for that, I would not normally have tried working with the Nikkei because the spread is so high.
This is a good start but you’ve got various problems:
first, it’s optimized on very little data so it really only works from July 2020, before that it’s a bust – sorry!
Also, you’ve changed the logic of the original. The idea is that it enters when the middle TF (ie 6 min) changes direction, then adds subsequent positions when the fast TF (2min) dips. You have it entering at the 7min level and adding at the 5min level, where there’s hardly any difference between the two.
If you really want to make a version for Japan 225 (although personally I think the spread is a killer), I would stick to the original 2min structure (v5.5) which is tried and tested and you’ll get twice as much data to work with.
As for the NAS version, I’ve been running it live for many months and never had a div/zero problem. No idea why you would get that error. Are you running the most recent version?
1 user thanked author for this post.
04/14/2021 at 5:54 PM #167082It may be that the code needs an extra Endif adding as the last line of the code?
It is the exact same version as the NAS one that works, only optimized for Short on DJ. I also get the same problem with other optimizations on other markets, even with Long. It´s so frustrating after so many hours of testing to get this problem…
04/14/2021 at 6:00 PM #167083As for the NAS version, I’ve been running it live for many months and never had a div/zero problem. No idea why you would get that error. Are you running the most recent version?
I have also been running the NAS 5.3 version for a long time without problems, so one issue can be the values I have chosen when optimizing. I can get Long to work on some markets, but never Short…
04/14/2021 at 6:01 PM #167084It may be that the code needs an extra Endif adding as the last line of the code?
It is the exact same version as the NAS one that works, only optimized for Short on DJ. I also get the same problem with other optimizations on other markets, even with Long. It´s so frustrating after so many hours of testing to get this problem…
Is there a blank line before the defparam instructions? This is not allowed, the resulting error message is confusing
1 user thanked author for this post.
04/14/2021 at 6:07 PM #167085Is there a blank line before the defparam instructions? This is not allowed, the resulting error message is confusing
Thanks for your reply! I´m checking right now but it doesn´t seem to help, but very good to know!
04/15/2021 at 8:27 AM #167128I delete a space line 2 and modified endif as @Grahal said and now there is no error to launch in autotrading.
First step is done. Now trouble with preloadbars
04/15/2021 at 8:39 AM #167129I still have error message after 100k preloadbars !!!
04/15/2021 at 8:46 AM #167130Still have problem after 500k preloadbars because an indicator …
04/15/2021 at 8:47 AM #167131Try again with 10000 preload bars as that is the maximum allowed anyway.
Have you got an indicator with a massive period like 20000 or something that requires more than 10000 bars to calculate?
1 user thanked author for this post.
04/15/2021 at 10:10 AM #167136Hello Nevertheless, thank you for your response and I appreciate her excellent work. I have 2 variants Live, NAS 1m Hull-SAR v.7.5 is very good for Long and Short ( see appendix ), but unfortunately brings bugs every now and then, Division Zero, which was also template for Nikkei, where it doesn’t work at all and then I still have NAS 2m Hull-SAR v5.5L Live, runs first without errors but unfortunately only Long good and Short rather bad (see appendix) . Is it possible to optimize, as the short also runs? That would be perfect! There are other times that the whole market short goes. Have version v5.5 also tested on Nikkei looks perfect ( see appendix ) it would pay off to get the short under control. I think you should have other values in your portfolio than DOW, DAX and so on. I’m happy to hear from them again and maybe you’re going to get to the short problem. Unfortunately, I am only a user and not a programmer, because I lack too many connections.
-
AuthorPosts
Find exclusive trading pro-tools on