Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TickReplay vs Live data OnMarketData

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

    TickReplay vs Live data OnMarketData

    In VolumeProfile.cs there is a statement for tick replay in OnMarketData, but in BuySellVolume.cs checking for Bars.IsTickReplay is not required. Is there a difference in the values of the bid/ask size and price between these two indicators?

    VolumeProfile.cs
    Code:
    if (Bars.IsTickReplay)
    
    
    			{
    				if (e.MarketDataType == MarketDataType.Last)
    				{
    					if (e.Price >= e.Ask)
    						askPrice = e.Price;
    					else if (e.Price <= e.Bid)
    						bidPrice = e.Price;
    
    					price	= e.Price;
    					volume	= e.Volume;
    
    					if (!cacheDictionary.ContainsKey(price))
    						cacheDictionary.Add(price, new VolumeInfoItem());
    
    					volumeInfoItem = cacheDictionary[price];
    
    					if (price >= askPrice)
    						volumeInfoItem.up		+= volume;
    					else if (price <= bidPrice)
    						volumeInfoItem.down		+= volume;
    					else
    						volumeInfoItem.neutral	+= volume;
    				}
    			} else
    			{
    				if (e.MarketDataType == MarketDataType.Ask)
    				{
    					askPrice = e.Price;
    					return;
    				}
    
    				if (e.MarketDataType == MarketDataType.Bid)
    				{
    					bidPrice = e.Price;
    					return;
    				}

    BuySellVolume.cs
    Code:
     if(e.MarketDataType == MarketDataType.Last)
    			{
    				double tradeVol = previousVol == 0 ? e.Volume : e.Volume - previousVol;
    				
    				if(e.Price >= e.Ask)
    				{
    					buys += tradeVol;
    				}
    				else if (e.Price <= e.Bid)
    				{
    					sells += tradeVol;
    				}
    			}

    #2
    Also, in tick replay, it doesn't look like the bid / ask Sizes are available.

    Comment


      #3
      Hello habibalex,

      Thank you for reporting this.

      There should be no different in how they are treated. From my understanding we would need to include the same logic in BuySellVolume. I will check with development on this.

      For the size, are you referring to Volume?

      Comment


        #4
        Hello habibalex,

        Thank you for your patience.

        The code for IsTickReplay in the VolumeProfile is the same as that which already exists in the BuySellVolume. The added code for VolumeProfile was added to improve it's behavior over historical sessions when using TickReplay.

        Comment


          #5
          yes the volume of the bid / ask

          Comment


            #6
            habibalex,

            Is marketDataUpdate.Volume what you are looking for?

            Comment


              #7
              No I am looking for the volume on the bid and ask, not last traded volume in Tick Replay.
              for example

              Code:
               
              if(Bars.IsTickReplay){
              
                  if(e.MarketDataType == MarketDataType.Bid){
                      //I need e.Volume here
                  }else if(e.MarketDataType == MarketDataType.Last){
                      //Or I can use it here, but there is nothing called e.BidVolume / e.AskVolume.  
                  }
              }

              Comment


                #8
                habibalex,

                It would be the following:
                Code:
                if(e.MarketDataType == MarketDataType.Bid)
                Print("Bid volume is " + e.Volume);
                As we have verified e is the Bid update, we pull the e.Volume for the bid volume.

                Comment


                  #9
                  If I do this, I do not get anything in the output window.

                  Code:
                                         if(Bars.IsTickReplay && State == State.Historical){
                  
                  			    if(e.MarketDataType == MarketDataType.Bid){
                  			        Print(e.Volume + " " + e.Price);
                  			    }
                  			}

                  Comment


                    #10
                    habibalex,

                    Thank you for your response.

                    My mistake as the historical volume for bid and ask is not available through OnMarketData() nor when using OnMarketData() in TickReplay. You would need to use AddDataSeries() and add the bid and ask and then call it's volume.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Rapine Heihei, 04-23-2024, 07:51 PM
                    2 responses
                    30 views
                    0 likes
                    Last Post Max238
                    by Max238
                     
                    Started by Shansen, 08-30-2019, 10:18 PM
                    24 responses
                    943 views
                    0 likes
                    Last Post spwizard  
                    Started by Max238, Today, 01:28 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post Max238
                    by Max238
                     
                    Started by rocketman7, Today, 01:00 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post rocketman7  
                    Started by wzgy0920, 04-20-2024, 06:09 PM
                    2 responses
                    28 views
                    0 likes
                    Last Post wzgy0920  
                    Working...
                    X