Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RE: Stoploss orders stay Initialized {372020}

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

    RE: Stoploss orders stay Initialized {372020}

    Dear Forum,

    I was redirected here by the guys at [email protected].

    My problem:

    I am using a strategy with my live IB account which sets the stoploss programatically with the SetStopLoss function (simulated parameter set to FALSE).
    As it enters a position, the stop loss should be sent to the broker.
    Usually, however, this order stays in the state 'Initialized', and it doesn't appear in TWS at all. Being aware of this I restart the strategy by pressing f5 on the chart, and then my stop loss is sent to the TWS, and in NT it becomes Working. This happens quite frequently with my live IB account, but never with my simulated IB account.
    It happened today at 9:30 and 15:00.
    I was told that this issue is likely to be in connection with my strategy.
    I disaggree with that, because as I've mentioned it happens only with my live IB account,
    and even with my live account restarting the strategy allows the stoploss to be activated.

    Anyway my StopLoss setting code :

    I am setting the stoploss whenever there's an execution.

    Code:
    protected override void OnExecution(IExecution execution)
    		{
    			IOrder ord=execution.Order;
    			base.OnExecution(execution);
    			if(manualStop && Position.MarketPosition != MarketPosition.Flat) return;
    			if(ord.OrderAction==OrderAction.Buy && ord.OrderType != OrderType.Stop && Position.Quantity>0)
    			{
    				SetStopLoss(Name+" EnterLong",CalculationMode.Price,avgPrice+ln/(Position.Quantity),false);	
    				if(!optimizing)
    				{
    					stopValue = avgPrice+ln/(Position.Quantity);
    					uplMinValue = avgPrice+uplmin/Position.Quantity;
    					if(MyGlobals.OrderWindow != null && !Historical) MyGlobals.OrderWindow.updateStopLoss(this);
    					drawStopLine();
    				}
    			}
    			else
    			{
    				SetStopLoss(Name+" EnterLong",CalculationMode.Price,TickSize,true);	
    				if(!optimizing)
    				{
    					stopValue = 0;
    					uplMinValue = 0;
    					if(MyGlobals.OrderWindow != null && !Historical) MyGlobals.OrderWindow.updateStopLoss(this);
    				}
    			}
    			
    		}
    Can you please help me resolve this issue?

    #2
    Hello vides2012,

    Can you let us know which version of TWS you're using? Check within their platform Help > About.

    One thing to check is the error message indicated in your logs:

    2010.09.23. 15:31:48|3|4|Failed to call method 'Initialize' for indicator 'UnrealizedPLKozos': Az objektumhivatkozás nincs beállítva semmilyen objektumpéldányra.
    2010.09.23. 15:32:10|3|4|Failed to call method 'Initialize' for indicator 'UnrealizedPLKozos': Az objektumhivatkozás nincs beállítva semmilyen objektumpéldányra.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Here's the output from "about":

      Build 906.9, Jul 8, 2010 9:52:08 AM
      Jolt Build 1.1.4, May 25, 2010 02:37:20 PM
      Nia Build 1.6.0, May 25, 2010 12:31:58 PM
      ModelNav Build 1.1.27, May 25, 2010 03:26:24 PM


      Java Version: 1.6.0_21
      OS: Windows XP (x86, 5.1)
      I've noticed that, but it's a faulty Indicator yet to be dealt with. It's an older issue, and has nothing to do with the strategy.

      Comment


        #4
        Thanks. Is there a case of this available in the log files you had sent? I went through all stop loss orders on 2010 -09-23 and they went through the normal cycle of order states.

        The 9:30 one that shows this, but no other records of the order is available with this file. Is this the issue you're seeing?


        2010.09.23. 10:14:14|1|32|Order='77b67879b7da45e6853b2a803f466 538/U805677' Name='Stop loss' New state=PendingCancel Instrument='FGBL 12-10' Action=Sell Limit price=0 Stop price=130,24 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
        2010.09.23. 10:14:14|1|32|Order='77b67879b7da45e6853b2a803f466 538/U805677' Name='Stop loss' New state=Cancelled Instrument='FGBL 12-10' Action=Sell Limit price=0 Stop price=130,24 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
        Last edited by NinjaTrader_RyanM1; 09-23-2010, 02:32 PM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          The 10:14 one in the log file, was when I restarted the strategy (and it cancelled the stop loss order).

          The issue actually doesn't appear in the log file, only in the trace:

          2010-09-23 09:30:01:617 (IB éles) Cbi.ExecutionEventArgs.Process: Execution='FGBL 12-10/0000d326.4c9af3c6.01.01' Instrument='FGBL 12-10' Account='U805677' Exchange=Eurex Price=130,74 Quantity=1 Market position=Long Operation=Insert Order='366288922' Time='2010.09.23. 9:30:01'
          2010-09-23 09:30:01:648 (IB éles) Cbi.Connection.ProcessEventArgs.OrderStatusEventAr gs: Order='77b67879b7da45e6853b2a803f466538/U805677' Name='Stop loss' New state=Initialized Instrument='FGBL 12-10' Action=Sell Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
          2010-09-23 09:30:01:648 (IB éles) Cbi.Order.Update1: oldid='77b67879b7da45e6853b2a803f466538' Order='77b67879b7da45e6853b2a803f466538/U805677' Name='Stop loss' New state=Initialized Instrument='FGBL 12-10' Action=Sell Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
          2010-09-23 09:30:01:664 (IB éles) Cbi.Connection.ProcessEventArgs.OrderStatusEventAr gs: Order='77b67879b7da45e6853b2a803f466538/U805677' Name='Stop loss' New state=Initialized Instrument='FGBL 12-10' Action=Sell Limit price=0 Stop price=130,24 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
          2010-09-23 09:30:01:664 (IB éles) Cbi.Order.Update1: oldid='77b67879b7da45e6853b2a803f466538' Order='77b67879b7da45e6853b2a803f466538/U805677' Name='Stop loss' New state=Initialized Instrument='FGBL 12-10' Action=Sell Limit price=0 Stop price=130,24 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
          2010-09-23 09:30:01:664 (IB éles) Cbi.OrderStatusEventArgs.Process: Order='77b67879b7da45e6853b2a803f466538/U805677' Name='Stop loss' New state=Initialized Instrument='FGBL 12-10' Action=Sell Limit price=0 Stop price=130,24 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
          2010-09-23 09:30:01:680 (IB éles) Cbi.OrderStatusEventArgs.Process: Order='77b67879b7da45e6853b2a803f466538/U805677' Name='Stop loss' New state=Initialized Instrument='FGBL 12-10' Action=Sell Limit price=0 Stop price=130,24 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''

          Comment


            #6
            Thanks vides2012,

            Can you check your IB account connections and verify a setting.

            Click Tools > Account Connections > Highlight the IB connection and click change > Click Next through the wizard >

            Do you have local OCO simulation checked? This may explain what you are seeing.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              No it's unchecked for both my live and simulated account.

              Maybe some setting in TWS is responsible for this?

              Comment


                #8
                I'm not sure why you're getting these results. We need to isolate to a reproducible scenario, with as simple a strategy as possible. We can test on an IB paper trading account to simulated live trading. Let us know if you can provide steps and a simple strategy that will demonstrate the issue.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  The problem is that I haven't seen this issue with the simulated (paper trading) account.

                  Anyway it looks like for the first time NT only simulates my stoploss, and thus it is not activated in TWS.
                  After I restrart the strategy it becomes a live working one.

                  Comment


                    #10
                    Thanks Vides,

                    We will need to verify this first on our demo account, as that's the safest way of checking this issue. We are going to need the exact steps and settings needed to see this. I will follow up with you by email, and we can setup a time for remote assistance.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks for the sharing all the steps and the strategy code. You were using SetStopLoss() with simulated property = true. This means the orders are not sent to TWS until price reaches the level.

                      There is a bug in version 21.
                      1) Place simulated stop order with strategy.
                      2) Stop strategy.


                      Restart strategy and your simulated order becomes working. This most likely explains why you your order is sent after resuming the strategy.

                      This bug has been fixed in beta 22. Please retest once this has been released.


                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        I'm sorry but you have misunderstood something. I am not having problem with the simulated stop loss orders. In fact they are to be simulated since they are not used - I don't want short stop losses when I am in long position!

                        As you could see in my mail:

                        SetStopLoss(Name+" EnterLong",CalculationMode.Price,avgPrice+l_ln/(Position.Quantity),FALSE);

                        This is used to submit a LIVE and NOT SIMULATED stop when I am in long position. And the problem is that THIS particular stoploss order is NOT submitted to TWS.

                        Is it clear now?

                        And anyway: it doesn't happen with my IB papertrader account - with the same strategy. Only with the live one. For NT they should be the same!

                        Comment


                          #13
                          You're using both statements (true and false) and the last Set statement executed is what's used.

                          You need to work from a simpler strategy to test this. The behavior you're seeing looks exactly like simulated stop orders. The strategy you're running has statements that submit simulated stop orders. If you want to evaluate this properly, then remove statements that submit simulated stop orders.
                          Last edited by NinjaTrader_RyanM1; 09-28-2010, 10:23 AM.
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #14
                            Then why does it work with the papertrading account?
                            Upon entry, the last SetStopLoss is the one which is not simulated.

                            Comment


                              #15
                              vides2012, unfortunately we would not know why the papertrading account would react differently to this scenario, however you're running into a bug with the simulated stop behavior that is unfortunately not working as expected in B22. We would appreciate if you could retest your setup once B22 is released and then report back here to us your findings.

                              Thanks for the support.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              621 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              359 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              105 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              562 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              566 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X