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

ATM NinjaScript Strategy: REVERSE at STOP then NOT

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

    ATM NinjaScript Strategy: REVERSE at STOP then NOT

    How do I write into a strategy for Reverse at Stop Loss, and if it triggers, I don't want it to have Reverse at stop loss again, just regular Stop Loss.

    Example: If ATM Strategy is Set to BUY 1 Contract @ 1.900 and Stop set 1.890. I want it to reverse @ 1.890, but I Don't want the NEW Stop Loss to have Reversal.

    Possible??? How?

    #2
    Hello ginx10k,

    Thanks for your post.

    To prevent the auto reversal, please make sure that under "advanced Properties" of the dom you have unchecked the "rev at stop" feature.

    In your strategy code you will want to check in OnExecution() to see if "Stop1" was the name of the last order filled. Then you would enter an order in the opposite direction. You can use a bool like doItOnce initilized to true to prevent a 2nd reversal

    protected override void OnExecution(IExecution execution)
    {
    if (execution.Name == "Stop1" && doItOnce)
    {
    // enter your next order here
    doItOnce = false; // set to false so the reversal doesn't reverse again
    }
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      1. To enter an order in the opposite direction would I use the AtmStrategyCreate() Method?
      2. If my strategy goes both long and short, how would I know whether it was a short or long position? (If I have to enter the reversed position by AtmStrategyCreate)

      Comment


        #4
        Hello MisterGee,

        Thanks for your post.

        You would want to use AtmStrategyClose() to close the current position then use the AtmStrategyCreate() to enter a new order.

        http://ninjatrader.com/support/helpG...ategyclose.htm
        http://ninjatrader.com/support/helpG...tegycreate.htm

        You can verify position with: http://ninjatrader.com/support/helpG...etposition.htm
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,967 views
        3 likes
        Last Post jhudas88  
        Started by rbeckmann05, Today, 06:48 PM
        0 responses
        4 views
        0 likes
        Last Post rbeckmann05  
        Started by rhyminkevin, Today, 04:58 PM
        4 responses
        55 views
        0 likes
        Last Post dp8282
        by dp8282
         
        Started by iceman2018, Today, 05:07 PM
        0 responses
        6 views
        0 likes
        Last Post iceman2018  
        Started by lightsun47, Today, 03:51 PM
        0 responses
        8 views
        0 likes
        Last Post lightsun47  
        Working...
        X