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

Has IsFirstTickOfBar issues reported ?

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

  • NinjaTrader_ChelseaB
    replied
    Hello pstrusi,

    This would depend on if you are looking at historical data or realtime data.

    if Calculate is set to OnPriceChange in real-time or historically with TickReplay enabled the behavaior should be the same. With TickReplay disabled, IsFIrstTickOfBar will always be true in historical data.

    From the help guide:
    "On a historical data set, only the OHLCVT of the bar is known and not each tick that made up the bar. As a result, State.Historical data processes OnBarUpdate() only on the close of each historical bar even if this property is set to OnEachTick or OnPriceChange. You can use TickReplay or a Multi-time frame script to obtain intrabar data."

    Below is a publicly available link to the help guide on Calculate.


    And TickReplay.

    Leave a comment:


  • pstrusi
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello pstrusi,

    Print the value of IsFirstTickOfBar along with the time.

    Is this true when you are expecting it? (and false when you are expecting it?)

    I've tested but I'm not able to reproduce any issues printing the IsFirstTickOfBar with Calculate set to OnEachTick in real-time or historically with TickReplay enabled.
    Chelsea, a simple question:

    If I set " Calculate as Calculate.OnPriceChange ", but I didn't activate the Tick replay property in the Data series: would it "IsFirstTickOfBar" still work? Tickreplay seems to be a feature to evaluate in the historical data, but when it comes to realtime data, whay would I need to have activated Tickreplay ?

    Thanks

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello pstrusi,

    Print the value of IsFirstTickOfBar along with the time.

    Is this true when you are expecting it? (and false when you are expecting it?)

    I've tested but I'm not able to reproduce any issues printing the IsFirstTickOfBar with Calculate set to OnEachTick in real-time or historically with TickReplay enabled.

    Leave a comment:


  • pstrusi
    started a topic Has IsFirstTickOfBar issues reported ?

    Has IsFirstTickOfBar issues reported ?

    I think there must be a problem with " IsFirstTickOfBar" cause I can't find any other cause. In the following simple code you can see the logic flow. If "IsFirstTickOfBar" is true, all statements should be triggered, but they doesn't.

    Here the code:
    Code:
    namespace NinjaTrader.NinjaScript.Strategies
    {
    	public class Trendline
    	{
    		public int Position;
    		public double Price; 
    		
    		public Trendline()   
    		{
    			Position=0;
    			Price=0.00;
    		}
    	}	
    	
    	public class R : Strategy
    	{		
    		Trendline[] Uptrend;			  	 															// Array of uptrends
    		Trendline[] Downtrend;																			// Array of uptrends
    		private int ARRAY_SIZE;																			// Array size
    		private int Uptrendcount;																		// Number of active uptrends
    		private int Downtrendcount;																		// Number of active Downtrends
    
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description									= @"";
    				Name										= "R";
    				Calculate									= Calculate.OnPriceChange;
    				MaximumBarsLookBack							= MaximumBarsLookBack.Infinite; 			
    			}
    			else if (State == State.Configure)
    			{
    				ARRAY_SIZE									= 100000;
    				Uptrendcount								= 0;
    				Downtrendcount								= 0;
    				Uptrend										= new Trendline[ARRAY_SIZE];
    				Downtrend									= new Trendline[ARRAY_SIZE];
    			}
    		}
    
    		protected override void OnBarUpdate()
    		{
    			if ( CurrentBar < 1 )
    			{
    				Uptrendcount=0;
    				Downtrendcount=0;
    				for (int i = 0; i <ARRAY_SIZE; i++)
    				{			
    					Uptrend[i]= new Trendline();
    					Downtrend[i]= new Trendline();
    				}
    				for (int i = 0; i <ARRAY_SIZE; i++)  // just in case this initialization was necessary to solve the issue
    				{			
    					Uptrend[i].Position=0;
    					Uptrend[i].Price=0.00;
    					Downtrend[i].Position=0;
    					Downtrend[i].Price=0.00;
    				}
    				return;
    			}			
    		    if (IsFirstTickOfBar) 
    		    {
    				if ( Uptrendcount==0 && Downtrendcount==0 )
    				{
    					Ps=0;
    				}
    				else
    				{
    					// certain code
    				}	
    				Uptrendcount+=1;
    				Downtrendcount+=1;		
    		    }
                        ...the continues relying on that at least are Uptrendcount=1 and Downtrendcount=1, but they're just 0....logically I got an array error outside of bounds
    So, I'd appreciate any apporach, idea, test...etc to perform in order to solve it. I'm thinking that perhaps is related to Tickreplay property.

    Thanks in advance
    Last edited by pstrusi; 09-11-2017, 11:47 AM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by Haiasi, 04-25-2024, 06:53 PM
2 responses
16 views
0 likes
Last Post Massinisa  
Started by Creamers, Today, 05:32 AM
0 responses
5 views
0 likes
Last Post Creamers  
Started by Segwin, 05-07-2018, 02:15 PM
12 responses
1,786 views
0 likes
Last Post Leafcutter  
Started by poplagelu, Today, 05:00 AM
0 responses
3 views
0 likes
Last Post poplagelu  
Started by fx.practic, 10-15-2013, 12:53 AM
5 responses
5,407 views
0 likes
Last Post Bidder
by Bidder
 
Working...
X