Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 07:24:57 +0000



Post From: Stop Limit Order

[2016-08-21 21:36:08]
Netz - Posts: 19
Hello.

I tested and the stop limit orders seem to work here.
I have another related question, Thanks in advance for your help.
A system that I am working on, I'm having problems cancelling orders.
I modified the auto retracement study (manual looping). I am able to place the stop limit order for entry at NewOrder.Price1.
I am having a problem cancelling the order after x bars. I copied code from the tradingsystems.cpp that seems to do this, but it's not working. I think I also read somewhere on your site that some cancel orders may have issue when not autoloop =1.
Can you explain how I can cancel the open stop limit order?
This is what I have and it's not working. I tried with just sc.CancelOrder(r_InternalOrderID) and now I added it to modifyorder. I also tried cancel all and flattencancelall.
else if (r_InternalOrderID != 0)
      {
        s_SCTradeOrder ExistingOrderDetails;
        if (sc.GetOrderByOrderID(r_InternalOrderID, ExistingOrderDetails))
        {
          //If original submitted order is still working.
          if (IsWorkingOrderStatus(ExistingOrderDetails.OrderStatusCode))
          {
            //When 1 new bar is added to chart since the original order submission
            if (r_PerformedOrderModification == 0 && sc.Index >= r_BarIndexOfOrder + 3)
            {
              //Modify the order
              s_SCNewOrder ModifyOrder;
              ModifyOrder.InternalOrderID = r_InternalOrderID;
              ModifyOrder.Price1 = sc.CancelOrder(r_InternalOrderID);

              if (sc.ModifyOrder(ModifyOrder) > 0)
                r_PerformedOrderModification = 1;
            }
            //When 2 new bars added to chart since the original order submission
            else if (sc.Index >= r_BarIndexOfOrder + 9)
            {
              //Cancel the order
              sc.FlattenAndCancelAllOrders();
            }
          }
        }