Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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,
    BertrandNinjaTrader Customer Service

    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 alifarahani, Today, 09:40 AM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by RookieTrader, Today, 09:37 AM
        4 responses
        17 views
        0 likes
        Last Post RookieTrader  
        Started by PaulMohn, Today, 12:36 PM
        0 responses
        4 views
        0 likes
        Last Post PaulMohn  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        40 views
        0 likes
        Last Post love2code2trade  
        Started by junkone, Today, 11:37 AM
        3 responses
        23 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X