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

Keeping a protective stop open

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

    Keeping a protective stop open

    I have a strategy where I wish to submit a stop order that stays open until either it executes or some other exit trigger closes the position. I can't find a workable example I can use on how to use the isliveuntilcancelled function. Example of my attempted code is below

    Here is what I have so far.

    // Set 3
    if (
    // Profit Protectionb
    ((CrossAbove(High[0], Bollinger5.Upper, 1)))
    ExitLongStopMarket(0,true,1, (Bollinger5.Upper[1] + (-4 * TickSize)) , "", @"");Click image for larger version

Name:	Capture.PNG
Views:	108
Size:	31.6 KB
ID:	1164226

    However, it's not working as expected. I circled the point at which this order should have triggered but did not.
    Last edited by dniedrauer; 07-19-2021, 08:28 PM.

    #2
    Hello dniedrauer,

    Thanks for your post.

    It seems that the execution is correct. If you set your strategy to run in the mode of Calculate.OnBarClose, this means that the strategy code executes once at the end of each bar and will perform calculations on completed bars. If your strategy determines to enter an order when a bar closes "trigger bar", the order would be placed on the next bar "fill bar".

    Using the calculate mode of Calculate.OnPriceChange, or Calculate.OnEachTick, will allow the strategy to be executed with a greater frequency which means your code will be executed on each tick or each change in price. Depending on the bar size and market volatility this could be a significant number of times per bar. Entry orders would be executed intrabar instead of waiting until the next bar.

    In regards to your inquiry about using isLiveUntilCanceled, please see the example script in the help guide link below which demonstrates using isLiveUntilCanceled to keep orders alive.

    Keeping Orders Alive: https://ninjatrader.com/support/help...ders_alive.htm

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    18 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    1 view
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    6 views
    0 likes
    Last Post Javierw.ok  
    Started by timmbbo, Today, 08:59 AM
    2 responses
    10 views
    0 likes
    Last Post bltdavid  
    Started by alifarahani, Today, 09:40 AM
    6 responses
    41 views
    0 likes
    Last Post alifarahani  
    Working...
    X