MA crossing seems not to be working

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #73067 quote
    robertogozzi
    Moderator
    Master

    I was backtesting one of my strategies and found out, while monitoring MA crossings, some differences between my strategy and my custom indicator, with the same settings, on DAX daily chart.

    While my indicator seems to identify crossings correctly, my strategy does not!

    I’d like someone to help me find out what’s wrong.

    This is my indicator:

    FastMA = average[27](close)
    SlowMA = average[262](close)
    x = FastMA CROSSES OVER  SlowMA
    y = FastMA CROSSES UNDER SlowMA
    return x, -y, 0

    This is my strategy:

    DEFPARAM CumulateOrders = false
    FastMA = average[27](close)
    SlowMA = average[262](close)
    CrossingUP = FastMA CROSSES OVER   SlowMA
    CrossingDN = FastMA CROSSES UNDER  SlowMA
    buy at market
    graph CrossingUP
    graph -CrossingDN

    and I attach 3 screenshots:

    • the first one shows my idicator detecting a bullish crossing on Nov. 26th 2015, while my strategy GRAPHED wrong values
    • the second one shows a my indicator detecting a bearish crossing on Dec. 11th 2015, while my strategy GRAPHED wrong values
    • the third and last one shows my indicator detecting no crossing (and it didn’t occur) on Feb. 22 2018, while my strategy GRAPHED a bearish value

    Setting MAs to 20 (faster MA)  and 100 (slower MA) did not change anything (just a few more crossings).

    Replacing MA from simple to exponential (adding “,1” within brackets of AVERAGE) didn’t change anything, as well.

    And I didn’t even drink a glass of wine before coding!

    MA1.jpg MA1.jpg MA2.jpg MA2.jpg MA3.jpg MA3.jpg
    #73072 quote
    Vonasi
    Moderator
    Master

    Have you tried graphing FASTMA and SLOWMA in the strategy to see what values you are getting?

    #73079 quote
    Vonasi
    Moderator
    Master

    It seems to work on my platform:

    [attachment file=73080]

    I’ve put two identical strategies on there – one graphing the averages and one graphing the CrossingUp and CrossingDn and also the indicator is on there.

    Screenshot_1-5.png Screenshot_1-5.png
    #73082 quote
    JC_Bywan
    Moderator
    Master

    Hi Roberto, assuming this is ig cfd dataflow, not futures? If yes, I don’t see the ig sunday candles on your daily graph (just a quick check made on the sunday nov 29th 2015), so I suppose you’ll have a difference in calculation of daily moving averages coming from backtest run on prt servers (adding a sunday candle to the daily chart), while your indicator on your pc seems to be customised with the classic 5 day week (no sunday candles) for probuilder…

    #73083 quote
    Vonasi
    Moderator
    Master

    It appears that your indicator is wrong because I have no crossing on that date shown.

    #73085 quote
    robertogozzi
    Moderator
    Master

    I got erratic results, on a 1-hour TF differences between GRAPH and MAs on chart are small and sometimes for the FASTER MA values match.

    I also tried to change some options, Display/Don’t display WE data, but that does not change much, still erratic (but different) values.

    I also tried to set up custom trading hours (7-21 UTC+1) and default trading hours, but still there are differences.

    Also trying to set PreloaBars to 0 or 10000 did not change the outcome.

    #73086 quote
    robertogozzi
    Moderator
    Master

    I’m using IG’s CFDs.

    #73087 quote
    JC_Bywan
    Moderator
    Master

    Clicking only the one box for applying weekend data? Or also clicking the second box just below it (apply these settings to daily and superior timeframes)?

    #73089 quote
    robertogozzi
    Moderator
    Master

    It seems that the only working combination is:

    • display weekend data (box ticked)
    • do not app apply to non intraday data (box unticked)

    So I will have to comply with PRT default settings. What use are custom settings then?

    When I tick option NOT to display WE data, that data shouldn’t be considered for any calculation and prices in that period should produce a gap, which indeed IS only visually.

    x-1.jpg x-1.jpg
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

MA crossing seems not to be working


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by robertogozzi
7 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/13/2018
Status: Active
Attachments: 5 files
Logo Logo
Loading...