Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicator values for non-daily bars not consistent with daily bars?

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

  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • joemiller
    replied
    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.]
    Attached Files

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • joemiller
    replied
    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.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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?

    Leave a comment:


  • joemiller
    replied
    hi Chelsea,

    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?

    Leave a comment:


  • joemiller
    replied
    it is a backtest.

    screen shot is attached.

    Run it once, clear the output window, then run the backtest again. I think maybe I've seen that make it happen...not sure.

    the double output is a problem I can live with. the other is much more important to me.
    Attached Files

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hi joemiller,

    I still am not able to replicate the duplicates.

    Are you running a backtest or optimization?

    May I have a screenshot of the parameters in the Strategy Analyzer?

    To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

    For detailed instructions please visit the following link
    http://take-a-screenshot.org/

    Leave a comment:


  • joemiller
    replied
    The output for dates Aug7 thru Aug13 In the Notepad file attached to Post 38 is repeated for both the day and the minute bars.

    One set of dates for the day and minute bars are then moved to the Excel file for hopefully easier analysis.

    bottom line, I want to have NT plot the correct red line in the analyzer chart for the non-day bars ... which is a function of the values returned by getdaybar.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hi joemiller,

    Sorry I forgot to address that second question.

    I am not seeing this repeating.. in my prints and in the files you have given me I am not seeing any duplicate prints.

    Can you provide a new output file showing these duplicates.

    Also, with the information you have 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?

    Leave a comment:


  • joemiller
    replied
    So now, per the Excel spread sheet, if I can get to the correct getdaybar values I am probably home free. But how do I do that? I have experimented with a few coding changes but no success so far.

    Second question: Why does the info in the output windows repeat?

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello joemiller,

    This info is all correct.

    Our time zones are making things confusing.

    From the data you have in the text files you have sent I am seeing that you are on the east coast.

    Currently, I am writing you from Denver Colorado, in mountain time.

    The 5:00 PM bar for you ends the session and is included with the day bar of the same date.

    For me the Forex session ends at 3:00 PM (5:00 PM eastern). My local 5:00 PM bar print is part of the session ending on the next day.

    Your data prints are correct however.

    Leave a comment:


  • joemiller
    replied
    Attached is the Excel zipped file referred to in the previous post.

    The following repeats what was said in the previous post about the spreadsheet:
    The output is for 5 days, wed aug7 thru tue aug13.
    In the Excel spreadsheet yellow high lites show OHLC, shifted for days vs non-days, to be the same. Red high lite values at the end broke the yellow pattern? [but not by much [ie] the open is slightly different].
    There is no 6 pm for Friday august9 [marked in red] because the Forex market shuts down for the weekend at 5pm.

    p.s. Why does the info in the output windows repeat?
    Attached Files
    Last edited by joemiller; 08-16-2013, 02:39 AM.

    Leave a comment:


  • joemiller
    replied
    Chelsea,

    Attached are:
    1 the indicator, updated to display 5 days instead of 3 in the output window
    2 the strategy
    3 the output window
    4 an Excel spreadsheet for the output window [not yet attached]
    I haven't been able to attach the Excel file yet. I am running out of time - please tell me how to do it. maybe a zip file?

    The output is for 5 days, wed aug7 thru tue aug13.
    In the Excel spreadsheet yellow high lites show OHLC, shifted for days vs non-days, to be the same. Red high lite values at the end broke the yellow pattern?

    The hourly bar indicator red line continues to be well behaved [a straight line for each 24 hour set] and correct for the wrong values it was given to calculate its value.
    Strange that my results and your results were not the same last time?
    There is no 6 pm for Friday august9 [marked in red] because the Forex market shuts down for the weekend at 5pm.

    I want to get this into your hands. Meanwhile I will try to make sense of it. Looks like the problem may be solvable if I can pick up values a day later [or earlier]?
    Attached Files

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello joemiller,

    I am not getting any prints when backtesting this with day bars.

    This is because you are only allowing the prints if the time of the bar is 5 or 6 on 8/12 or 8/13.

    Even so, using the $EURUSD my prints for the hours bars are:

    from joeXXOindicator 08/12/13 5:00PM//17:00
    ***MINUTE BARS***
    GetDayBar open= 1.3313
    GetDayBar high= 1.3343
    GetDayBar low= 1.3276
    GetDayBar close= 1.3299
    from joeXXOindicator 08/12/13 6:00PM//18:00
    ***MINUTE BARS***
    GetDayBar open= 1.3313
    GetDayBar high= 1.3343
    GetDayBar low= 1.3276
    GetDayBar close= 1.3299
    from joeXXOindicator 08/13/13 5:00PM//17:00
    ***MINUTE BARS***
    GetDayBar open= 1.3297
    GetDayBar high= 1.3316
    GetDayBar low= 1.3232
    GetDayBar close= 1.3261
    from joeXXOindicator 08/13/13 6:00PM//18:00
    ***MINUTE BARS***
    GetDayBar open= 1.3297
    GetDayBar high= 1.3316
    GetDayBar low= 1.3232
    GetDayBar close= 1.3261

    Looking at a daily chart I am seeing the following:

    8/12:
    Open: 1.3313
    High: 1.3343
    Low: 1.3276
    Close: 1.3299

    8/13:
    Open: 1.3299
    High: 1.3316
    Low: 1.3232
    Close: 1.3261


    The bar for the 13th actually has a 2 tick discrepancy. This is because the minute data is showing the first tick (from the first trade of the day). The daily bar is showing the open price that is controlled by the broker.

    To see this difference, please open a 1440 minute $EURUSD chart and a daily interval with the same instrument on another chart. Be sure to use the same session template for both.

    Compare the open high low close values of these charts.

    I am attaching a screenshot of how this looks for me.
    Attached Files
    Last edited by NinjaTrader_ChelseaB; 08-15-2013, 01:46 PM.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by charlesugo_1, 05-26-2026, 05:03 PM
0 responses
60 views
0 likes
Last Post charlesugo_1  
Started by DannyP96, 05-18-2026, 02:38 PM
1 response
148 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by CarlTrading, 05-11-2026, 05:56 AM
0 responses
162 views
0 likes
Last Post CarlTrading  
Started by CarlTrading, 05-10-2026, 08:12 PM
0 responses
97 views
0 likes
Last Post CarlTrading  
Started by Hwop38, 05-04-2026, 07:02 PM
0 responses
284 views
0 likes
Last Post Hwop38
by Hwop38
 
Working...
X