Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

SMA of an Indicator at Certain Times

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

    SMA of an Indicator at Certain Times

    Dear Support,

    In NT7, can the value of an indicator (5-min chart) at a certain time during the past n days be programmed?

    Example: I want to calculate the average value of the RSI(14) at 10:00 AM over the past 10 days on a 5-minute chart.

    SMA = Sum (RSI(14) [Date0,Time 10:00] + RSI(14) [Date1, Time 10:00]

    +RSI(14) [Date2, Time 10:00) +......+ RSI(14) [Date 9, Time 10:00]) / 10

    What would be the simple statement in NT7 to calculate the above SMA?

    Thanks.

    #2
    Hello aligator,

    Thank you for writing in.

    You can use the GetBar() method call to obtain the bar index that matches the time stamp based on the DateTime parameter passed in. With this information, you can calculate the barsAgo value of the bar you wish to get your indicator values at: http://ninjatrader.com/support/helpG...t7/?getbar.htm

    Example:
    Code:
    // obtain the barsAgo value of the 10 AM bar for May 11th, 2016
    int barsAgo = CurrentBar - Bars.GetBar(new DateTime(2016, 5, 11, 10, 0, 0));
    Using this method call, you will be able to obtain the barsAgo values for the dates and times desired and use this value to get the indicator value for that specific bar.

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rocketman7, Today, 02:12 AM
    7 responses
    28 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by guillembm, Yesterday, 11:25 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by junkone, 04-21-2024, 07:17 AM
    10 responses
    148 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by tsantospinto, 04-12-2024, 07:04 PM
    6 responses
    101 views
    0 likes
    Last Post tsantospinto  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    7 responses
    28 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X