Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Bid/Ask in backtesting

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

    Using Bid/Ask in backtesting

    Hello,

    Is it possible to trigger OnBarUpdate() for every new best bid/best ask?

    I've added both series in Initialize() thus:

    Code:
    Add("6N 12-13", PeriodType.Tick, 1, MarketDataType.Last);
    Add("6N 12-13", PeriodType.Tick, 1, MarketDataType.Bid);
    Add("6N 12-13", PeriodType.Tick, 1, MarketDataType.Ask);

    But when OnBarUpdate() is called, I cannot find the bid/ask's size, only its timestamp.

    Please advise.

    #2
    Hi Boaza,

    Thank you for your post.

    OnBarUpdate() will only get called in two instances. The first is when CalculateOnBarClose is set to true. Then OBU will only get updated when the bar being built closes.

    When COBC is set to false then OBU will get called with every incoming tick of data.

    This tick of data is the Last price unless the chart is set to only show Ask or Bid prices.

    However, you can use OnMarketData() that will get called when Bid or Ask data comes in.
    Below is a link on the method -
    http://www.ninjatrader.com/support/h...marketdata.htm

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,

      Sorry for not being clearer, but I meant during backtesting, not live trading.

      Boaz

      Comment


        #4
        Boaza,

        Adding the multiple time series as you have, you will need to use BarsArray[] to tell the script which data series to call and use for the calculations.

        Below is a link on the Multi-Timeframe and Instruments with NinjaScript -
        http://www.ninjatrader.com/support/h...nstruments.htm

        The second link is on using the BarsArray[] -
        http://www.ninjatrader.com/support/h...?barsarray.htm
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, Yesterday, 10:06 AM
        0 responses
        17 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        16 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        14 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        9 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        36 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X