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

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.
    JesseNinjaTrader Customer Service

    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 helpwanted, Today, 03:06 AM
      1 response
      12 views
      0 likes
      Last Post sarafuenonly123  
      Started by Brevo, Today, 01:45 AM
      0 responses
      9 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      5 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      242 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      387 views
      1 like
      Last Post Gavini
      by Gavini
       
      Working...
      X