Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

historical bid ask data

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

    historical bid ask data

    I created an indicator that requires bid ask data. How do I ask it when loading up a chart? It works live but not on initial loading

    #2
    Hello ballboy11,

    Thank you for your post.

    Is this indicator using GetCurrentBid() and/or GetCurrentAsk()? It would be expected for these to only function on real time data. For the indicator to function on historical data, Tick Replay would need to be used:



    Here's the example of how to access historical bid/ask prices using Tick Replay from the above link:

    Code:
    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
      // TickReplay events only occur on the "Last" market data type
      if (marketDataUpdate.MarketDataType == MarketDataType.Last)
      {
        if (marketDataUpdate.Price >= marketDataUpdate.Ask)
        {
            Print(marketDataUpdate.Volume + " contracts traded at asking price " + marketDataUpdate.Ask);
        }
    
        else if (marketDataUpdate.Price <= marketDataUpdate.Bid)
        {
            Print(marketDataUpdate.Volume + " Contracts Traded at bidding price " + marketDataUpdate.Bid);
        }
      }
    }
    Basically you'd want to separate your logic out so that on real time, it uses GetCurrentBid and GetCurrentAsk but on Historical data it uses the above approach. Tick replay would need to be turned on on the chart the indicator is applied to for the historical portion to function.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Kate if you want to take the above script, which i have try without success and calculate the spread where would i place the following into that script

      Spread[0] = (marketDataUpdate.Ask - marketDataUpdate.Bid);

      or do i not actually need all of that script, thanks

      Comment


        #4
        Hello DTSSTS,

        Thank you for your reply.

        You'd want to assign a non- Series<T> double variable the spread you calculate in OnMarketData. You can then use that variable in OnBarUpdate to assign the value to your Series<T> variable.

        I've attached a simple example script that shows how you could accomplish this. It requires Tick Replay to be turned on for it to function correctly.

        Please let us know if we may be of further assistance to you.
        Attached Files

        Comment


          #5
          Thanks much

          Comment


            #6
            Tick replay is resource intensive, and I could not be sure clients would enable as well so best not to use anything like that in strategies, Thanks for help.

            Comment


              #7
              Kate with you help I have an indicator that plots oneachtick the spread. If the chart remains open the plot continues through out the session. Of course if instruments are changed on the chart the plot starts with zero historical and creates a new plot for the new instrument. Point is the chart instrument has to remain live for the indicator to show any history

              Question is. If I create a condition in my Strategy using the indicator, (understand will not work on backtesting) After applying strategy to a chart the Spread Tracker would of course work same as it does as an indicator on a chart.

              IF I PLACE MY STRATEGY ON A INSTRUMENT LIST IN THE CONTROL CENTER (no charts) WILL THAT STILL TRACK THE SPREAD for all instruments the strategy is applied to

              Thanks, Hap

              Comment


                #8
                Hello DTSSTS,

                Thank you for your reply.

                If the strategy calls the spread indicator, yes, that would still calculate when the strategy is applied to the Strategies tab in the Control Center.

                Please let us know if we may be of further assistance to you.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                601 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                347 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                559 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                558 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X