NAS 3 x HULL MA trading system
Forums › ProRealTime English forum › ProOrder support › NAS 3 x HULL MA trading system
- This topic has 18 replies, 7 voices, and was last updated 3 years ago by boonet.
-
-
09/18/2020 at 12:43 PM #144658
Hello all, I stumbled upon this more or less by accident and can’t understand why it seems that it ‘might’ actually work.
It enters long when a) the slow MA is above the fast MA (normally short conditions) and b) when the slow MA changes direction. How is this possible? By the time a slow MA can change direction surely it would be below the fast MA?
Attached are backtests for 4min and 3min versions, both of which appear to be profitable over the past year. Position size = €1
If anyone could enlighten me as to what is going on here, I’d be most grateful.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869// Definition of code parametersDEFPARAM CumulateOrders = false // Cumulating positions deactivatedDEFPARAM preloadbars = 5000//Money Management NASMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize=1ENDIFif MM = 1 thenONCE startpositionsize = 1ONCE factor = 10 // 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 = 1 // enter minimum position allowedIF Not OnMarket THENpositionsize = startpositionsize + Strategyprofit/(factor*margin)ENDIFIF Not OnMarket THENIF startpositionsize + Strategyprofit/(factor*margin) > tier1 thenpositionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 //incorporating tier 2 marginENDIFIF Not OnMarket 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 >=080000 and time <210000TIMEFRAME(default)Period= 5inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice)HULLa = weightedaverage[round(sqrt(Period))](inner)Periodb= 24innerb = 2*weightedaverage[round( Periodb/2)](typicalprice)-weightedaverage[Periodb](typicalprice)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)Periodc= 90innerc = 2*weightedaverage[round( Periodc/2)](typicalprice)-weightedaverage[Periodc](typicalprice)HULLc = weightedaverage[round(sqrt(Periodc))](innerc)c1 = HULLb > HULLac2 = HULLb < HULLac3 = HULLb > HULLb[1]and HULLb[1]<HULLb[2]c4 = HULLb < HULLb[1]and HULLb[1]>HULLb[2]c5 = HULLc > HULLc[1]c6 = HULLc < HULLc[1]// Conditions to enter long positionsIF Ctime and c1 AND C3 AND C5 THENBUY positionsize CONTRACT AT MARKETENDIF// Conditions to enter short positionsIF Ctime and c2 AND C4 AND C6 THENSELLSHORT positionsize CONTRACT AT MARKETENDIF//SET STOP %LOSS sl//SET TARGET %PROFIT tp09/18/2020 at 2:03 PM #144671It’s because of conditions C3 and C4, both form a reversal peak while the lowest average, C5 and C6, is also going the reversed way.
09/18/2020 at 3:19 PM #144680Sorry Roberto, I still don’t get it.
c5 means the MA90 is rising – this is unproblematic. c3 means the MA24 has reversed from falling to rising, this also makes sense.
But how can that happen when it is also above the MA5 ? By the time MA24 reverses, the MA5 is surely going to be above it ???
09/18/2020 at 4:39 PM #144691Use this indicator:
1234567891011121314151617181920212223242526272829Period= 5inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice)HULLa = weightedaverage[round(sqrt(Period))](inner)Periodb= 24innerb = 2*weightedaverage[round( Periodb/2)](typicalprice)-weightedaverage[Periodb](typicalprice)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)Periodc= 90innerc = 2*weightedaverage[round( Periodc/2)](typicalprice)-weightedaverage[Periodc](typicalprice)HULLc = weightedaverage[round(sqrt(Periodc))](innerc)c1 = HULLb > HULLac2 = HULLb < HULLac3 = HULLb > HULLb[1]and HULLb[1]<HULLb[2]c4 = HULLb < HULLb[1]and HULLb[1]>HULLb[2]c5 = HULLc > HULLc[1]c6 = HULLc < HULLc[1]// Conditions to enter long positionscLong = c1 AND C3 AND C5cShort = c2 AND C4 AND C6IF cLong THENDRAWARROWUP(barindex,low - range*3) coloured(0,255,0,255)ELSIF cShort THENDRAWARROWDOWN(barindex,high + range*3) coloured(255,0,0,255)ENDIF//RETURN Hulla AS "Ha", Hullb AS "Hb", Hullc AS "Hc"the attached pic shows that:
- HullB (blue) has formed a (almost invisible) peak – C3
- HullB (blue) > HullA (red) – C1
- HullC (purple) > previous HullC (purple) – C5
1 user thanked author for this post.
09/18/2020 at 6:40 PM #144712Thanks for that Roberto, so at least its not impossible for those conditions to occur.
Still very odd that it should give a decent result. If I remove HULLa (MA5) completely, with just the rising MA90 and the MA24 reversal the results are much worse. I don’t see why the HULLa should improve anything, but there it is.
09/18/2020 at 7:05 PM #144713Because (Long example) C is ascending, B is reversing from descending so it’s now ascending, thus the idea is that the faster A, temporarily behind, will soon cross over B.
09/18/2020 at 8:11 PM #144722Yes, short term weakness, medium and long term uptrend, so you buy the dip to enter the medium and long term uptrend (good entry point)
1 user thanked author for this post.
09/18/2020 at 9:31 PM #14472709/18/2020 at 10:10 PM #144730Thank you for stumbling across this Nonetheless.
I get more or less same as you on 4 min, but wildly different on 3 min … weird, why should that be??
For the 3min version, I have Periodb = 27, all other values are the same. Interesting that, as far as i can see, the 4min and 3min pick up completely different trades, so could be run in tandem.
There is another problem though; the MM doesn’t seem to do anything. This is weird because it’s just an add-on block of code that I’ve been using for ages, but here it makes no difference if MM=1 or 0 … could you test it to see if you get the same?
09/19/2020 at 12:53 AM #144734Hello, as I can see the MM will not step up because that the strategy is always in market (Over 99%). No stop, no target, no sell and no takeprofit.
1 user thanked author for this post.
09/20/2020 at 4:26 AM #144784Yes, that’s true, but positions are still closed and reopened… how long does it realistically take to calculate strategy profit and position size? Should be a matter of milliseconds. If the time on market is anything less than 100% there should be time for the MM to activate at some point.
Any use of stops or targets results in worse performance.
09/21/2020 at 1:21 AM #144842“If the time on market is anything less than 100% there should be time for the MM to activate at some point.”
I was thinking that the other 1 or 2 % had to do with the time before the strategy took the first trade. I have no idea as I am a beginner on this.
Can @Nicolas or someone else tell us how Prorealtime internals works when the strategy is doing like this eg. when there is no stop nor any target in the code and the trade reverses by the strategy?
Does Prorealtime send a command to the broker IG to “reverse” the trade or is there two commands sent? (sell/short vs exitshort(sell)/buy depending on direction)?
09/21/2020 at 6:18 AM #144844The only commands sent to the broker are those the author coded within the strategy.
In this strategy there are two, BUY and SELLSHORT.
Whenever one of the two is executed the position is automatically reversed since there cannot be two opposite positions open within the same strategy.
Reversing implies first closing the open position, then opening a new one the opposite direction. There’s no need to use SELL/EXITSHORT to stay 100% of time on the market.
The author commented the las two lines to avoid being on market less than 100% of time.
1 user thanked author for this post.
09/21/2020 at 8:11 AM #144848time before the strategy took the first trade
I think this may be the case?
I have never had an always on strategy to be on market 100% of the time and often wondered where the < 1% or 2% ish went to?
I have no idea as I am a beginner on this.
Seems you do have good ideas, keep them coming!
It’s good to have new blood in the Community! 🙂1 user thanked author for this post.
09/22/2020 at 12:06 AM #144928@robertogozzi thanks! That’s almost what I suspected. Does this mean that there is no chance for ProRealTime to run the “Not OnMarket” code in this strategy and that the specific part of the MM code will not run?
GraHal thanks. I will do my very best 😉
Excellent Community you have here. Everyone, thanks for sharing. Thumbs up to you all 😀
-
AuthorPosts
Find exclusive trading pro-tools on