Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD Indicator values

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MACD Indicator values

    Hi,

    I encountered an offset between the MACD indicator value (blue bar chart) and the same indicator applied in a strategy (value printed in chart).

    Both applied period (15m) and setting (10, 38, 38) are the same! So I would expect the values be the same as well. But the value of the strategy is at 41 an the indicator show -14.

    What could be the cause of this difference?

    Thanks.
    Attached Files

    #2
    Hello P-Sionic, and thank you for your query.

    So that I may have a more complete picture of what is happening, would it be possible for you to show me the code in your strategy both to generate and print out your MACD values? Could you also let me know what instrument you are trading, including its expiry date, and at what time of day you observed this?
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick reply.

      Instrument: $GER_CFDEUR (=German Index via FXCM)
      Start of Code:

      protected override void Initialize()
      {
      Add(PeriodType.Minute, 15);
      Add(PeriodType.Minute, 60);

      CalculateOnBarClose = false;
      ExitOnClose = false;
      TraceOrders = true;
      EntryHandling = EntryHandling.UniqueEntries;
      }

      protected override void OnBarUpdate()
      {
      Info = "MACD: " + Math.Round(BarsArray[1], MACD(10, 38, 38)[1],0)"
      DrawTextFixed("",Info,TextPosition.BottomRight);
      }

      End of Code



      So the MACD value should go directly into the print out.

      Presently the print out value is at -5 and the value of the MACD indicator chart is at around -10.
      Attached the settings of the MACD indicator.
      Attached Files

      Comment


        #4
        Hello again P-Sionic,

        I noticed that you called Math.Round using the overload covered in this publicly available MSDN documentation link :

        Rounds a value to the nearest integer or to the specified number of fractional digits.


        The first argument is the number you are rounding, where the second argument is the maximum number of decimal places. I have reason to believe, therefore, that the code you are using is actually printing the value of BarsArray[1] , and not the value of your MACD indicator. I also noticed that you are looking 1 bar ago with the MACD indicator, rather than examining the current bar.

        I would like to ask, then, if you could use this in your Print statement, and if it gives you a different result :

        Math.Round(MACD(10, 38, 38)[0], System.MidpointRounding.AwayFromZero)

        Or, if you are comparing to your secondary data series in both instances,

        Math.Round(MACD(BarsArray[1], 10, 38, 38)[0], System.MidpointRounding.AwayFromZero)

        Please let us know if there are any other ways we can help.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Thanks that was exactly it!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          576 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X