Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Series Value is Zero

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

    Series Value is Zero

    Need a bit of help on creating a series. I've got the following code snip to create myMACDDiff series. The problem is that referencing myMACDDiff[1] always has 0.

    Code:
    protected override void OnBarUpdate()
            {
    
    
                double MACDDiff = MACD(MACDfast, MACDSlow, MACDSignalLength)[0];
                Series<double> myMACDDiff = new Series<double>(this);
                myMACDDiff[0] = MACDDiff;
    What have I done wrong?

    #2
    Data series should be created in state DataLoaded and stored as a global indicator/strategy/etc. class variable.

    Comment


      #3
      Fixed. Thank you.

      Comment


        #4
        Hello Kentoes,

        MojoJojo is correct. If you are declaring something in OnBarUpdate() then it will only exist in that run of OnBarUpdate() and then will cease to exist.

        Below is a link to the help guide on declaring custom series.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        71 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        152 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        100 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        288 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X