Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    JesseNinjaTrader Customer Service

    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 rbeckmann05, Yesterday, 06:48 PM
      1 response
      12 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Working...
      X