Login Page - Create Account

Support Board


Date/Time: Sat, 04 May 2024 03:32:04 +0000



[Programming Help] - Stop Limit Order

View Count: 1602

[2016-08-19 04:03:13]
Netz - Posts: 19
Hello.

I'm trying to enter a buy or sell order several ticks below/above the signal bar close.
For example,
If I get a sell signal, have a sell stop order to enter several ticks above the signal bar close.
Is this how it is done in ASCIL?


  
if (BAR SIGNAL) // Enter buy when long signal is formed.
    {
s_SCNewOrder NewOrder;
    NewOrder.OrderType = SCT_ORDERTYPE_STOP_LIMIT;
    NewOrder.Price1 = sc.Close[sc.Index] - 4 * sc.TickSize;
}
if (BAR SIGNAL) // Enter sell when short signal is formed.
    {
    s_SCNewOrder NewOrder;
    NewOrder.OrderType = SCT_ORDERTYPE_STOP_LIMIT;
    NewOrder.Price1 = sc.Close[sc.Index] + 4 * sc.TickSize;
}
  

[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();
            }
          }
        }

[2016-08-21 23:20:25]
Netz - Posts: 19
Hi.

Please disregard it all. I figured it out.
Add the bar index order at the neworder area.
It was all in the tradingsystem.cpp
Now I just have to figure out how to reset.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account