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

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 agclub, Yesterday, 08:57 PM
        2 responses
        16 views
        0 likes
        Last Post agclub
        by agclub
         
        Started by cre8able, 04-17-2024, 04:16 PM
        6 responses
        55 views
        0 likes
        Last Post cre8able  
        Started by Mindset, 05-06-2023, 09:03 PM
        13 responses
        293 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by kaywai, 09-01-2023, 08:44 PM
        4 responses
        600 views
        0 likes
        Last Post joselube001  
        Started by dpolyakov, 03-29-2024, 11:30 AM
        3 responses
        135 views
        2 likes
        Last Post sonia0101  
        Working...
        X