Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

stop execution of orders and limited bar [0]

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

    stop execution of orders and limited bar [0]

    Hello I have a system that, after the entry used ExitLongStop, the problem is that this statement sends the order after closing [0] and therefore no longer running in the bar [0] if it were the case, instruction is necessary to get running on the bar [0] thank you very much.
    protected override void OnBarUpdate()
    {
    // definición del stop.





    double xclose = Position.AvgPrice - Position.AvgPrice * (filterR/100) ;
    // CONDICIONES DE ENTRADA
    if (CrossAbove(ZeroLagTEMA(Period).ZeroTEMA,ZeroLagHA TEMA(Period).ZeroHATEMA, 1)
    && RelativeSlope(period)[0]<filterR

    )

    {
    EnterLong(1, "");

    }


    if (Position.MarketPosition == MarketPosition.Long)

    {
    ExitLongStop(xclose);

    }



    }
    Last edited by optimuss; 08-10-2011, 12:34 PM.

    #2
    Hello,

    I'm sorry but I do not fully understand.

    The close price used for the stop order willb e the close price of the bar. Is this not occurring/ Also, you must wait one OnBarUpdate for Position.MarketPosition to update.

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      hello, I want the stop order Can Be Executed in the bar [0], thank you very much.

      Comment


        #4
        Hello,

        Ninjatrader is hard coded to take order action in backtest on the open of the next bar. You would not be able to get NinjaTrader to take order action on the close of the bar. This is specifically designed for realism in actual markets.

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          hello, I want the stop order Can Be Executed in the bar of entry , that instruction is necessary? and where I have to put the system to send you?
          thank you very much.
          Attached Files
          Last edited by optimuss; 08-10-2011, 02:03 PM.

          Comment


            #6
            Hello,

            The stop will always execute on Bar[1] is the entry was on Bar[0][. This is NinjaTrader design.
            BrettNinjaTrader Product Management

            Comment


              #7
              please lend me a little attention, is not as complicated as you desire, just wish I could run my stop in the entry bar, please.

              sent you a visual example of stop executed in the entry bar.

              that's what I want for my system, help me please.
              Attached Files
              Last edited by optimuss; 08-10-2011, 03:41 PM.

              Comment


                #8
                Hello,

                When you run live this is how it will run, the stop will submit as soon as your long or short.

                However when your running backtest or historical theres no way to run the stop intrabar. As actions always take place at the close of the bar since we dont know what happened at what time during the bar formation we only know the close. Which the the open price for the next bar is used.

                The only way oto work around this is to code the stop to run manually (Not using SetStopLoss()). Then using intrabar granularity with the below sample. This starts to get into more complex coding however.

                Backtesting NinjaScript Strategies with an intrabar granularity
                BrettNinjaTrader Product Management

                Comment


                  #9
                  Hi, sorry for not explaining well what I need, I return to explain.

                  just what I want is my stop to run on the same entry bar, I send you some visual examples in the file, you need to do please tell me that I can use instruction, and where I have to settle for the following system I show. thank you very much

                  mims order now can not stop at the bar ejecuatar input, sorry for my English because it is not all good I want, thank you very much.

                  protected override void OnBarUpdate()
                  {
                  // definición del stop.





                  double stoploss = Position.AvgPrice - Position.AvgPrice * (filterR/100) ;
                  // CONDICIONES DE ENTRADA
                  if (CrossAbove(ZeroLagTEMA(Period).ZeroTEMA,ZeroLagHA TEMA(Period).ZeroHATEMA, 1)
                  && RelativeSlope(period)[0]<filterR

                  )

                  {
                  EnterLong(1, "");

                  }


                  if (Position.MarketPosition == MarketPosition.Long)

                  {
                  ExitLongStop(stoploss);

                  }









                  Escuchar
                  Leer fonéticamente
                  Attached Files

                  Comment


                    #10
                    Hello,

                    You would use SetStopLoss() to submit a stop after entry if I understand what your asking correctly.



                    Let me know if I can be of further assistance.
                    BrettNinjaTrader Product Management

                    Comment


                      #11
                      ok, tell me how serious I do not get it right, would you please tell me what I am doing wrong? Thank you.

                      protected override void OnBarUpdate()
                      {
                      // definición del stop.





                      double stoploss = Position.AvgPrice - Position.AvgPrice * (filterR/100) ;
                      // CONDICIONES DE ENTRADA
                      if (CrossAbove(ZeroLagTEMA(Period).ZeroTEMA,ZeroLagHA TEMA(Period).ZeroHATEMA, 1)
                      && RelativeSlope(period)[0]<filterR

                      )

                      {
                      EnterLong(1, "");
                      SetStopLoss (CalculationMode .Price ,stoploss);

                      }


                      if (Position.MarketPosition == MarketPosition.Long)

                      {
                      ExitLongStop(stoploss);

                      }

                      Comment


                        #12
                        You must SetStopLoss() before the EnterLong() call. This way its setup internally before you enter the position. Otherwise it would not set right.
                        BrettNinjaTrader Product Management

                        Comment


                          #13
                          Hi sorry but I do not work that way, could you please tell me exactly how serious the system which I refer, thanks.

                          double stoploss = Position.AvgPrice - Position.AvgPrice * (filterR/100);

                          if (CrossAbove (ZeroLagTEMA (Period). ZeroTEMA, ZeroLagHATEMA (Period). ZeroHATEMA, 1)
                          & & RelativeSlope (period) [0] <filterR)



                          {

                          SetStopLoss (CalculationMode. Price, stoploss);
                          EnterLong (1, "");
                          }

                          Comment


                            #14
                            Hello,

                            This should work as is now. The stop should be placed. Are you not seeing the stop be placed?

                            I look forward to assisting you further.
                            BrettNinjaTrader Product Management

                            Comment


                              #15
                              Hi sorry but I do not work like it does not close any position, if you want I can send you the complete code, thanks.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by CarlTrading, 03-31-2026, 09:41 PM
                              1 response
                              67 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by CarlTrading, 04-01-2026, 02:41 AM
                              0 responses
                              36 views
                              0 likes
                              Last Post CarlTrading  
                              Started by CaptainJack, 03-31-2026, 11:44 PM
                              0 responses
                              59 views
                              1 like
                              Last Post CaptainJack  
                              Started by CarlTrading, 03-30-2026, 11:51 AM
                              0 responses
                              62 views
                              0 likes
                              Last Post CarlTrading  
                              Started by CarlTrading, 03-30-2026, 11:48 AM
                              0 responses
                              53 views
                              0 likes
                              Last Post CarlTrading  
                              Working...
                              X