Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StopMarket cancelled by stoploss before entry

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

    StopMarket cancelled by stoploss before entry

    Hi I am trying to make a strategy where when it reaches a certain price, it would enter a trade. So in my approach, I am using a stop market for entering trades based on the specific price. But when I'm backtesting, I realized that my entry are stopped out by the stop loss before even entering. In my case, I only want stop loss to work after the trade is entered, not when a stopmarket order is submitted. Check the picture that I have attached for references. Thanks
    Attached Files

    #2
    Hello horace chow,

    Thanks for posting.

    To assist we will need more information about your strategy.

    Please post the entry order code you are using as well as the stoploss coding you are using.

    If you are using the Strategy Builder, please post the screenshots of the sets with the entry order and the stop and profit window (if you are using those methods).

    Comment


      #3
      Ignore the print statements, they are for debugging


      SetProfitTarget(CalculationMode.Price, Instrument.MasterInstrument.RoundToTickSize(EntryL ine-1.5*(ShortLimitLine-EntryLine)));
      SetStopLoss(CalculationMode.Price, ShortLimitLine);
      EnterShortStopMarket((int)Math.Round(quantity),Ent ryLine, "Short Entry");

      In this section of code, first I set the profit target, then I set the stop loss. lastly, I submitted a shortstopmarket order. However, before the order is entered(submitted an order but hasn't entered the trade), assuming the price continues to approach and touched my stop loss, the shortstopmarket order will be canceled. I was wondering would there be any better way to approach it. Would it be possible for me to remove my stoploss and set it within OnOrderUpdate() when it's entered into the trade?
      Attached Files

      Comment


        #4
        Hello horace chow,

        Thanks for your reply.

        I see that you have print statements. Can you also print out your entry price as well?

        It looks like you are placing a short stop type entry so this entry would need to be above the current price, I would also print out the current price as a check.


        Comment


          #5
          the code that I have provided is for entering short, in the example I provided is entering long, it has almost the same layout.

          Comment


            #6
            Hello horace chow,

            Thanks for your reply.

            In both cases, I would use and add to your print statements to determine what the calculated entry price verses the current price.


            Comment


              #7
              From the example in first comment, I have printed the profit target, entry price, and stop loss

              Quantity = 5.45454545454545 = 1500 / -5.5*50
              Profit target = 3093.75
              Entry price = 3085.5
              Stop loss = 3080

              Comment


                #8
                I have watched the playback very slowly, it seems like after the order has been submitted with EnterShortStopMarket(), once the next bar has been formed, the order was canceled. By any chance this is an error?

                Comment


                  #9
                  Hello horace chow,

                  Thanks for your reply.

                  When you run your strategy, do you see any related error messages in the "log" tab of the control center?

                  Limit type entry orders will be automatically canceled if not filled in the bar they are submitted. Please see the "managed approach" information here: https://ninjatrader.com/support/help...d_approach.htm

                  To keep the order in play, you would need to resubmit the order on each new bar or use the bool IsLiveUntilCanceled in the entry order method.
                  Reference: https://ninjatrader.com/support/help...stopmarket.htm
                  This is the overload: EnterShortStopMarket(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName)

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, Today, 05:17 AM
                  0 responses
                  50 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  127 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  69 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  42 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  46 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X