Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Box Chart Type with Indicators or Strategies

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

    Box Chart Type with Indicators or Strategies

    It is my understanding that multiple data series need to be added programmatically in indicator and strategy code like is shown generally below for example, rather than being added to charts manually, to insure reliable time synchronization and Bars object indexing.

    Code:
    protected override void OnStateChange()
    {
        if (State == State.Configure)
        {
            // Add a 1 minute Bars object
            AddDataSeries(BarsPeriodType.Minute, 1);
        }
    }
    
    protected override void OnBarUpdate()
    {
        if (BarsInProgress == 1)
        {
            // Do processing here that is to be performed at the close of each data-series minute.
    
        }
        else if (BarsInProgress == 0)
        {
            // Do processing here that is to be performed at the close of each chart bar.
    
        }
    }
    If that is true, does it follow that neither indicators nor strategies can be used reliably with the Box Chart Type, because either data series may happen by chance to be indexed as 0 or 1?

    #2
    Hello caveat_lector,

    Thanks for your post.

    The chart style of Box is just a way to present the underlying data which is the same OHLC values used to build the chart style of candlesticks. The box only presents the High and Low of the data series but the price series of Open and Close are still available even thought in the chart style of Box they are not visualized. By default most indicators will use the Close price of the data series and this would be no different with the chart style of Box. You can verify this by creating a chart with box and with candle sticks using the same data series as the input and add the same indicators and compare verify their price levels.

    In terms of Multi time frames or multi series, when using Calculate.OnBarClose the script is not working with the currently forming bar but the previously closed bar, so if one time frame is 15 minute and the chart bars are 1 minute at the 14 minute mark of the new 15 bar if the one minute bars ask for the value of the 15 minute bar, they would actual return the last close 15 minute bar's values which was 14 minutes ago. This is true for Calculate.OnBarClose OR looking an any historical data regardless of the calculate mode used. For a better visualization, please see the diagram in the section " How Bars Data is Referenced" https://ninjatrader.com/support/help...nstruments.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I may have a misunderstanding and will study information on the Multi-Time Frame & Instruments page you referenced tomorrow when I have more time, but based upon my current understanding my concern is with what seems to me will be unpredictable bars-back indexing. Of course, indicators and strategies commonly depend on information about market prices and/or trading volumes at specified time-intervals in the past. If a user loads both a 1-minute and a 15-minute time-frame data series to be able to see 1-minute chart candles plotted over 15-minute High/Low bars by means of the Box chart style and then loads any indicator that uses bars-back, it seems to me that depending on which of those two data series happen to load first and become primary, a length setting of 10, for example, might be either 10-minutes or 150-minutes back.
      Last edited by caveat_lector; 01-21-2020, 01:54 PM.

      Comment


        #4
        Hello caveat_lector,

        Thanks for your reply.

        When you have a multi series/time frame script, each data series, when it updates the OnBarUpdate() (as determined by the Calculate mode when using live data) will call the OnBarUpdate() method. If you are not segmenting your code by BarsInProgress then certainly the references will shift from one to the other, for example if you had the condition if (SMA(30)[0] > SMA(30)[1]) when the 1 minute bar calls OnBarUpdate this would evaluate as an 30 minute SMA. If the 15 minute bars call OnBarUpdate() that would evalue at as 30 15 minute bars for the SMA which would be an entirely different value. The previously provided help guide link does cover these concepts and provides alternatives depending on the specific needs of your script.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Brevo, Today, 01:45 AM
        0 responses
        6 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        6 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Working...
        X