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

    #16
    Hello franatas,

    Thanks for your notes.

    There are no documented/supported methods or properties for getting the account that other NinjaScript strategies are enabled on.

    You could consider creating user-defined properties that allow you to set the accounts in the Properties section of the Strategies window when enabling the script. Then, use those to loop through <Account>.Positions

    See the reference sample on this forum thread demonstrating using a TypeConverter to create user-defined account properties: https://forum.ninjatrader.com/forum/...01#post1175601

    TypeConverterAttribute: https://ninjatrader.com/support/help...=typeconverter

    The contract date would need to be hard-coded in the strategy each time the instrument changes. Or, you could consider creating a user-defined string property that would allow you to set the instrument name/contract date and then used that variable for if (position.Instrument.FullName == "NQ 06-23") in the script.

    For example:
    Code:
    //OnStateChange() State.SetDefaults
    InstrumentOne  = "NQ 06-23";
    
    //OnBarUpdate()
    if (position.Instrument.FullName == InstrumentOne)
    
    
    //Properties
    [NinjaScriptProperty]
    [Display(Name="InstrumentOne", Order=1, GroupName="Parameters")]
    public string InstrumentOne
    { get; set; }


    Creating User Defined Input Properties: https://ninjatrader.com/support/help...g+user+defined
    Brandon H.NinjaTrader Customer Service

    Comment


      #17
      I am going to try this.
      lock (Account.All)
      myAccount = Account.All.FirstOrDefault(a => a.Name == Name);​​
      foreach (Position position in myAccount.Positions)
      {

      if (position.Instrument.FullName.StartsWith("NQ"))
      NQPosiciones = position.Quantity;

      if (position.Instrument.FullName.StartsWith("ES"))
      ESPosiciones = position.Quantity;

      if (position.Instrument.FullName.StartsWith("CL"))
      CLPosiciones = position.Quantity;

      if (position.Instrument.FullName.StartsWith("GC"))
      GCPosiciones = position.Quantity;
      }​
      but I couldn't try it yet, and I don't know if it would work well, maybe you can tell me how you see it

      Comment


        #18
        Hello franatas,

        Thanks for your note.

        Using .StartsWith() is not documented in the help guide so this is something you would need to test on your end to ensure it works as you are expecting it to.

        That said, I do not see anything wrong with the code you shared.

        This forum thread will also be open for other community members to share their insights on this.
        Brandon H.NinjaTrader Customer Service

        Comment


          #19
          Great thing about properties, it did not occur to me but it is also valid to locate the account from properties the account

          unexpected character and token and the truth is that no matter how much I look, I don't know where the error is


          ignore esto comentario, ya esta resuelto
          Attached Files
          Last edited by franatas; 06-08-2023, 10:03 AM.

          Comment


            #20
            [NinjaScriptProperty]
            [Display(Name = "Seleccion de Cuenta", Order = 1, GroupName = "Seleccion de Cuenta")]
            public string NombreCuenta
            { get; set; }​

            this works perfect to identify the account
            y StartsWith also

            so here it is solved:
            thanks, again

            Comment


              #21
              good morning, to finish off the logic of maximum contracts of the funding accounts
              Would it be possible to obtain the sum of the entry orders pending execution?
              Attached Files

              Comment


                #22
                Another thing that I can't understand is that when two assets have pending orders and one of them opens three positions, at the next tick it should cancel the other's pending orders and it doesn't. Is something missing in the cancelorder?

                if (OrdenEntrada != null && CurrentBar == Velaentrada + 1 || SumaPosiciones >= Max_Contratos)
                {
                CancelOrder(OrdenEntrada);
                }​
                resolved. I was missing the true in the order to give the order to cancel myself instead of ninja
                Last edited by franatas; 06-09-2023, 09:45 AM.

                Comment


                  #23
                  buen dia y perdon por la toma de confianza
                  I opened a new thread so as not to spread this but the response was not even half the commitment that you put into it
                  that's why I'm doing it here again

                  these are my entry orders
                  ​EnterLongStopLimit(0, true, ContratosBuy, PrecioEntradaLimite, PrecioEntrada, "LARGOS");
                  EnterLongStopLimit(0, true, ContratosBuy, PrecioEntradaLimite, PrecioEntrada, "LARGOS");

                  and this is the placement of Sl and TP

                  if (OrdenEntrada != null && OrdenEntrada == execution.Order)
                  {
                  if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled
                  || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                  {
                  // Sumamos las cantidades de cada ejecución que componen la orden de entrada
                  sumFilled += execution.Quantity;
                  // Enviar órdenes de salida para rellenos parciales
                  if (execution.Order.OrderState == OrderState.PartFilled)
                  {
                  if (Largos)
                  {
                  OrdenStop = ExitLongStopMarket(0, true, execution.Order.Filled, StopLoss, "STOP", "LARGOS");
                  OrdenProfit = ExitLongLimit(0, true, execution.Order.Filled, Target, "TARGET", "LARGOS");
                  }
                  if (Cortos)
                  {
                  OrdenStop = ExitShortStopMarket(0, true, execution.Order.Filled, StopLoss, "STOP", "CORTOS");
                  OrdenProfit = ExitShortLimit(0, true, execution.Order.Filled, Target, "TARGET", "CORTOS");
                  }

                  }
                  // Actualice las cantidades de nuestras órdenes de salida una vez que el estado de la orden se complete y
                  // hayamos visto que las cantidades de ejecución coinciden con las cantidades de las órdenes
                  else if (execution.Order.OrderState == OrderState.Filled && sumFilled == execution.Order.Filled)
                  {
                  // Orden Stop-Loss para OrderState.Filled
                  if (Largos)
                  {
                  OrdenStop = ExitLongStopMarket(0, true, execution.Order.Filled, StopLoss, "STOP", "LARGOS");
                  OrdenProfit = ExitLongLimit(0, true, execution.Order.Filled, Target, "TARGET", "LARGOS");
                  }
                  if (Cortos)
                  {
                  OrdenStop = ExitShortStopMarket(0, true, execution.Order.Filled, StopLoss, "STOP", "CORTOS");
                  OrdenProfit = ExitShortLimit(0, true, execution.Order.Filled, Target, "TARGET", "CORTOS");
                  }
                  }
                  // Restablece el objeto OrdenEntrada y el contador sumFilled a nulo / 0 después de completar el pedido
                  if (execution.Order.OrderState != OrderState.PartFilled && sumFilled == execution.Order.Filled)
                  {
                  OrdenEntrada = null;
                  sumFilled = 0;
                  Cortos = false;
                  Largos = false;
                  }
                  }
                  }
                  but it gives me these errors:
                  1- It doesn't work for me when you fill out the order, complete the TP
                  2- the string is not correct​
                  ​I already tried everything I could think of. with @ before the string for the error of the string, and changing in a thousand ways the way to calculate the amounts of SL and TP
                  Attached Files

                  Comment


                    #24
                    the first time you enter the partial fill the chain is fine and it ejaculates perfectly, the problem comes the second time you enter either by another partial or full fill of the order
                    This is when it gives a string error and I don't understand how it is correct the first time and then not anymore, the string follows the parameters of:
                    int quantity, double stopPrice, string signalName, string fromEntrySignal​

                    OrdenStop = {orderId='a7a7b46de1c34ddbb14495f9c9ecd5ca' account='Playback101' name='STOP' orderState=Accepted instrument='ES JUN23' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=4245.5 quantity=3 tif=Gtc oco='' filled=0 averageFillPrice=0 onBeha...
                    Attached Files
                    Last edited by franatas; 06-11-2023, 04:06 AM.

                    Comment


                      #25
                      Hello franatas,

                      Thanks for your notes.

                      Since this inquiry is not related to your initial inquiry on this forum thread and you have opened a different forum thread regarding this inquiry and are working with a technician already, please direct the inquiries you have about this topic to that forum thread you have open and the technician working with you will be happy to assist you with this matter further.

                      If you have any further questions about your initial inquiry in this thread, you could direct those questions here. Otherwise, please direct your questions to the other forum thread you have open with the other technician.

                      Brandon H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Christopher_R, Today, 12:29 AM
                      0 responses
                      10 views
                      0 likes
                      Last Post Christopher_R  
                      Started by sidlercom80, 10-28-2023, 08:49 AM
                      166 responses
                      2,235 views
                      0 likes
                      Last Post sidlercom80  
                      Started by thread, Yesterday, 11:58 PM
                      0 responses
                      3 views
                      0 likes
                      Last Post thread
                      by thread
                       
                      Started by jclose, Yesterday, 09:37 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post jclose
                      by jclose
                       
                      Started by WeyldFalcon, 08-07-2020, 06:13 AM
                      10 responses
                      1,415 views
                      0 likes
                      Last Post Traderontheroad  
                      Working...
                      X