Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bid / Ask historical

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

    Bid / Ask historical

    Hello,

    I'm trying to run a backtest - working with historical data - with my indicator. However, something is wrong.

    My real-time data logic - OnMarketData:

    if (e.MarketDataType == MarketDataType.Last)
    lastVolume = e.Volume;
    lastPrice = e.Price;
    else if (e.MarketDataType == MarketDataType.Ask)
    priceAsk = e.Price;
    else if (e.MarketDataType == MarketDataType.Bid)
    priceBid = e.Price;
    //My method
    myMethod(lastPrice, lastVolume);



    I've moved that logic to OnBarUpdate, now it's looks like this:

    protected override void Initialize()
    {

    Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Last);
    Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Ask);
    Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Bid);
    CalculateOnBarClose = true;

    }
    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)
    {
    lastVolume = Volume[0];
    lastPrice = Close[0];
    myMethod(lastPrice, lastVolume);
    }
    if (BarsInProgress == 2)
    {
    priceAsk = Close[0];
    }
    if (BarsInProgress == 3)
    {
    priceBid = Close[0];
    }
    }


    I would really appreciate any help you can give me.

    Cheers,

    Ronald.

    #2
    Hi Ronald, would you mind clarifying what is not working according to your expectations? The method you've designed is only called in BIP0 so for Last data per your code.

    Comment


      #3
      Hi Bertrand,

      Yes, that's correct. I need to be sure that my indicator works properly on historical and realtime data. That's the reason why I moved my logic to OnBarUpdate. However, the indicador is not displaying the right bid-ask information.

      My question is: How can I get Bid/Ask Intrabar values for historical purposes? I just need to simulate the OMD logic for backtest.

      Cheers,

      Comment


        #4
        I've read this online, is this accurate?

        The reason being that historical bid and ask data are stored in separate data structures with only 1 second time stamp resolution. This make it impossible to reconstruct historical bid, ask and last data in the same sequence as it occurred real time.
        Last edited by ronald.garcia; 02-01-2013, 03:14 PM.

        Comment


          #5
          Ronald, that's correct the timestamp resolution is down to 1 second. For our next major update we're looking to enhance this by allowing down the .NET .Ticks resolution (1 tick == 100 nanoseconds)

          Also, the 3 streams you work with are individually updating per series and are not inherently synched as the pure OnMarketDate() Level1 stream.

          Comment


            #6
            Thank you for your help.

            I'm looking forward to the next version.

            Ronald.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            576 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            553 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X