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 Max238, Today, 01:28 AM
    4 responses
    36 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by r68cervera, Today, 05:29 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by geddyisodin, Today, 05:20 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by timko, Today, 06:45 AM
    2 responses
    14 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by habeebft, Today, 07:27 AM
    0 responses
    7 views
    0 likes
    Last Post habeebft  
    Working...
    X