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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        36 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        20 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        14 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        20 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X