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

Leeloo's account with ríthmic does not execute operations

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

    Leeloo's account with ríthmic does not execute operations

    I have a strategy that works very well in the demo but in the leeloo account it does not execute operations, can you help me with this?

    #2
    Hello franatas,

    Thanks for your post.

    Please answer all of the questions below so I may accurately assist you.
    • What version of NinjaTrader are you using?
    • If you open up a chart window, do you see realtime data populating on the chart when connected to your Leeloo account?
    • Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?
    • Have you added debugging prints to the strategy to understand how it is behaving?

    I look forward to assisting further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      everything seems to be fine, if I put the sim101 it executes but operations in the leeloo nothing
      Click image for larger version

Name:	2023-06-06_17h50_33.png
Views:	143
Size:	53.0 KB
ID:	1254817
      Attached Files
      Last edited by NinjaTrader_BrandonH; 06-06-2023, 10:17 AM.

      Comment


        #4
        Here I leave the version, and how it can be seen when activating the strategy, it also shows me the possible entries that occurred before activating

        Click image for larger version

Name:	2023-06-06_17h56_32.png
Views:	151
Size:	40.6 KB
ID:	1254807
        Last edited by NinjaTrader_BrandonH; 06-06-2023, 10:17 AM.

        Comment


          #5
          Hello franatas,

          Thanks for your notes.

          I see in the screenshots you shared that your strategies are set to be enabled on the Sim101 account which is why they are running on the Sim101 account.

          If you want the strategy to run on your Leeloo account and place orders to the Leeloo account, you will need to set the Account property in the Strategies window to use the Leeloo account when enabling the strategy.

          Disable a strategy on the Strategies tab of the Control Center, right-click on the strategy in the Strategies tab of the Control Center, select 'Edit strategy', set the 'Account' property drop-down menu to your Leeloo account, and click OK. Then, when you enable the strategy, it will enable on your Leeloo account instead of the Sim101 account.

          See this help guide page for more information about running a NinjaScript strategy: https://ninjatrader.com/support/help...t_strategy.htm

          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            I didn't even notice this, but even having Leeloo's account on the chart, it shouldn't automatically switch to that account that's on the chart???, or is there a way to configure this automatically
            thank you so much

            Comment


              #7
              So even though in the cahart the account box is empty, but in the strategies window is the account that I want to operate, would it be okay?

              Click image for larger version  Name:	2023-06-06_19h32_04.png Views:	6 Size:	55.5 KB ID:	1254841

              Click image for larger version  Name:	2023-06-06_19h32_39.png Views:	6 Size:	58.2 KB ID:	1254842
              Last edited by NinjaTrader_BrandonH; 06-06-2023, 12:28 PM.

              Comment


                #8
                Hello franatas,

                Thanks for your note.

                Anytime you go to enable a NinjaScript strategy on a chart, you must always ensure that you are setting the Account drop-down property in the Strategies window to the account that you want to enable the strategy on.

                The strategy will run on whatever account you have selected in the Strategies window when enabling the strategy regardless of what account you have selected in Chart Trader.

                Review this help guide page for more information: https://ninjatrader.com/support/help...t_strategy.htm
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  many thanks for everything
                  one more query.
                  How can I get the sum of the account positions?​
                  Attached Files

                  Comment


                    #10
                    Hello Franatas,

                    Thanks for your note.

                    PositionAccount.Quantity could be used to get the number of positions on an account in the strategy.

                    For example:

                    // Prints out the current market position
                    Print(PositionAccount.MarketPosition.ToString() + " " + PositionAccount.Quantity.ToString());​


                    Note that NinjaScript strategies are only able to see the orders placed on an account/instrument combination by that specific instance of the strategy. It cannot see orders placed by other strategies or see manually placed orders.

                    For example, say you have two strategies running on the ES instrument and each strategy placed 1 Long order, putting you in a total account position of 2 Long on that instrument. PositionAccount.Quantity would return a value of 2 since you are 2 Long on the ES instrument on that account.

                    Say you have two strategies. One is running on the NQ instrument and the other is running on the ES instrument. Each strategy places 1 Long order so you are in a 1 Long position on NQ and are in a 1 Long position on ES. When the strategy running on the ES prints PositionAccount.Quantity, it will return a value of 1 since there is 1 Long position on that instrument/account combination and it cannot see orders placed by the strategy running on the other instrument.

                    See this help guide page for more information: https://ninjatrader.com/support/help...t_quantity.htm
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      Let's say you have a strategy in two instruments. One is running on the NQ instrument and the other is running on the ES instrument.::
                      I do not understand that if PositionAccount.MarketPosition adds the positions of an account and I have the same strategy in two instruments in the same account, it does not add all the positions
                      If I work in a funding account that allows me a maximum of 3 contracts, we need to obtain all the positions and pending orders so as not to break the account in case of a signal in one instrument when another has 3 open positions
                      even in a real account if I want an account to only have a maximum of 3 positions and working on several instruments would not be worth it either

                      Comment


                        #12
                        something else: EnterLongStopLimit(Convert.ToInt32(BuyContracts), EntryPrice + 2 * TickSize, EntryPrice, @"LONGS"); would this be well posed?
                        I have not been able to see it in the market, but I understood that if it is a stop limit and slippage occurs, the order in this case cannot be executed above two ticks from the entry price, is that correct? And if so, would the order be discarded?​

                        Comment


                          #13
                          Hello franatas,

                          Thanks for your notes.

                          PositionAccount.MarketPosition will check what market position you are in for the instrument/account combination the strategy is running on.

                          After further research, I have found that you could loop through <Account>.Positions to accomplish this. You could create class-level double variables named something like 'esQty', 'nqQty', and 'totalQty'. Then loop through <Account>.Positions and in the loop check if position.Instrument.FullName is equal to the instrument (such as "NQ 06-22") and assign position.Quantity to the variable nqQty variable.

                          Then, you could add together the variables holding quantities and assign that to the totalQty variable.

                          For example:
                          Code:
                          //class-level variables
                          private Account myAccount;
                          private double esQty;
                          private double nqQty;
                          private double totalQty;​
                          
                          //OnStateChange()
                          // Find our Sim101 account
                          lock (Account.All)
                              myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");​
                          
                          //OnBarUpdate()
                          foreach (Position position in myAccount.Positions)
                          {
                              Print(String.Format("Position: {0} at {1} and the instrument is {2}", position.MarketPosition, position.Quantity, position.Instrument));
                          
                              if (position.Instrument.FullName == "NQ 06-23")
                                  nqQty = position.Quantity;
                          
                              if (position.Instrument.FullName == "ES 06-23")
                                  esQty = position.Quantity;
                          }
                          
                          totalQty = nqQty + esQty;
                          Print("totalQty " + totalQty);
                          See the help guide pages below for more information.

                          Account: https://ninjatrader.com/support/help...ount_class.htm
                          <Account>.Positions: https://ninjatrader.com/support/help...tsub=myAccount. Positions​
                          Brandon H.NinjaTrader Customer Service

                          Comment


                            #14
                            great, just a small detail, it would be possible to obtain the name of the account dosde the strategy is being executed automatically, that would avoid me having a code for each account name, if this is possible it would be great, and if not with This would fix me, thank you very much BrandonH your performance is wonderful

                            Comment


                              #15
                              Of course I also see that I should change the code every time the contract changes, in this case it's simple but I also use the code that changes every month and the gc that changes every two

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by inanazsocial, Today, 01:15 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post inanazsocial  
                              Started by trilliantrader, 04-18-2024, 08:16 AM
                              5 responses
                              22 views
                              0 likes
                              Last Post trilliantrader  
                              Started by Davidtowleii, Today, 12:15 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Davidtowleii  
                              Started by guillembm, Yesterday, 11:25 AM
                              2 responses
                              9 views
                              0 likes
                              Last Post guillembm  
                              Started by junkone, 04-21-2024, 07:17 AM
                              9 responses
                              71 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X