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 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