Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Display average indicator output looking back x bars.

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

    Display average indicator output looking back x bars.

    Is there any way to get an indicator to display the average output value looking back x bars? For example if I took the SMA and wanted to display it as a horizontal line that updated it's value every week instead of updating with each bar and displaying the average over x bars looking back. Is this possible in the Ninjascript Editor using Ninjatrader 8? Any tips on how I could accomplish this? Thanks

    #2
    Hi jerblaster23, thanks for your question.

    There could be a number of ways to do this. In NinjaScript you can make multi time frame scripts. So you run the script on the primary data series and the script will also have the added data series added with the AddDataSeries() method. We have a guide on multi time frame an instrument scripts here:

    https://ninjatrader.com/support/help...nstruments.htm

    The idea here is to add the larger time period and gather data from each bar close of that series e.g.

    if(BarsInProgress == 1) //secondary series OnBarUpdate() call
    {

    double value = SMA(Highs[1], 20)[0];
    double value1 = SMA(Closes[1], 20)[0];

    }

    Please let me know if I can assist any further.

    Comment

    Latest Posts

    Collapse

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