Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

tick data during historical

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

    tick data during historical

    i have a indicator where i do calculation in the tick mode by adding tick as multitimeframe series.
    when the indicator starts and processes historical data, does it execute tick by tick during the historical state?

    i did a test and it shows that it does not calculate historical data
    Code:
       protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                Overlay				= false;
    			 Add(PeriodType.Tick, 1);
    			  CalculateOnBarClose = false;
    			
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
    			if(BarsInProgress==0){
    				if(FirstTickOfBar)
    				{
    					myInput0=0;
    				}
    				
                Plot0.Set(myInput0);
    			}
    			if(BarsInProgress==0){
    				myInput0+=1;
    			}
    			
    			
            }
    Last edited by junkone; 11-19-2016, 03:36 PM.

    #2
    Hello,

    There are two problems with the logic.
    1, FirstTickOfBar is always true in historcial as CalculateOnBarClose would always be true. The order of operations would need to change between realtime and historical for this.
    2, you have BarsInProgress == 0 twice, 1 is needed for the second condition.

    Here is a sample that cuts off in historical on each new bar, but would accumulate and plot for the ticks:


    Code:
      
    protected override void OnBarUpdate()
    {
              if(BarsInProgress==0)
              {
    		if(!Historical)
    		{
    		        if(FirstTickOfBar)
    			{
    				myInput0=0;
    			}
    			Plot0.Set(myInput0);
    		} else {
    			Plot0.Set(myInput0);
    			myInput0=0;
    		}
    	}
    	else if(BarsInProgress==1)
            {
    		myInput0+=1;
    	}
    }
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      let me clarify further?
      i have a indicator on 5 minute bar and do some calculation on the tick data using multitimeframe series,

      when it is processing during the Historical state, does the barsinprogress==tick have all the ticks that it collected or does it have only 1 tick per 5 minute interval?

      Comment


        #4
        Hello junkone,

        Thanks for your reply.

        Using the example of a chart with 5 minute bars and your script is adding 1 tick bars.

        The 5 minute bars will be associated with BarsInProgress 0. You would see BarsInProgress==0 once per 5 minute bar.

        The 1 tick bars will be associated with BarsInProgress 1. You would see BarsInProgress == 1 once per tick bar.

        To further illustrate, lets assume that when the 5 minute bar was recorded there were 1000 tick bars recorded in the same time (this is just an example). When your code is run on this specific example, OnBarUpdate() would be called 1001 times. The first 1000 OBU calls, BarsInProgress == 1 would be true. For the 1001st OBU call BarsInProgress == 0 would be true.

        You can access the tick dataseries during BarsInProgress == 0 by specifying the BarsArray[1] which will point to the tick data series, so for example:

        if (BarsInProgress == 0) // of the 5 minute bar
        {
        double smaValue = SMA(BarsArray[1], 100)[0]; // get the 100 period SMA of the tick data
        }

        References:
        http://ninjatrader.com/support/helpG...nstruments.htm
        http://ninjatrader.com/support/helpG...inprogress.htm
        http://ninjatrader.com/support/helpG...?barsarray.htm
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by PhillT, 04-19-2024, 02:16 PM
        4 responses
        31 views
        0 likes
        Last Post PhillT
        by PhillT
         
        Started by ageeholdings, 05-01-2024, 05:22 AM
        5 responses
        36 views
        0 likes
        Last Post ageeholdings  
        Started by reynoldsn, Today, 02:34 PM
        0 responses
        10 views
        0 likes
        Last Post reynoldsn  
        Started by nightstalker, Today, 02:05 PM
        0 responses
        17 views
        0 likes
        Last Post nightstalker  
        Started by llanqui, Yesterday, 09:59 AM
        8 responses
        30 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Working...
        X