• 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 tonynt, Today, 02:18 PM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_JoshG  
      Started by denalek2419, Today, 01:46 PM
      2 responses
      9 views
      0 likes
      Last Post denalek2419  
      Started by REI140205, Today, 12:58 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by Aditrade, Today, 12:33 PM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by music_p13, Today, 12:22 PM
      2 responses
      10 views
      0 likes
      Last Post music_p13  
      Working...
      X