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 & ExitLongLimit

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

    ExitLongStop & ExitLongLimit

    When i'm use ExitLongStop() with ExitLongLimit(), ExitLongLimit() always have been Cancelled. Why?

    My onOrderUpdate() code:
    Code:
    [LEFT]if (myEntryOrder != null && myEntryOrder == order) {
            		if (order.OrderState == OrderState.Filled) {
    					if (myStopOrder != null) { CancelOrder(myStopOrder); }
    					if (myProfitOrder != null) { CancelOrder(myProfitOrder); }
    					myStopOrder = ExitLongStop(0, true, qty, stopPrice, "long position", "long position");
    					myProfitOrder = ExitLongLimit(0, true, qty, profitPrice, "long position", "long position");
                    	myEntryOrder = null;[/LEFT]
    				}
        		}

    #2
    Hello nordseven,

    Thank you for your post.

    Just based on this code the Stop Loss and Profit Target should not be cancelled unless the myEntryOrder is not null. Can you attach you full code to your response?
    You can attach your strategy to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your Strategy > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.

    If you prefere you can send to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H - 1470924' in the subject line.

    Comment


      #3
      Hello NinjaTrader_PatrickH.
      This may be due to the back tests? Im using "Strategy performance -> Historical".
      Maybe i missed some thing?
      My strategy have alot of code and not finished yet. But i'm trying to create another one 4 you, with error.
      Last edited by nordseven; 02-23-2016, 03:45 PM.

      Comment


        #4
        Hello nordseven,

        Thank you for the follow up.

        I am not sure how Historical Performance would affect this.

        Comment


          #5
          Hello nordseven,

          Thank you for your patience.

          I am seeing the Stop Loss cancelled on my end. Can you attach a screenshot of the results you are looking at so I may investigate further?

          Comment


            #6
            Hello Patrick.

            I'm not exactly understand what i must show to you?

            I'm enable debug mode, attach process in "visual c" and watch.

            My entry points in Strategy this is (for Long): stopPrice, profitPrice, longPrice, (for Short): stopPrice, profitPrice, shortPrice.

            I don't understand why myProfitOrder = ExitLongLimit() always have been Cancelled, when i'm trying to set him. My profitPrice is Larger then my current Price (for Long) and Lower then my current Price (for Short).
            Last edited by nordseven; 02-24-2016, 09:26 AM.

            Comment


              #7
              nordseven,

              So you are seeing this in Visual Studio? Where are you seeing the cancel? Can you provide a screenshot?

              Comment


                #8
                Screenshot attached.
                Attached Files

                Comment


                  #9
                  Patrick? Any one here?

                  Comment


                    #10
                    nordseven,

                    Thank you for your patience.

                    This would make sense as the limit orders would be re-submitted on each bar. Setting liveUntilCancelled to True allows NinjaTrader to automatically re-submit the order rather than you needing to do so.

                    Comment


                      #11
                      Hello Patrick.

                      liveUntilCancelled = true, this is visible on my screenshot.

                      If i'm right understand you, you want say NinjaTrader automatically re-submit the order? Cancel my current profitOrder and set new profitOrder for new candle? Then why my stop order does not do that? Why all my profitOrders never will be filled.

                      Comment


                        #12
                        I made indicator based on my strategy and it shows my entry points, stop loss, and profit points. And i clear see what part of my profitOrders must be filled.

                        Comment


                          #13
                          Hello nordseven,

                          Thank you for your response.

                          I was incorrect, the Limit order should stay active. Can you run the strategy in real-time on the Sim101 account? Do you see the order cancelled?

                          Comment


                            #14
                            Hello Patrick.
                            How i can see this?
                            On history data i did not see filled profitOrders.

                            I'm rebuild my strategy orders with Unmanaged Approach and now profitOrders don't cancelled.

                            Comment


                              #15
                              Hello nordseven,

                              Thank you for your response.

                              You could watch the Orders tab of the Control Center to see if the order is cancelled.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Stanfillirenfro, Today, 07:23 AM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              2 responses
                              20 views
                              0 likes
                              Last Post cmtjoancolmenero  
                              Started by olisav57, Yesterday, 07:39 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by cocoescala, 10-12-2018, 11:02 PM
                              7 responses
                              944 views
                              0 likes
                              Last Post Jquiroz1975  
                              Started by oviejo, Today, 12:28 AM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X