Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SMA of the data within the Indicator

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

    SMA of the data within the Indicator

    Would be able to tell my how to fix the follow code so that the SMA will plot, or just direct me to a tutorial. Thanks!

    /// </summary>
    protected override void OnBarUpdate()
    {
    double NH1 = BarsArray[1][0];
    double NL1 = BarsArray[2][0];
    double NHNLavg = (NH1/(NH1 + NL1));
    double NHNLSMA = SMA(Close, SMAInput)[0]; <----This is wrong, I'm sure.



    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Plot0.Set(NHNLSMA);

    I am looking to be able to plot the "SMAInput" day SMA of NHNLSMA. Thanks.

    #2
    Hi dunwoodyjr,

    For multiInstrument scripts, there is a sample built into the platform. Click tools > edit NinjaScript > Strategy > SampleMultiInstrument.


    Often you will need to add something like the following, that prevents script processing for all series when they are not available. Add to the top of OnBarUpdate().

    if(CurrentBar < 0 || CurrentBars[1] < 0 || CurrentBars[2] < 0) return;
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    599 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    344 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    558 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    557 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X