Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 13:57:00 +0000



[Programming Help] - NewOrder structure: Buy Exit + 3 ticks

View Count: 565

[2020-05-06 14:53:02]
User104896 - Posts: 11
Hello,

I am trying to update Buy Exit NewOrder structure to send a limit order for the SC_LAST + 3 ticks:

if (Input1.GetIndex() == 0 || Input1.GetIndex() == 2)
  {
    int& lastBuyEntryBar = sc.GetPersistentInt(3);
    int& lastBuyExitBar = sc.GetPersistentInt(3);
    if (SIGNAL[sc.Index] == string("BUY"))
    {      
      s_SCNewOrder NewOrder;
      NewOrder.OrderType = SCT_ORDERTYPE_LIMIT;
      NewOrder.Price1 = sc.BaseDataIn[SC_LAST][sc.Index];
      NewOrder.OrderQuantity = 100;
      NewOrder.TimeInForce = SCT_TIF_IMMEDIATE_OR_CANCEL;
      
      int Result = int(sc.BuyEntry(NewOrder));
      if (Result > 0)
      {
        BuyEntrySubgraph[sc.Index] = sc.BaseDataIn[SC_LAST][sc.Index];
        lastBuyEntryBar = sc.Index;
      }
      else
        sc.AddMessageToLog(sc.GetTradingErrorTextMessage(Result), 1);
    }

    if (SIGNAL[sc.Index - 1] == string("BUY"))
    {
      s_SCNewOrder NewOrder;
      NewOrder.OrderType = SCT_ORDERTYPE_LIMIT;
      NewOrder.OrderQuantity = 0;
      NewOrder.Price1 = sc.BaseDataIn[SC_LAST][sc.Index] + 3*sc.TickSize;
      NewOrder.TimeInForce = SCT_TIF_DAY;
      int Result1 = int(sc.BuyExit(NewOrder));
      if (Result1 > 0)
      {
        BuyExitSubgraph[sc.Index] = sc.BaseDataIn[SC_LAST][sc.Index] + 3*sc.TickSize;
        lastBuyExitBar = sc.Index;
      }
      else
        sc.AddMessageToLog(sc.GetTradingErrorTextMessage(Result1), 1);


The portion in bold is what I have added. This is not working and the Trade Service Log says that the Buy Exit signal is being ignored.

Can you help please?

If i do not include the "+ 3*sc.TickSize", then the Buy Exit happens on the same bar as the Buy Entry, which is useless.

Thanks.
[2020-05-07 04:35:09]
Flipper - Posts: 65
You sure its not because of you have order size set to 0?

NewOrder.OrderQuantity = 0;

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

Login

Login Page - Create Account