Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Translating a v6.0 strategy to 7

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

    #61
    You can either work with CalculateOnBarClose = true, or move the order generation into if (FirstTickOfBar) in your script.

    Comment


      #62
      I now seem to be having an issue with exit orders cancelling themselves without reason. the strategy holds up to 3 positions with 3 different profit targets, when I run a single strategy it seems to be working ok, however when I run it on multiple contracts at once some times exit orders will cancel themselves before being executed and I am often left with an open position of 3 contracts but a profit target for only 1 contract. It almost seems as if trades in other contracts are triggering these cancellations (In the log it shows up as order cancelled).

      Has anyone else come across this before, or is it simply a bug in my strategy?

      There are no time stops or anything similar

      Comment


        #63
        What is the trace orders output showing? Are you working with any non unique OCO id's perhaps?

        Comment


          #64
          Betrand, that sounds like it might be the case. Any info on using unique OCO orders?

          Comment


            #65
            You just want to make sure the different individual strategies are using unique ones to provide the correct 'linking' - if you run your strategy on 2 markets, please have a look at the OCOid's used in Orders tab to check into.

            Comment


              #66
              Betrand,the order ID's all look unique, however when I get a long position in 1 strategy, then a long position (same name in OCO column) in another strategy, the exit for the first one is cancelled. Almost as if it can only handle 1 exit across however many strategies Im running......

              Comment


                #67
                maninjapan,

                Please turn on TraceOrders = true for both of your strategies. Then when you see the order get cancelled, please send in what is outputted into the Output Window as the reason the order was cancelled. Thank you.
                Josh P.NinjaTrader Customer Service

                Comment


                  #68
                  Sorry Bertrand, any examples of where to add trace orders?

                  Comment


                    #69
                    Please see this example here - http://www.ninjatrader.com/support/f...ead.php?t=3627

                    You would add it in the Initialize() of your strategies and then the additional debug info is shown in your output window.

                    Comment


                      #70
                      Thanks for that. was able to implement it. Fills of an exit OCO in 1 contract (CL 10-10) are definately resulting in an exit OCO of the same name being cancelled in another contract (FDAX 09-10) and visa versa. Im not sure how to interpret the output window though, below is the output as the orders cancelled each other out.
                      I cant see where the FDAX orders were cancelled though.

                      Changing unmanaged order at 9/8/2010 5:43:55 AM: Order='fdb8abd5288542b197e053290806be33/Sim101' Name='Long Limit1' State=Working Instrument='CL 10-10' Action=Buy Limit price=73.49 Stop price=0 Quantity=1 Strategy='MMStrategy' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='fdb8abd5288542b197e053290806be33' Gtd='12/1/2099 12:00:00 AM'
                      Changing unmanaged order at 9/8/2010 5:43:55 AM: Order='827096782abe4c8fa36680ff3b861e19/Sim101' Name='Short Limit1' State=Working Instrument='CL 10-10' Action=SellShort Limit price=73.59 Stop price=0 Quantity=1 Strategy='MMStrategy' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='827096782abe4c8fa36680ff3b861e19' Gtd='12/1/2099 12:00:00 AM'
                      Changing unmanaged order at 9/8/2010 5:43:55 AM: Order='69f97330d1df46969ac4b72751db4921/Sim101' Name='Long Limit2' State=Working Instrument='CL 10-10' Action=Buy Limit price=73.47 Stop price=0 Quantity=1 Strategy='MMStrategy' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='69f97330d1df46969ac4b72751db4921' Gtd='12/1/2099 12:00:00 AM'
                      Changing unmanaged order at 9/8/2010 5:43:55 AM: Order='26429310aee84ced89e09e26d867bb61/Sim101' Name='Short Limit2' State=Working Instrument='CL 10-10' Action=SellShort Limit price=73.61 Stop price=0 Quantity=1 Strategy='MMStrategy' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='26429310aee84ced89e09e26d867bb61' Gtd='12/1/2099 12:00:00 AM'
                      Changing unmanaged order at 9/8/2010 5:43:55 AM: Order='890ad138ed9046e6b0384840d908edf5/Sim101' Name='Long Limit3' State=Working Instrument='CL 10-10' Action=Buy Limit price=73.45 Stop price=0 Quantity=1 Strategy='MMStrategy' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='890ad138ed9046e6b0384840d908edf5' Gtd='12/1/2099 12:00:00 AM'
                      Changing unmanaged order at 9/8/2010 5:43:55 AM: Order='7912302fe33e4d1ebc49804744974e3c/Sim101' Name='Short Limit3' State=Working Instrument='CL 10-10' Action=SellShort Limit price=73.63 Stop price=0 Quantity=1 Strategy='MMStrategy' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='7912302fe33e4d1ebc49804744974e3c' Gtd='12/1/2099 12:00:00 AM'
                      Sell Order Filled73.59
                      Cancelled custom managed order at 9/8/2010 5:44:49 AM: Order='fdb8abd5288542b197e053290806be33/Sim101' Name='Long Limit1' State=Working Instrument='CL 10-10' Action=Buy Limit price=73.49 Stop price=0 Quantity=1 Strategy='MMStrategy' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='fdb8abd5288542b197e053290806be33' Gtd='12/1/2099 12:00:00 AM'
                      Cancelled custom managed order at 9/8/2010 5:44:49 AM: Order='69f97330d1df46969ac4b72751db4921/Sim101' Name='Long Limit2' State=Working Instrument='CL 10-10' Action=Buy Limit price=73.47 Stop price=0 Quantity=1 Strategy='MMStrategy' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='69f97330d1df46969ac4b72751db4921' Gtd='12/1/2099 12:00:00 AM'
                      Cancelled custom managed order at 9/8/2010 5:44:49 AM: Order='890ad138ed9046e6b0384840d908edf5/Sim101' Name='Long Limit3' State=Working Instrument='CL 10-10' Action=Buy Limit price=73.45 Stop price=0 Quantity=1 Strategy='MMStrategy' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='890ad138ed9046e6b0384840d908edf5' Gtd='12/1/2099 12:00:00 AM'
                      9/8/2010 5:44:49 AM Entered internal SubmitOrder() method at 9/8/2010 5:44:49 AM: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=73.54 StopPrice=0 OcoId='ShortExit1' Name='Short Profit1'
                      9/8/2010 5:44:49 AM Entered internal SubmitOrder() method at 9/8/2010 5:44:49 AM: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=73.69 OcoId='ShortExit1' Name='Short StopLoss1'
                      Sell Order Filled73.6
                      9/8/2010 5:46:34 AM Entered internal SubmitOrder() method at 9/8/2010 5:46:34 AM: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=73.55 StopPrice=0 OcoId='ShortExit2' Name='Short Profit2'
                      9/8/2010 5:46:34 AM Entered internal SubmitOrder() method at 9/8/2010 5:46:34 AM: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=73.70 OcoId='ShortExit2' Name='Short StopLoss2'
                      Sell Order Filled73.61
                      9/8/2010 5:46:39 AM Entered internal SubmitOrder() method at 9/8/2010 5:46:39 AM: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=73.56 StopPrice=0 OcoId='ShortExit3' Name='Short Profit3'
                      9/8/2010 5:46:39 AM Entered internal SubmitOrder() method at 9/8/2010 5:46:39 AM: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=73.71 OcoId='ShortExit3' Name='Short StopLoss3'
                      Exit Order ExecutedCurrent Avg Price =Short
                      Exit Order ExecutedCurrent Avg Price =Short
                      Exit Order ExecutedCurrent Avg Price =Short

                      Comment


                        #71
                        maninjapan, I don't see the FDAX here either : is this the full output you get for running the strategy on both contracts? Have you tried to use a OCOid in the SubmitOrder() call that would include for example the instrument name in it's ID?

                        Comment


                          #72
                          Could you post an example of how to add that?

                          Comment


                            #73
                            I would do something like this below -

                            Code:
                             
                            entryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, 10000, 0, Close[0] + 200 * TickSize, "Scalp" + Instrument.MasterInstrument.Name, "BuyStop");
                            entryOrder2 = SubmitOrder(0, OrderAction.SellShort, OrderType.Stop, 10000, 0, Close[0] - 200 * TickSize, "Scalp" + Instrument.MasterInstrument.Name, "SellStop");

                            Comment


                              #74
                              bertrand, adding the '+ Instrument.MasterInstrument.Name' seems to have fixed the problem at first glance. Perhaps it was getting confused somewhere with both contracts using the same name for multiple contracts?

                              Comment


                                #75
                                Great to hear, thanks for reporting back here.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                649 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                370 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                109 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                574 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                576 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X