Support Board
Date/Time: Wed, 15 Jan 2025 23:57:39 +0000
[Programming Help] - SC Function to find trade position
View Count: 1156
[2017-09-27 16:42:23] |
User203925 - Posts: 40 |
Main objective is to have a strategy that has a triggered trailing stop to reverse when criteria are met. Question 1: Do I have to have sc.AllowMultipleEntriesInSameDirection set to true to make this happen? Here is the code that launches my triggered trailing stop if (sc.BaseData[SC_LAST][sc.Index - 1] < b_TradeTarget && sc.BaseData[SC_LAST][sc.Index] >= b_TradeTarget && ExistingOrder.Price1 != b_TrailStop) { b_TrailStop = b_TradeTarget - (TrailStopOff.GetInt() *sc.TickSize); NewOrder.OrderQuantity = OrderQuantity.GetInt(); NewOrder.OrderType = SCT_ORDERTYPE_TRIGGERED_TRAILING_STOP_3_OFFSETS; NewOrder.Price1 = b_TrailStop;// Stop price NewOrder.Price2 = b_TradeTarget;// Trail trigger price NewOrder.TimeInForce = SCT_TIF_DAY; int Result = sc.SellEntry(NewOrder); } } Question 2: If sc.AllowMultipleEntriesInSameDirection has to be set to true, what is the best function to determine 1. The strategy is in a trade and 2. The direction of the trade? I am using sc.GetOrderByIndex(EntryID, ExistingOrder) and (ExistingOrder.BuySell == BSE_SELL / Buy) functions to determine the direction of the trade but multiple entries still exist. |
[2017-09-27 18:42:03] |
Sierra Chart Engineering - Posts: 104368 |
1. No. 2. Use this function: Automated Trading From an Advanced Custom Study: sc.GetTradePosition 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: 2017-09-27 18:43:08
|
[2017-09-27 20:27:10] |
User203925 - Posts: 40 |
Okay, if you were going to allow reversals and use the SCT_ORDERTYPE_TRIGGERED_TRAILING_STOP_3_OFFSETS order type what would the sc.Defaults need to be?
|
[2017-09-27 20:47:10] |
Sierra Chart Engineering - Posts: 104368 |
We can only refer you to the documentation here: Automated Trading Management Have a look at SupportReversals. 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 |
[2017-09-27 20:52:36] |
User203925 - Posts: 40 |
Cool and thank you!
|
[2017-09-27 22:18:15] |
User203925 - Posts: 40 |
My sc.Defaults are : sc.AllowMultipleEntriesInSameDirection = false; sc.AllowOnlyOneTradePerBar = true; sc.MaintainTradeStatisticsAndTradesData = true; sc.AlertOnlyOncePerBar = true; sc.SupportReversals = true; c.AllowEntryWithWorkingOrders = true; sc.CancelAllWorkingOrdersOnExit = true; I initial launch an order and a stop when certain conditions are met. Next, if another type of conditions are met I am launching a SCT_ORDERTYPE_TRIGGERED_TRAILING_STOP_3_OFFSETS as a BuyExit or SellExit depending on the entry needed. This works great bc the Trailing Stop will launch with sc.AllowMultipleEntriesInSameDirection = false. The issue is that when a reversal condition is met. The order cancels out the reversal order if the trailing stop did not close out the initial order. I need to have sc.AllowMultipleEntriesInSameDirection set to false bc if not my system will launch multiple entries. If I try to use sc.GetTradePosition and require the entry to launch if sc.GetTradePosition = -1 meaning it's not in a trade then my entries will not reverse bc it's in a trade when the reversing entry is launched. If I change SCT_ORDERTYPE_TRIGGERED_TRAILING_STOP_3_OFFSETS to a BuyEntry / SellEntry the orders will not launch bc I have sc.AllowMultipleEntriesInSameDirection set to false. Any suggestions? I feel like I am running in circles. |
To post a message in this thread, you need to log in with your Sierra Chart account: