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

ExitLongStop not executed

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

    ExitLongStop not executed

    Hallo,

    I'm testing some simple strategies, does anybody see why the Enter works fine, but the ExitLongStop is never executed ?

    regards Ali

    Code:
                if (ADX(14)[0] > 25
                    && Close[0] < SMA(10)[0]
                    && Close[0] > EMA(30)[0]
                    && 1 == Swing(0).SwingLowBar(0, 1, 10))
                {
                    EnterLong(DefaultQuantity, "");
                }
    
                ExitLongStop(Swing(1).SwingLow[0], "StopExit", "");

    #2
    Code:
                if (ADX(14)[0] > 25
                    && Close[0] < SMA(10)[0]
                    && Close[0] > EMA(30)[0]
                    && 1 == Swing(0).SwingLowBar(0, 1, 10))
                {
                    EnterLong(DefaultQuantity, "");
                }
    
                if (Low[0] < Swing(1).SwingLow[0]){
                    ExitLong("Exit Long", "");
    	    }
    This excample works, buts not the same like an exitstoplong order.

    Comment


      #3
      ali321,

      When you submit stops or limit orders you need to keep them alive on every single sequential bar otherwise they will auto cancel. To keep them alive, you need to call ExitLongStop() again with the same quantity, price, and name and it will keep the order alive.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Josh View Post
        ali321,

        When you submit stops or limit orders you need to keep them alive on every single sequential bar otherwise they will auto cancel. To keep them alive, you need to call ExitLongStop() again with the same quantity, price, and name and it will keep the order alive.
        Sorry, I don't understand how the code should look like.
        Do you have an excample ?

        Comment


          #5
          ali321,

          I have no code example I can provide you as it is highly dependent on what logic you want to put into place. All you need to do is decide when you want to cancel the order if it still doesn't fill. Then create an if-statement

          Code:
          if (Position.MarketPosition == MarketPosition.Long && [I]some other conditions[/I])
               ExitLongStop(...);
          As long as your other conditions are true you will try to keep the stop order alive. When it is false, you stop and then the order is cancelled.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            ExitLongStop

            Hallo,

            does anyone know a link or support thread where the handling of the ExitLongStop is explaint better then in the programming help system ?

            regards ali

            Comment


              #7
              Ali, another option would be to specify that these orders are live until cancelled. That way you won't have to keep re-submitting the orders.
              Code:
              //ExitLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal)
              
              ExitLongStop(0, true, 1, Swing(1).SwingLow[0], "StopExit", "");
              AustinNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CortexZenUSA, Today, 12:53 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by CortexZenUSA, Today, 12:46 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by usazencortex, Today, 12:43 AM
              0 responses
              5 views
              0 likes
              Last Post usazencortex  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              168 responses
              2,266 views
              0 likes
              Last Post sidlercom80  
              Started by Barry Milan, Yesterday, 10:35 PM
              3 responses
              13 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X