Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Market Order: Keep alive for x number of bars?

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

    Stop Market Order: Keep alive for x number of bars?

    Good morning,

    I am using Ninja 8 strategy builder. Placing a stop market order to be filled when price rises to the stop. It only stays valid on the current bar, then disappears on the next. Is there a setting to use to keep the stop market order alive for 2, 3, or any number of bars? I am using the price: low touch of a moving average to trigger the stop market order but I need to keep it alive for 3 or 4 bars until the price can rise back to the order..

    Thanks!

    #2
    Hello ms8274!,

    The liveUntilCancelled will not be used with orders in the Strategy Builder and this is false by default.

    This causes the order to be cancelled when the bar it is submitted on closes.

    To keep it alive, continue re-submitting the order on each new bar as long as the condition is still true.


    Or unlock the script and change the overload with the order call to use the liveUntilCancelled parameter and set this as true.
    ExitLongStopMarket(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal)

    Below is a publicly available link to the help guide.



    This issue would be counting bars. To count you would need to increment a value and this would require math. The Strategy Builder is not able to do math as it is designed for very simple comparisons.

    For this you would need to unlock the script and implement an integer that is incremented on each new bar after the order is placed. And then allow the order to be cancelled once this is above x number.
    Last edited by NinjaTrader_ChelseaB; 02-21-2018, 09:40 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks.

      The coding is over my head. I am using the "cross below" condition, (if price:low cross below ema12, then place stop market at price high plus 1 tick). For the next candle I tried using the "bars ago" setting, if price:low cross below ema12 "bars ago:1" and found the "cross below" setting does not recognize the bars ago function. The "less than" setting does but not "cross below".

      Comment


        #4
        Hello ms8274!,

        Setting the look back period on the CrossBelow would allow the condition to be true as long as a cross occurred within the number of bars set in the look back period.

        You would want to make two conditions if going about it this way.
        One that initially places the order and sets a bool to true when the cross happens within one bar.
        Then the other condition to check the bool is true and continues placing the order as long as a cross below has happened with the look back period set to the number of bars you would like.

        You also use the BarsSinceEntryExecution to be less than a number of bars and require the position to be long and continue placing the order.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        20 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        119 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        63 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        45 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X