Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Place Orders with OnBarUpdate = false

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

    Place Orders with OnBarUpdate = false

    Hi,
    I am testing a sample strategy that place sell limit orders when "Close[0] > level" and buy lmit when "close[0] < level" with CalculateOnBarClose = false.
    when the price is triggered the strategy correctly place the orders immediatly(NOT at the end of the bar), but if the market come back above/below the level it waits the close of a bar to change/delete the orders (like CalculateOnBarUpdate= true).. can you help me?

    thanks
    Last edited by kantkant2; 08-31-2016, 05:23 AM.

    #2
    Hello,

    Because you are running on each tick, you would need to add logic to account for this specific situation.

    if you would like to wait at least 1 bar, an example could be BarsSinceEntry : http://ninjatrader.com/support/helpG...tsub=barssince

    You could use something as simple as the following to prevent any further orders after the entry on the same bar:

    Code:
    if (BarsSinceEntry() > 0)
    This would entail at least 1 bars since the entry had occurred.

    Another way would be to check if it is the First tick of a bar, this would signal the previous bar had closed.




    It would really depend on how you want to handle that according to your trading goals.


    I look forward to being of further assistance.

    Comment


      #3
      Thanks jesse, I've used yed barssincesession function, and it works correctly to place orders immediatly, but not for the modification that wait until the bar close (also in calculateonbarclose=false).
      My goal is to modify my order immediatly when price go up/down the specific trigger point (medianrange in this case)
      I post you the simple code:
      Code:
       protected override void OnBarUpdate()
              {
      
      			if (Bars.FirstBarOfSession)
      			{
      				dayHigh = High[0];
      				dayLow = Low[0];
      				
      			}
      
      			
      			if (High[0] > dayHigh
      				&& Bars.BarsSinceSession <= 12
      				)
      			{	
      				dayHigh = High[0];
      				
      			}
      			
      			
      			if (Low[0] < dayLow
      				&& Bars.BarsSinceSession <= 12
      				
      				)
      			{
      				dayLow = Low[0];
      				
      			}
      			
      			double medianrange = (dayHigh + dayLow) /2;
      			
      			if(Bars.BarsSinceSession > 12
      				&& Close[0] > medianrange)
      				EnterLongLimit(DefaultQuantity, dayHigh+(1*TickSize), "");
      			
      			if(Bars.BarsSinceSession > 12
      				&& Close[0] < medianrange)
      				EnterShortLimit(DefaultQuantity, dayLow-(1*TickSize), "");
      			
      			
              }
      thanks for your help
      Last edited by kantkant2; 08-31-2016, 12:42 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      133 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      75 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      117 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      113 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      90 views
      0 likes
      Last Post CarlTrading  
      Working...
      X