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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    44 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    27 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    163 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    158 views
    2 likes
    Last Post CaptainJack  
    Working...
    X