Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Multiple Time Frame Issue

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

    #16
    The problem here is that NinjaTrader cannot correctly add daily bars to any DataSeries.
    I have written numerous posts about this subject, but my posts have been ignored.


    Daily bars problem

    For example

    Code:
    double close1        = Closes[1][1];
    will only work when being connected to a datafeed. As soon as you disconnect and refresh the chart, NinjaTrader will not be able to access the correct close. If you wish to call daily data you can only do it the way it has been done for the pivots indicator that ships with NinjaTrader. Please copy the code from that indicator for calling daily data. Also the pivots indicator has some bugs, as it does not correctly call the prior day's data for all trading days.

    BarsRequiredToPlot

    BarsRequiredToPlot does not affect the calculation of any Series<double> objects. All objects will be calculated, but not displayed. BarsRequiredToPlot is applied to the primary bars, and there is no logical need to apply it to the secondary bar series. Anything like

    Code:
    if (CurrentBars[0] <= BarsRequiredToPlot || CurrentBars[1] <= BarsRequiredToPlot) return;
    does not make sense. It is important to understand what BarsRequiredToPlot is good for. For example if you calculate a EMA(20), the values calculated for the first 60 something bars are false. Therefore you do not wish to display them, and you would ideally set BarsRequiredToPlot = 3* period. This avoids displaying false results on your chart.

    Each indicator has a training period, where you wish to perform calculations, but not yet display the results, because they are inaccurate. If you do not perform the calculations during the training period (as you did with your code) then you will simply need to wait for 120 bars (60 hidden and 60 false bars) before your indicator works correctly.

    Just check CurrentBars[0] and CurrentBars[1] against the value 0. That is entirely sufficient.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CortexZenUSA, Today, 12:53 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by CortexZenUSA, Today, 12:46 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by usazencortex, Today, 12:43 AM
    0 responses
    5 views
    0 likes
    Last Post usazencortex  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    168 responses
    2,265 views
    0 likes
    Last Post sidlercom80  
    Started by Barry Milan, Yesterday, 10:35 PM
    3 responses
    11 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X