Optimization moving average crossing strategy

Forums ProRealTime English forum ProOrder support Optimization moving average crossing strategy

Viewing 15 posts - 46 through 60 (of 186 total)
  • #123152

    Thanks Jan for the clarification. I’m mostly using OTD now with these so no need for other exit rules. 👍

    #123153
    Jan

     

    I managed to code double crossing in two time frames, with different variables in the two time frames, see attached for the itf file with the code.

    Main issue here is that the combinations possible are way too high, 70 x 70 x 70 x 70, so optimizing with all variables needs several simulations with each limited variables.

     

    The trading concept below generates too few trades (no very reliable, risky to say it would be a robust trading system), as thought and mentioned above by Nonetheless.

    if AvType (short time frame) crosses above AvTypeV2 (short time frame)  and AvTypeV3 (long time frame) crosses above AvTypeV4 (long time frame), go long

    Vice versa if AvType (short time frame) crosses under AvTypeV2 (short time frame)  and AvTypeV3 (long time frame) crosses under AvTypeV4 (long time frame), go short

     

    An alternative trading concept below can be tried as well:

    if AvType (short time frame) crosses above AvTypeV2 (short time frame)  and AvTypeV3 (long time frame) is higher as the previous and  AvTypeV4 (long time frame) is higher as the previous, go long

    Vice versa if AvType (short time frame) crosses under AvTypeV2 (short time frame)  and AvTypeV3 (long time frame) is smaller as the previous, and  AvTypeV4 (long time frame) is smaller as the previous, go short

    Endless variations possible !!!

     

    At the bottom of the code, I arbitrary add the code below, to stop trading after 120 bars, when the position is not positive (regardless the stoploss, which was not triggered sofar)

     

    If you have trading concepts, please let me know !!

     

    1 user thanked author for this post.
    avatar CMM
    #123771

    Thank you both and every other attributer for this. Its great to look at and expirement with. I am sure I speak for a few when I say, this is proving very enlightening and helpful.

    #124277

    I share attached, settings at the top by me, but the clever work / coding was done by Jan. Nonetheless split out part of that code (I think?).

    It’s difficult to keep track of it all, but we’re not complaining! 🙂

    Spread = 10 set in backtester to achieve attached.

    #124299

    This looks really good GraHal. Although I have a question. The original code is quite time specific (as it only trades a few hours in the morning). I tested your code as is. But as I am in mainland Europe at the moment, the results differed massively ( I only ended up with 13k profit instead of 21k). However, adjusting to the UK time zone by adding a single hour (I am assuming by looking at the flag /nationality linked to your avatar on your post) our results matched. So this leads me to my question, did you at all consider running the system at US market open hours, as it is a US index after all?

    I adjusted the code to trade in US mornings and doing so would actually yield a loss. Also, as the US changes their clocks on a different date compared to Europe and the UK, the backtest would not be consistent, as there would be a few weeks, twice a year, where the timing is out by an additional hour.
    I get that these results are good and thats all that matters, but it just feels wrong to me to run a system on an index when it’s underlying market is technically closed.

    Kind of hoping you have an answer for this that puts my mind at ease, and we can carry on getting to that yacht life.
    Hashtag – If youre not working remotely, are you even remotely working

    #124301

    Hi,

    I´m using this code on a algo but with MA 12 and 34 i get an “division by 0” error when market is inactive. Can I prevent this by any meen?

    My guesses is that it is the 34 MA that is the problem. I’ve seen someone else have the same Division 0 error on another algo and put in like: <>0 or something like that, but how do i code it on this one?

    Thank you for great coding.

    #124318

    I adjusted the code to trade in US mornings and doing so would actually yield a loss.

    I guess you proved that the System does not suit the volatility during DJI market hours?

    The DJI during the first few market hours is a different beast than later on in the USA working day  and outside market hours.

    It be good if you optimised the settings to suit  DJI market hours … let us know how you get on?

     

     

    #124319

    AFR = 0.4360409450*Series[0]+0.3658689069*Series[1]+0.2460452079*Series[2]+0.1104506886*Series[3]-0.0054

    Love to know where the above numbers come from … they look crazy values??

    #124320

    AFR = 0.4360409450*Series[0]+0.3658689069*Series[1]+0.2460452079*Series[2]+0.1104506886*Series[3]-0.0054

    Love to know where the above numbers come from … they look crazy values??

    They come from the code, ask Jan =)

    #125592

    hello, I tried his sp1HV1 in 25KE but frankly it does not give the same curve as you is weird, what exact setting do you use?
    thank you

    #125601

    hello, would it be possible please have the .itf file of your MAX US500 H1V1 version to test it in 200,000 candles, thank you
    ——————————-

    #125606

    @thebigdeal
    I highlighted the broken rule,
    please abide by them!

    There are some simple rules that everyone using the forums is expected to follow. The forum rules are as follows:

    • Post your topic in the correct forum:
      _ ProRealTime Platform Support: only platform related issues.
      _ ProOrder: only strategy topics.
      _ ProBuilder: only indicator topics.
      _ ProScreener: only screener topics
      _ General Discussion: any other topics.
      _ Welcome New Members: for new forum members to introduce themselves.
    • 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’.
    • Only post in the language of the forumthat you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
    • Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
    • Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
    • Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
    • Do not include personal informationsuch as email addresses or telephone numbers in your posts.
    • Always be polite and courteous to others.
    • ‘…and most importantly – have fun! 🙂
    #125893

    Thank you Jan for this code.

    It gives so much opportunities to test.

    I also begin to work on period at 15, and period 2 as a variable, testing every crossing between 10 and 20 period. It seems to improve %winning

    #125996
    Jan

    Just be aware that you do not over-optimise with the found optimum mix.  I try not to over optimise, running this strategy to find a optimum set without out of sample  (lets say it give AFR 3 and 45 and more AFR3 combis are second, third etc best), and then I do an In Sample/Out of Sample test (with IS 66% and OOS 34%) with limited value setting of AFR = 3, and AFRv2 is lets say 0-15, then see of the outcome with the IS/OOS varies a lot from the non IS/OOS test, to be a bit more secure about robustness of the algo.

    1 user thanked author for this post.
    #125998
    Jan

    As on request, please find attached the two averages as an indicator (with two averages, to be selected by the user),

    This indicator shows you 2 lines of average, so you can compare the lines in the graph, with the optimized crossings, from your findings when running the strategy  (as on request of   nilsla1981 )

     

Viewing 15 posts - 46 through 60 (of 186 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login