Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strat Frozen

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

    Strat Frozen

    I'm having an issue with my strats. For a reason I can't seem to figure out, when I load a strat, sometimes I will get the following (numbers obviously change from strat to strat) in the output window:

    7/13/2010 9:00:00 AM Enter Long

    7/13/2010 9:00:00 AM Cancelled expired order: BarsInProgress=0: Order='NT-00005/Sim101' Name='Stop loss' State=Cancelled Instrument='ES 09-10' Action=Sell Limit price=0 Stop price=1078.25 Quantity=1 Strategy='PP' Type=Stop Tif=Gtc Oco='NT-00002' Filled=0 Fill price=0 Token='c63314e02ee1435e96953d40594798ed' Gtd='12/1/2099 12:00:00 AM'
    The order name Stop loss stop price is currently 1083.75
    The order name Stop loss stop price is currently 1083.75
    The order name Stop loss stop price is currently 1083.75
    The order name Profit target limit price is currently 1091.25
    The order name Profit target limit price is currently 1091.25
    The order name Profit target limit price is currently 1091.25
    7/13/2010 11:00:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00008/Sim101' Name='Stop loss' State=Working Instrument='ES 09-10' Action=Sell Limit price=0 Stop price=1083.75 Quantity=1 Strategy='PP' Type=Stop Tif=Gtc Oco='NT-00004' Filled=0 Fill price=0 Token='0018dbf878524bcb8e6f914bb860665a' Gtd='12/1/2099 12:00:00 AM'
    The order name Stop loss stop price is currently 1083.75
    The order name Stop loss stop price is currently 1083.75
    7/13/2010 11:00:00 AM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00008/Sim101' Name='Stop loss' State=Cancelled Instrument='ES 09-10' Action=Sell Limit price=0 Stop price=1083.75 Quantity=1 Strategy='PP' Type=Stop Tif=Gtc Oco='NT-00004' Filled=0 Fill price=0 Token='0018dbf878524bcb8e6f914bb860665a' Gtd='12/1/2099 12:00:00 AM'
    7/13/2010 12:00:00 PM Cancelled expired order: BarsInProgress=0: Order='NT-00008/Sim101' Name='Stop loss' State=Cancelled Instrument='ES 09-10' Action=Sell Limit price=0 Stop price=1083.75 Quantity=1 Strategy='PP' Type=Stop Tif=Gtc Oco='NT-00004' Filled=0 Fill price=0 Token='0018dbf878524bcb8e6f914bb860665a' Gtd='12/1/2099 12:00:00 AM'

    I have an entry signal, a stop loss and a target in place. The strat is setup to set the entry back to null and remove stop and target tokens upon fill, cancellation or rejection. When this happens, my strat stops taking trades and just shows the previous ones it WOULD have taken, had it been working at the time (see screenshot). Any idea why this is happening?
    Attached Files

    #2
    dsraider, just to clarify, it appears that right after you load the strategy, it cancels a bunch of orders? And then it doesn't run and take any trades after that?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Yes, sir. At least, that's what it looks like. The only reason it has today's date is because I set Format Data Series to 1 day. Once I set it back to 15, it "cancelled" orders from a week ago and then stopped trading. Would it help if I posted my stop loss and/or target removal code?

      Comment


        #4
        dsraider, yes that could help. However, if you posted the complete strategy, that would be much better because we could see exactly what is going on.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Only because there's a bunch of proprietary and personal info I'd have to remove, I'm hoping you can take a look at my relevant stop loss code as an example. If nothing jumps out at you, I'll edit and post the entire strat. Thanks, Austin.

          PHP Code:
          if (stopLossTokens.Contains(order.Token))
                      {
                          // Check order for terminal state
                          if (order.OrderState == OrderState.Filled && stopSent == false)
                          {
                              // Print out information about the order
                              if (Performance.RealtimeTrades.Count > 0) 
                                  {     
                                      // Get the last completed real-time trade (at index 0) 
                                      Trade lastTrade = Performance.AllTrades[Performance.AllTrades.Count - 1];
                                      
                                      if (lastTrade != null) 
                                      {
                                          if(lastTrade.ProfitPoints >= 0)
                                          {    
                                          Print("The last trade profit is " + (lastTrade.ProfitPoints >= 0 ? "+" + Convert.ToString(lastTrade.ProfitPoints) : Convert.ToString(lastTrade.ProfitPoints)));
              
                                          stopSent = true;    
                                          }
                                          else 
                                          {    
                                          Print("The last trade profit is " + (lastTrade.ProfitPoints >= 0 ? "+" + Convert.ToString(lastTrade.ProfitPoints) : Convert.ToString(lastTrade.ProfitPoints)));
              
                                          stopSent = true;
                                          }    
                                      } 
                                  }    
                          if (order.OrderState == OrderState.Cancelled || order.OrderState == OrderState.Filled || order.OrderState == OrderState.Rejected)    
                              // Remove from collection
                              {
                              stopLossTokens.Remove(order.Token);
                              entryOrder1 = null;    
                              entryOrder2 = null;
                              }
                              
                          }
                          // Print out the current stop loss price
                          else
                              Print("The order name " + order.Name + " stop price is currently " + order.StopPrice);
                      } 
          

          Comment


            #6
            dsraider, I can't see anything specific in that bit of code that would cause your issue. You'll have to add Print() statements throughout your code to help debug this behavior.
            AustinNinjaTrader Customer Service

            Comment


              #7
              I hear you Austin and I've tried Print all over. The problem, though, is that the strat is printing entries and cancellations the moment I start it up, which I don't think it even has the ability to do. If this happened when my signal kicked in, I could understand, but the instant I set a strat?

              Comment


                #8
                From your output logs, it appears as if there is some information being printed from the strategy, so I'd say give it a shot. Would you mind sending me your strategy (along with the steps that lead up to the canceled orders) so I can try this out on my end? If you don't want to post it here on the forum, you can send it to support at ninjatrader dot com attn 'austin - thread 31371, ticket 340488'. Thank you for your assistance on this matter.
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Dave we've received the files but unfortunately I won't be able to test this out until tomorrow. Could you please list a few steps to get NinjaTrader ready to run this order canceling strategy? Should I just put it on a chart? Run it through a backtest?
                  AustinNinjaTrader Customer Service

                  Comment


                    #10
                    Hi Austin,

                    No worries. I appreciate the help. All I did was bring up a 60 minute ES chart and add the strat. This doesn't happen 100% of the time so I'm hoping it doesn't end with you suggesting I get medication.

                    Have a good night,
                    Dave

                    Comment


                      #11
                      Dave, I ran your strategy and got the same results you did with the trades ending after the first one or two. Then I took a look at the code and the very first section (stop the strategy after certain P/L) jumped out at me. I commented it out and the strategy then ran until the current date during both a backtest and real-time test. You may want to revise that section and/or reset it after every trading day.
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        Hi Austin,

                        Interesting. Question, though. Since this happens the second I start a strategy (before any actual trades are taken) is it STILL possible for that to happen, based on what I guess would be unrealized gains?

                        Thanks,
                        Dave

                        Comment


                          #13
                          Dave, each time I started the strategy there were around 2-3 trades taken at the very beginning of the time period, during the historical portion of the strategy run. This also happened in the Strategy Analyzer. So yes, I believe it is the P/L portion of your strategy that is stopping your strategy, especially because during one backtest, it quit exactly at -$250, which is the stopping point you've set. You can add some Print() statements to that section to verify if this is the reason your strategy is stopping early.
                          AustinNinjaTrader Customer Service

                          Comment


                            #14
                            Well, thanks a ton for finding that. It never would have occurred to me to look there since I figured PnL only referred to trades taken since loading. Off-hand, do you know of a filter to which you can point me?

                            Thanks again,
                            Dave

                            Comment


                              #15
                              Dave, I'm not sure if you've seen the reference sample that deals with this, but here is a link to it: Using trade performance statistics for money management.

                              You can use only the real-time trades in your performance calculations by switching this line:
                              Code:
                              if (Performance.AllTrades.TradesPerformance.Currency.CumProfit >= 250 
                                              || Performance.AllTrades.TradesPerformance.Currency.CumProfit <= -250)
                              to this:
                              Code:
                              if (Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit >= 250 
                                              || Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit <= -250)
                              However, if you wanted to keep a running total, this reference could also help: Resetting values at the beginning of new trading sessions
                              AustinNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              596 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              343 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              556 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              554 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X