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

SetStopLoss or ExitLongLimit

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

    #16
    Hello Cal,

    What Can I do to fix it?

    I imported the script, and still isn't working.

    Comment


      #17
      Hello marcyomatheus,

      My apologizes for the confusion here.

      The example was to be a representation of IOrders and OnExecution. To ensure the orders are not cancelled you would add the liveUntilCancelled bool to the order method. For example:
      Code:
      ExitLongLimit(0, true, Close[0], "exit", "entry");
      Please take a look at the Order Methods at the following link for more information: http://www.ninjatrader.com/support/h...er_methods.htm

      Comment


        #18
        SetStopLoss or ExitLongLimit Reply to Thread

        Hello PatrickH.

        Didn't work.

        See attachment.

        Thank you!
        Attached Files

        Comment


          #19
          We would also need to Qty listed:
          Code:
          ExitLongLimit(0, true, [B]1[/B], Close[0], "exit", "entry");

          Comment


            #20
            SetStopLoss or ExitLongLimit Reply to Thread

            Hello PatrickH.

            I put this part that you sent me in my code, but StopLoss still isn't working.

            See attachments.

            Attached Files

            Comment


              #21
              Hello ,

              Thank you for your response.

              On historical bars/backtesting the orders will not be submitted until the bar closes that triggers the exit. So the exit order is submitted to the next bar. Using ExitLongStop() will result in the order being filled as a Stop Market order. If you want to limit the exit level you can use ExitLongStopLimit(): http://www.ninjatrader.com/support/h...gstoplimit.htm

              Comment


                #22
                Originally posted by leocrespo
                There is absolutely nothing on the link you have provided that could help us understand that "orders to exit a position (such as ExitLongLimit()) will be ignored if a position is open and an order submitted by a set method".

                Can you please refer us to the proper link?
                Expand the last bullet on that page.

                Comment


                  #23
                  Originally posted by leocrespo
                  Thank you.




                  I would also be good to know what exactly they mean by "will be ignored". Will it return null? Will it return an IOrder object with an Error code?
                  Probably zilch.

                  Comment


                    #24
                    Hello leocrespo,

                    I've done a test and it looks like the method will return null.

                    As an example, I've created a simple strategy here that has a SetStopLoss() as well as an ExitLongStop(). ExitLongStop() will be ignored per the handling rules:

                    Code:
                    private IOrder test = null;
                    
                    protected override void Initialize()
                    {
                         SetStopLoss(CalculationMode.Ticks, 20);
                    }
                    
                    protected override void OnBarUpdate()
                    {
                         if (Position.MarketPosition == MarketPosition.Flat)
                         {
                              test = EnterLong();
                              Print("test EnterLong(): " + test.ToString() + " " + Time[0]);
                         }
                    			
                         if (Position.MarketPosition == MarketPosition.Long)
                         {
                              test = ExitLongStop(1);
                    
                              if (test == null)
                                   Print("test ExitLongStop() is null " + Time[0]);
                              else if (test != null)
                                   Print("test ExitLongStop(): " + test.ToString() + " " +  Time[0]);
                         }
                    }
                    Zachary G.NinjaTrader Customer Service

                    Comment


                      #25
                      Originally posted by leocrespo
                      Thank you.

                      For anyone also looking for it, it's in the last bullet named "Internal Order Handling Rules that Reduce Unwanted Positions". It's not the best location since neither the Stop or the Target orders are "unwanted positions" .

                      These rules are important, not intuitive, and they're in a bad spot in the documentation. They should put this in every one of the methods Exit... Long....

                      Here are the rules:



                      I would also be good to know what exactly they mean by "will be ignored". Will it return null? Will it return an IOrder object with an Error code?
                      Examine the log for the verbiage returned, then examine the order to see if you can match what was returned. As I accept the limitation, and code to it, I have never bothered to examine the return.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by burtoninlondon, Today, 12:38 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post burtoninlondon  
                      Started by AaronKoRn, Yesterday, 09:49 PM
                      0 responses
                      11 views
                      0 likes
                      Last Post AaronKoRn  
                      Started by carnitron, Yesterday, 08:42 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post carnitron  
                      Started by strategist007, Yesterday, 07:51 PM
                      0 responses
                      12 views
                      0 likes
                      Last Post strategist007  
                      Started by StockTrader88, 03-06-2021, 08:58 AM
                      44 responses
                      3,982 views
                      3 likes
                      Last Post jhudas88  
                      Working...
                      X