• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarType OnDataPoint Question

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

    BarType OnDataPoint Question

    In the RangeBarsType class contains the following code:

    Code:
        protected override void OnDataPoint(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isBar, double bid, double ask)
            {
                if (SessionIterator == null)
                    SessionIterator = new SessionIterator(bars);
    
                bool isNewSession = SessionIterator.IsNewSession(time, isBar);
                if (isNewSession)
                    SessionIterator.GetNextSession(time, isBar);
                if (bars.Count == 0 || bars.IsResetOnNewTradingDay && isNewSession)
                    AddBar(bars, open, high, low, close, time, volume);
                else
                {
                    double        barClose    = bars.GetClose(bars.Count - 1); 
                    double        barHigh        = bars.GetHigh(bars.Count - 1); 
                    double        barLow        = bars.GetLow(bars.Count - 1); 
                    double        tickSize    = bars.Instrument.MasterInstrument.TickSize;
                    double        rangeValue    = Math.Floor(10000000.0 * bars.BarsPeriod.Value * tickSize) / 10000000.0;

    bars.GetClose(bars.Count - 1) gets the close of the current bar. How is this different from the close parameter that is being passed into the OnDataPoint method?

    Also: Is there a tutorial anywhere that explains how BarType classes work?

    #2
    Hello kevinenergy,

    Thanks for your post.

    bars.GetClose will reference the close value from the Bars object you are building with the BarsType, while OnDataPoint will give the OHLC values from the underlying data series that builds the bar. For example, using a tick based, minute based, or daily based bar.

    OnDataPoint documentation can be referenced here - https://ninjatrader.com/support/help...ndatapoint.htm

    BarsType documentation can be found here - https://ninjatrader.com/support/help.../bars_type.htm

    We do not have any additional tutorial information on BarsTypes, but I may suggest using the open source BarsTypes as reference as well as other free and open source bars types that are available from User App Submissions.

    Misc. NinjaTrader 8 user submissions - https://ninjatraderecosystem.com/use...atrader-8-misc

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      bars.GetClose will reference the close value from the Bars object you are building with the BarsType, while OnDataPoint will give the OHLC values from the underlying data series that builds the bar. For example, using a tick based, minute based, or daily based bar.
      This is very helpful info Jim - thanks for the clarification. I managed to make a new Bar Type! They should consider adding the above to the OnDataPoint docs page; it is succinct and massively helpful for understanding how BarTypes work.

      Thanks again!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by dkbyond, Today, 04:11 PM
      0 responses
      5 views
      0 likes
      Last Post dkbyond
      by dkbyond
       
      Started by markus3500, Today, 03:29 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by bohenriksen, Today, 04:00 AM
      1 response
      21 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by brett0, Today, 12:33 PM
      3 responses
      15 views
      0 likes
      Last Post marcus2300  
      Started by lordvader34, Today, 11:12 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Working...
      X