Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help me with a order

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

    #31
    Hello firecan,

    If you're looking to define user input parameters, this post can help:
    Creating User Defined Input Parameters


    We realize that lost connections can be frustrating. A connection state between NinjaTrader and your broker/market data vendor is not dictated by NinjaTrader. The NinjaTrader application only reports the connection state as it is reported by the API you are connected through. NinjaTrader behaves like a radio receiver in that it receives signals from the connected server. If the signals are not coming through, the underlying broker/market data vendor API reports this to the NinjaTrader application which in turn reports this back to you. Once a loss of connection is reported, NinjaTrader or the underlying API wil continuously try to re-establish a connection.
    Common reasons that contribute to connection stability are:
    • ISP issues
    • Hardware firewall changing IP addresses frequently
    • Dynamic IP addresses changing frequently intraday. Usually this happens once a week buy you may want to check with your ISP. If they do change daily, requesting a static IP address may help.
    • With Windows XP SP2, if you have more than 10 open TCPIP socket connections (10 programs making socket connections through the internet) Windows will randomly shut down some connections
    • Broker/market data servers may be experiencing temporary downtime
    Ryan M.NinjaTrader Customer Service

    Comment


      #32
      Thanks again.

      Once I implemented the strategy, in chart appears the situation of the price entry and stop loss and profit.

      Try changing your position and in a few seconds return to initial place.

      It is possible with any order to let me move and stay in the new place.

      Regards.

      Comment


        #33
        Hello firecan,

        This is possible when you connect your NinjaScript stratey to an ATM strategy. Control of these orders is passed on to the ATM strategy and you can manually adjust orders here.

        You can view a sample through Tools > Edit NinjaScript > Strategy > SampleAtmStrategy.

        Ryan M.NinjaTrader Customer Service

        Comment


          #34
          Thanks again I´ll try it.

          Now I Find a problem with these orders:

          Order 1)

          if (Close[0] >= Position.AvgPrice + 8 * TickSize)
          { SetStopLoss(CalculationMode.Price,Position.AvgPric e + 1 * TickSize);}

          Order 2)

          if (Close[0] >= Position.AvgPrice + 14 * TickSize)
          { SetStopLoss(CalculationMode.Price,Position.AvgPric e + 7 * TickSize);}

          While the condition are true the price is going to the new place.

          But if the price down the condition is false and the stop loss returns to the starting point.

          What I'm doing wrong, how I can fix it
          Regards.

          Comment


            #35
            What's happening is your first condition continues to evaluate true. What you can do here is use bool variables so that this first movement is only evaluated once.

            VariablesRegion:
            private bool firstMove = true;


            Code:
             
            if (Close[0] >= Position.AvgPrice + 8 * TickSize && firstMove)
            {
             SetStopLoss(CalculationMode.Price,Position.AvgPrice + 1 * TickSize);
            firstMove = false;
            }
             
             
            if (Close[0] >= Position.AvgPrice + 14 * TickSize)
            {
            SetStopLoss(CalculationMode.Price,Position.AvgPrice + 7 * TickSize);
            }
            Reset these variables when you're flat.
            Last edited by NinjaTrader_RyanM1; 10-22-2010, 03:54 PM.
            Ryan M.NinjaTrader Customer Service

            Comment


              #36
              Hello.

              Dont run OK, something I'm doing wrong.

              Maybe dont understand "Reset these variables when you're flat."

              How can I do it.

              Regards.

              Comment


                #37
                Originally posted by firecan View Post
                Hello.

                Dont run OK, something I'm doing wrong.

                Maybe dont understand "Reset these variables when you're flat."

                How can I do it.

                Regards.
                Firecan, what Ryan means is that when your strategy is flat, reset the stop losses to a price of 0.
                Code:
                if (Position.MarketPosition == MarketPosition.Flat)
                {
                   SetStopLoss(CalculationMode.Price, 0);
                }
                AustinNinjaTrader Customer Service

                Comment


                  #38
                  Hello again.

                  This is the code, can you tell me if is it ok.

                  protectedoverridevoid Initialize()

                  {
                  SetStopLoss(CalculationMode.Ticks, stoplossticks);
                  SetProfitTarget(CalculationMode.Ticks, profittargetticks);

                  TraceOrders =
                  true ;
                  CalculateOnBarClose =
                  true;
                  }

                  protectedoverridevoid OnBarUpdate()

                  {
                  // Resetea stop loss y profit al cerrar la posicion.
                  if (Position.MarketPosition == MarketPosition.Flat)
                  { SetStopLoss(CalculationMode.Ticks, stoplossticks); }

                  // Abierta una posicion Larga, modifica el Stop Loss a Breakeven.
                  elseif (Position.MarketPosition == MarketPosition.Long)

                  {
                  /* Cuando el precio es mayor que la entrada en + ? ticks
                  envia el Stop Loss a Breakeven +/- ? */

                  if (Close[0] >= Position.AvgPrice + distbreak1 * TickSize && PriMove)
                  { SetStopLoss(CalculationMode.Price,Position.AvgPric e - enviabreak1 * TickSize); PriMove =
                  false; }

                  if (Close[0] >= Position.AvgPrice + distbreak2 * TickSize)
                  { SetStopLoss(CalculationMode.Price,Position.AvgPric e + enviabreak2 * TickSize); }
                  }

                  // Condicion de Entrada en Largo.
                  if (ToTime(Time[0]) == ToTime(horas,minutos,00))
                  { EnterLongStop(
                  0, true, contratos, Close[0] + distmercado * TickSize, "Largo 1"); }

                  Comment


                    #39
                    firecan,

                    Your code uses PriMove, but you never reset its value anywhere. You will most likely need logic to reset it or else it will only act once and then never again.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #40
                      I have :

                      #region Variables

                      private int contratos = 1;
                      private int profittargetticks = 50;
                      private int stoplossticks = 10;
                      private int distmercado = 7;
                      private int distbreak1 = 0;
                      private int enviabreak1 = 0;
                      private int distbreak2 = 0;
                      private int enviabreak2 = 0;
                      private int horas = 0;
                      private int minutos = 0;
                      private bool PriMove = true;
                      #endregion

                      Comment


                        #41
                        Hello,

                        These are variable declarations when the script is loaded.

                        You need to reset this Inside of as well when it is needed to be reset.

                        OnBarUpdate()
                        {


                        }

                        Let me know if I can be of further assistance.

                        Comment


                          #42
                          Hello again, sorry.

                          I'm confused . Please, could you write me the missing piece of code and tell me where I put it, thanks

                          Regards.

                          Comment


                            #43
                            firecan,

                            You want to reset the stop loss to an initial value when flat. You also want to reset your bool flag.

                            if (Position.MarketPosition == MarketPosition.Flat)
                            {
                            SetStopLoss(CalculationMode.Ticks, 20);
                            PriMove = true;
                            }
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #44
                              Hello.

                              I re-wrote the scrip without variables to make it look more clear about what I do.

                              Could you make it run and tell me where is the error it does not work.

                              I try to place a pending order on the market at a particular time. And run the stop loss 3 times when touch each price set, without wait close a bar.

                              I do not why the stop loss only run when the price is +20 , and forget +3 , +8 an +14 ticks.

                              Regards

                              Comment


                                #45
                                protectedoverridevoid Initialize()

                                {
                                SetStopLoss(CalculationMode.Ticks, stoplossticks);
                                SetProfitTarget(CalculationMode.Ticks, profittargetticks);

                                TraceOrders =
                                true ;
                                CalculateOnBarClose =
                                true;
                                }

                                protectedoverridevoid OnBarUpdate()
                                {
                                // Resetea stop loss y profit al cerrar la posicion.
                                if (Position.MarketPosition == MarketPosition.Flat)
                                { SetStopLoss(CalculationMode.Ticks, stoplossticks); }

                                // Abierta una posicion Larga, modifica el Stop Loss a Breakeven.
                                if (Position.MarketPosition == MarketPosition.Long)


                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by The_Sec, Today, 02:29 PM
                                1 response
                                5 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by jeronymite, 04-12-2024, 04:26 PM
                                2 responses
                                30 views
                                0 likes
                                Last Post NinjaTrader_BrandonH  
                                Started by Mindset, 05-06-2023, 09:03 PM
                                10 responses
                                265 views
                                0 likes
                                Last Post NinjaTrader_BrandonH  
                                Started by michi08, 10-05-2018, 09:31 AM
                                5 responses
                                743 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by tsantospinto, 04-12-2024, 07:04 PM
                                4 responses
                                63 views
                                0 likes
                                Last Post aligator  
                                Working...
                                X