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:	143
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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    54 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    72 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X