Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddChartIndicator

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

    AddChartIndicator

    Hello, I’m trying to figure out AddChartIndicator. I start with an “empty” strategy, and just adds the two lines as described in the help guides:
    }
    else if (State == State.Configure)
    {
    AddChartIndicator(SMA(20));
    }
    }

    protected override void OnBarUpdate()
    {
    double sma = SMA(20)[0];
    }
    When I then select my strategy from the chart menu, nothing happens! I had expect to see a SMA plot at my chart, but nothing.

    What am I missing here?

    #2
    Hello AndBro,

    Thanks for your post.

    The code:
    else if (State == State.Configure)
    {
    AddChartIndicator(SMA(20));
    }

    Will add the SMA(20) as an indicator on the chart. The code in the OnBarUpdate() would not be related.


    When you apply and enable the strategy are you seeing any error messages in the "log" tab of the NinjaTrader control center that relate to the strategy? If you are seeing the error of trying to access a bars ago that may be related to the code you show in the OnbarUpdate().

    Comment


      #3
      Thank you Paul, “enable” was the solution  (it was not set!).
      Now it is working as I was expecting.
      /AndBro

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      656 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      371 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      579 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X