Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot the SMA of user defined variable

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

    Plot the SMA of user defined variable

    Hi,

    I am a beginner with Ninjascript, so sorry if I am not able to explain the problem well... I'm trying to plot the SMA of some data I calculate on each bar... I tried saving the data into

    private Series<double> MySeries

    So that I could do something like this:


    //assign values
    MySeries[0] = A + B; //This isn't the actual calculation, just an example


    //store the values after calculating the SMA of MySeries
    MySeriesSMA[0] = SMA(MySeries, 20)[0];

    //plot
    Values[0][0] = MySeriesSMA[0]


    I do not get a compiler errors and I can even see the data inside MySeriesSMA using Print() and it seems correct...

    But it will not plot... If I do something like switch out SMA(MySeries, 20)[0]; with this SMA(ATR(), 20)[0]; it plots this data, so it means MySeries is causing the problem...

    I hope that I am going about this completely wrong and that there is an easier way.

    Thanks for any help


    #2
    Hello maximusmeridius,

    Welcome to the NinjaTrader forums!

    Are you adding a plot with AddPlot() in State.SetDefaults?

    Below is a link to a forum post on adding plots.
    I'm trying to expose my variables to the strategy builder so everyone can have better use of the WaveTrend indicator (it has a lot of code). Explain this to me like I am 5 because this isnt the first time I've tried to figure it out and hit a wall. What is Series? I know its like an array that stores bars. Why not just call it
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I ended up just creating a new project, and then starting over, slowly making sure each part works, and for some reason everything works as expected now LOL... The SMA of my data series plots now... I was basically wanting to plot 1 and 2 Stdev up/down lines of the data I was calculating, which I was able to do.. It is a TOS thinkscript that I use but I wanted to see if I could code it into ninjascript and eventually have Ninja trade it for me...
      I'm sure I'll be asking more questions about strategy building soon

      Thanks for the reply

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      637 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      366 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      571 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X