Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

custom Trade Copier for scalping NQ

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

    custom Trade Copier for scalping NQ

    I scalp the NQ and am needing a Trade Copier that won't choke on fast entry / exits.

    Also, one where I can set parameters for No Fill, Spread, et cetera.


    So, I copied one of the freeware versions, modified it, and in general it works well.


    However, when the Master Account closes I don't copy the Close Order to the Target Accounts.

    Instead I issue a Account.Flatten on each target account.

    I do this for simplicity.


    This is because my style of scalping is very simple....to have a simple position (not complex orders) or to be flat.


    In reality this works fine, the Target Account positions are close and are in reality Flat. This is shown in the Order List.


    But, Ninja is getting confused. On one of the accounts Ninja is reporting (on the Positions Tab, and Chart Trader) an active position.


    But it is not really on the market, and the position cannot be "closed" with a Flatten on the Position Tab, or issuing a Close on Chart Trader.


    (I'm testing with live account Micro NQ)


    The only way I can "exit" the position is to place an opposite order. Which then creates a new "real" position.




    This happens on the first account in the Target Account List, but not the second. (so far)

    Ideas?



    #2
    Note: it doesn't do this when Copy Trading SIM accounts

    Comment


      #3
      maybe what is happening is that Ninja gets confused if I issue multiple Flatten on different accounts just milliseconds apart?

      Comment


        #4
        the target accounts are in a List....to flatten them I just iterate the list, so the Flatten instructions are happening very fast

        Comment


          #5
          this is not happening when there is only one Target Account in the list

          Comment


            #6
            If I disconnect the data feed and reconnect, the "phantom" position disappears. It is not on the market, just that Ninja thinks it is.

            Comment


              #7
              Hello llanqui,

              Are these accounts NinjaTrader Brokerage accounts and are you connected with the NinjaTrader connection type?

              Are you able to reproduce the behavior with multiple Sim accounts?

              I've tested using a few sim accounts and positions and I'm not seeing an issue that I would suspect is related to NinjaScript.

              Below is a link to a video of the test.


              Code:
              System.Collections.Generic.List<Cbi.Account> myAccounts = Cbi.Account.All.Where(acct => acct.Name.Contains("SimAccount")).ToList();
              myAccounts.ForEach(acct =>
              {
              Code.Output.Process(acct.DisplayName, PrintTo.OutputTab1);
              acct.Flatten((from position in acct.Positions select position.Instrument).ToArray());
              });
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                These are Apex Rithmic Accounts

                Does not do this on SIM

                Following is the base code...(how can I maintain the indents???)

                Description:

                When OnOrderUpdate signals a CLOSE on the Master Account, this starts a Timer to Flatten the Target accounts. There is more code than is here, the purpose of the timer (not in this case) is to delay the close of the targets IF the Master order was cancelled or closed immediately (milliseconds) after it was filled This can happen on the NQ scalps.

                But in this case the timer is set to execute immediately (1ms).

                I put a delay in the timer to see if it made any difference, but not.

                Next week if necessary I can make a video and send it to you private.

                The problem does not occur in SIM and does not occur if there is only one Target Account.




                private void OnOrderUpdate(object sender, OrderEventArgs e)
                {
                // Only processes MASTER ACCOUNT Orders for the Chart Instrument

                if (!copyEnabled)
                return;

                if (e.Order.Account != MasterAccount)
                return;

                if (e.Order.Instrument != Instrument)
                return;

                if (e.Order.Name == closeOrder)
                {
                CloseTargetsTimer.Interval = 1; // timer cannot be 0 evidently, will compile but messes up Ninja instantiating all indicators

                CloseTargetsTimer.Start();

                return;
                }

                }

                // TIMER

                private void CloseTargetAccounts(Object source, ElapsedEventArgs e) // this method is triggered by a timer in OnPositionUpdate (position update parameters set by each broker...can be different...not reliable)
                {
                for (int i=0; i < TargetAccountList.Count; i++)
                {
                TargetAccountList[i].Account.Flatten(new [] { Instrument });
                TargetAccountList[i].Quantity = 0;

                Task.Delay(500); // don't overload ninja with flatten instructions
                }

                // stop timer
                CloseTargetsTimer.Stop();
                }

                Comment


                  #9
                  Hello llanqui,

                  The issue is likely with the Rithmic connection.

                  There is an open case about rithmic updates not being received. Please send an email to platformsupport [at] ninjatrader.com so that we may collect your log and trace files and add you to the impact report.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    ok, thanks

                    Comment


                      #11
                      I'm running this version of Ninja, could that be a problem?

                      8.0.28.0 64-bit

                      I have a grandfathered lifetime license, from a long time ago. Don't have a Ninja Brokerage account.

                      It used to be I would get a notice when there was a new version.

                      Did not port to the Login Ninja version cause there were some complaints that you had to log in each time Ninja was started,

                      Did you fix that?

                      Comment


                        #12
                        how do I port over to 8.1?

                        Comment


                          #13
                          Hello,

                          Yes, this could be part of the issue.

                          Currently NinjaTrader has released 8.1.3.1.

                          Updates to NinjaTrader will contain the latest security updates and bug fixes, as well as occasional new features and instruments.

                          To update NinjaTrader
                          • Shutdown all programs including NinjaTrader *important
                          • Download NinjaTrader from the link below
                            Click here to download NinjaTrader
                          • Double click the downloaded file to execute it
                          • Follow the on screen instructions
                          • Restart NinjaTrader
                          You can read about changes to this release in the release notes linked below.



                          "Did not port to the Login Ninja version cause there were some complaints that you had to log in each time Ninja was started,

                          Did you fix that?​"

                          This is correct, you must login when starting NinjaTrader.
                          This will not be changed and will be how it is from now on.​
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            1) will this install keep the existing license code?

                            2) when I try to import the license code on the web page I get an error: The license key you entered could not be imported. Please contact support

                            Comment


                              #15
                              is 8.0.28.0 64-bit not being updated?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              597 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              343 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              556 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              555 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X