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

How to make purchases and sales at the close of the bar and update the stop in ticks

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

    #61
    Hello jmarcano,

    This is Jim responding on behalf of Chelsea who is out of the office at this time.

    Your print "Print(Time[0] + " Condition true");" will be seen when the order submission method is reached. This can confirm that the strategy has reached this part of the code.

    You may test the strategy in the Playback Connection to attempt to reproduce an occurrence that happened when the strategy was processing realtime data.

    If you test in Playback and see that the order method was reached but the order did not submit, set TraceOrders to true and then repeat your test to see the TraceOrders feedback for why the order would have been ignored. TraceOrders is set in State.SetDefaults in OnStateChange and the strategy will need to be removed and re-added to take in changes made in State.SetDefaults.

    The TraceOrders feedback will tell you why the order got ignored.

    Please also consider testing with Order Fill Resolution set to High with a single tick data series. With historical processing, it is possible where an Exit and a Set method fill on the same bar which would put you in a reverse position. Further entries would be ignored because we would already have exceeded the allowed number of EntriesPerDirection. Using High Order Fill resolution will have orders filled with intrabar granularity and can reduce the chances of 2 orders getting filled on the same bar.

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #62
      Good afternoon Jim, a greeting, yesterday in the last thing I spoke with ChelseaB, he told me to send him the code and an exit from the printing since the purchase action has not yet been executed as far as we have come.

      in post # 60 I sent him the code and the output.

      Thanks you

      Comment


        #63
        Good afternoon Jim validating the printing output today at 9:40 the purchase should have been executed but it indicates that the volume is zero, he should not take is the value of the candle that closes?



        10/14/2020 9:40:00 AM Strategy 'BreakOutV01/203089315': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False

        10/14/2020 9:40:00 AM Times[0][0].TimeOfDay: 09:40:00 => Apertura.TimeOfDay: 09:35:00

        10/14/2020 9:40:00 AM Times[0][0].TimeOfDay: 09:40:00 < Cierre.TimeOfDay: 11:30:00

        10/14/2020 9:40:00 AM Position.MarketPosition: Flat == MarketPosition.Flat: Flat

        10/14/2020 9:40:00 AM VolumeUpDown1.UpVolume[0]: 0 > 1300

        10/14/2020 9:40:00 AM Close[1]: 12133.25 < Swing1.SwingHigh[1]: 12128 && Close[0]: 12131.75 > Swing1.SwingHigh[0]: 12128

        10/14/2020 9:40:00 AM Close[0]: 12131.75 > EMA1[0]: 12114.1766088843

        10/14/2020 9:40:00 AM Operaciones: 0 < TradeDay: 1

        10/14/2020 9:40:00 AM Long: True == true: True

        Comment


          #64
          Hello jmarcano,

          Thank you for your reply.

          Chelsea is currently out of the office, but I'm not seeing from your prints above that you've turned on the TraceOrders function as Jim recommended - can you confirm, have you enabled TraceOrders and are not seeing the order being submitted?

          Thanks in advance; I look forward to assisting you further.
          Kate W.NinjaTrader Customer Service

          Comment


            #65

            Hello Kate, good afternoon, if I fear it active here where Chelsea indicated me but I don't know if it would be fine there, could you help me to see if it is okay

            IsInstantiatedOnEachOptimizationIteration = true;
            Apertura = DateTime.Parse("09:35", System.Globalization.CultureInfo.InvariantCulture) ;
            Cierre = DateTime.Parse("11:30", System.Globalization.CultureInfo.InvariantCulture) ;
            CierreSeguro = DateTime.Parse("11:59", System.Globalization.CultureInfo.InvariantCulture) ;
            Profit = 95;
            Stop = 46;
            BE = 42;
            TradeDay = 1;
            Long = false;
            Short = false;
            Operaciones = 0;
            }
            else if (State == State.Configure)
            {

            TraceOrders = true;

            /* There are several ways you can use SetStopLoss and SetProfitTarget. You can have them set to a currency value
            or some sort of calculation mode. Calculation modes available are by percent, price, and ticks. SetStopLoss and
            SetProfitTarget will submit real working orders unless you decide to simulate the orders. */
            SetStopLoss(CalculationMode.Ticks, Stop);
            SetProfitTarget(CalculationMode.Ticks, Profit);
            }
            else if (State == State.DataLoaded)
            {
            VolumeUpDown1 = VolumeUpDown(Close);
            Swing1 = Swing(Close, 6);
            EMA1 = EMA(Close, 20);
            VolumeUpDown1.Plots[0].Brush = Brushes.Green;
            VolumeUpDown1.Plots[1].Brush = Brushes.Crimson;
            Swing1.Plots[0].Brush = Brushes.Crimson;
            Swing1.Plots[1].Brush = Brushes.Lime;
            EMA1.Plots[0].Brush = Brushes.Blue;
            AddChartIndicator(VolumeUpDown1);
            AddChartIndicator(Swing1);
            AddChartIndicator(EMA1);
            TraceOrders = true;
            }
            }

            protected override void OnBarUpdate()
            {

            if (CurrentBar < 1) return;

            // Reset stop

            if ((Position.MarketPosition == MarketPosition.Flat))
            {
            SetStopLoss(CalculationMode.Ticks, Stop);
            }

            // // Long Condition

            if (IsFirstTickOfBar)
            {
            Print("\r\n" + Time[0].ToString() + " Times[0][0].TimeOfDay: " + Times[0][0].TimeOfDay.ToString() + " => Apertura.TimeOfDay: " + Apertura.TimeOfDay.ToString());
            Print("\r\n" + Time[0].ToString() + " Times[0][0].TimeOfDay: " + Times[0][0].TimeOfDay.ToString() + " < Cierre.TimeOfDay: " + Cierre.TimeOfDay.ToString());
            Print("\r\n" + Time[0].ToString() + " Position.MarketPosition: " + Position.MarketPosition.ToString() + " == MarketPosition.Flat: " + MarketPosition.Flat.ToString());
            Print("\r\n" + Time[0].ToString() + " VolumeUpDown1.UpVolume[1]: " + VolumeUpDown1.UpVolume[0].ToString() + " > 1300");
            Print("\r\n" + Time[0].ToString() + " Close[1]: " + Close[1].ToString() + " < Swing1.SwingHigh[1]: " + Swing1.SwingHigh[1].ToString() + " && " + " Close[0]: " + Close[0].ToString() + " > Swing1.SwingHigh[0]: " + Swing1.SwingHigh[0].ToString());
            Print("\r\n" + Time[0].ToString() + " Close[0]: " + Close[0].ToString() + " > EMA1[0]: " + EMA1[0].ToString());
            Print("\r\n" + Time[0].ToString() + " Operaciones: " + Operaciones.ToString() + " < TradeDay: " + TradeDay.ToString());
            Print("\r\n" + Time[0].ToString() + " Long: " + Long.ToString() + " == true: " + true.ToString());
            }

            if (IsFirstTickOfBar
            && (Times[0][0].TimeOfDay >= Apertura.TimeOfDay)
            && (Times[0][0].TimeOfDay < Cierre.TimeOfDay)
            && (Position.MarketPosition == MarketPosition.Flat)
            && (VolumeUpDown1.UpVolume[0] > 1300)
            && (CrossAbove(Close, Swing1.SwingHigh, 1))
            && (Close[0] > EMA1[0])
            && (Operaciones < TradeDay)
            && (Long == true))

            // Action Long

            {
            EnterLong(Convert.ToInt32(DefaultQuantity), "@Buy");
            Operaciones = Operaciones + 1;
            Print(Time[0] + " Condition true");

            }


            // else
            // {
            // Print(Time[0].ToString() + " not first tick of bar");
            // }

            // BE Long Condition

            else if ((Position.MarketPosition == MarketPosition.Long)
            && (Close[0] >= Position.AveragePrice))
            {

            // BE Long Action

            if (Close[0] >= Position.AveragePrice + BE * TickSize)
            {
            SetStopLoss(CalculationMode.Price, Position.AveragePrice + (6 * TickSize));
            Print(Time[0].ToString() + " not first tick of bar Long");
            }
            }

            Thanks you

            Comment


              #66
              Hello jmarcano,

              Thank you for your reply.

              TraceOrders should generally be set in State == State.SetDefaults, not in State.Configure. Do you see prints confirming the order was submitted if you set it within State.SetDefaults instead?

              Thanks in advance; I look forward to assisting you further.
              Kate W.NinjaTrader Customer Service

              Comment


                #67

                Hello, thanks for your support, I already set it in (State == State.SetDefaults) as true, in real time it tells me the following


                10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False

                10/14/2020 9:38:00 AM Times[0][0].TimeOfDay: 09:38:00 => Apertura.TimeOfDay: 09:35:00

                10/14/2020 9:38:00 AM Times[0][0].TimeOfDay: 09:38:00 < Cierre.TimeOfDay: 11:30:00

                10/14/2020 9:38:00 AM Position.MarketPosition: Flat == MarketPosition.Flat: Flat

                10/14/2020 9:38:00 AM VolumeUpDown1.UpVolume[1]: 5877 > 1300

                10/14/2020 9:38:00 AM Close[1]: 12099.75 < Swing1.SwingHigh[1]: 12128 && Close[0]: 12133.25 > Swing1.SwingHigh[0]: 12128

                10/14/2020 9:38:00 AM Close[0]: 12133.25 > EMA1[0]: 12112.3267782406

                10/14/2020 9:38:00 AM Operaciones: 0 < TradeDay: 1

                10/14/2020 9:38:00 AM Long: True == true: True
                10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SubmitOrderManaged() method at 10/14/2020 9:38:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='@Buy' FromEntrySignal=''
                10/14/2020 9:38:00 AM Condition true



                when I try to execute it in play back, the purchase is not executed at that moment.

                Thanks.

                Comment


                  #68

                  Kate, This is the output that shows me in playback


                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:00 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                  10/14/2020 9:38:01 AM Strategy 'BreakOutV01/203089318': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False

                  10/14/2020 9:40:00 AM Times[0][0].TimeOfDay: 09:40:00 => Apertura.TimeOfDay: 09:35:00

                  10/14/2020 9:40:00 AM Times[0][0].TimeOfDay: 09:40:00 < Cierre.TimeOfDay: 11:30:00

                  10/14/2020 9:40:00 AM Position.MarketPosition: Flat == MarketPosition.Flat: Flat

                  10/14/2020 9:40:00 AM VolumeUpDown1.UpVolume[1]: 1 > 1300

                  10/14/2020 9:40:00 AM Close[1]: 12133.25 < Swing1.SwingHigh[1]: 12128 && Close[0]: 12133 > Swing1.SwingHigh[0]: 12128

                  10/14/2020 9:40:00 AM Close[0]: 12133 > EMA1[0]: 12114.2956565034

                  10/14/2020 9:40:00 AM Operaciones: 0 < TradeDay: 1

                  10/14/2020 9:40:00 AM Long: True == true: True


                  Thanks very Much for you support

                  Comment


                    #69
                    Hello jmarcano,

                    Thank you for your reply.

                    To confirm, you're not seeing prints after the "10/14/2020 9:40:00 AM Long: True == true: True" print? Or are there further prints?

                    Are any error messages visible in the Log tab of the Control Center?

                    Thanks in advance; I look forward to assisting you further.
                    Kate W.NinjaTrader Customer Service

                    Comment


                      #70

                      Hello Kate, if there are more instructions after that time, I only sent you the moment where the action should be executed and it is not carried out.


                      And don't see any errors in the control center, it just doesn't execute the inputs. A query and excuse my ignorance, the strategy should not perform the validation is with the candle that is closing and not with the one that is opening because if so, the parameters will never be executed

                      Comment


                        #71


                        Reviewing today this is another entry that marks the entry but in real time the entry is not executed, but the impression tells me that if the parameters were given and a supposed entry that I did not see


                        10/16/2020 10:00:00 AM Long: True == true: True
                        10/16/2020 10:02:00 AM Strategy 'BreakOutV01/203089326': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False

                        10/16/2020 10:02:00 AM Times[0][0].TimeOfDay: 10:02:00 => Apertura.TimeOfDay: 09:35:00

                        10/16/2020 10:02:00 AM Times[0][0].TimeOfDay: 10:02:00 < Cierre.TimeOfDay: 11:30:00

                        10/16/2020 10:02:00 AM Position.MarketPosition: Flat == MarketPosition.Flat: Flat

                        10/16/2020 10:02:00 AM VolumeUpDown1.UpVolume[1]: 3625 > 1300

                        10/16/2020 10:02:00 AM Close[1]: 11962 < Swing1.SwingHigh[1]: 11969.5 && Close[0]: 11970.75 > Swing1.SwingHigh[0]: 11969.5

                        10/16/2020 10:02:00 AM Close[0]: 11970.75 > EMA1[0]: 11955.0372368852

                        10/16/2020 10:02:00 AM Operaciones: 0 < TradeDay: 1

                        10/16/2020 10:02:00 AM Long: True == true: True
                        10/16/2020 10:02:00 AM Strategy 'BreakOutV01/203089326': Entered internal SubmitOrderManaged() method at 10/16/2020 10:02:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='@Buy' FromEntrySignal=''
                        10/16/2020 10:02:00 AM Condition true

                        10/16/2020 10:04:00 AM Times[0][0].TimeOfDay: 10:04:00 => Apertura.TimeOfDay: 09:35:00

                        10/16/2020 10:04:00 AM Times[0][0].TimeOfDay: 10:04:00 < Cierre.TimeOfDay: 11:30:00

                        10/16/2020 10:04:00 AM Position.MarketPosition: Long == MarketPosition.Flat: Flat

                        10/16/2020 10:04:00 AM VolumeUpDown1.UpVolume[1]: 4627 > 1300

                        10/16/2020 10:04:00 AM Close[1]: 11970.75 < Swing1.SwingHigh[1]: 11969.5 && Close[0]: 11992 > Swing1.SwingHigh[0]: 11969.5

                        10/16/2020 10:04:00 AM Close[0]: 11992 > EMA1[0]: 11958.557500039

                        10/16/2020 10:04:00 AM Operaciones: 1 < TradeDay: 1

                        10/16/2020 10:04:00 AM Long: True == true: True
                        10/16/2020 10:04:00 AM Strategy 'BreakOutV01/203089326': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Price Value=11972.5 IsSimulatedStop=False IsMarketIfTouched=False
                        10/16/2020 10:04:00 AM Strategy 'BreakOutV01/203089326': Amended stop order orderId='NT-00010-36' account='Sim101' name='Stop loss' orderState=Working instrument='NQ 12-20' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=11959.5 quantity=1 tif=Day oco='NT-00006-36' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-10-16 10:02:00' gtd='2099-12-01' statementDate='2020-10-16'
                        10/16/2020 10:04:00 AM not first tick of bar Long
                        10/16/2020 10:04:00 AM Strategy 'BreakOutV01/203089326: Cancelled pending exit order, since associated position is closed, orderId='NT-00010-36' account='Sim101' name='Stop loss' orderState=Working instrument='NQ 12-20' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=11972.5 quantity=1 tif=Day oco='NT-00006-36' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-10-16 10:02:00' gtd='2099-12-01' statementDate='2020-10-16'
                        10/16/2020 10:04:00 AM Strategy 'BreakOutV01/203089326': Cancelled OCO paired order: BarsInProgress=0, orderId='NT-00010-36' account='Sim101' name='Stop loss' orderState=Cancelled instrument='NQ 12-20' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=11972.5 quantity=1 tif=Day oco='NT-00006-36' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-10-16 10:02:00' gtd='2099-12-01' statementDate='2020-10-16'
                        10/16/2020 10:06:00 AM Strategy 'BreakOutV01/203089326': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False

                        10/16/2020 10:06:00 AM Times[0][0].TimeOfDay: 10:06:00 => Apertura.TimeOfDay: 09:35:00

                        10/16/2020 10:06:00 AM Times[0][0].TimeOfDay: 10:06:00 < Cierre.TimeOfDay: 11:30:00

                        10/16/2020 10:06:00 AM Position.MarketPosition: Flat == MarketPosition.Flat: Flat

                        10/16/2020 10:06:00 AM VolumeUpDown1.UpVolume[1]: 0 > 1300

                        10/16/2020 10:06:00 AM Close[1]: 11992 < Swing1.SwingHigh[1]: 11969.5 && Close[0]: 11991.25 > Swing1.SwingHigh[0]: 11969.5

                        10/16/2020 10:06:00 AM Close[0]: 11991.25 > EMA1[0]: 11961.6710714638

                        10/16/2020 10:06:00 AM Operaciones: 1 < TradeDay: 1

                        10/16/2020 10:06:00 AM Long: True == true: True
                        10/16/2020 10:08:00 AM Strategy 'BreakOutV01/203089326': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False
                        Attached Files

                        Comment


                          #72
                          Hello ChelseaB, good morning please I need help, with this topic.

                          Thanks

                          Comment


                            #73
                            Hello jmarcano,

                            Thank you for your reply.

                            I've modified your prints slightly so each line prints whether those values would make each condition true. Please replace your current Prints with the following and test - if any of these has False at the end, we would not expect the order would be taken on that particular bar.

                            Code:
                             if (IsFirstTickOfBar)
                            {
                            Print("\r\n" + Time[0].ToString() + " Times[0][0].TimeOfDay: " + Times[0][0].TimeOfDay.ToString() + " => Apertura.TimeOfDay: " + Apertura.TimeOfDay.ToString() + ": " + (Times[0][0].TimeOfDay >= Apertura.TimeOfDay));
                            Print("\r\n" + Time[0].ToString() + " Times[0][0].TimeOfDay: " + Times[0][0].TimeOfDay.ToString() + " < Cierre.TimeOfDay: " + Cierre.TimeOfDay.ToString() + ": " + (Times[0][0].TimeOfDay < Cierre.TimeOfDay));
                            Print("\r\n" + Time[0].ToString() + " Position.MarketPosition: " + Position.MarketPosition.ToString() + " == MarketPosition.Flat: " + MarketPosition.Flat.ToString() + ": " + (Position.MarketPosition == MarketPosition.Flat));
                            Print("\r\n" + Time[0].ToString() + " VolumeUpDown1.UpVolume[0]: " + VolumeUpDown1.UpVolume[0].ToString() + " > 1300: " + (VolumeUpDown1.UpVolume[0] > 1300) );
                            Print("\r\n" + Time[0].ToString() + " Close[1]: " + Close[1].ToString() + " < Swing1.SwingHigh[1]: " + Swing1.SwingHigh[1].ToString() + " && " + " Close[0]: " + Close[0].ToString() + " > Swing1.SwingHigh[0]: " + Swing1.SwingHigh[0].ToString() + ": " + (CrossAbove(Close, Swing1.SwingHigh, 1)));
                            Print("\r\n" + Time[0].ToString() + " Close[0]: " + Close[0].ToString() + " > EMA1[0]: " + EMA1[0].ToString() + ": " + (Close[0] > EMA1[0]));
                            Print("\r\n" + Time[0].ToString() + " Operaciones: " + Operaciones.ToString() + " < TradeDay: " + TradeDay.ToString() + ": " + (Operaciones < TradeDay));
                            Print("\r\n" + Time[0].ToString() + " Long: " + Long.ToString() + " == true: " + (Long == true));
                            }
                            Do you see any instances of running this where all the above print lines in the output lines have True at the end, but an order is not being taken?

                            Thanks in advance; I look forward to assisting you further.
                            Kate W.NinjaTrader Customer Service

                            Comment


                              #74
                              Hello, I send you the output printout, it tells me that it is false

                              10/19/2020 12:38:00 PM Close [1]: 11784.5 <Swing1.SwingHigh [1]: 11807.75 && Close [0]: 11787.5> Swing1.SwingHigh [0]: 11807.75: False

                              However, in the graph it marks an entry for me.



                              10/19/2020 12:36:00 PM Strategy '/203086409': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False

                              10/19/2020 12:36:00 PM Times[0][0].TimeOfDay: 12:36:00 => Apertura.TimeOfDay: 09:40:00: True

                              10/19/2020 12:36:00 PM Times[0][0].TimeOfDay: 12:36:00 < Cierre.TimeOfDay: 15:30:00: True

                              10/19/2020 12:36:00 PM Position.MarketPosition: Flat == MarketPosition.Flat: Flat: True

                              10/19/2020 12:36:00 PM VolumeUpDown1.UpVolume[0]: 0 > 1300: False

                              10/19/2020 12:36:00 PM Close[1]: 11785 < Swing1.SwingHigh[1]: 11807.75 && Close[0]: 11784.5 > Swing1.SwingHigh[0]: 11807.75: False

                              10/19/2020 12:36:00 PM Close[0]: 11784.5 > EMA1[0]: 11777.1939277888: True

                              10/19/2020 12:36:00 PM Operaciones: 3 < TradeDay: 10: True

                              10/19/2020 12:36:00 PM Long: True == true: True

                              10/19/2020 12:36:00 PM Times[0][0].TimeOfDay: 12:36:00 => Apertura.TimeOfDay: 09:40:00: True

                              10/19/2020 12:36:00 PM Times[0][0].TimeOfDay: 12:36:00 < Cierre.TimeOfDay: 15:30:00: True

                              10/19/2020 12:36:00 PM Position.MarketPosition: Flat == MarketPosition.Flat: Flat: True

                              10/19/2020 12:36:00 PM VolumeUpDown1.DownVolume[0]: 1555 > 1300: True

                              10/19/2020 12:36:00 PM Close[1]: 11785 > Swing1.SwingHigh[1]: 11807.75 && Close[0]: 11784.5 < Swing1.SwingHigh[0]: 11807.75: False

                              10/19/2020 12:36:00 PM Close[0]: 11784.5 < EMA1[0]: 11777.1939277888: False

                              10/19/2020 12:36:00 PM Operaciones: 3 < TradeDay: 10: True

                              10/19/2020 12:36:00 PM Long: True == true: True
                              10/19/2020 12:38:00 PM Strategy '/203086409': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=46 IsSimulatedStop=False IsMarketIfTouched=False

                              10/19/2020 12:38:00 PM Times[0][0].TimeOfDay: 12:38:00 => Apertura.TimeOfDay: 09:40:00: True

                              10/19/2020 12:38:00 PM Times[0][0].TimeOfDay: 12:38:00 < Cierre.TimeOfDay: 15:30:00: True

                              10/19/2020 12:38:00 PM Position.MarketPosition: Flat == MarketPosition.Flat: Flat: True

                              10/19/2020 12:38:00 PM VolumeUpDown1.UpVolume[0]: 2046 > 1300: True

                              10/19/2020 12:38:00 PM Close[1]: 11784.5 < Swing1.SwingHigh[1]: 11807.75 && Close[0]: 11787.5 > Swing1.SwingHigh[0]: 11807.75: False

                              10/19/2020 12:38:00 PM Close[0]: 11787.5 > EMA1[0]: 11778.1754584755: True

                              10/19/2020 12:38:00 PM Operaciones: 3 < TradeDay: 10: True

                              10/19/2020 12:38:00 PM Long: True == true: True

                              10/19/2020 12:38:00 PM Times[0][0].TimeOfDay: 12:38:00 => Apertura.TimeOfDay: 09:40:00: True

                              10/19/2020 12:38:00 PM Times[0][0].TimeOfDay: 12:38:00 < Cierre.TimeOfDay: 15:30:00: True

                              10/19/2020 12:38:00 PM Position.MarketPosition: Flat == MarketPosition.Flat: Flat: True

                              10/19/2020 12:38:00 PM VolumeUpDown1.DownVolume[0]: 0 > 1300: False

                              10/19/2020 12:38:00 PM Close[1]: 11784.5 > Swing1.SwingHigh[1]: 11807.75 && Close[0]: 11787.5 < Swing1.SwingHigh[0]: 11807.75: False

                              10/19/2020 12:38:00 PM Close[0]: 11787.5 < EMA1[0]: 11778.1754584755: False

                              10/19/2020 12:38:00 PM Operaciones: 3 < TradeDay: 10: True

                              10/19/2020 12:38:00 PM Long: True == true: True



                              thanks very much for you support
                              Attached Files

                              Comment


                                #75
                                hello Kate, I send you my execution logic


                                if (IsFirstTickOfBar)
                                {
                                Print("\r\n" + Time[0].ToString() + " Times[0][0].TimeOfDay: " + Times[0][0].TimeOfDay.ToString() + " => Apertura.TimeOfDay: " + Apertura.TimeOfDay.ToString() + ": " + (Times[0][0].TimeOfDay >= Apertura.TimeOfDay));
                                Print("\r\n" + Time[0].ToString() + " Times[0][0].TimeOfDay: " + Times[0][0].TimeOfDay.ToString() + " < Cierre.TimeOfDay: " + Cierre.TimeOfDay.ToString() + ": " + (Times[0][0].TimeOfDay < Cierre.TimeOfDay));
                                Print("\r\n" + Time[0].ToString() + " Position.MarketPosition: " + Position.MarketPosition.ToString() + " == MarketPosition.Flat: " + MarketPosition.Flat.ToString() + ": " + (Position.MarketPosition == MarketPosition.Flat));
                                Print("\r\n" + Time[0].ToString() + " VolumeUpDown1.UpVolume[0]: " + VolumeUpDown1.UpVolume[0].ToString() + " > 1300: " + (VolumeUpDown1.UpVolume[0] > 1300) );
                                Print("\r\n" + Time[0].ToString() + " Close[1]: " + Close[1].ToString() + " < Swing1.SwingHigh[1]: " + Swing1.SwingHigh[1].ToString() + " && " + " Close[0]: " + Close[0].ToString() + " > Swing1.SwingHigh[0]: " + Swing1.SwingHigh[0].ToString() + ": " + (CrossAbove(Close, Swing1.SwingHigh, 1)));
                                Print("\r\n" + Time[0].ToString() + " Close[0]: " + Close[0].ToString() + " > EMA1[0]: " + EMA1[0].ToString() + ": " + (Close[0] > EMA1[0]));
                                Print("\r\n" + Time[0].ToString() + " Operaciones: " + Operaciones.ToString() + " < TradeDay: " + TradeDay.ToString() + ": " + (Operaciones < TradeDay));
                                Print("\r\n" + Time[0].ToString() + " Long: " + Long.ToString() + " == true: " + (Long == true));
                                }

                                if (IsFirstTickOfBar
                                && (Times[0][0].TimeOfDay >= Apertura.TimeOfDay)
                                && (Times[0][0].TimeOfDay < Cierre.TimeOfDay)
                                && (Position.MarketPosition == MarketPosition.Flat)
                                && (VolumeUpDown1.UpVolume[0] > 1300)
                                && (CrossAbove(Close, Swing1.SwingHigh, 1))
                                && (Close[0] > EMA1[0])
                                && (Operaciones < TradeDay)
                                && (Long == true))

                                // Action Long

                                {
                                EnterLong(Convert.ToInt32(DefaultQuantity), "@Buy");
                                Operaciones = Operaciones + 1;
                                Print(Time[0] + " Condition true");

                                }


                                // BE Long Condition

                                else if ((Position.MarketPosition == MarketPosition.Long)
                                && (Close[0] >= Position.AveragePrice))
                                {

                                // BE Long Action

                                if (Close[0] >= Position.AveragePrice + BE * TickSize)
                                {
                                SetStopLoss(CalculationMode.Price, Position.AveragePrice + (6 * TickSize));
                                Print(Time[0].ToString() + " not first tick of bar Long");
                                }
                                }

                                // // Short Condition


                                if (IsFirstTickOfBar)
                                {
                                Print("\r\n" + Time[0].ToString() + " Times[0][0].TimeOfDay: " + Times[0][0].TimeOfDay.ToString() + " => Apertura.TimeOfDay: " + Apertura.TimeOfDay.ToString() + ": " + (Times[0][0].TimeOfDay >= Apertura.TimeOfDay));
                                Print("\r\n" + Time[0].ToString() + " Times[0][0].TimeOfDay: " + Times[0][0].TimeOfDay.ToString() + " < Cierre.TimeOfDay: " + Cierre.TimeOfDay.ToString() + ": " + (Times[0][0].TimeOfDay < Cierre.TimeOfDay));
                                Print("\r\n" + Time[0].ToString() + " Position.MarketPosition: " + Position.MarketPosition.ToString() + " == MarketPosition.Flat: " + MarketPosition.Flat.ToString() + ": " + (Position.MarketPosition == MarketPosition.Flat));
                                Print("\r\n" + Time[0].ToString() + " VolumeUpDown1.DownVolume[0]: " + VolumeUpDown1.DownVolume[0].ToString() + " > 1300: " + (VolumeUpDown1.DownVolume[0] > 1300) );
                                Print("\r\n" + Time[0].ToString() + " Close[1]: " + Close[1].ToString() + " > Swing1.SwingHigh[1]: " + Swing1.SwingHigh[1].ToString() + " && " + " Close[0]: " + Close[0].ToString() + " < Swing1.SwingHigh[0]: " + Swing1.SwingHigh[0].ToString() + ": " + (CrossAbove(Close, Swing1.SwingHigh, 1)));
                                Print("\r\n" + Time[0].ToString() + " Close[0]: " + Close[0].ToString() + " < EMA1[0]: " + EMA1[0].ToString() + ": " + (Close[0] < EMA1[0]));
                                Print("\r\n" + Time[0].ToString() + " Operaciones: " + Operaciones.ToString() + " < TradeDay: " + TradeDay.ToString() + ": " + (Operaciones < TradeDay));
                                Print("\r\n" + Time[0].ToString() + " Long: " + Long.ToString() + " == true: " + (Long == true));
                                }


                                if (IsFirstTickOfBar
                                && (Times[0][0].TimeOfDay >= Apertura.TimeOfDay)
                                && (Times[0][0].TimeOfDay < Cierre.TimeOfDay)
                                && (Position.MarketPosition == MarketPosition.Flat)
                                && (VolumeUpDown1.DownVolume[0] > 1300)
                                && (CrossBelow(Close, Swing1.SwingLow, 1))
                                && (Close[0] < EMA1[0])
                                && (Operaciones < TradeDay)
                                && (Short == true))


                                // Action Short


                                {
                                EnterShort(Convert.ToInt32(DefaultQuantity), "@Sell");
                                Operaciones = Operaciones + 1;
                                Print(Time[0] + " Condition true");

                                }


                                // // // BE Short Condition

                                else if ((Position.MarketPosition == MarketPosition.Short)
                                && (Close[0] <= Position.AveragePrice))
                                {

                                // BE Short Action

                                if (Close[0] <= Position.AveragePrice + (-BE * TickSize))
                                {
                                SetStopLoss(CalculationMode.Price, Position.AveragePrice + (-6 * TickSize ));
                                Print(Time[0].ToString() + " not first tick of bar short");
                                }
                                }

                                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
                                70 views
                                0 likes
                                Last Post jeronymite  
                                Working...
                                X