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

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, [B]double high, double low, double close[/B], 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
                {
    [B]                double        barClose    = bars.GetClose(bars.Count - 1); 
                    double        barHigh        = bars.GetHigh(bars.Count - 1); 
                    double        barLow        = bars.GetLow(bars.Count - 1); [/B]
                    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 cmtjoancolmenero, Yesterday, 03:58 PM
      11 responses
      39 views
      0 likes
      Last Post cmtjoancolmenero  
      Started by FrazMann, Today, 11:21 AM
      0 responses
      5 views
      0 likes
      Last Post FrazMann  
      Started by geddyisodin, Yesterday, 05:20 AM
      8 responses
      52 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by DayTradingDEMON, Today, 09:28 AM
      4 responses
      26 views
      0 likes
      Last Post DayTradingDEMON  
      Started by George21, Today, 10:07 AM
      1 response
      22 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Working...
      X