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 rjbtrade1, 11-30-2023, 04:38 PM
      2 responses
      75 views
      0 likes
      Last Post DavidHP
      by DavidHP
       
      Started by Stanfillirenfro, Today, 07:23 AM
      3 responses
      12 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by FitSpressoHonest, Today, 09:14 AM
      0 responses
      1 view
      0 likes
      Last Post FitSpressoHonest  
      Started by Davide999, 05-18-2023, 03:55 AM
      4 responses
      557 views
      1 like
      Last Post kcwasher  
      Started by rexsole, Today, 08:39 AM
      2 responses
      8 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X