Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entering too many contracts with Tradestation order

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

    Entering too many contracts with Tradestation order

    I have something like the following.

    VARS: entryP(0), ccN(0), eFlag(true);

    if NTMarketPosition("") = 0 then begin
    entryP = Close;
    eFlag = true;
    NTCancel("LL");
    NTCancel("LPT");
    NTCancel("LStop");
    end;

    // I used this code b/c a thread on Ninja's website said NTMarketPosition is unreliable on partial fills.
    ccN = NTFilled("LEn") + NTFilled("LL");

    NTBuyMarket("LEn", 1);

    if NTMarketPosition("") > 0 then begin
    if eFlag then
    NTBuyLimit("LL", 3, entryP-10);
    eFlag = false;

    if ccN >= 4 then
    NTCancel("LL");

    NTSellLimit("LPT", ccN, entryP + 10);
    NTSellStop("LStop", ccN, entryP - 20);
    end;

    In this case, sometimes it will enter many more than 3 contracts on the add on. It has entered as many a 15 contracts. Could this be a Ninja setting, or am I overlooking something else?

    Thanks for your help!

    #2
    This is all occurring in simulation mode.

    Comment


      #3
      You need to debug your code.

      if NTMarketPosition("") > 0 then begin
      if eFlag then
      NTBuyLimit("LL", 3, entryP-10);
      eFlag = false;

      See why your eFlag is not stopping the additional NTBuyLimit()s.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Josh,

        Thanks for your response. I don't set eFlag anywhere else. Also, it will fill the order multiple times on each bar. When I look in the log, it is only buying one contract at a time eventhough the order specifies 3.

        Comment


          #5
          Hi sgordon77, do you happen to use IntraBar order generation in TradeStation? Does the same happen with the provided NTSample strategy?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            No, I do not use intrabar execution in Tradestation. I can try the NTSample strategy, but I have not yet. As I recall, this strategy does not do multiple entries is the same direction, could this be part of the problem?

            Comment


              #7
              This occurred again last night. The strategy was supposed to buy 3 contracts as an "add on", but it bought 4. I am running the exact same thing in TS, and it work fine (I do NOT have the email connection to Ninja setup). I have the TS orders and the Ninja orders in the same strategy, but I don't see how that could be realted.

              For example:
              Buy next bar at market;
              if NTConnected("") then
              NTBuyMarket("LEn", 1);

              Comment


                #8
                Also, this same behavior also occurred when I was using an ATM strategy and NTCommand to place/modify the orders.

                Comment


                  #9
                  Hi sgordon77, are you testing this with a flat Sim 101 account position in NinjaTrader?

                  Please attach your full TS test code so I can run this on my end here. Thanks!
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Yes, I am. If the strategy has a position, I match it using the DOM.

                    I will send you the code in a few hours in a PM.

                    Comment


                      #11
                      Okay thanks will look out for it.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        I have a quick question and I didn't want to start a new thread for what will probably be a simple answer.

                        If I use Tradestation with Forex.com and Rosenthal Collins Group which are both Ninjatrader supported brokerage partners, will I be able to trade on those accounts using Ninjatrader?

                        Many thanks

                        Comment


                          #13
                          Hello,

                          If the broker uses one of these data feeds, you can trade with it if you have a live license:


                          However, for TradeStation, you will not have access to live trading. This link will help:
                          DenNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Stanfillirenfro, Today, 07:23 AM
                          3 responses
                          10 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by FitSpressoHonest, Today, 09:14 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post FitSpressoHonest  
                          Started by Davide999, 05-18-2023, 03:55 AM
                          4 responses
                          556 views
                          1 like
                          Last Post kcwasher  
                          Started by rexsole, Today, 08:39 AM
                          2 responses
                          7 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Started by cmtjoancolmenero, Yesterday, 03:58 PM
                          6 responses
                          29 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Working...
                          X