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

cancelling stop orders.

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

    cancelling stop orders.

    My strategy works with SetProfitTarget..
    However I want to cancel the stop order already placed or at least send a similar order with a inverted direction..

    Any clue?

    #2
    Hello,
    You will not be able to cancel a stop order that is submitted with the SetStopLoss() method.
    If you are wanting to cancel the stop you will need to use a different exit order method and then cancel the order using the CancelOrder() method. For example:
    Code:
    private IOrder myStopOrder = null;
    
    protected override void OnBarUpdate()
    {
          	if(myStopOrder = null)
    	{
    		myStopOrder = ExitLongStop(20);
    	}
    	if(/*Condition for when you want to cancel*/)
    	{
    		CancelOrder(myStopOrder);	
    	}
    }
    For more information on IOrder please see the following link: http://ninjatrader.com/support/helpG...nt7/iorder.htm

    For more information on the CancelOrder() method please see the following link: http://ninjatrader.com/support/helpG...ancelorder.htm

    If we can be of any other assistance please let us know.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      I am trying to use this method. But i have one question.

      if (Position.MarketPosition == MarketPosition.Flat)//&& priorClosePrice-Medians[1][0] < DifVolL)
      {
      EnterShort(0,positionTaken, "difOpenCurSYV");
      myShortStopOrder = EnterShortStopLimit(positionTaken, 0, (Medians[0][0]*1+StopLevelMovel), "Stop short");
      myShortProfitTargetOrder = EnterShortStopLimit(positionTaken, 0, (Medians[0][0]/1+StopGainNumber), "Profit target short");
      }

      What is the difference between limitPrice, and stopPrice inside the EnterShortStopLimit method?

      Comment


        #4
        Another question would be:
        Everytime I send an EnterLong() order how I generate the stop loss and profit target orders connected? Should I use :
        myShortStopOrder = ExitShortStopLimit(positionTaken,((priceShort*(1+S topLevelMovel))),(priceShort*(1+StopLevelMovel)), "Stop loss short","difOpenCurSYV");//+(10 * TickSize)

        myShortProfitTargetOrder = ExitShortLimit(positionTaken, (priceShort/(1+StopGainNumber)), "Profit target short","difOpenCurSYV");

        Or there is another simple way?
        still,
        I presume, every time I use ExitLong() I need to cancel the stop loss and profit target orders related to the original Long order.
        How do i do that? should I use :
        ExitShort(positionTaken,"ExitSYV","difOpenCurSYV") ;
        CancelOrder(myShortStopOrder);
        CancelOrder(myShortProfitTargetOrder);
        Last edited by dafonseca; 02-20-2016, 09:14 PM.

        Comment


          #5
          Trying to fix it, and using traceOrder = true; I found out that my stop orders has been cancelled by NT (highlighted below) as they are cancelled if (myLongStopOrder == null) does not work anymore and the strategy logic falls apart.
          I need to find out why this orders has been cancelled.

          1/5/2016 9:34:00 AM Entered internal PlaceOrder() method at 1/5/2016 9:34:00 AM: BarsInProgress=0 Action=Sell OrderType=StopLimit Quantity=150 LimitPrice=103.76 StopPrice=103.76 SignalName='Stop loss long' FromEntrySignal='difOpenCurLYV'
          1/5/2016 9:34:00 AM Entered internal PlaceOrder() method at 1/5/2016 9:34:00 AM: BarsInProgress=0 Action=Sell OrderType=Limit Quantity=150 LimitPrice=105.20 StopPrice=0 SignalName='Profit target long' FromEntrySignal='difOpenCurLYV'
          1/5/2016 9:34:00 AM Entered internal PlaceOrder() method at 1/5/2016 9:34:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=150 LimitPrice=0 StopPrice=0 SignalName='difOpenCurLYV' FromEntrySignal=''
          1/5/2016 9:34:00 AM Ignored PlaceOrder() method at 1/5/2016 9:34:00 AM: Action=Buy OrderType=Market Quantity=150 LimitPrice=0 StopPrice=0 SignalName='difOpenCurLYV' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

          1/5/2016 9:35:00 AM Cancelled expired order: BarsInProgress=0: Order='NT-00001/Backtest' Name='Stop loss long' State=Working Instrument='AAPL' Action=Sell Limit price=103.762962962963 Stop price=103.762962962963 Quantity=150 Strategy='aaplCurOpenVolIDStopTrail' Type=StopLimit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='212bbba2708d49daa6a1e84522098e5a' Gtd='12/1/2099 12:00:00 AM'

          1/5/2016 9:35:00 AM Cancelled expired order: BarsInProgress=0: Order='NT-00002/Backtest' Name='Profit target long' State=Working Instrument='AAPL' Action=Sell Limit price=105.201831 Stop price=0 Quantity=150 Strategy='aaplCurOpenVolIDStopTrail' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='420c36e6eae14084966070918fab0378' Gtd='12/1/2099 12:00:00 AM'

          Comment


            #6
            Hello,
            What is the difference between limitPrice, and stopPrice inside the EnterShortStopLimit method?
            The difference between the stop price and the limit price is the stop price is the price that the stop order will trigger, the limit price is the price that the limit order will execute once the stop has been triggered. For more information on stop limit orders and how they work I would recommend to review the following link: http://www.investopedia.com/articles...mit-orders.asp

            Everytime I send an EnterLong() order how I generate the stop loss and profit target orders connected? Should I use :
            myShortStopOrder = ExitShortStopLimit(positionTaken,((priceShort*(1+S topLevelMovel))),(priceShort*(1+StopLevelMovel)), "Stop loss short","difOpenCurSYV");//+(10 * TickSize)

            myShortProfitTargetOrder = ExitShortLimit(positionTaken, (priceShort/(1+StopGainNumber)), "Profit target short","difOpenCurSYV");

            Or there is another simple way?
            This process does suffice. You could also use SetProfitTarget() and SetStoploss() for these orders. For more information on SetProfitTarget() please see the following link:http://ninjatrader.com/support/helpG...ofittarget.htm For more information on SetStopLoss() please see the following link: http://ninjatrader.com/support/helpG...etstoploss.htm

            I presume, every time I use ExitLong() I need to cancel the stop loss and profit target orders related to the original Long order.
            How do i do that?
            To cancel the orders you are correct in that you would use the CancelOrder() method.

            Trying to fix it, and using traceOrder = true; I found out that my stop orders has been cancelled by NT (highlighted below) as they are cancelled if (myLongStopOrder == null) does not work anymore and the strategy logic falls apart.
            I need to find out why this orders has been cancelled.
            NinjaTrader will cancel an order if the order is not filled in the same bar that it is submitted to and if the entry order condition is not true again.

            If you would like the order to remain either the entry condition has to be true the next bar, or you may use the Advanced Order Handling approach and use the following overload:
            Code:
            ExitShortStopLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, double stopPrice, string signalName, string fromEntrySignal)
            For more information on the Advanced Order Handling Concepts please see the following link: http://ninjatrader.com/support/helpG...r_handling.htm

            If we can be of any other assistance please let us know.
            Cody B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by inanazsocial, Today, 01:15 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by rocketman7, Today, 02:12 AM
            0 responses
            10 views
            0 likes
            Last Post rocketman7  
            Started by dustydbayer, Today, 01:59 AM
            0 responses
            2 views
            0 likes
            Last Post dustydbayer  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            5 responses
            23 views
            0 likes
            Last Post trilliantrader  
            Started by Davidtowleii, Today, 12:15 AM
            0 responses
            3 views
            0 likes
            Last Post Davidtowleii  
            Working...
            X