Hull average cross over strategy – where I am going wrong?
Forums › ProRealTime English forum › ProOrder support › Hull average cross over strategy – where I am going wrong?
- This topic has 52 replies, 4 voices, and was last updated 4 years ago by
8ficusst.
-
-
04/21/2021 at 4:49 PM #167721
Could someone please advise me here?
I am developing a crossover type of trading system using aligning (< < or >>) HullAverage indicators for long and short triggers. The system performs well in BT, but I need to convert it for testing on the AUTO demo system. (It either triggers on every candle, or not at all)
This system is designed to trade intraday swings on the EUR/USD 1-Min bars. At each new bar, I press BT and only follow the direction of the two HullAverage indicators when they both align with each other – either up (long trigger) or down (short trigger).
I have attached a very shortened version of this system here, because it contains a few hundred lines of code due to its multiple variables. I inserted both the BT version and the corresponding AUTO format on the same page to make it easier for you to compare the two systems.
I would greatly appreciate someone having a look at this code in case you can see something wrong with it.
Thanking you!
04/21/2021 at 5:16 PM #16772304/22/2021 at 8:42 AM #1677558ficusst – One place you are going wrong is by not giving your topic a meaningful title!
- Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
I changed your title to something that describes your topic.
1 user thanked author for this post.
04/22/2021 at 9:06 AM #16776004/22/2021 at 9:26 AM #167766I posted the code as Roberto asked so then the coding wizards can readily spot any problems without having to download the .itf file.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384defparam cumulateorders = falsedefparam preloadbars = 1000// a and b variables: 300-350-50// c and d variables: 180-200-20MA1=HullAverage[c](momentum[a](close))MA2=HullAverage[d](momentum[a](close))S = MA1 < MA2MA3=HullAverage[c](momentum[b](close))MA4=HullAverage[d](momentum[b](close))L = MA3 > MA4if S and NOT L thensellshort at close stopendifif L and NOT S thenbuy at close stopendifGRAPH MA1 COLOURED (255,195,77) AS "Hullone"// orangeGRAPH MA2 COLOURED (102,179,255) AS "Hulltwo"// blueGRAPH MA3 COLOURED (255,195,77) AS "Hullthree"// orangeGRAPH MA4 COLOURED (102,179,255) AS "Hullfour"// blue// Below is my AUTO TRADING coding attempt for the above//////// SHORTS ///////////////////////AnyOfTheShorts = S1 or S2 or S3 or S4OpposingShorts = (h1 > h2) or (h3 > h4) or (h5 > h6) or (h7 > h8)h1=HullAverage[900](momentum[300](close))h2=HullAverage[950](momentum[300](close))S1 = (h1 < h2)h3=HullAverage[950](momentum[300](close))h4=HullAverage[900](momentum[300](close))S2 = (h3 < h4)h5=HullAverage[900](momentum[350](close))h6=HullAverage[950](momentum[350](close))S3 = (h5 < h6)h7=HullAverage[950](momentum[350](close))h8=HullAverage[900](momentum[350](close))S4 = (h7 < h8)//////// LONGS ///////////////////////AnyOfTheLongs = L1 or L2 or L3 or L4OpposingLongs = (k1 < k2) or (k3 < k4) or (k5 < k6) or (k7 < k8)k1=HullAverage[900](momentum[300](close))k2=HullAverage[950](momentum[300](close))L1 = (k1 > k2)k3=HullAverage[950](momentum[300](close))k4=HullAverage[900](momentum[300](close))L2 = (k3 > k4)k5=HullAverage[900](momentum[350](close))k6=HullAverage[950](momentum[350](close))L3 = (k5 > k6)k7=HullAverage[950](momentum[350](close))k8=HullAverage[900](momentum[350](close))L4 = (k7 > k8)//////// SHORTS ///////////////////////if AnyOfTheShorts and OpposingLongs thensellshort at close stopendif//////// LONGS ///////////////////////if AnyOfTheLongs and OpposingShorts thenbuy at close stopendif04/22/2021 at 9:27 AM #16776704/22/2021 at 9:28 AM #16776904/22/2021 at 9:32 AM #16777004/22/2021 at 11:41 AM #167777Does adding not onmarket as below sort your problem?
1234567891011//////// SHORTS ///////////////////////if not onmarket and AnyOfTheShorts and OpposingLongs thensellshort at close stopendif//////// LONGS ///////////////////////if not onmarket and AnyOfTheLongs and OpposingShorts thenbuy at close stopendif04/22/2021 at 12:20 PM #167783GraHa – the “if NOT ONMARKET” instruction would be OK for the first trade when it is not yet onmarket, but thereafter the code itself keeps it always on market (it never exits – it just changes from shorts to longs, or vice versa), therefore the “if NOT ONMARKET” instruction would surely prevent it from being able to trigger another trade? Please correct me if my thinking is wrong about this?
04/22/2021 at 12:27 PM #16778504/22/2021 at 5:37 PM #16780904/22/2021 at 7:07 PM #167810Did you try below …
123456789if not shortonmarket and AnyOfTheShorts and OpposingLongs thensellshort at close stopendif//////// LONGS ///////////////////////if not longonmarket and AnyOfTheLongs and OpposingShorts thenbuy at close stopendif04/22/2021 at 7:11 PM #16781104/22/2021 at 7:21 PM #167812 -
AuthorPosts
