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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      548 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      549 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X