Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMarketData -> Problem with Multi Timeframe

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

    OnMarketData -> Problem with Multi Timeframe

    Hi,
    Can anybody tell me why my script showing OnMarketData volume twice ?


    Code:
     protected override void Initialize()
            {
                Overlay				= false;
    	  Add(PeriodType.Tick, 1);
    			
            }
    
            protected override void OnBarUpdate()
            {
           
    		if (BarsInProgress == 0) 
            	return; 
    			
    		
            }
    		
    		protected override void OnMarketData(MarketDataEventArgs e)
    		{
    			
    			if (Historical)
    				return;
    		
    		
    			 
    		if (e.MarketDataType == MarketDataType.Last){
    				
    		Print(this.BarsInProgress	+"---- HIT LAST---"+FormatPriceMarker(e.Price)+" -> " + e.Volume);
    				
    		}
    
    						
    		}

    in output window it show like this:

    0---- HIT LAST---128.11 -> 5
    0---- HIT LAST---128.11 -> 5
    0---- HIT LAST---128.11 -> 1
    0---- HIT LAST---128.11 -> 1
    0---- HIT LAST---128.11 -> 6
    0---- HIT LAST---128.11 -> 6

    you see it flash twice same last price volume.
    is there a bug when you using Add(PeriodType.Tick, 1); ?
    i know variable BarsInProgress but its always 0.

    #2
    Hello,

    Thank you for the question.

    This would be expected because you are Adding an additional series in Initialize which will also be calling OnMarketData.

    There is no default way to check that these are not the same event, instead you would need to use logic to do this.

    One of the support members had answered this question in a prior ticket and provided the following example script to help identify if the event was the same or not.

    Please let me know if I may be of further assistance.
    Attached Files

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello,

      Thank you for the question.

      This would be expected because you are Adding an additional series in Initialize which will also be calling OnMarketData.

      There is no default way to check that these are not the same event, instead you would need to use logic to do this.

      One of the support members had answered this question in a prior ticket and provided the following example script to help identify if the event was the same or not.

      Please let me know if I may be of further assistance.
      Yes it works !
      Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      82 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      43 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      68 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      56 views
      0 likes
      Last Post CarlTrading  
      Working...
      X