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

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 llanqui, Today, 08:32 AM
        1 response
        5 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by lollers, Yesterday, 03:26 AM
        1 response
        52 views
        0 likes
        Last Post lollers
        by lollers
         
        Started by Salahinho99, 05-05-2024, 04:13 AM
        7 responses
        62 views
        0 likes
        Last Post Salahinho99  
        Started by knighty6508, 05-10-2024, 01:20 AM
        4 responses
        29 views
        0 likes
        Last Post knighty6508  
        Started by OllieFeraher, 05-09-2024, 11:14 AM
        6 responses
        19 views
        0 likes
        Last Post OllieFeraher  
        Working...
        X