Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop price cannot be change below market price

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

    Stop price cannot be change below market price

    Hi, I faced this issues before, and I know that have to make a check to make sure it is below market price such as :

    Code:
    if (stopLongPriceWithOffset >= GetCurrentAsk() && StopLongType == OrderType.StopMarket)
    stopLongPriceWithOffset = GetCurrentAsk() - TickSize;
    
    if (stopLongPriceWithOffset >= GetCurrentBid() && StopLongType == OrderType.StopMarket)
    stopLongPriceWithOffset = GetCurrentBid() - TickSize;
    But sometime, I still getting the error back.

    Currently, i put this command in the onbarupdate().

    Can i know why still getting this error ??
    Attached Files

    #2
    Hello soon123,

    Thanks for your post.

    What Calculate setting is used for the strategy?

    Are you only placing long orders?

    Is the calculated stop price immediately used?

    If you increase the distance one more tick does the error continue.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      1) What Calculate setting is used for the strategy?
      Calculate = Calculate.OnBarClose;


      2) Are you only placing long orders?
      Yes, i only placing Long Order.


      3) Is the calculated stop price immediately used?
      Sry, i didn't make my statement very clear for 1st post.
      The Stop Long actually happens on Bar 3890, but then that time not fulfill.
      So when it move to following bar onward, the price will be update to Close[0] and at the same time using GetCurrentAsk() && GetCurrentBid() to check the condition.
      ** Condition you can refer above.

      Then until bar 3903 it still update.
      Unfortunately, the error prompt out at Bar 3904.


      4) If you increase the distance one more tick does the error continue.
      If I increase the tick, it will execute with no error.
      But my question is how much tick size should I implement so that no matter what I wont faced this issues again.
      Attached Files

      Comment


        #4
        Hello soon123,

        Thanks for your reply.

        I would suggest removing: if (stopLongPriceWithOffset >= GetCurrentAsk() && StopLongType == OrderType.StopMarket) stopLongPriceWithOffset = GetCurrentAsk() - TickSize;

        If you are only entering long you want to keep your exit order below the bid.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Even using OnEachTick processing, I used to run into this same problem occasionally, because sometimes the market moves too fast or too far...even ON EACH TICK. What I ultimately did was issue a HARD stop-loss 10 ticks below where I want the ACTUAL starting stop-loss to be when the trade opens. I never move the HARD stop loss and it resides on the brokers platform, so it's actually just a "worst case" / power-loss / emergency backup stop loss and is cancelled when each trade ends. I implement and manipulate my "real" stop-loss with strategy LOGIC -- it's just a "number", either a price or a relative number of ticks above or below the entry price.. Example: my StopLossTicks mgiht be -18 and my ProfitTargetTicks might be 38.
          Then if the price-or-level of the CurrentPrice touches or exceeds my "magic number", I exit the trade. Since I may "move" my stop loss (number) as (or IF) the trade makes gains, I could exit with a "StopWin" or a "StopLoss" situation. I do something very similar with the Profit Target -- it's all just software-logic -- no HARD stop for the Profit Target at all. Since I've implemented this scheme, I no longer get the error message you referred to, which always completely STOPPED my strategy I hope this helps....Your OnBarUpdate() must look at every tick for this to work. :-( -Bill-

          Comment


            #6
            NinjaTrader_PaulH

            Removing ??
            Last time Ninjatrader customer service suggest me to use
            GetCurrentAsk() and GetCurrentBid() to check.

            If now you asking me to remove, can I know how to prevent problems such as Price cannot placed below bid price ??

            Comment


              #7
              Hello soon123,

              Thanks for your reply.

              You advise that you are only placing Long orders. So your exit long stop order (which is really a sell order), when moved, must remain below the Bid.

              Paul H.NinjaTrader Customer Service

              Comment


                #8
                NinjaTrader_PaulH
                ARE you really understand my question??


                I waiting for your reply, and you didn't answer my question??
                ** To be honest, i really a bit mad.

                Comment


                  #9
                  Hello soon123,

                  Thanks for your reply.

                  Sorry that you feel that way as I thought I had provided you with a solution based on what you advised you were doing.

                  To that end, i've created a short video to help clarify: https://paul-ninjatrader.tinytake.co...OF8xNTkyMTM1MQ

                  The bottom line here is that when you move the stop for a long order, the stop has to be at or below the bid price. Depending on market dynamics the bid price and ask price will be next to each other and can also be spread apart greater than 1 tick so when you move your stop 1 tick below the Ask you may be moving the order above the bid and that is when you would get an error as shown in the video example.

                  iI your duplicated forum thread here: https://ninjatrader.com/support/foru...t-price-update Jim has provided you with further diagnostic information that I will not duplicate here. Between this reply and Jims, you should have a better understanding of what you need to do.
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    The video explained is what I want for.
                    I like it and understood.

                    Ya, I saw Jim got reply me.
                    Still in progress of reading and understanding it.

                    Thanks in advanced.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by soon123, Today, 10:15 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post soon123
                    by soon123
                     
                    Started by tuliomgui, Today, 10:07 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post tuliomgui  
                    Started by bhydsnh, Today, 10:06 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post bhydsnh
                    by bhydsnh
                     
                    Started by ketoeliteusa, Today, 09:59 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post ketoeliteusa  
                    Started by ketoeliteusa, Today, 09:58 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post ketoeliteusa  
                    Working...
                    X