Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicator historical data problem

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

    indicator historical data problem

    I want to create my own indicator but i need to use the MACD(12, 26, 9).Diff[1] and i can't get any value from it.

    If i use the currentBar for my indicator (MACD(12, 26, 9).Diff[0]), i can see the values.


    For example, when i try to add the following indicator to my chart, I can't see any value.

    thanks for your help.

    protectedoverridevoid Initialize()
    {
    Add(
    new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Dot, "Plot0"));
    Overlay =
    false;
    }

    protectedoverridevoid OnBarUpdate()
    {
    Plot0.Set(MACD(12, 26, 9).Diff[1]);
    }

    #region Properties
    [Browsable(
    false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries Plot0
    {
    get { return Values[0]; }
    }
    #endregion
    }

    #2
    Pimax, welcome to our forums - our NinjaScript trainee will review your issue shortly and then reply back with a suggestion how to approach and hopefully resolve.

    Thanks for the patience,

    Comment


      #3
      Hello Pimax,

      Thank you for your post.

      First, do you see any errors in the log tab in Control Center? This can help you track down what is going wrong.

      Also, you are using MACD().Diff[1], saying you want the Diff of one bar ago. But first, you will want to check if you have a bar one bar ago. You can do this by checking CurrentBar, it starts at 0. Ex:

      if (CurrentBar > 0)

      You can find a full example of checking if you have enough bars at the following link:


      Give this a try and let me know if I can assist you any further.
      DexterNinjaTrader Customer Service

      Comment


        #4
        Thank you so much, it works now.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 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
        554 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