Support Board
Date/Time: Mon, 13 Jan 2025 00:08:28 +0000
Post From: Multiple Limit Order Entries in Both Directions
[2017-03-13 15:27:04] |
Gary Lockwood - Posts: 16 |
I'm writing an automated trading system that puts out limit orders in both directions at certain levels, but am having issues getting more than one of the s_SCNewOrder's to start working on the chart. Below is the code associated with my Orders. I'm sorry if this question has already been answered, but I couldn't find an answer anywhere. Thank you. s_SCNewOrder Upper1Order; s_SCNewOrder Upper2Order; s_SCNewOrder Upper3Order; s_SCNewOrder Upper4Order;
s_SCNewOrder Lower1Order; s_SCNewOrder Lower2Order; s_SCNewOrder Lower3Order; s_SCNewOrder Lower4Order; Upper1Order.OrderQuantity = Entry1Size.GetInt(); Upper2Order.OrderQuantity = Entry2Size.GetInt(); Upper3Order.OrderQuantity = Entry3Size.GetInt(); Upper4Order.OrderQuantity = Entry4Size.GetInt(); Lower1Order.OrderQuantity = Entry1Size.GetInt(); Lower2Order.OrderQuantity = Entry2Size.GetInt(); Lower3Order.OrderQuantity = Entry3Size.GetInt(); Lower4Order.OrderQuantity = Entry4Size.GetInt(); Upper1Order.OrderType = SCT_ORDERTYPE_LIMIT; Upper2Order.OrderType = SCT_ORDERTYPE_LIMIT; Upper3Order.OrderType = SCT_ORDERTYPE_LIMIT; Upper4Order.OrderType = SCT_ORDERTYPE_LIMIT; Lower1Order.OrderType = SCT_ORDERTYPE_LIMIT; Lower2Order.OrderType = SCT_ORDERTYPE_LIMIT; Lower3Order.OrderType = SCT_ORDERTYPE_LIMIT; Lower4Order.OrderType = SCT_ORDERTYPE_LIMIT; Upper1Order.Price1 = UpperLine1; Upper2Order.Price1 = UpperLine2; Upper3Order.Price1 = UpperLine3; Upper4Order.Price1 = UpperLine4; Lower1Order.Price1 = LowerLine1; Lower2Order.Price1 = LowerLine2; Lower3Order.Price1 = LowerLine3; Lower4Order.Price1 = LowerLine4; Upper1Order.Target1Price = (float)YellowLine; Upper2Order.Target1Price = UpperLine1; Upper3Order.Target1Price = UpperLine2; Upper4Order.Target1Price = UpperLine3; Lower1Order.Target1Price = (float)YellowLine; Lower2Order.Target1Price = LowerLine1; Lower3Order.Target1Price = LowerLine2; Lower4Order.Target1Price = LowerLine3; Upper1Order.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT; Upper2Order.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT; Upper3Order.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT; Upper4Order.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT; Lower1Order.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT; Lower2Order.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT; Lower3Order.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT; Lower4Order.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT; Upper1Order.AttachedOrderStopAllType = SCT_ORDERTYPE_STOP; Upper2Order.AttachedOrderStopAllType = SCT_ORDERTYPE_STOP; Upper3Order.AttachedOrderStopAllType = SCT_ORDERTYPE_STOP; Upper4Order.AttachedOrderStopAllType = SCT_ORDERTYPE_STOP; Lower1Order.AttachedOrderStopAllType = SCT_ORDERTYPE_STOP; Lower2Order.AttachedOrderStopAllType = SCT_ORDERTYPE_STOP; Lower3Order.AttachedOrderStopAllType = SCT_ORDERTYPE_STOP; Lower4Order.AttachedOrderStopAllType = SCT_ORDERTYPE_STOP; Upper1Order.StopAllPrice = RedLineSubgraph[sc.Index] + (RedLineSubgraph[sc.Index] - BlueLineSubgraph[sc.Index]) * StopPerc.GetDouble(); Upper2Order.StopAllPrice = RedLineSubgraph[sc.Index] + (RedLineSubgraph[sc.Index] - BlueLineSubgraph[sc.Index]) * StopPerc.GetDouble(); Upper3Order.StopAllPrice = RedLineSubgraph[sc.Index] + (RedLineSubgraph[sc.Index] - BlueLineSubgraph[sc.Index]) * StopPerc.GetDouble(); Upper4Order.StopAllPrice = RedLineSubgraph[sc.Index] + (RedLineSubgraph[sc.Index] - BlueLineSubgraph[sc.Index]) * StopPerc.GetDouble(); Lower1Order.StopAllPrice = BlueLineSubgraph[sc.Index] - (RedLineSubgraph[sc.Index] - BlueLineSubgraph[sc.Index]) * StopPerc.GetDouble(); Lower2Order.StopAllPrice = BlueLineSubgraph[sc.Index] - (RedLineSubgraph[sc.Index] - BlueLineSubgraph[sc.Index]) * StopPerc.GetDouble(); Lower3Order.StopAllPrice = BlueLineSubgraph[sc.Index] - (RedLineSubgraph[sc.Index] - BlueLineSubgraph[sc.Index]) * StopPerc.GetDouble(); Lower4Order.StopAllPrice = BlueLineSubgraph[sc.Index] - (RedLineSubgraph[sc.Index] - BlueLineSubgraph[sc.Index]) * StopPerc.GetDouble(); //////////////////////////////////////////// if (LongEnabled.GetYesNo()) { sc.BuyEntry(Lower1Order); sc.BuyEntry(Lower2Order); sc.BuyEntry(Lower3Order); sc.BuyEntry(Lower4Order); } if (ShortEnabled.GetYesNo()) { sc.SellEntry(Upper1Order); sc.SellEntry(Upper2Order); sc.SellEntry(Upper3Order); sc.SellEntry(Upper4Order); } |