Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Next day open price lover than stop loss.

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

    Next day open price lover than stop loss.

    I foud in back test the situation that the entry signal is generated on last bar in session so the order will be placed in the next day as soon as market will be open and if the opening price will be lower than stop loss strategy place order but do not place stop loss. It could be the cause of big loss.

    Sample:
    Stop loss 50 tick
    Closing price ( entry long signal) - 1000 (Stop loss should be 950)
    Next day opening price 900 - strategy place market order and buy for 900 but do not place stop loss.

    I think there are now way to avoid place order if entry singal have been generated but maybe there are any ways to close position immidately and wait for next entry signal or if no other way terminate strategy ( and close all position).

    Czarek.

    #2
    If you use SetStopLoss() and use CalculationMode.Ticks it shouldn't matter what your actual fill price is. It will calculate the stop loss from the value of entry.

    Perhaps you could try a EnterLongStop() or an EnterLongStopLimit() order type.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh.
      I also think that stop loss should be calculated from entry price not from entry signal.
      Unfortunately I checked few sizes of stop loss and only if stop loss value is bigger than gap stop loss is placed. It happend during the weekend. Friday entry signal, Monday entry.
      I use OnExecution mehtod.
      Could you take a look to my code and tell me where the problem could be??
      Czarek

      Code:
      /// <summary>
              /// Called on each incoming execution
              /// </summary>
              protected override void OnExecution(IExecution execution)
              {
       
         /* We advise monitoring OnExecution to trigger submission of stop/target orders instead of OnOrderUpdate() since OnExecution() is called after OnOrderUpdate()
         which ensures your strategy has received the execution which is used for internal signal tracking. */
         if (entryOrder != null && entryOrder.Token == execution.Order.Token)
         {
          if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
          { 
           // Stop-Loss order 4 ticks below our entry price
           stopOrderShort  = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + stop * TickSize, "MyStopShort1", "MyEntryShort1");
       
           // Target order 8 ticks above our entry price
           targetOrder = ExitShortLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - limit * TickSize, "MyTargetShort1", "MyEntryShort1");
       
       
       
           // Stop-Loss order 4 ticks below our entry price
           stopOrderLong  = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - stop * TickSize, "MyStopLong1", "MyEntryLong1");
       
       
           // Target order 8 ticks above our entry price
           targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + limit * TickSize, "MyTargetLong1", "MyEntryLong1");
       
          }
              {  
            entryOrder = null;
       
           }     
         }

      Comment


        #4
        Czarek,

        Please use TraceOrders = true and debug your orders. According to your code you should be calculating stop loss based on the fill price. Please also notice that you are still using the same IOrder for your profit target orders. You need to separate those out just like the stop orders.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Entry at Session Opening Price and Exit at Session Closing Price

          Dear Ninja Trader Support Forum,


          I have a question regarding programming my strategy.

          My strategy will

          1) Place following two orders one kills the other at the OPENING PRICE of each market session.
          EnterLongLimit (at certain price)
          EnterShortLimit (at certain price)

          2) Exit either trades at CLOSING PRICE of each market session.

          Simple as that.

          I have checked the Ninja Trader 7 Help, but could not find such types of orders which will enter at OPENING price of the market, and exit at the CLOSING price of the market.

          Is there any way to place such kind of orders using Ninja Trader?

          Your assistance is highly appreciated.

          Comment


            #6
            You would need to go with the new unmanaged order submission mode in NT7 to be able to place such an entry bracket without running into the internal order handling rules present in the managed approach :

            Comment


              #7
              Dear Mr. Bernard,

              Thanks for your assistance.
              Let me look through the documents to see how to programme it.
              I think I will set entry condition using this Unmanaged approach.
              Maybe I will need to amend the session hours to start say 5 minuites ealier than it really does so that the order will be submit to the exchange right?

              Now, about exit, if you set the session manager at correct time, and set "Exit on Close = true", will it submit exit order during the pre closing time, which is within 5 minuites before the closing time?
              Or will it work someway other than I think?

              I'd appreciate it if you could kindly let me know how this session manager would work with the "Exit on Close = true" option.


              Look forward to hearing from you.

              Comment


                #8
                You're welcome, you could definitely setup a custom session template for your strategy and needs:



                ExitOnClose is tied to these hours, with the ExitOnCloseSeconds property defining how many seconds before the template defined close the orders will be submitted from this method :

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                648 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                108 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                572 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                574 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X