Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

multitime frame access

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

    multitime frame access

    I want to create a single method that accesses moving averages from different time periods, i.e. simple moving average of the 60 minute, and the 30 minute, etc... Is there a way to do this nicely?

    Right now, the only way I can access moving averages of different time frames is by adding
    a new time, such as,
    Add(PeriodType.Minute, 30)

    but I am unable to access the different times in the same single method. How can I fix this?

    In addition, I would like to add this in userdefinedmethods because I want to do basically the same thing in a number of different strategies.

    Thanks,
    Matt

    #2
    Matt, I don't believe this would be possible in the UserDefinedMethods script.

    You will have to add each timeframe, and then you can use either BarsInProgress filtering or BarsArray to tell the moving average method what data set you're trying to use.

    If your base chart is 5 minutes, and you add a 30 minute series -
    Code:
    OnBarUpdate()
    {
       if (BarsInProgress == 0) // primary series, 5 minute
       {
          double mavalue = SMA(Close, 10); // get the 10 period sma of the primary series
       }
       if (BarsInProgress == 1) // secondary series, 30 minute
       {
          double anotherMaValue = SMA(Close, 10); // get the 10 period sma of the 30 minute bars
       }
    }
    
    // or you could use Closes[1] to reference the secondary series anywhere in the script (no need for BIP filtering)
    
    double SMA_again = SMA(Closes[1], 10); // another 10 period sma of the 30 minute bars
    
    // another option is to use BarsArray[1]
    double yet_again = SMA(BarsArray[1], 10);
    Here are some links to help you out:


    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    630 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    566 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X