Login Page - Create Account

Support Board


Date/Time: Fri, 29 Mar 2024 12:39:05 +0000



[Programming Help] - TRAILING STOP TRIGGER Help

View Count: 1579

[2018-04-14 16:03:37]
User28317 - Posts: 147
I have been trying to set up a trailing stop for 3 months.

When the first contract target is filled, the trailing stop is triggered.

Code snippet:

order.Target2Price = target02_;
order.Stop2Price = stop02_;
order.OCOGroup2Quantity = amount02_;
order.AttachedOrderTarget2Type = SCT_ORDERTYPE_LIMIT;
order.AttachedOrderStop2Type = SCT_ORDERTYPE_STOP;

order.Target1Price = target01_;
order.Stop1Price = stop01_;
order.OCOGroup1Quantity = amount01_;

order.TriggeredTrailStopTrailPriceOffset = trailingDistance_;
order.TriggeredTrailStopTriggerPriceOffset = absoluteTriggerValue_ - stop01_;

order.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT;
order.AttachedOrderStop1Type = SCT_ORDERTYPE_TRIGGERED_TRAILING_STOP_3_OFFSETS;
order.OrderQuantity = amount01_ + amount02_;
if (sc.BuyEntry(order) < 0)
sc.AddMessageToLog("Failed to submit order to the trading service.", 0);

We need to place an order with a specific formulation. We supply the
following data:

e - entry for the order as absolute value in points
t1 - Target for the first order as absolute value in points
t2 - Target for the attached order as absolute value in points
s1 - stop for the first order as absolute value in points
s2 - stop for the attached order as absolute value in points
l - Trigger value to start trailing as absolute value in points
d - trailing distance in points
n - amount of contracts for the first order
k - amount of contracts for the attached order

We need to place an OCO with entry e, Target as Limit at t1, stop at
s1. We need to add an attached order with target as limit at t2, stop
at s2, and which triggers a trailing at l with distance d. We place n
contracts in the order and k contracts in the attached order.

What is the correct way to submit this order to Sierra Chart in an
Automatic trading study?
[2018-04-14 22:33:44]
Sierra Chart Engineering - Posts: 104368
In regards to this, understand that these variables set an actual price value and not an offset in points.
order.Target2Price = target02_;
order.Stop2Price = stop02_;


t1 - Target for the first order as absolute value in points
t2 - Target for the attached order as absolute value in points
s1 - stop for the first order as absolute value in points
s2 - stop for the attached order as absolute value in points

All of these are describing Attached Orders related to the main parent order price specified with:
Automated Trading From an Advanced Custom Study: [Type: double] s_SCNewOrder::Price1


You did not specify this price or order type in the code above.

They are all Attached Orders. An attached order cannot have a target or a stop. They themselves are a target and stop. So it would appear as though you have a misunderstanding.
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: 2018-04-15 04:13:02
[2018-04-15 09:49:28]
User28317 - Posts: 147
OK, so I have a further question, just to see if I understood it correctly. Looking at their documentation it's not really clear.

Follow up question:

So that means that I have to put into Price1 the actual price in Dollars, which means get the tick amount giving the price in points I have and multiply it with sc.CurrencyValuePerTick, is that correct?
[2018-04-16 04:18:49]
Sierra Chart Engineering - Posts: 104368
No, none of that is making any sense. Refer to the scsf_TradingExample2WithAdvancedAttachedOrders study function in the /ACS_Source/TradingSystem.cpp file.
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