NexusFi: Find Your Edge


Home Menu

 





MultiTimeframes in NT8


Discussion in NinjaTrader

Updated
    1. trending_up 2,645 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
UweH
Myslenice Poland
 
Posts: 25 since Aug 2019
Thanks Given: 6
Thanks Received: 8

Hey there :-)
I have a question about using Multi-Timeframes in NT8. I've tried to use in my indicator three different Timeframes, 1. my actual Chart-Timeframe, 2. Range-10 and 3. Range-30. The first line after OnBarUpdate() is

if (CurrentBars[0] < BarsRequiredToPlot || CurrentBars[1] < BarsRequiredToPlot || CurrentBars[2] < BarsRequiredToPlot)
return;

If I try to start up, I got this error:

Error calling 'OnBarUpdate' method at Bar 20: You are accessing an index with an invalid value that is outside the expected range. E.g. Access a row with [BarsAgo] with a value of 5 if there are only 4 candles in the chart.

I know, what this error means and I have tried some options to fix it, for example I have changed RequiredBarsToPlotfrom 20 to 256 and changes the OR-Operator between CurrentBars to AND. That fixed the problem, if the Bar-Value on my Chart is between the two additional timeframes. But if I want to change my Chart-Timeframe to lower Values, for example to Range 4, Tick or anything else, I got this error immediatly. I have marked the whole Indicator-Logic as a comment, to rule out other sources of error.

I think that the spread between the lowest and the highest Timeframe could be too big, because for an 30-Range-Bar you need hundreds of Ticks or 4-Range-Bars and this could be the problem, when data is loading. Am I right with this assumption?
Is there a way to work around the problem? The same problem should arise, if someone calculates Res/Sup-Lines on Daily-Timeframe, but trades it in 10min or Tick.
Ani suggestions?


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
The May 31 Binary: 60% Trump Declares Iran Ops Over, Onl …
Prediction Markets & Event Contracts
GDP Day: The First Economic Reckoning -- Pahlavi at 6.55 …
Prediction Markets & Event Contracts
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
CME Group Fee Schedule Changes Hit All Four Exchanges -- …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 SpeculatorSeth   is a Vendor
 
Posts: 781 since Apr 2016
Thanks Given: 22
Thanks Received: 1,026

With indicators and strategies that utilize multiple data series you typically need to take advantage of the BarsInProgress property. In this case you might be able to solve the problem by only worrying about when your time series bar is updated.

 
Code
if (BarsInProgress != 0)
return;
https://ninjatrader.com/support/helpGuides/nt8/multi-time_frame__instruments.htm


Reply With Quote
  #3 (permalink)
UweH
Myslenice Poland
 
Posts: 25 since Aug 2019
Thanks Given: 6
Thanks Received: 8


BarsInProgress unfortunately doesn’t fix the problem, I’ve already tried this... Before I have written down my post here, I’ve searched for solutions in the internet and of course also in the NT-Helpfiles, because I don’t like ask other people and waste their time, because I’m too lazy to search for myself at first :-) Unfortunately I have searched without getting results. The problem often occurs, if people try to access f.e. Close[30] and getting the same error, because BarsRequiredToPlot is 20 by default.

You can correct me if I’m wrong, but BarsInProgress is an EventMarker, which returns the index value from that timeframe, which was actually updated, to split timeframe-based operations in separate blocks and avoid polling the whole indicator logic.


Sent using the NexusFi mobile app


Reply With Quote
  #4 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114

The likely problem here is that you are not taking into account which of the bar series is currently being processed. Depending on what bars are processed you need to adapt the code.

It is likely that there is a simple logical error in your code. If you wish to have it fixed, you need to disclose the code allowing us to look for the bug. In case you do not wish to disclose it in public, you may also contact me via direct message, and I will have a look.


Reply With Quote
  #5 (permalink)
UweH
Myslenice Poland
 
Posts: 25 since Aug 2019
Thanks Given: 6
Thanks Received: 8

Hi Fat Tails, of course it will be a simple error, because a big error would be easy to find :-D
I will post the code-fragment tomorrow, so you can have a look at it.


Sent using the NexusFi mobile app


Reply With Quote




Last Updated on June 10, 2020


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts