Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 18:21:58 +0000



Order for different symbol - supported for IB with Equity options?

View Count: 708

[2019-05-14 19:06:28]
User177773 - Posts: 4
I have not been successful in placing orders for different symbols in using IB with equity options. Is this supported by SC?
If I execute code with partial snippet below, it works for different symbols like ETFs: chart with SPY symbol and trade rules applied, executing trade on QQQ,
but if I instead use option symbol instead of QQQ (see below), it does not work. Is this a known limitation or am I doing something wrong?

Thanks!

if (TradingAllowed && sc.CrossOver(Subgraph1Reference, Subgraph2Reference) == CROSS_FROM_BOTTOM)
  {
    // mark the crossover on the chart
    Subgraph_BuyEntry[sc.Index] = sc.Low[sc.Index];

    // Create a market order and enter long.
    s_SCNewOrder NewOrder;
    NewOrder.OrderQuantity = 1;
    NewOrder.OrderType = SCT_ORDERTYPE_MARKET;
    NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
    NewOrder.Symbol = "SPY-OPT-20190515-285-C-SMART-100-USD";
    //NewOrder.Symbol = "SPY 190515C00285000";
    //NewOrder.Symbol = "QQQ";

    //sc.BuyEntry(NewOrder);
    sc.BuyOrder(NewOrder);
[2019-05-14 20:58:43]
User177773 - Posts: 4
I should add that I believe that the IB option symbol string is correct, since I have successfully used it to chart the option prices in a chart window as well as successfully sent options orders to IB from the chart window.
[2019-05-16 04:26:14]
Sierra Chart Engineering - Posts: 104368
There is an error occurring. Refer to:
Automated Trading From an Advanced Custom Study: Debugging/Troubleshooting Automated Trading Systems

Most likely the error is related to the symbol settings not existing. The documentation explains in detail what to do.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2019-05-16 04:26:38
[2019-05-20 20:09:04]
User177773 - Posts: 4
Tried adding the error message code per above link -> No error messages generated in the main log and no trades appear in trade service log

Here is a code:

if (TradingAllowed && sc.CrossOver(Subgraph1Reference, Subgraph2Reference) == CROSS_FROM_BOTTOM)
  //if (TradingAllowed)    
  {
    // mark the crossover on the chart
    Subgraph_BuyEntry[sc.Index] = sc.Low[sc.Index];

    // Create a market order and enter long.
    s_SCNewOrder NewOrder;
    NewOrder.OrderQuantity = 1;
    NewOrder.OrderType = SCT_ORDERTYPE_MARKET;
    NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
    //NewOrder.Symbol = "SPY-OPT-20190520-285-C-SMART-100-USD";
    //NewOrder.Symbol = "SPY 190520C00285000";
    //NewOrder.Symbol = "QQQ1";
    //NewOrder.Symbol = "IWM";
    //NewOrder.Symbol = "SPY 190520C00283000-SMART-OPT-USD";
    NewOrder.Symbol = "SPY-OPT-20190520-283-C-SMART-100-USD";

    //sc.BuyEntry(NewOrder);
    //sc.BuyOrder(NewOrder);
    //int Result = sc.BuyEntry(NewOrder);
    int Result = sc.BuyOrder(NewOrder);
if (Result > 0)//order was accepted
{
//Take appropriate action if order is successful
}
else//order error
{
//Only report error if at the last bar
if (sc.Index == sc.ArraySize -1)
{
//Add error message to the Sierra Chart Message Log for interpretation
sc.AddMessageToLog(sc.GetTradingErrorTextMessage(Result), 0);
}
}

The symbol name used ("SPY-OPT-20190520-283-C-SMART-100-USD") matches the SC online manual definition:
and was used successfully as the symbol name in SC to chart option prices with data received from IB.
I also double checked in IB option chain that this particular option exists - it does, and price data matches price displayed in SC chart.

I should point out that the IB account used for this is a "papertrade" account of type DUxxxxx associated with a real IB account.

Please advise next step!

Thanks!

Erik
[2019-05-20 22:40:48]
Sierra Chart Engineering - Posts: 104368
There must be an error. Remove this line:
if (sc.Index == sc.ArraySize -1)

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-05-21 00:09:05]
User177773 - Posts: 4
Looking at your previous response above "Most likely the error is related to the symbol settings not existing."
Does this mean that explicitly using the symbol name alone (NewOrder.Symbol = "SPY-OPT-20190520-283-C-SMART-100-USD";)
is not sufficient? it also has to be defined in the symbol setting xml database?
If this is the answer - can this then be specified using the "use pattern matching character option"?
For example, SPY-OPT-20190522-283-C-SMART-100-USD => SPY-OPT-########-###-?-SMART-100-USD
and SPY-OPT-20190522-269.5-P-SMART-100-USD => SPY-OPT-########-###*#-?-SMART-100-USD

I certainly hope that's the case so that each option in the option chain does not have to be individually defined in the symbol setting xml data base.

Thanks,

Erik
[2019-05-21 00:28:36]
Sierra Chart Engineering - Posts: 104368
You do definitely have to add it to the Global Symbol Settings and only a pattern is needed.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

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

Login

Login Page - Create Account