MACD Value Discrepancy

Forums ProRealTime English forum ProOrder support MACD Value Discrepancy

Viewing 15 posts - 1 through 15 (of 16 total)
  • #235060

    Hi all,

    I am trying to backtest a strategy that relies on the precise values of the MACD line and signal. However, the ProBacktest values always seem to be slightly different to the indicator (sometimes the difference is quite severe and the actual histogram is wrong).

    I’ve attached a screenshot of what this looks like. For this example, I’ve simply graphed the MACD line and signal values at each current bar to see what exactly is going on.

    I’ve tried playing around with Preloadbars and the number of units to no avail. This is also run on a single TF.

    If anyone can shed some light on this, that would be very much appreciated.

    Thank you.

    #235077
    JS

    So, there is a (big) difference between your system and the indicator, I see that you use Forex as data, is this difference also there when you use an index, for example…?

    #235086

    Yes, only dealing with Forex at the moment (I should have mentioned that in the original post).

    You are correct, even when previous values of MACD are referenced ([1], [2], etc) the difference is present. It simply spits out the value that it calculated previously, still with a big difference.

    #235087
    JS

    Can you show (part of) your strategy?

    #235095

    It doesn’t quite matter what the strategy is as you will never get the correct MACD values anyway. Take this very basic example that tries to capture the movement of a water line cross.

    The discrepancies are enough to provide false entries. Compare this to an identical indicator in ProBuilder without the order placement.

    I hope someone can clarify this strange behaviour.

     

    #235100
    JS

    When I use your last example/information, I get (almost) the same values for the indicator as for the system for the MACD…

    1 user thanked author for this post.
    #235103

    I get areas that are relatively close and some that are not. Are yours the same?

    In theory, shouldn’t they be exactly the same? I still don’t want to accept best case scenario as they are “close enough” as this is quite annoying for what I am trying to do.

    #235104
    JS

    The difference you see are “rounding errors” and only noticeable after the fourth decimal place… (six decimal places doesn’t make sense anyway)

    I’ve checked the other areas, and the values are the same…

    #235105
    JS

    You can use this mathematical function in your strategy, to adjust the decimal places (e.g. 2 decimal places) …

    https://www.prorealcode.com/documentation/round/

    2 users thanked author for this post.
    #235113

    The stock, custom and custom indicator called from another file all align up.

    However, results from the backtest versions do slightly deviate.

    Can’t shed any further light on that.

    On a different observation, you can write the code this way as well. Because most variables store its value for each bar,  you can use the [‘n’] to get previous values. This way you only have to repeatedly call external code for one since there all got the same settings.

     

     

     

    1 user thanked author for this post.
    #235115

    This is quite a shame as I do need exact values since some instruments have MACD values only beginning at the 4th decimal (in some cases 5th). So it’s not an option for me to round.

    Is it possible to get an official confirmation as to why this is happening, or a workaround?

    Thanks for your help so far guys.

    #235118
    JS

    It seems that the BackTest module calculates with a maximum of 5 decimal places, while an Indicator calculates with 6 decimal places…

    5 decimal places should be enough for Forex, because here, with most pairs, 5 decimal places are also used (tick size = 0.00001) …

    3 users thanked author for this post.
    #235123

    That solves one of life’s great mystery’s…

    iMacd = round(MACDline[12,26,9](close)),5)    in an indicator matches

    iMacd = MACDline[12,26,9](close)   in backtest.

     

     

    3 users thanked author for this post.
    #235125
    JS
    Plenty of other “Great Mystery’s” in PRT to solve… 🙂
    #235128

    Glad we were able to get to the bottom of this. This discrepancy in decimal precision surely affects other indicators as well, and not just MACD.

    I’ve checked both the IG and PRT Trading platforms and this looks like a fundamental issue that impacts the accuracy of all calculations.

    Accurate indicators are the backbone of any reliable strategy, so it is legitimately beyond me why this is something we have to discuss and “deal with” in the first place.

Viewing 15 posts - 1 through 15 (of 16 total)

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