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

Oco

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

    Oco

    Hi All,

    Does an OCO order submited thanks to the NTCommand function has to be linked with an ATMStrategy ? I want to use OCO orders but not the SuperDOM is this possible ?

    I have this in my code :
    Success = NTCommand("PLACE", AccountID, "SELL", TG1Qty, "LIMIT", PivotLevel + TicksTarget1, 0, "DAY", "StopLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "TargetLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "", "");

    I don't have any error message, NT is processing, but nothing happen there is no order placed in the market :

    01/04/2009 14:50:38;ATI;AT,
    'PLACE;Sim101;FESXM09;BUY;1;LIMIT;1961;0;DAY;StopS hort1_FESXM09_NT_Cassure_v1_A_14:50:31;TargetShort 1_FESXM09_NT_Cassure_v1_A_14:50:31;;' processing ;

    Regards.

    #2
    Hi, you don't have to call an ATM strategy template with the Command function however when you do this the stop and target will be linked via OCO. So you don't see a limit order 'Working' under the orders tab with your command?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Correct I don't see neither the limit order nor the stop order working under th orders tab.

      I don't know why, is something wrong with my NTCommand (I use TradeStation for signal generation) ?

      Comment


        #4
        sebastienb,

        Just to be clear, the way you place OCO orders for stops and targets is you need to call NTCommand() twice and place in a stop order and a target order. Then you want to be sure that on the OCO parameter for the NTCommand() that you use the same OCO id for both the stop and target orders.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          What's surprising is that it looks like that what I did is correct.

          Here is the NTCommand that I use in my TS code :

          Success = NTCommand("PLACE", AccountID, "SELL", TG1Qty, "LIMIT", PivotLevel + TicksTarget1, 0, "DAY", "StopLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "TargetLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "", "");

          Success = NTCommand("PLACE", AccountID, "SELL", TG1Qty, "STOP", 0, PivotLevel - TicksStop1, "DAY", "TargetLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "StopLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "", "");

          Comment


            #6
            Are you still experiencing difficulties?
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Still experiencing difficulties. I'm currently using the Sim Mode does this have an impact on OCO orders placement ?

              Comment


                #8
                No, the orders would then only be placed on the Sim101 internally. Are you connected to live data in NinjaTrader when you try your code?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Yes I'm connected to the TradeStation live date feed.

                  I tried to use the NTCommand to change on order and had the same problem, processing but nothing happen :

                  Success = NTCommand("CHANGE", "", "", RemainingPos_TBT, "", 0, PrixTheorique, "", "", "StopLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "", "");

                  I didn't have any error message but my order wasn't changed and in the log tab I have this :

                  03/04/2009 18:04:25;ATI;AT, 'Cancel;;FESXM09;;0;;0;0;;;EnterLong_FESXM09_NT Color Switch_A_17:55:22;;' processing ;

                  I don't understand where is my mistake

                  Comment


                    #10
                    sebastienb, please contact me at support at ninjatrader dot com Attn Bertrand with your log and trace files and the TS code you used, I will then review this and get back to you - Thanks!
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Ok thanks Bertrand I will send to you the code.

                      I have another question I have this in my strategy :

                      If PositionLive_TBT < 0 then begin
                      Success = NTCancel("TargetShort1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID);
                      Success = NTCancel("TargetShort2" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID);
                      Success = NTCancel("StopShort1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID);
                      Success = NTSellMarket("ExitShortOnReverse" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, RemainingPos_TBT);
                      End;

                      The SellMarket is correctly send in the but orders "TargetShort1" and TargetShort", "Stopshort1" are not canceled I'm not sure to understand why ?

                      ManyThanks,

                      Sebastien

                      Comment


                        #12
                        Thanks I will have a look at the code and comment - do you get an error for the order id not being found, I suspect and issue there, can you try with a simple one to verify like the "MyOrderId" used in the NTSample TS code?
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Bertrand I'm not sure to understand what you want me to do, to replace

                          Success = NTCancel("TargetShort1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID);

                          by something simpler like (is my original order ID to long ?)

                          Succes = NTCancel("MyOrderId")

                          Or to do something like this :

                          MyOrderID = "TargetShort1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID

                          Succes = NTCancel(MyOrderId)

                          Regards,

                          Sebastien

                          Comment


                            #14
                            Hi Sebastien - yes I was suggesting simplifying your code to track down the issue and then work up from there. Did you already send me your code to support at ninjatrader dot com? Then I can have a look...Thanks!
                            BertrandNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by judysamnt7, 03-13-2023, 09:11 AM
                            4 responses
                            57 views
                            0 likes
                            Last Post DynamicTest  
                            Started by ScottWalsh, Today, 06:52 PM
                            4 responses
                            36 views
                            0 likes
                            Last Post ScottWalsh  
                            Started by olisav57, Today, 07:39 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post olisav57  
                            Started by trilliantrader, Today, 03:01 PM
                            2 responses
                            19 views
                            0 likes
                            Last Post helpwanted  
                            Started by cre8able, Today, 07:24 PM
                            0 responses
                            9 views
                            0 likes
                            Last Post cre8able  
                            Working...
                            X