Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Repopulating iOrder object after disconnect

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

    #16
    Hello RedDuke,

    Can you check on your chart to see if your Stop Loss order is filled by chance?

    The order is being submitted on "3/27/2014 10:33:07 AM" which I am sure will have moved 40 Ticks by today.
    JCNinjaTrader Customer Service

    Comment


      #17
      JC,

      The reason why that date was in past is due to it being generated from Replay.

      I have also tested this logic in real time with IB, but got the same result. This is info from output window:

      5/8/2014 11:56:31 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Short' Mode=Price Value=1881 Currency=0 Simulated=False

      And once again, I do not see any accepted orders in control center.

      Thanks,
      redduke

      Comment


        #18
        Hello redduke,

        Thanks for the added information. Then we may want to look into your entry order. When is your entry order being filled Historically?

        You will see something like "Date/Time Entered internal PlaceOrder() method at Date/Time : BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='TestStrategy' FromEntrySignal='' in the Output Window and then see when it was placed on your chart.
        JCNinjaTrader Customer Service

        Comment


          #19
          Hi JC,

          I loaded 2 months of data in the chart, and the virtual entry order in historical is being placed in March, this is where it meets the first instance of the price from the file where I stored the data.

          Could the issue be that virtual entry order and and stop order dates are over a month apart? Should I try to place both virtual entry order and stop at the same day?

          Thanks,
          redduke

          Comment


            #20
            Hello RedDuke,

            I would not expect the amount of time to be the issue but I would expect that your stop loss order is filled in the 2 months in with only a 40 Tick offset.

            Just for a test can you try to set the Stop Loss to something like 4000.

            SetStopLoss(entryOrder.Name, CalculationMode.Price, entryOrder.AvgFillPrice-TickSize*4000, false);

            This way it has a more movement room to try not to get filled.

            Note that you should be able to see if your stop loss is filled by right clicking inside of your Chart/Strategy -> select Strategy Performance -> select your strategy name -> then select Historical. This will bring up only the Historical Trades that your strategy has taken where you can check the Executions tab to see if your Stop Loss Order was filled.
            JCNinjaTrader Customer Service

            Comment


              #21
              JC,

              The issue was the dates. Once I loaded just few days of data, and stop loss was generated on the same date as the virtual order, all worked well. The stop loss appeared in control center orders tab in Accepted status.

              Thanks for all your help.

              Regards,
              redduke

              Comment


                #22
                Hi JC,

                Hope you had good Memorial day weekend.

                I stumbled on another issue. Let's say I was short at 1842.75. Then I loose connection, and the market keeps going down. Once I get connection back, and resubmit virtual short order in historical, it gets stuck in Waiting status instead of being Filled. I use EnterShortLimit to place my orders.

                Thanks,
                redduke

                Comment


                  #23
                  RedDuke, would you mean 'working' as status for the order here? From the price you submit at in historical would you expect to get it filled on the fill type chosen for backtesting? On default the limit price would need to be traded through in order to get it filled, which is in contract to our liberal algorithm.

                  Comment


                    #24
                    Hi Bertrand,

                    I triggered the following code in historical:

                    entryOrder=EnterLongLimit(BarsInProgress, true, OrderQty, OrderEntryLevel, OrderName);

                    The entry level was set to 1840.5 as you can can from Output window log:

                    3/27/2014 10:05:20 AM Entered internal PlaceOrder() method at 3/27/2014 10:05:20 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=2 LimitPrice=1840.50 StopPrice=0 SignalName='Long' FromEntrySignal=''
                    ,
                    The attached file called "chart" has a Bar circled where historical order was triggered, and as you can see the closing price is above the limit price. Which I assume means that it traded through it, and as the result the order should have been filled.

                    The attached file called "orders tab" displays submitted historical order in "working status".

                    I think that the issue is that the price moved higher than Limit order level.

                    How can I get this order into Filled Status and the specified price?



                    Thanks,
                    redduke
                    Attached Files
                    Last edited by RedDuke; 05-28-2014, 09:34 PM.

                    Comment


                      #25
                      RedDuke, thanks - so this was run in replay for the historical chart portion, so CalculateOnBarClose true? Or was it placed during forward replay with CalculateOnBarClose potentially false? You would always place the order for the next bar, so not knowing what kind of chart you're on it's hard to say if it should have been filled. If the price was higher before the order was placed, I would not expect a fill if it not came back, if though you placed an order at higher price while the current price was lower > would expect an immediate market order comparable fill (this limit order would be be called marketable).

                      Comment


                        #26
                        Hi Bertrand,

                        Yes, I am doing my tests in replay, and the virtual order was set while in historical. I have CalculateOnBarClose is set to false. I want strategy to be calculating all the time.

                        I am using Range based charts.

                        Essentially I am testing situation with disconnect. I put all order variables in the file, and on the restart recreate iOrder object while in historical.

                        I need AvgFillPrice in virtual historical order to be the same as when it was placed originally.

                        Is it possible or will I need to place an order at higher price while the current price was lower, and get what ever fill the bar gives me?

                        Thanks,
                        redduke

                        Comment


                          #27
                          Thanks, for the historical part the processing would then still be on CalculateOnBarClose = true.

                          If you just want to get in a market order or truly marketable limit order would be best for your test.

                          Comment


                            #28
                            But how can I make sure that entry price in historical matches the entry price that I originally got before the "disconnect"?

                            Thanks

                            Comment


                              #29
                              You could look into running the historical fill processing with a limit order on Liberal Fills instead of default, this will fill the limit at your price specified.

                              Comment


                                #30
                                Thanks. I will try this. This will only affect historical entries I assume?

                                Thanks

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                668 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                377 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                110 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                575 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                580 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X