Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I have a question on multiple time frames. I am looking back in time and need to figure out exactly which CurrentBars[] match. I can get close but doesn't seems to match reliable and have started to record associated CurrentBar for the other time series to see if I can get around it.
So here is what I am trying to do, the "simple" case: I have a primary 1 Min bar on the chart and add a 5 min bar as part of a strategy. I am now at bar CurrentBars[0]=1567 for the 1min bar and need to look back 13 bars to find the SMA(1min)[13] and the SMA(5min)[X]. I am hoping there is a simple or internal record of the associate between the bars so I don't need to try an create this association.
So in the above case, the 1min reference bar would be 1567-13 = 1554, the 5min initial bar CurrentBars[1] ~1567/5=313 is the 13th bar back the truncated value of 1554/5 = ~310 bars back 313-310 or 3 bars. It seems like using the 13/5 = ~2.6 might not be a reliable bars back calculation due to starting points of the time series.
I do not think that it is possible to associate the indices of two different bar series. I have always accepted that each of the bar series has its own index whatever it is. With 1 and 5 minutes things may be still easy, but if you take other timeframes you will typically experience cut-off bars at the session end.
I sometimes use a "sync" series that stores current bars of one bar series in a dataseries inside the other bar series. It helps with exotic bars ,but due to NT's MTF logic you still get that 1 bar discrepancy when bars close at the exact same moment.
Thanks, I found another problem which you may already be aware of with the simple 1 -> 5 ratio. In the off hours, if there is 0 volume for 1 minute, you will only have 4 bars (or even less) per 5 minute bar!
I have tried to go with the sync method in an IntSeries for now. This is better, but still not right, maybe due to the NT MTF bar close issue. I have not tried this with 1 Min vs 3 Renko for example, not sure how things will work in that case. I am sure I can only go in one direction, but it might change based upon number of bars produced by each series. In this 1 Min/3Renko the number of bars/min for the renko is no longer correlated, could be more or less due to price action.
I'm a little bit lost or maybe it's getting too late but I'd like to put up some question here if I'm doing things right:
My strategy has 1 Minute Bar Chart and CalculateOnBarClose false. Now I'd like to calculate the EMA of 5 min chart and save it to a DataSeries.
So to analyse when the bar has closed I wait for FirstTickOfBar then use the last Bar (barsAgo = 1 in realtime, for historical bars this has to be 0 I guess)
Would this code result in correct values (realtime and histocial)?
In my project I have this issue all the time so here's the summary:
Most, if not all, of all bar referencing mechanism in NT is based on barsAgo, which is opposite to the internal 0-based array indexing. Since I need to record absolute indexing (array style), the following assumes absolute (0 is 1st bar) indexing:
If i is the array zero-based indexing, then its 'barsAgo' is always CurrentBar -i.
For two instruments in the same chart/indicator/strategy, assume their BarsArray index is p and q respectively,
then
the index of 'bar i (in timeframe p)' in timeframe q =
BarsArray[q].GetBar(Time[CurrentBars[p]-i])
For the reduced, and most likely case of p is the the 'current isntrument', then this is reduced to
If you use a multi-timeframe indicator in a strategy, then you definitely introduce an additional lag. Compare
-> value from 5 minute bar retrieved -> projected onto primary bars -> used by strategy
-> value from 5 minute bar retrieved -> directly used by strategy
The projection is only done after the bar close of the secondary 5 min bars. For example, if you project on a 1-min bar series - most unfavourable case when primary and secondary bars have identical time stamps - then you will the result of the 5-min EMA only one bar later, if you run the strategy in COBC = true.
The indicator addresses the lag by repainting in One-Tick-Correction and Visual mode. It can be run in COBC = false. But if you use the MTF indicator in a strategy then you do not want it to repaint. Actually, I have somewhere presented an example how to access the indicator in other than strategy mode in order to let the strategy repaint, but in fact this is pretty insane.
It is also insane to let the strategy run in COBC= false, but not update the indicator values. I don't understand why you are doing this.
What about simply adding a secondary bar series of 5 min bars and applying an EMA to that series?
i am currently coding an indicator which is using a second dataseries.
the primary is a 1 minute chart and the second is a 5 minute.
could somebody please tell me how many bars of the second (m5) dataseries are getting loaded?
does it just load all available historical 5 minute bars or is there a way i can control this?