Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Secondary timeframe interfering with strategy execution?

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

    Secondary timeframe interfering with strategy execution?

    Hello,

    I've been struggling with this for what seems like forever. I have a very simple strategy that works perfectly fine when run on any chart, using that same chart's data. I want to further refine it by combining it with a lower timeframe.

    However, when the lower timeframe chart runs it, using BarsArray[1] to reference the higher timeframe, it always starts off order pending. I run the strategy on the lower timeframe and the voice says "order pending", regardless of whether or not the conditions on the higher timeframe are appropriate for an entry.

    The code, when run on a 500 tick chart, referencing no other timeframes, works just fine:

    Code:
            protected override void Initialize()
            {
                CalculateOnBarClose = true;
            }
    
    //other stuff
    			if  (dsdiff < 1) 
    			{			
    				if (DoubleStochastics(11).K[0] < 20)
    
    				{  if ( (Position.MarketPosition == MarketPosition.Flat) && (useEntries == true)   ) 
    					{	EnterLong(quantity); 
    						SetProfitTarget(CalculationMode.Ticks, ProfitTicks); SetStopLoss(CalculationMode.Ticks, StopTicks);  
    					}  
    				}
                             }

    This code, when run on a 250 tick chart with a secondary timeframe of 500 ticks initialized as BarsArray[1], starts off "order pending" regardless of the conditions:

    Code:
    	
            protected override void Initialize()
            {
                CalculateOnBarClose = true;
    	    Add(PeriodType.Tick,  500); 	//  BarsArray[1]			
            }
    
    //other stuff, identical to the above
    
    		if  (dsdiff < 1) 
    			{			
    				if (DoubleStochastics(BarsArray[1], 11).K[0] < 20)
    
    				{ if ( (Position.MarketPosition == MarketPosition.Flat) && (useEntries == true)   ) 
    					{	EnterLong(quantity); 
    						SetProfitTarget(CalculationMode.Ticks, ProfitTicks); SetStopLoss(CalculationMode.Ticks, StopTicks);  
    					}  
    				}
                            }
    These code snippets are identical except for the "BarsArray" part. Both snippets should, theoretically, execute the trade when the conditions on the 500 tick chart are met. Run it on the 500 tick chart (with no other timeframes) and it's great. Run it on a lower timeframe and reference the higher one with BarsArray[1], and every execution starts off with "order pending" no matter what.

    What am I missing here?

    Thanks in advance,
    Gary

    #2
    Hello hawks67,

    Are you doing any checks for bars in progress to ensure that your trade is being triggered in the correct series?

    Is your condition to submit an order true when the strategy starts?

    Below is a link to an example of adding intra-bar granularity (adding a secondary series and referencing them correctly).
    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,404 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    95 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    8 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    159 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    8 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X