Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Working with several time frames.

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

    Working with several time frames.

    Good morning.

    I am coding a strategy that works OnEachTick and that uses time frames of 1 tick, 5 seconds and 60 minutes. This strategy is executed on a 1-minute chart.
    My question is the following: I need to take the maximum, minimum, opening and closing values ​​of the current 60-minute candle [0] (the one that is forming) but, until it finishes, the program takes into account the values ​​of the previous candle in each tick (which is the one that is really finished). How can I make it so that, while OnEachTick performs the relevant calculations, it waits until the 60-minute candle finishes so that it only takes into account the values ​​of its closing?

    Thank you very much in advance and have a nice day.​

    #2
    Hello BIOK.NT,

    Require BarsInProgress to be 3 and require IsFirstTickOfBar to be true. Then use a barsAgo index of [1] (for the completed previous bar) with Closes[3][1].

    if (CurrentBars[3] > 1 && BarsInProgress == 3 && IsFirstTickOfBar)
    {
    Print(string.Format("{0} | Closes[3][1]: {1}", Times[3][1], Closes[3][1]));
    }
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Working...
    X