Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Buy Stop Limit Orders Cant Be Placed

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

    #31
    Hello tkaboris,

    Your question relates to the stop market order. you need to look at any conditions that use the stop market order. I don't understand why you are bringing up the entry, that is not related to your stoploss having a rejection for having a wrong price.

    If you are not able to use prints to output what your stop loss conditions are doing I can only suggest to reach out to a third party developer to have something made for you.

    To solve this question you need to use prints to find out more about what prices you calculate for the stop market order.


    I am a bit confused about this Set price in my case. What is Set Price suppose to be?
    I don't know what you are referring to here. I see you mentioned that a few times but I don't know what that is, that's not valid code so I don't know what you mean by set price.


    is this a StopLoss level that corresponds to this line slLongMinMax[1]
    ExitLongStopMarket(0, true, Position.Quantity, slLongMinMax[1], "SLL", "TLL");
    You used slLongMinMax[1] for the price, you need to print that price and use it in a condition if you want to know if that's valid at the time of order submission.


    Comment


      #32
      Hi Here is a screenshot for Long order with Prints. I added prints that pertaining to setting stop order. How can I make sure no error of buystop cant be placed from occuring. if(slLongMinMax[1] > CurrentAsk) will always be false..

      Entering Jump Long : 4/14/2023 7:27:06 AM- 2068
      Current ask13144.25
      bid13143.75
      slShortMinMax[1] 13145
      FixedStopLoss : False
      slLongMinMax[1] 13135.25​

      in my onbarupdate i have these
      slShortMinMax[0] = High[0] + (StopLossOffset * TickSize); // currently used
      slLongMinMax[0] = Low[0] - (StopLossOffset * TickSize);​

      And here is once again how I place sl and tp
      if ((Position.MarketPosition == MarketPosition.Long && myFreeTradeLong == true) )

      {


      if (FixedStopLoss)
      {
      ExitLongStopMarket(0, true, Position.Quantity, StopLossTicks, "SLL", "JumpL");

      }
      else
      {

      ExitLongStopMarket(0, true, Position.Quantity, slLongMinMax[1], "SLL", "JumpL");
      }



      if (ProfitTarget)

      {
      ExitLongLimit(0, true, Position.Quantity, Position.AveragePrice + (TickSize * ProfitTargetTicks), "PTL", "JumpL");
      }

      if (UseTPByATR )
      {
      ExitLongLimit(0, true, Position.Quantity, Position.AveragePrice + (TickSize * tpByATR), "PTL", "JumpL");
      }


      }​


      Click image for larger version

Name:	image.png
Views:	93
Size:	851.4 KB
ID:	1255995

      Comment


        #33
        Hello tkaboris,

        The answer is still the same here, to prevent the error you need to make price conditions to check the prices you use for the order. This is not something I can do for you, you need to use prints to know how the strategy is working and then come up with conditions of your own to solve that situation. We have already covered why you get that error and how to approach solving the error. At this point it would be up to you to further debug your strategy and come up with a solution that works with the logic you are writing. Our support is not able to provide debugging assistance, we can only guide you to be able to do your own debugging of the scripts you write.

        Comment


          #34
          Hi so I made a condition as stated in the last post
          if(slLongMinMax[1] > CurrentAsk)​
          and then perform ExitLongStopMarket . In my case stoploss doesn’t get executed because if statement is false.

          Previously we talked that I need to make sure calculates price is above ask price. I performed this statement and get false.
          did I perform check if(set price> ask) correctly ?

          Comment


            #35
            Hello tkaboris,

            If that is not the solution then you need to continue to work on that. You can use Prints to find out why that condition was false and then make any necessary adjustments. If slLongMinMax is not greater than the price you check it against in the condition then that would make the condition false and that would be a correct result based on the condition you made.

            Comment


              #36
              Hi,
              in the below example from strategy analyzer, it opened short on firsttickofbar without SL. because Open was higher then previous close.
              I want to add a logic where i place my ExitShortStopMarket if (currentBid = Open[0] ) but it doesnt do what i want. I need to make sure open on firstTickOfbar is the same as previous close. How can I do that?


              Click image for larger version

Name:	image.png
Views:	74
Size:	31.5 KB
ID:	1256920

              Comment


                #37
                Or should i just put this condition before I enter a position?
                && (Open[0] == Close[1])

                Comment


                  #38
                  Hello tkaboris,

                  If you are using firstTickOfbar that is going to be always true in a backtest because OnBarClose processing is used. You can test that type of logic in realtime where you can use OnEachTick processing.

                  Checking if two double values are equal will be false, you would need to use math to find if there is a difference in values. you can read about that here: https://ninjatrader.com/support/help...arithmetic.htm

                  Comment


                    #39
                    Hello, I have a following code where i check for current price more for stops, and current price less then ask for Take profits.
                    However, i am getting eror price stops cant be change below market


                    if (UseFixedSLTP)
                    if(Position.MarketPosition == MarketPosition.Short && Position.AveragePrice + (TickSize * StopLossTicks) >= ask){
                    ExitShortStopMarket(1, true, Position.Quantity, Position.AveragePrice + (TickSize * StopLossTicks), "SLS", "Short");
                    }
                    if(Position.MarketPosition == MarketPosition.Short && Position.AveragePrice - (TickSize * StopLossTicks) <= ask){
                    ExitShortLimit(1, true, Position.Quantity, Position.AveragePrice - (TickSize * ProfitTargetTicks), "PTS", "Short");

                    }​

                    Comment


                      #40
                      Hello tkaboris,

                      If you are still getting the error that means you are still calculating an incorrect price. in the code you provided you are using a variable named ask, you would need to make sure that whatever value you are setting to that variable is valid at the time you submit the order. The rest of your condition is comparing against that variable so if that is not valid you would still get the error.

                      if you continue to have problems here I would suggest to avoid placing the order so close to the market to help avoid pricing the order on the wrong side. The error you are seeing is a normal error which happens when incorrectly pricing an order.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by NullPointStrategies, Today, 05:17 AM
                      0 responses
                      52 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      130 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      70 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      44 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      48 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X