Announcement

Collapse
No announcement yet.

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:	146
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.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X