haven't heard from you for a few days. what are your thoughts about the indicator values for non-daily bars not consistent with daily bars?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
indicator values for non-daily bars not consistent with daily bars?
Collapse
X
-
Hello joemiller,
Sorry for the delay, I didn't see your reply.
Backtesting a strategy twice could indeed cause duplicates as you do not have ClearOutputWindow() in your script. This means each backtest will print and nothing is set to clear it. (Sometimes the output window clears itself but not always)
Regarding the behavior of your script, I am going to suggest that you use an if statement that uses a particular days ago value for items before 5 and a different days ago value for prints after 5. However, I still do not know what actions do you want your strategy to take for a 5:00 PM bar and for a 6:00 PM bar knowing these will print different days.
What is the "correct" redline?Chelsea B.NinjaTrader Customer Service
Comment
-
In summary, the problem I am having is as follows:
my testing and checking tells me that the indicator [the red line on the chart] is computed correctly for day bars [ie] the “correct red line” . However hourly bars result in different [therefor wrong] values. So we have a “one right and one wrong” situation.
for 1440 min bars and 60 min bars the values are the same, but both are wrong, suggesting to me that getdaybars is not doing what I think it should reasonably be doing for me. I suspect they are wrong because they are shifted one day per the following paragraph. So that’s encouraging [ie] I recognize behavior to be defined and consistent for non-day bars. Maybe [probably] my code is somehow screwing up on how the results get plotted.
I was doing 5 and 6pm to demonstrate what I was talking about in the previous paragraph [ie] that the values for day bars are the same as the values for the next day hourly bars. Then I attached an excel spread sheet to try to further show and explain what I was seeing.
I will create more output window messages trying to clarify what I have just said and post a report to you.
Comment
-
Hello joemiller,
A 1440 minute chart will show the first tick (from the first trade of the day). The daily bar is showing the open price that is controlled by the data provider.
These are controlled by the broker. The more accurate data series is the one that is not filtered by the data provider and is made with 1440 minute data.
http://www.investopedia.com/ask/answ...osingprice.asp
Bars.GetDayBar will calculate the day bar using minute data (as its applied to a minute chart).
You can confirm this buy using the PriorDayOHLC on a chart with minute data and comparing to the values of Bars.GetDayBar.
I would recommend that you use a 1440 minute bar instead of a daily bar if the open discrepancy is causing your script to calculate differently.
The 5 PM bar and 6 PM bar are part of different sessions. They will not show the same data. Bars before 5:01 PM will have Bars.GetDayBar reference the same day. Bars after 5:00 PM will reference the next day.
Here is what i would recommend for minute bars:
int daysAgo = 1;
if (ToTime(Time[0]) > 170000)
{
daysAgo =2;
}
Then where you have Bars.GetDayBar use the daysAgo value.
For example:
XXCloseyest=((Bars.GetDayBar(daysAgo).Open + Bars.GetDayBar(daysAgo).High + Bars.GetDayBar(daysAgo).Low + Bars.GetDayBar(daysAgo).Close) * 0.25);
The issue with this is that you will get an error if you try and call a day that doesn't exist yet. You will need to count the sessions with first bar of session and then program logic to not do this check when there isn't enough data.
I have tested this and the Prints match exactly with a 1440 minute bar.Last edited by NinjaTrader_ChelseaB; 08-21-2013, 11:21 AM.Chelsea B.NinjaTrader Customer Service
Comment
-
Hello Chelsea,
Please take a look at the following and let me know what you think.
Attached is an image of the strategy analyzer chart for 12 hour bars. The redline indicator shown in the attached image is shown to be plotted consistent with the calculations for the hourly bars. Independent calculations show that day bar calculations are correct, and they are displayed on the analyzer chart as correct.
Attached also are two Notepad files for side by side comparison. Hourly bar indicator calculations show to be different from day bar calculations [but are close when ‘shifted’ as discussed in the following sentences]. A clue to the problem [assuming I am correct and there is a problem] may be that [eg] 08/15/13 5:00PM//17:00 day bar OHLC values are the same as for 08/16/13 5:00AM//05:00 non-day bar values. The same situation exists for all other dates as well. My concern is not to learn why the problem exists, it is only to correct the problem – which probably can be done by fixing the Ninja code which does the getdaybar calculations. In all humbleness, I am aware that my perceptions can be wrong, it has happened before.
In summary, the redline indicator on a day chart is not the same as the redline indicator on a non-day chart…and to me that makes no sense. I think the getdaybar calculation needs to be tweaked a bit per the discussion just above].
[Note: there is no discrepancy between 60 minute bar and 1440 minute bar calculations, probably because they are both calculated from the getdaybar function.]
Comment
-
Hello joemiller,
A 1440 minute chart will show the first tick (from the first trade of the day). The daily bar is showing the open price. This is controlled by the data provider.
A chart open with 1440 minute bars does not use Bars.GetDayBar.
Please open a chart with 1440 minute bars using the forex template and a daily chart using the same template. Compare the open prices looking back for a few weeks.
I recommend you stop using day bars.Chelsea B.NinjaTrader Customer Service
Comment
-
In my strategy analyzer back testing using day bars, on many days both the profit limit and stop loss prices are hit. Not knowing which is hit first, the conservative guess is to assume the stop loss price is touched first.
When I have made a back test using day bars, I then need to back test using minute bars. The use of minute bars presents the answer to which was hit first during the day to close out the position.
Are you suggesting that simply running a one minute bar back test will accomplish my objective?
[I would of course use minute bars rather than 60 minutes, 360 minute, 1440 minute bars etc. Those longer duration bars have been used only to try to simplify our discussion.]
Comment
-
joemiller,
I am saying that you should use 1440 minute bars for running this strategy and to stop using day bars.
Day bars are shaped by the data provider.
Regarding not know if the stop or target is hit add TraceOrders = true; to the initialize part of your script.
This will let you know the names of the orders being filled.Chelsea B.NinjaTrader Customer Service
Comment
-
I know that day bars are giving me the correct indicator so I need to then proceed from there.
I know that 1440 minute bars and 1 minute bars result in indicators that that are equal to each other, which sounds great, but they are not equal to the day bar indicator so they are of no use.
My indicator is a function of yesterday’s bar open, high, low, close. If those open, high, low, close values are different for minute bars and day bars then there is no point in running the minute bar back test.
I must continue trading on a day bar basis. I don’t have the time or interest to manage trades on an intra day basis. My strategy is to enter GTC orders. When position close out occurs [on the first day or any day thereafter] then I am flat for the remainder of the day, entering new orders the next day. Valid minute bar analysis will tell me whether or not, for instance, the worst case scenario of always hitting the stop loss price first is likely to occur.
The implication to me is that getdaybar values of open, high, low, close do just simply that…and I don’t understand why that cannot simply be done, all the values are there and available. Looks to me like NT does hundreds of things seemingly far more complicated than that.
Comment
-
Hello,
Bars.GetDayBar returns the Open, High, Low, and Close for a 1440 Minute Bar (non-filtered Day Bar).
This is the intended functionality of Bars.GetDayBar.
If you would like Bars.GetDayBar to return the OHLC for the filtered day bar (filtered by the data provider) I can submit a feature request in your behalf to include a second type of GetDayBar that uses the filtered day bar.
Would you like me to submit this request in your behalf?
In response to your statement mentioning that on the daily bar that you are running this strategy on you would like to know if the stop or the target is hit, adding TraceOrders = True will allow you to see if it is the stop or the target is hit. If you are wanting some indication of when this happens, then add logic to the the OnExecution part of your script to print or draw when the stop or target is filled.
There is no need to have intra-bar granularity to see if the profit target or stop loss is being filled.Chelsea B.NinjaTrader Customer Service
Comment
-
Re: Would you like me to submit this request in your behalf?
Definitely yes, please do. Thank you and much appreciated. How long do you think it will take until implementation?
Re: adding TraceOrders = True
I am only interested in seeing results as reflected in the analyzer profit graph, which can only be achieved using minute bars, so I think there is a need for the minute bar analysis. The profit target/stop loss was only an example of the kind of info hidden in a day bar which can only be exposed with minute bar analysis.
Comment
-
Hi joemiller,
I have submitted this feature request for a second Bars.GetDayBar which uses the data provider filtered Daily Bar.
I cannot comment on when or if this will be implemented in NinjaTrader, that will be up to our development team to decide.
I will give you a tracking number for this request when I receive one from development so that you can check in on the progress at a later time.
Thank you for the great suggestion to improve NinjaTrader.Chelsea B.NinjaTrader Customer Service
Comment
-
Hi Joe, reviewing this suggestion made I guess I'm not clear on why this would be beneficial, the provider native daily bar series could be for example added through the Add() method in the script's Initialize() and you could reference the data then or have an indicator method run on this series as well.
Comment
-
Hi Bertrand,
If it takes 58 posts to get to this point without being advised of an easy fix, plus a lot of time spent by me and NT, then something needs to be fixed. I will try to understand and do what you advise [which is more mickey mousing around]. Any additional detailed coding examples to accomplish the goal will be appreciated.
An undetected/unrealized discrepancy between the indicator daily and hourly bars could even potentially generate lawsuits claiming use of faulty software tools provided by NT. People sue all the time on flimsier grounds. [There is no threat from me to do so. I am not one of those, plus all my trading using NT has been simulated, not real.]
Comment
-
Hello joemiller,
The issue here is the discrepancy between a Daily bar that is filtered by the data provider and a 1440 minute bar using the same Forex template that may not show the same open price.
Daily bars are created by the data provider and will not always match the open high low or close of intraday data.
Please open a chart with 1440 minute bars using the Forex template and a daily chart using the same Forex template. Compare the open prices looking back for a few weeks.
For example with a $EURUSD Daily bar on FXCM the bar for yesterday 8/26 opens at 1.3375 while a 1440 minute bar with the same template opens at 1.3378 a difference of 3 ticks.
Please open two charts to the $EURUSD. One with a daily bar and one with a 1440 minute bar. Please compare the open prices for these bars for August 26th 2013.
Regarding Bars.GetDayBar tool with NinjaTrader, this is from our help guide.
Returns a Bar object that represents a trading day whose properties for open, high, low, close, time and volume can be accessed. This bar is a virtual bar built off of the underlying data series. In some cases, the trading day bar can be used to represent a daily bar. Since this bar is virtual, its property values are calculated based on session definitions contained in the trading day only. This does not necessarily represent the actual day.
http://www.ninjatrader.com/support/h.../getdaybar.htm
This means that you can have Bars.GetDayBar reference the provider made daily bar if you use a day bar for your chart.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
50 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
126 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
69 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment