Support Board
Date/Time: Mon, 27 Jan 2025 19:36:32 +0000
[Programming Help] - Get 2 positions insted of 1 when i use BuyEnter /SellEnter
View Count: 612
[2019-02-28 15:11:33] |
User214624 - Posts: 3 |
Hi! Building an Advanced Custom Study. Use this code to start a position. s_SCNewOrder NewOrder; NewOrder.OrderQuantity = 1; NewOrder.OrderType = SCT_ORDERTYPE_LIMIT; NewOrder.TimeInForce = SCT_TIF_DAY; NewOrder.Price1 = sc.BaseData[SC_LAST][sc.Index]-0.25 ; sc.Subgraph[22].Data[1]=sc.BaseData[SC_LAST][sc.Index]-0.25 ; int Result = sc.BuyEntry(NewOrder); if (Result > 0)//order was accepted { //Take appropriate action if order is successful sc.Subgraph[22].Data[2] = NewOrder.InternalOrderID; sc.Subgraph[22].Data[3] =1; InputData22.SetInt((sc.Subgraph[22].Data[1]*100)); InputData23.SetInt(sc.Subgraph[22].Data[2]); InputData24.SetInt(sc.Subgraph[22].Data[3]); InputData25.SetInt(0); InputData29.SetInt(InputData29.GetInt()+1); } else//order error { //Only report error if at the last bar if (sc.Index == sc.ArraySize -1) { sc.AddMessageToLog(sc.GetTradingErrorTextMessage(Result), 0); } } } and sc.SendOrdersToTradeService=0; sc.SupportAttachedOrdersForTrading = 0; sc.CancelAllWorkingOrdersOnExit=0; sc.CancelAllOrdersOnEntries=0; sc.CancelAllOrdersOnReversals = 0; sc.SupportReversals = 0; sc.SupportTradingScaleIn=0; sc.SupportTradingScaleOut=0; sc.AllowMultipleEntriesInSameDirection =0; sc.AllowOppositeEntryWithOpposingPositionOrOrders =1; sc.AllowEntryWithWorkingOrders=0; sc.SupportAttachedOrdersForTrading = 0; sc.UseGUIAttachedOrderSetting = 0; sc.MaximumPositionAllowed = 1; |
To post a message in this thread, you need to log in with your Sierra Chart account: