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

order cancellation message

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

    order cancellation message

    Hey guys, so I'm trying to figure out whats going on. When the system enters an order it sometimes puts the stops above price for a long although it is set to put stops below swing lows - 3 ticks... Having some trouble deciphering where the issue is.

    The swing stop strength is set to 5 and I noticed that price is in a downtrend and there are not swing lows anywhere near price, could this be the issue?

    chart with no swing lows



    error messages




    #2
    Hello brucelevy,

    When calculating the price of your stop are you checking that the buy stop is above the ask or that the sell stop is below the bid?

    Do you have prints that show the price that the order is being set to along with the current bid or ask price?
    http://ninjatrader.com/support/helpGuides/nt7/print.htm

    If so, please attach these prints to your next post.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I have the output window up now so if anything shows up ill repost; this is what I have for now from the log

      Comment


        #4
        Hello brucelevy,

        The Log is showing that an order was cancelled after another order was executed. (It looks like a profit target filled to close a short position and then the associated stop was cancelled)

        However, the Log wouldn't show you which condition is setting the stop loss to an invalid price or what the current ask or bid price is when the stop is placed.

        TraceOrders and prints are going to give you this information.
        TraceOrders - http://ninjatrader.com/support/helpG...raceorders.htm
        Prints - http://ninjatrader.com/support/helpGuides/nt7/print.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I put in the trade but I am getting thousands of these occurrences where it prints exits..

          I have this before any of the exits so I don't know why its printing exits if its not in a position

          if(Position.MarketPosition == MarketPosition.Long

          9/22/2015 12:06:24 PM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='S2' Reason='This was an exit order but no position exists to exit'
          Exit Short trade at 1125.3 at 9/22/2015 12:06:22 PM

          Comment


            #6
            Hello brucelevy,

            Try printing the position outside of that condition.

            Print(Time[0] + " | " + Position.MarketPosition);
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              9/22/2015 12:41:03 PM Amended stop order: Order='86bdfacafc2d40f6b85de20c02df8e02/Sim101' Name='Stop loss' State=Accepted Instrument='YM 12-15' Action=Sell Limit price=0 Stop price=16151 Quantity=1 Strategy='VolatilityTrader' Type=Stop Tif=Gtc Oco='1b045cef11fc42eaa7eb8555d10f0abd-429' Filled=0 Fill price=0 Token='86bdfacafc2d40f6b85de20c02df8e02' Gtd='12/1/2099 12:00:00 AM'

              9/22/2015 12:41:03 PM Cancelled pending exit order, since associated position is closed: Order='86bdfacafc2d40f6b85de20c02df8e02/Sim101' Name='Stop loss' State=Accepted Instrument='YM 12-15' Action=Sell Limit price=0 Stop price=16151 Quantity=1 Strategy='VolatilityTrader' Type=Stop Tif=Gtc Oco='1b045cef11fc42eaa7eb8555d10f0abd-429' Filled=0 Fill price=0 Token='86bdfacafc2d40f6b85de20c02df8e02' Gtd='12/1/2099 12:00:00 AM'



              Here is a screen shot of the above trade, I don't know why it has exited like that, the exit logic is either 10 ticks then breakeven or the yellow line crossbelow the pink... The swing stops look like they were placed 3 ticks below the swing low at 16151 according to the log which is correct..

              Comment


                #8
                Hi brucelevy,

                To assist I will need information.

                What do you want to troubleshoot first?

                Do you want to find out why orders are being rejected?
                Do you want to know why the exit order was cancelled after the entry order trade was closed?

                The exit order that closed the trade on the chart is just named Sell. This means that it was not a stop loss that exited the order.

                Do you call ExitLong, ExitLongLimit, or ExitLongStopLimit anywhere in your code?

                Having added prints to each condition to see what time each condition is being triggered?
                May we see these prints?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I'd like to first find out why the trades are exiting prematurely. Here is the long exit condition set (flip for shorts)

                  // Exit Long Condition
                  if(Position.MarketPosition == MarketPosition.Long
                  && CrossBelow(LinReg(14), KAMA(2, 10, 30), 1))
                  {
                  ExitLong("", "L1");

                  }

                  // Swing Stop

                  if(Position.MarketPosition == MarketPosition.Long)
                  {
                  SetStopLoss(CalculationMode.Price, Swing(5).SwingLow[0] - 3 * TickSize);
                  }

                  //breakeven at 9 ticks then plus 2

                  if (Position.MarketPosition == MarketPosition.Long
                  && Close[0] > Position.AvgPrice + 9 * TickSize)
                  {
                  SetStopLoss(Position.AvgPrice + 2 * TickSize);
                  }
                  //trail on KAMA after x ticks

                  if (Position.MarketPosition == MarketPosition.Long
                  && Close[0] > Position.AvgPrice + 12 * TickSize)
                  {
                  SetStopLoss(CalculationMode.Price, KAMA(2, 10, 30)[0] - 1 * TickSize);
                  }

                  Comment


                    #10
                    Hello brucelevy,

                    Looking at the provided code (I cannot say wether or not the issue is with code that was not included) the following could be exiting your order:
                    Code:
                    if(Position.MarketPosition == MarketPosition.Long 
                    && CrossBelow(LinReg(14), KAMA(2, 10, 30), 1))
                    {
                    ExitLong("", "L1");
                    }
                    Try a print to see if this is the order causing the exit.

                    Code:
                    if(Position.MarketPosition == MarketPosition.Long 
                    && CrossBelow(LinReg(14), KAMA(2, 10, 30), 1))
                    {
                    Print(Time[0]+" | exiting order")
                    ExitLong("", "L1");
                    }
                    Do you see this print appear at the time the order is closed?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      It just says exiting order continuously..


                      9/25/2015 10:52:40 AM | exiting order L2
                      9/25/2015 10:52:40 AM | exiting order L3
                      9/25/2015 10:52:40 AM | exiting order L4
                      9/25/2015 10:52:40 AM | exiting order S2
                      9/25/2015 10:52:40 AM | exiting order S4
                      9/25/2015 10:52:40 AM | exiting order S5
                      9/25/2015 10:53:07 AM | exiting order L2
                      9/25/2015 10:53:07 AM | exiting order L3
                      9/25/2015 10:53:07 AM | exiting order L4
                      9/25/2015 10:53:07 AM | exiting order S2
                      9/25/2015 10:53:07 AM | exiting order S4
                      9/25/2015 10:53:07 AM | exiting order S5
                      9/25/2015 10:53:17 AM | exiting order L2
                      9/25/2015 10:53:17 AM | exiting order L3
                      9/25/2015 10:53:17 AM | exiting order L4
                      9/25/2015 10:53:17 AM | exiting order S2
                      9/25/2015 10:53:17 AM | exiting order S4
                      9/25/2015 10:53:17 AM | exiting order S5

                      Comment


                        #12
                        Can you look over the script if I send it to you?

                        Comment


                          #13
                          Is this correct where it says if market position is short AND Ling Reg cross above KAMA exit short?
                          It should exit the short position if the linreg crosses above the kama...

                          if (Position.MarketPosition == MarketPosition.Short
                          && CrossAbove(LinReg(14), KAMA(2, 10, 30), 1))
                          {
                          ExitShort("", "S1");
                          Print(Time[0]+" | exiting order S1");


                          }

                          Comment


                            #14
                            Here is what I have for an ES long position that went off and immediately closed out at breakeven
                            Output window:

                            9/25/2015 11:15:00 AMLong Entry L2Flat
                            9/25/2015 11:15:00 AM | exiting order L2

                            Log:



                            Executions page:

                            Last edited by brucelevy; 09-25-2015, 09:20 AM.

                            Comment


                              #15
                              It tried to go short and said I cant put a buy stop limit below the market... I dont know why its trying to put stop losses below the sell when the code doesnt say to do that..

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bmartz, 03-12-2024, 06:12 AM
                              3 responses
                              27 views
                              0 likes
                              Last Post NinjaTrader_Zachary  
                              Started by Aviram Y, Today, 05:29 AM
                              2 responses
                              8 views
                              0 likes
                              Last Post Aviram Y  
                              Started by gentlebenthebear, Today, 01:30 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by cls71, Today, 04:45 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by TradeForge, Today, 02:09 AM
                              1 response
                              24 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X