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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    164 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    318 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    246 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X