Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting stopped on same bar (CalcOnBarClose = True)

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

    Getting stopped on same bar (CalcOnBarClose = True)

    I'm running a bunch of market replays and am encountering scenarios where I am getting stopped out on the same bar...

    What I find odd is I'm using 2 Range bars, am having a target of 5 ticks, and stop of 4 ticks... CalculateOnBarClose is set to True in the Strategy setup, although its set to False in the actual code.... I'm assuming the strategy setup overrides the code?

    Any ideas as to why this is happening?

    #2
    BigDog008, yes the UI setting would override the code.

    Did you work with TraceOrders to debug which stop orders are placed and executed?

    Comment


      #3
      Bertrand, yep

      in fact there have been scenarios where I've been down say $125... and then the strategy gets stuck on a bar and 1 minute later am up $2000....

      Comment


        #4
        Is this happening on all replay speeds or just particular ones?

        Comment


          #5
          will check that out right now... i've been running at 500x replay where this error has been popping up....

          Under the Simulator Tab in Options, I have Delay comm. (msec) set as 0 and Delay exchange (msec) set as 0.... per my discussions with Josh, this was supposed to let my results be consistent whether I was running at 500x or 1x...

          nonetheless, I will check right now...

          Comment


            #6
            Ok, thanks please me know what you find out.

            Comment


              #7
              Bertrand,

              So I got the following error...

              7/13/2009 9:32:00 AM Strategy Strategy 'LimitOrderSkeleton' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.

              7/13/2009 9:32:00 AM Order Buy stop or buy stop limit orders can't be placed below the market. Affected Order: BuyToCover 1 Stop @ 944.75

              and then got a flood of orders...

              this was at 20x market replay
              Last edited by BigDog008; 07-13-2009, 08:45 AM.

              Comment


                #8
                BigDog008, then you would need to debug why the order got rejected and caused your strategy to become terminated. If you like, send me your logs and traces using the Help > Mail to Support feature (Attn Bertrand) and I take a look.

                Comment


                  #9
                  ok, 944 is a while ago..now just off 875. Looks long today... we will see


                  Your error
                  Order Buy stop or buy stop limit orders can't be placed below the market. Affected Order: BuyToCover 1 Stop @ 944.75

                  is quite common in real trading. Best cure is once your strategy code triggers the stop to compare stop price to current ask price. If your stop price is below current market don't place that stop order any more but place a market order instead to exit.

                  Good luck


                  Andreas

                  Comment


                    #10
                    Being that my stops are limit orders,

                    can't I simply just place a limit order and if its hit its hit?


                    i don't have any market orders being placed, hence why i'm a bit confused
                    Last edited by BigDog008; 07-13-2009, 09:21 AM.

                    Comment


                      #11
                      BigDog008, yes, but from your posted error it looks like this was a Stop order.

                      Comment


                        #12
                        Code:
                        shortstopOrderC = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 4 * TickSize, "ShortStopC", "ShortC");
                        is what I'm using...


                        is there a ShortStopLimit command?
                        Last edited by BigDog008; 07-13-2009, 09:29 AM.

                        Comment


                          #13
                          No, this is a Buy Stop exit order that you tried to place below the market and thus it was rejected and your strategy got terminated then...

                          Comment


                            #14
                            what's confusing me Bertrand, is this is the code I'm using...

                            would changing my ExitShortStop to ExitShortStopLimit and same for LongStop fix this issue?

                            Code:
                                        // LONG ORDER A STOP AND TARGET
                                        if (longentryOrderA != null && longentryOrderA.Token == execution.Order.Token)
                                        {
                                            if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                                            {
                                                longstopOrderA     = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 4 * TickSize, "LongStopA", "LongA");
                                                longtargetOrderA = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 6 * TickSize, "LongTargetA", "LongA");
                                            }
                                        }
                                        // LONG ORDER B STOP AND TARGET
                                        if (longentryOrderB != null && longentryOrderB.Token == execution.Order.Token)
                                        {
                                            if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                                            {
                                                longstopOrderB     = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 4 * TickSize, "LongStopB", "LongB");
                                                longtargetOrderB = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 5 * TickSize, "LongTargetB", "LongB");
                                            }
                                        }
                                        // LONG ORDER C STOP AND TARGET
                                        if (longentryOrderC != null && longentryOrderC.Token == execution.Order.Token)
                                        {
                                            if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                                            {
                                                longstopOrderC     = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 4 * TickSize, "LongStopC", "LongC");
                                                longtargetOrderC = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 4 * TickSize, "LongTargetC", "LongC");
                            
                                            }
                                        }
                                        
                                        // SHORT ORDER A STOP AND TARGET
                                        if (shortentryOrderA != null && shortentryOrderA.Token == execution.Order.Token)
                                        {
                                            if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                                            {
                                                shortstopOrderA = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 4 * TickSize, "ShortStopA", "ShortA");
                                                shorttargetOrderA = ExitShortLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 6 * TickSize, "ShortTargetA", "ShortA");
                                            }
                                        }
                                        // SHORT ORDER B STOP AND TARGET
                                        if (shortentryOrderB != null && shortentryOrderB.Token == execution.Order.Token)
                                        {
                                            if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                                            {
                                                shortstopOrderB = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 4 * TickSize, "ShortStopB", "ShortB");
                                                shorttargetOrderB = ExitShortLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 5 * TickSize, "ShortTargetB", "ShortB");
                                            }
                                        }
                                        // SHORT ORDER C STOP AND TARGET
                                        if (shortentryOrderC != null && shortentryOrderC.Token == execution.Order.Token)
                                        {
                                            if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                                            {
                                                shortstopOrderC = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 4 * TickSize, "ShortStopC", "ShortC");
                                                shorttargetOrderC = ExitShortLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 4 * TickSize, "ShortTargetC", "ShortC");
                                            }

                            Comment


                              #15
                              I don't think so BigDog008, you would most likely need to incorporate the check zweistein recommended in his post.

                              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
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              573 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              575 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X