Support Board
Date/Time: Tue, 21 Jan 2025 12:24:34 +0000
[Programming Help] - Multiple Trades Per Bar
View Count: 743
[2018-08-07 11:11:12] |
rahul - Posts: 167 |
Hello, I am aware that sc.SupportReversal = true will help reverse a trade even when sc.AllowOnlyOneTradePerBar = true Suppose I need to exit 1 open contract (BuyExit after this open quantity = 0) and enter 2 new contracts (SellEntry) on the same bar instantly, what's the best way of doing so? Can someone please write that code for me. Much appreciated. Currently my code is (for reversing 1 contract) on Bar Close using sc.GetBarHasClosedStatus(sc.Index) == BHCS_BAR_HAS_CLOSED: sc.AllowMultipleEntriesInSameDirection = false; sc.MaximumPositionAllowed = 2; sc.SupportReversals = true; sc.AllowOppositeEntryWithOpposingPositionOrOrders = false; sc.SupportAttachedOrdersForTrading = false; sc.CancelAllOrdersOnEntriesAndReversals = true; sc.AllowEntryWithWorkingOrders = false; sc.CancelAllWorkingOrdersOnExit = true; sc.AllowOnlyOneTradePerBar = true; sc.MaintainTradeStatisticsAndTradesData = true; s_SCNewOrder NewOrder; NewOrder.OrderQuantity = 1; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED; sc.SellEntry(NewOrder); Date Time Of Last Edit: 2018-08-07 16:06:42
|
[2018-08-07 23:29:46] |
rahul - Posts: 167 |
I might have found the answer. According to this page, Automated Trading Management: SupportReversals it says "When a reversal order is given it will flatten the existing Position, and create a new Position which will have a quantity equal to the Order Quantity specified. Therefore, there must be an Order Quantity specified." So, if I want to exit my current 1 long Position (Qty = 1) and enter 2 Short Positions, is it as simple as: sc.SupportReversals = true; NewOrder.OrderQuantity = 2; sc.SellEntry(NewOrder); |
To post a message in this thread, you need to log in with your Sierra Chart account: