Overall Statistics |
Total Trades 38 Average Win 0.00% Average Loss -0.01% Compounding Annual Return 0.000% Drawdown 0.000% Expectancy 0.005 Net Profit 0.001% Sharpe Ratio 0.027 Probabilistic Sharpe Ratio 0.006% Loss Rate 5% Win Rate 95% Profit-Loss Ratio 0.06 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.494 Tracking Error 0.183 Treynor Ratio -0.121 Total Fees $1.10 |
namespace QuantConnect { ////////// USDCHF DOWN S1/////////////// /* prices_BID_Open[0] - prices_ASK_Close[0] > 0.002m && prices_BID_Open[0] - prices_ASK_Close[0] < 0.003m && prices_ASK_Close[0] - prices_BID_Close[0] > 0.00001m && prices_ASK_Close[0] - prices_BID_Close[0] < 0.0015m SYMBOL_DOWN_S2_SL = 0.0045m; SYMBOL_DOWN_S2_TP1 = SYMBOL_DOWN_S2_SL * 5; // 30 DAY */ }
namespace QuantConnect { public partial class Base ///ONDATA { public class Alpha_SYMBOL_DOWN_S2 : AlphaModel { private readonly Symbol _symbol; private string SYMBOL = "AUDCHF" ; public Alpha_SYMBOL_DOWN_S2(Symbol symbol) { _symbol = symbol; } public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice data) { var open_orders = algorithm.Transactions.GetOpenOrders(x=>x.Status == OrderStatus.Submitted); if (!open_orders.Any(x=>x.Tag.Contains("SYMBOL_DOWN_S2_OCO1"))) { Base.SYMBOL_OCO1_DOWN_S2_IsReady = true; } if (!open_orders.Any(x=>x.Tag.Contains("SYMBOL_DOWN_S2_OCO2"))) { Base.SYMBOL_OCO2_DOWN_S2_IsReady = true; } if (!open_orders.Any(x=>x.Tag.Contains("SYMBOL_DOWN_S2_OCO3"))) { Base.SYMBOL_OCO3_DOWN_S2_IsReady = true; } if (!open_orders.Any(x=>x.Tag.Contains("SYMBOL_DOWN_S2_OCO4"))) { Base.SYMBOL_OCO4_DOWN_S2_IsReady = true; } if (open_orders.Any(x=>x.Tag.Contains("SYMBOL_DOWN_S2"))) { foreach (var order in open_orders) { if (Base.SYMBOL_OCO1_EO1_DOWN_S2) Base.SYMBOL_OCO1_EO1_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO1_EO2_DOWN_S2) Base.SYMBOL_OCO1_EO2_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO1_EO3_DOWN_S2) Base.SYMBOL_OCO1_EO3_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO1_EO4_DOWN_S2) Base.SYMBOL_OCO1_EO4_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO1_EO5_DOWN_S2) Base.SYMBOL_OCO1_EO5_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO1_EO6_DOWN_S2) Base.SYMBOL_OCO1_EO6_DOWN_S2_ID = order.Id; if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.SYMBOL_DOWN_S2_OCO_DELAY_7DAY)) { int SYMBOL_OCO1S1_DOWN_S2 = 0; for (; SYMBOL_OCO1S1_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets1.Count; SYMBOL_OCO1S1_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets1[SYMBOL_OCO1S1_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO1Sets1[SYMBOL_OCO1S1_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_1__Time out_OCO1"); Base.SYMBOL_DOWN_S2_OCO1Sets1.Clear(); SYMBOL_OCO1S1_DOWN_S2 = 0; break; } int SYMBOL_OCO1S2_DOWN_S2 = 0; for (; SYMBOL_OCO1S2_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets2.Count; SYMBOL_OCO1S2_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets2[SYMBOL_OCO1S2_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO1Sets2[SYMBOL_OCO1S2_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_2__Time out_OCO1"); Base.SYMBOL_DOWN_S2_OCO1Sets2.Clear(); SYMBOL_OCO1S2_DOWN_S2 = 0; break; } int SYMBOL_OCO1S3_DOWN_S2 = 0; for (; SYMBOL_OCO1S3_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets3.Count; SYMBOL_OCO1S3_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets3[SYMBOL_OCO1S3_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO1Sets3[SYMBOL_OCO1S3_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_3__Time out_OCO1"); Base.SYMBOL_DOWN_S2_OCO1Sets3.Clear(); SYMBOL_OCO1S3_DOWN_S2 = 0; break; } int SYMBOL_OCO1S4_DOWN_S2 = 0; for (; SYMBOL_OCO1S4_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets4.Count; SYMBOL_OCO1S4_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets4[SYMBOL_OCO1S4_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO1Sets4[SYMBOL_OCO1S4_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_4__Time out_OCO1"); Base.SYMBOL_DOWN_S2_OCO1Sets4.Clear(); SYMBOL_OCO1S4_DOWN_S2 = 0; break; } int SYMBOL_OCO1S5_DOWN_S2 = 0; for (; SYMBOL_OCO1S5_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets5.Count; SYMBOL_OCO1S5_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets5[SYMBOL_OCO1S5_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO1Sets5[SYMBOL_OCO1S5_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_5__Time out_OCO1"); Base.SYMBOL_DOWN_S2_OCO1Sets5.Clear(); SYMBOL_OCO1S5_DOWN_S2 = 0; break; } int SYMBOL_OCO1S6_DOWN_S2 = 0; for (; SYMBOL_OCO1S6_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets6.Count; SYMBOL_OCO1S6_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets6[SYMBOL_OCO1S6_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO1Sets6[SYMBOL_OCO1S6_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_6__Time out_OCO1"); Base.SYMBOL_DOWN_S2_OCO1Sets6.Clear(); SYMBOL_OCO1S6_DOWN_S2 = 0; break; } } if (Base.SYMBOL_OCO2_EO1_DOWN_S2) Base.SYMBOL_OCO2_EO1_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO2_EO2_DOWN_S2) Base.SYMBOL_OCO2_EO2_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO2_EO3_DOWN_S2) Base.SYMBOL_OCO2_EO3_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO2_EO4_DOWN_S2) Base.SYMBOL_OCO2_EO4_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO2_EO5_DOWN_S2) Base.SYMBOL_OCO2_EO5_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO2_EO6_DOWN_S2) Base.SYMBOL_OCO2_EO6_DOWN_S2_ID = order.Id; if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.SYMBOL_DOWN_S2_OCO_DELAY_7DAY)) { int SYMBOL_OCO2S1_DOWN_S2 = 0; for (; SYMBOL_OCO2S1_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets1.Count; SYMBOL_OCO2S1_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets1[SYMBOL_OCO2S1_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO2Sets1[SYMBOL_OCO2S1_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_1__Time out_OCO2"); Base.SYMBOL_DOWN_S2_OCO2Sets1.Clear(); SYMBOL_OCO2S1_DOWN_S2 = 0; break; } int SYMBOL_OCO2S2_DOWN_S2 = 0; for (; SYMBOL_OCO2S2_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets2.Count; SYMBOL_OCO2S2_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets2[SYMBOL_OCO2S2_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO2Sets2[SYMBOL_OCO2S2_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_2__Time out_OCO2"); Base.SYMBOL_DOWN_S2_OCO2Sets2.Clear(); SYMBOL_OCO2S2_DOWN_S2 = 0; break; } int SYMBOL_OCO2S3_DOWN_S2 = 0; for (; SYMBOL_OCO2S3_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets3.Count; SYMBOL_OCO2S3_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets3[SYMBOL_OCO2S3_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO2Sets3[SYMBOL_OCO2S3_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_3__Time out_OCO2"); Base.SYMBOL_DOWN_S2_OCO2Sets3.Clear(); SYMBOL_OCO2S3_DOWN_S2 = 0; break; } int SYMBOL_OCO2S4_DOWN_S2 = 0; for (; SYMBOL_OCO2S4_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets4.Count; SYMBOL_OCO2S4_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets4[SYMBOL_OCO2S4_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO2Sets4[SYMBOL_OCO2S4_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_4__Time out_OCO2"); Base.SYMBOL_DOWN_S2_OCO2Sets4.Clear(); SYMBOL_OCO2S4_DOWN_S2 = 0; break; } int SYMBOL_OCO2S5_DOWN_S2 = 0; for (; SYMBOL_OCO2S5_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets5.Count; SYMBOL_OCO2S5_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets5[SYMBOL_OCO2S5_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO2Sets5[SYMBOL_OCO2S5_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_5__Time out_OCO2"); Base.SYMBOL_DOWN_S2_OCO2Sets5.Clear(); SYMBOL_OCO2S5_DOWN_S2 = 0; break; } int SYMBOL_OCO2S6_DOWN_S2 = 0; for (; SYMBOL_OCO2S6_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets6.Count; SYMBOL_OCO2S6_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets6[SYMBOL_OCO2S6_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO2Sets6[SYMBOL_OCO2S6_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_6__Time out_OCO2"); Base.SYMBOL_DOWN_S2_OCO2Sets6.Clear(); SYMBOL_OCO2S6_DOWN_S2 = 0; break; } } if (Base.SYMBOL_OCO3_EO1_DOWN_S2) Base.SYMBOL_OCO3_EO1_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO3_EO2_DOWN_S2) Base.SYMBOL_OCO3_EO2_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO3_EO3_DOWN_S2) Base.SYMBOL_OCO3_EO3_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO3_EO4_DOWN_S2) Base.SYMBOL_OCO3_EO4_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO3_EO5_DOWN_S2) Base.SYMBOL_OCO3_EO5_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO3_EO6_DOWN_S2) Base.SYMBOL_OCO3_EO6_DOWN_S2_ID = order.Id; if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.SYMBOL_DOWN_S2_OCO_DELAY_7DAY)) { int SYMBOL_OCO3S1_DOWN_S2 = 0; for (; SYMBOL_OCO3S1_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets1.Count; SYMBOL_OCO3S1_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets1[SYMBOL_OCO3S1_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO3Sets1[SYMBOL_OCO3S1_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_1__Time out_OCO3"); Base.SYMBOL_DOWN_S2_OCO3Sets1.Clear(); SYMBOL_OCO3S1_DOWN_S2 = 0; break; } int SYMBOL_OCO3S2_DOWN_S2 = 0; for (; SYMBOL_OCO3S2_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets2.Count; SYMBOL_OCO3S2_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets2[SYMBOL_OCO3S2_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO3Sets2[SYMBOL_OCO3S2_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_2__Time out_OCO3"); Base.SYMBOL_DOWN_S2_OCO3Sets2.Clear(); SYMBOL_OCO3S2_DOWN_S2 = 0; break; } int SYMBOL_OCO3S3_DOWN_S2 = 0; for (; SYMBOL_OCO3S3_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets3.Count; SYMBOL_OCO3S3_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets3[SYMBOL_OCO3S3_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO3Sets3[SYMBOL_OCO3S3_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_3__Time out_OCO3"); Base.SYMBOL_DOWN_S2_OCO3Sets3.Clear(); SYMBOL_OCO3S3_DOWN_S2 = 0; break; } int SYMBOL_OCO3S4_DOWN_S2 = 0; for (; SYMBOL_OCO3S4_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets4.Count; SYMBOL_OCO3S4_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets4[SYMBOL_OCO3S4_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO3Sets4[SYMBOL_OCO3S4_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_4__Time out_OCO3"); Base.SYMBOL_DOWN_S2_OCO3Sets4.Clear(); SYMBOL_OCO3S4_DOWN_S2 = 0; break; } int SYMBOL_OCO3S5_DOWN_S2 = 0; for (; SYMBOL_OCO3S5_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets5.Count; SYMBOL_OCO3S5_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets5[SYMBOL_OCO3S5_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO3Sets5[SYMBOL_OCO3S5_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_5__Time out_OCO3"); Base.SYMBOL_DOWN_S2_OCO3Sets5.Clear(); SYMBOL_OCO3S5_DOWN_S2 = 0; break; } int SYMBOL_OCO3S6_DOWN_S2 = 0; for (; SYMBOL_OCO3S6_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets6.Count; SYMBOL_OCO3S6_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets6[SYMBOL_OCO3S6_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO3Sets6[SYMBOL_OCO3S6_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_6__Time out_OCO3"); Base.SYMBOL_DOWN_S2_OCO3Sets6.Clear(); SYMBOL_OCO3S6_DOWN_S2 = 0; break; } } if (Base.SYMBOL_OCO4_EO1_DOWN_S2) Base.SYMBOL_OCO4_EO1_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO4_EO2_DOWN_S2) Base.SYMBOL_OCO4_EO2_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO4_EO3_DOWN_S2) Base.SYMBOL_OCO4_EO3_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO4_EO4_DOWN_S2) Base.SYMBOL_OCO4_EO4_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO4_EO5_DOWN_S2) Base.SYMBOL_OCO4_EO5_DOWN_S2_ID = order.Id; if (Base.SYMBOL_OCO4_EO6_DOWN_S2) Base.SYMBOL_OCO4_EO6_DOWN_S2_ID = order.Id; if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.SYMBOL_DOWN_S2_OCO_DELAY_7DAY)) { int SYMBOL_OCO4S1_DOWN_S2 = 0; for (; SYMBOL_OCO4S1_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets1.Count; SYMBOL_OCO4S1_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets1[SYMBOL_OCO4S1_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO4Sets1[SYMBOL_OCO4S1_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_1__Time out_OCO4"); Base.SYMBOL_DOWN_S2_OCO4Sets1.Clear(); SYMBOL_OCO4S1_DOWN_S2 = 0; break; } int SYMBOL_OCO4S2_DOWN_S2 = 0; for (; SYMBOL_OCO4S2_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets2.Count; SYMBOL_OCO4S2_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets2[SYMBOL_OCO4S2_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO4Sets2[SYMBOL_OCO4S2_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_2__Time out_OCO4"); Base.SYMBOL_DOWN_S2_OCO4Sets2.Clear(); SYMBOL_OCO4S2_DOWN_S2 = 0; break; } int SYMBOL_OCO4S3_DOWN_S2 = 0; for (; SYMBOL_OCO4S3_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets3.Count; SYMBOL_OCO4S3_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets3[SYMBOL_OCO4S3_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO4Sets3[SYMBOL_OCO4S3_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_3__Time out_OCO4"); Base.SYMBOL_DOWN_S2_OCO4Sets3.Clear(); SYMBOL_OCO4S3_DOWN_S2 = 0; break; } int SYMBOL_OCO4S4_DOWN_S2 = 0; for (; SYMBOL_OCO4S4_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets4.Count; SYMBOL_OCO4S4_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets4[SYMBOL_OCO4S4_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO4Sets4[SYMBOL_OCO4S4_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_4__Time out_OCO4"); Base.SYMBOL_DOWN_S2_OCO4Sets4.Clear(); SYMBOL_OCO4S4_DOWN_S2 = 0; break; } int SYMBOL_OCO4S5_DOWN_S2 = 0; for (; SYMBOL_OCO4S5_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets5.Count; SYMBOL_OCO4S5_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets5[SYMBOL_OCO4S5_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO4Sets5[SYMBOL_OCO4S5_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_5__Time out_OCO4"); Base.SYMBOL_DOWN_S2_OCO4Sets5.Clear(); SYMBOL_OCO4S5_DOWN_S2 = 0; break; } int SYMBOL_OCO4S6_DOWN_S2 = 0; for (; SYMBOL_OCO4S6_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets6.Count; SYMBOL_OCO4S6_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets6[SYMBOL_OCO4S6_DOWN_S2].InOrders(order.Id)) { Base.SYMBOL_DOWN_S2_OCO4Sets6[SYMBOL_OCO4S6_DOWN_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_DOWN_S2_Entry_6__Time out_OCO4"); Base.SYMBOL_DOWN_S2_OCO4Sets6.Clear(); SYMBOL_OCO4S6_DOWN_S2 = 0; break; } } } } foreach (var SY1D in D1D.Values) { if (SY1D.BQIsReady && SY1D.WasJustUpdated(algorithm.Time)) { if (SY1D.BQ[0] != SY1D.BQ[1]) { Base.SymbolCount = SY1D.Symbol.Value.Count(); } if (SY1D.BQM[0].Close != 0) { algorithm.Debug("High : " + SY1D.BQM[0].High + " Low : " + SY1D.BQM[0].Low + " Time : " + SY1D.BQM[0].Time + " ENDTime : " + SY1D.BQM[0].EndTime); } DOWM_SYMBOL_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday); DOWT_SYMBOL_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday); DOWW_SYMBOL_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday); DOWTH_SYMBOL_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday); DOWR_SYMBOL_DOWN_S2 = DOWM_SYMBOL_DOWN_S2 || DOWT_SYMBOL_DOWN_S2 || DOWW_SYMBOL_DOWN_S2 || DOWTH_SYMBOL_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday; //if (SY1D.Symbol.Equals(SYMBOL)) //{ var prices_BID_Open = SY1D.BQ.Select(x => x.Bid.Open).ToList(); var prices_ASK_Open = SY1D.BQ.Select(x => x.Ask.Open).ToList(); var prices_ASK_Close = SY1D.BQ.Select(x => x.Ask.Close).ToList(); // var prices_BID_Close = SY1D.BQ.Select(x => x.Bid.Close).ToList(); // var prices_ASK_Low = SY1D.BQ.Select(x => x.Ask.Low).ToList(); // var prices_BID_Low = SY1D.BQ.Select(x => x.Bid.Low).ToList(); // var prices_ASK_High = SY1D.BQ.Select(x => x.Ask.High).ToList(); // var prices_BID_High = SY1D.BQ.Select(x => x.Bid.High).ToList(); // var pricesM_BID_Open = SY1D.BQM.Select(x => x.Bid.Open).ToList(); var pricesM_ASK_Open = SY1D.BQM.Select(x => x.Ask.Open).ToList(); var pricesM_ASK_Close = SY1D.BQM.Select(x => x.Ask.Close).ToList(); // var pricesM_BID_Close = SY1D.BQM.Select(x => x.Bid.Close).ToList(); // var pricesM_ASK_Low = SY1D.BQM.Select(x => x.Ask.Low).ToList(); // var pricesM_BID_Low = SY1D.BQM.Select(x => x.Bid.Low).ToList(); // var pricesM_ASK_High = SY1D.BQM.Select(x => x.Ask.High).ToList(); // var pricesM_BID_High = SY1D.BQM.Select(x => x.Bid.High).ToList(); // decimal coefS2 = prices_ASK_Close[0] - prices_BID_Close[0]; int coefIntS2 = (int)(coefS2/0.0001m); if (Base.SYMBOL_OCO1_DOWN_S2_IsReady == false || Base.SYMBOL_OCO2_DOWN_S2_IsReady == false || Base.SYMBOL_OCO3_DOWN_S2_IsReady == false || Base.SYMBOL_OCO4_DOWN_S2_IsReady == false) { Base.SYMBOL_OCO1_DOWN_S2_Monthly_IsReady = false; Base.SYMBOL_OCO2_DOWN_S2_Monthly_IsReady = false; Base.SYMBOL_OCO3_DOWN_S2_Monthly_IsReady = false; Base.SYMBOL_OCO4_DOWN_S2_Monthly_IsReady = false; } if (algorithm.Time == SY1D.BQM[0].EndTime) { Base.SYMBOL_OCO1_DOWN_S2_Monthly_IsReady = true; Base.SYMBOL_OCO2_DOWN_S2_Monthly_IsReady = true; Base.SYMBOL_OCO3_DOWN_S2_Monthly_IsReady = true; Base.SYMBOL_OCO4_DOWN_S2_Monthly_IsReady = true; } SYMBOL_Signal_Condition_DOWN_1 = ( pricesM_ASK_Open[0] - pricesM_BID_Close[0] > Base.Oth_Min_Size && ( prices_ASK_High[0] > pricesM_ASK_High[0] + ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m) ) && prices_ASK_Close[0] - prices_BID_Close[0] > 0 && prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD ); SYMBOL_Signal_Condition_DOWN_2 = ( pricesM_ASK_Open[0] - pricesM_BID_Close[0] > Base.Oth_Min_Size && ( prices_ASK_High[0] > pricesM_ASK_High[0] + ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) ) && prices_ASK_Close[0] - prices_BID_Close[0] > 0 && prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD ); SYMBOL_Signal_Condition_DOWN_3 = ( pricesM_ASK_Open[0] - pricesM_BID_Close[0] > Base.Oth_Min_Size && ( prices_ASK_High[0] > pricesM_ASK_High[0] + ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) ) && prices_ASK_Close[0] - prices_BID_Close[0] > 0 && prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD ); if (SYMBOL_Signal_Condition_DOWN_1) { SYMBOL_DOWN_S2_SL = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m); } if (SYMBOL_Signal_Condition_DOWN_2) { SYMBOL_DOWN_S2_SL = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m); } if (SYMBOL_Signal_Condition_DOWN_3) { SYMBOL_DOWN_S2_SL = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m); } if (SYMBOL_Signal_Condition_DOWN_1) { SYMBOL_DOWN_S2_TP1 = (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.05m ; } if (SYMBOL_Signal_Condition_DOWN_2) { SYMBOL_DOWN_S2_TP1 = (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.1m ; } if (SYMBOL_Signal_Condition_DOWN_3) { SYMBOL_DOWN_S2_TP1 = (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.2m ; } SYMBOL_DOWN_S2_TP2 = SYMBOL_DOWN_S2_SL * 0; SYMBOL_DOWN_S2_TP3 = SYMBOL_DOWN_S2_SL * 0; SYMBOL_DOWN_S2_TP4 = SYMBOL_DOWN_S2_SL * 0; SYMBOL_DOWN_S2_TP5 = SYMBOL_DOWN_S2_SL * 0; SYMBOL_DOWN_S2_TP6 = SYMBOL_DOWN_S2_SL * 0; if (coefIntS2 != 0 && SYMBOL_DOWN_S2_SL != 0) { SYMBOL_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)*0.015m); SYMBOL_quantity_SL_DOWN_S2 = SYMBOL_quantity_DOWN_S2; SYMBOL_quantity_TP1_DOWN_S2 = (SYMBOL_quantity_DOWN_S2 ); SYMBOL_quantity_TP2_DOWN_S2 = (SYMBOL_quantity_TP1_DOWN_S2 * 0); SYMBOL_quantity_TP3_DOWN_S2 = (SYMBOL_quantity_TP2_DOWN_S2 * 0); SYMBOL_quantity_TP4_DOWN_S2 = (SYMBOL_quantity_TP3_DOWN_S2 * 0); SYMBOL_quantity_TP5_DOWN_S2 = (SYMBOL_quantity_TP4_DOWN_S2 * 0); SYMBOL_quantity_TP6_DOWN_S2 = (SYMBOL_quantity_TP5_DOWN_S2 * 0); } oco1: if ((SYMBOL_Signal_Condition_DOWN_1 || SYMBOL_Signal_Condition_DOWN_2 || SYMBOL_Signal_Condition_DOWN_3) && DOWR_SYMBOL_DOWN_S2 && Base.SYMBOL_OCO1_DOWN_S2_IsReady == true && Base.SYMBOL_OCO1_DOWN_S2_Monthly_IsReady == true) { Base.SYMBOL_OCO1_EO1_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP1_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP1_OCO1"); Base.SYMBOL_OCO1_EO1_DOWN_S2 = false; Base.SYMBOL_OCO1_EO2_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP2_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP2_OCO1"); Base.SYMBOL_OCO1_EO2_DOWN_S2 = false; Base.SYMBOL_OCO1_EO3_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP3_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP3_OCO1"); Base.SYMBOL_OCO1_EO3_DOWN_S2 = false; Base.SYMBOL_OCO1_EO4_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP4_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP4_OCO1"); Base.SYMBOL_OCO1_EO4_DOWN_S2 = false; Base.SYMBOL_OCO1_DOWN_S2_IsReady = false; if (Base.SYMBOL_OCO1_DOWN_S2_IsReady == false) break; } oco2: if ((SYMBOL_Signal_Condition_DOWN_1 || SYMBOL_Signal_Condition_DOWN_2 || SYMBOL_Signal_Condition_DOWN_3) && DOWR_SYMBOL_DOWN_S2 && Base.SYMBOL_OCO2_DOWN_S2_IsReady == true && Base.SYMBOL_OCO1_DOWN_S2_IsReady == false && Base.SYMBOL_OCO2_DOWN_S2_Monthly_IsReady == true) { Base.SYMBOL_OCO2_EO1_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP1_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP1_OCO2"); Base.SYMBOL_OCO2_EO1_DOWN_S2 = false; Base.SYMBOL_OCO2_EO2_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP2_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP2_OCO2"); Base.SYMBOL_OCO2_EO2_DOWN_S2 = false; Base.SYMBOL_OCO2_EO3_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP3_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP3_OCO2"); Base.SYMBOL_OCO2_EO3_DOWN_S2 = false; Base.SYMBOL_OCO2_EO4_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP4_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP4_OCO2"); Base.SYMBOL_OCO2_EO4_DOWN_S2 = false; Base.SYMBOL_OCO2_DOWN_S2_IsReady = false; if (Base.SYMBOL_OCO2_DOWN_S2_IsReady == false && Base.SYMBOL_OCO1_DOWN_S2_IsReady == false) break; } oco3: if ((SYMBOL_Signal_Condition_DOWN_1 || SYMBOL_Signal_Condition_DOWN_2 || SYMBOL_Signal_Condition_DOWN_3) && DOWR_SYMBOL_DOWN_S2 && Base.SYMBOL_OCO3_DOWN_S2_IsReady == true && Base.SYMBOL_OCO1_DOWN_S2_IsReady == false && Base.SYMBOL_OCO2_DOWN_S2_IsReady == false && Base.SYMBOL_OCO3_DOWN_S2_Monthly_IsReady == true) { Base.SYMBOL_OCO3_EO1_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP1_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP1_OCO3"); Base.SYMBOL_OCO3_EO1_DOWN_S2 = false; Base.SYMBOL_OCO3_EO2_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP2_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP2_OCO3"); Base.SYMBOL_OCO3_EO2_DOWN_S2 = false; Base.SYMBOL_OCO3_EO3_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP3_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP3_OCO3"); Base.SYMBOL_OCO3_EO3_DOWN_S2 = false; Base.SYMBOL_OCO3_EO4_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP4_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP4_OCO3"); Base.SYMBOL_OCO3_EO4_DOWN_S2 = false; Base.SYMBOL_OCO3_DOWN_S2_IsReady = false; if (Base.SYMBOL_OCO3_DOWN_S2_IsReady == false && Base.SYMBOL_OCO2_DOWN_S2_IsReady == false && Base.SYMBOL_OCO1_DOWN_S2_IsReady == false) break; } oco4: if ((SYMBOL_Signal_Condition_DOWN_1 || SYMBOL_Signal_Condition_DOWN_2 || SYMBOL_Signal_Condition_DOWN_3) && DOWR_SYMBOL_DOWN_S2 && Base.SYMBOL_OCO4_DOWN_S2_IsReady == true && Base.SYMBOL_OCO1_DOWN_S2_IsReady == false && Base.SYMBOL_OCO2_DOWN_S2_IsReady == false && Base.SYMBOL_OCO3_DOWN_S2_IsReady == false && Base.SYMBOL_OCO4_DOWN_S2_Monthly_IsReady == true) { Base.SYMBOL_OCO4_EO1_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP1_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP1_OCO4"); Base.SYMBOL_OCO4_EO1_DOWN_S2 = false; Base.SYMBOL_OCO4_EO2_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP2_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP2_OCO4"); Base.SYMBOL_OCO4_EO2_DOWN_S2 = false; Base.SYMBOL_OCO4_EO3_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP3_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP3_OCO4"); Base.SYMBOL_OCO4_EO3_DOWN_S2 = false; Base.SYMBOL_OCO4_EO4_DOWN_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1); SYMBOL_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP4_DOWN_S2, false,"SYMBOL_DOWN_S2_Entry_TP4_OCO4"); Base.SYMBOL_OCO4_EO4_DOWN_S2 = false; Base.SYMBOL_OCO4_DOWN_S2_IsReady = false; if (Base.SYMBOL_OCO4_DOWN_S2_IsReady == false && Base.SYMBOL_OCO3_DOWN_S2_IsReady == false && Base.SYMBOL_OCO2_DOWN_S2_IsReady == false && Base.SYMBOL_OCO1_DOWN_S2_IsReady == false) break; } yield break; } //} } } } } }
using System; using System.Collections.Generic; using System.Linq; using QuantConnect.Data; using QuantConnect.Data.Consolidators; using QuantConnect.Data.Market; using QuantConnect.Indicators; using QuantConnect.Indicators; using QuantConnect.Orders; using QuantConnect.Algorithm.Framework.Alphas; using QuantConnect.Algorithm.Framework.Execution; using QuantConnect.Algorithm.Framework.Portfolio; using QuantConnect.Algorithm.Framework.Selection; namespace QuantConnect { public partial class Base : QCAlgorithm { public static TimeSpan BP1m = TimeSpan.FromMinutes(1); public static TimeSpan BP1M = TimeSpan.FromDays(1); public static int RLLWS = 8; public static int RLLWSM = 8; public static decimal Yen_Min_SPRD = 0.01m; public static decimal Oth_Min_SPRD = 0.01m; public static decimal Yen_Min_Size = 0.2m; public static decimal Oth_Min_Size = 0.2m; public static decimal Yen_TP_1 = 0.05m; public static decimal Oth_TP_1 = 0.0005m; public static int SymbolCount = 0; public static Dictionary<string, SY1D> D1D = new Dictionary<string, SY1D>(); private SYMBOL_UP_S2_OnOrderEvent up_OnOrderEvent; private SYMBOL_DOWN_S2_OnOrderEvent down_OnOrderEvent; private readonly SecurityManager _securities; List<string> Pairs = new List<string> { //"AUDUSD", //"EURCHF", //"EURGBP", //"EURJPY", //"EURUSD", //"GBPUSD", //"NZDUSD", //"USDCAD", //"USDCHF", //"USDJPY" "USDJPY", }; public override void Initialize() { SetStartDate(2007, 1, 1); SetEndDate(DateTime.Now); SetCash(1000000); Settings.RebalancePortfolioOnInsightChanges = false; Settings.RebalancePortfolioOnSecurityChanges = false; SetBrokerageModel(BrokerageName.AlphaStreams); foreach (var symbol in Pairs) { var _symbol = AddForex(symbol, Resolution.Minute, Market.FXCM); D1D.Add(symbol, new SY1D(_symbol.Symbol, BP1m, BP1M, RLLWS, RLLWSM)); up_OnOrderEvent = new SYMBOL_UP_S2_OnOrderEvent(this); down_OnOrderEvent = new SYMBOL_DOWN_S2_OnOrderEvent(this); } foreach (var kvp in D1D) { var SY1D = kvp.Value; var consolidator1D_Q = (IDataConsolidator)new QuoteBarConsolidator(BP1m); var consolidator1D_QM = (IDataConsolidator)new QuoteBarConsolidator(CalendarTypee.Weekly); consolidator1D_Q.DataConsolidated += (sender, baseData) => { var bar = (QuoteBar)baseData; SY1D.BQ.Add(bar); }; SubscriptionManager.AddConsolidator(SY1D.Symbol, consolidator1D_Q); consolidator1D_QM.DataConsolidated += (sender, baseData) => { var bar = (QuoteBar)baseData; SY1D.BQM.Add(bar); }; SubscriptionManager.AddConsolidator(SY1D.Symbol, consolidator1D_QM); } foreach (var symbol in Pairs) { AddAlpha(new Alpha_SYMBOL_UP_S2(_SYMBOL)); //AddAlpha(new Alpha_SYMBOL_DOWN_S2(_SYMBOL)); } } public override void OnOrderEvent(OrderEvent orderEvent) { up_OnOrderEvent.OnOrderEvent(this, orderEvent); down_OnOrderEvent.OnOrderEvent(this, orderEvent); } public void OnInsightsGeneratedVerifier(IAlgorithm algorithm, GeneratedInsightsCollection insightsCollection) { if ( insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("GBPNZD")) != 1 ) { throw new Exception("Unexpected insights were emitted"); } } } public class SY1D { public readonly Symbol Symbol; public readonly RollingWindow<QuoteBar> BQ; public readonly RollingWindow<QuoteBar> BQM; public readonly TimeSpan BP1m; public readonly TimeSpan BP1M; public RelativeStrengthIndex RSI; public SY1D(Symbol symbol, TimeSpan bP1m, TimeSpan BARM, int RLLWSM, int RLLWS) { Symbol = symbol; BP1m = bP1m; BP1M = BARM; BQ = new RollingWindow<QuoteBar>(RLLWS); BQM = new RollingWindow<QuoteBar>(RLLWSM); } public bool BQIsReady { get { return BQ.IsReady && BQM.IsReady ;} } public bool WasJustUpdated(DateTime current) { return BQ.Count > 0 && BQM.Count > 0 && BQ[0].Time == current - BP1m; } } }
using QuantConnect.Securities; namespace QuantConnect { public partial class Base ///ONDATA { public class Alpha_SYMBOL_UP_S2 : AlphaModel { private readonly Symbol _symbol; private string SYMBOL = "USDJPY" ; public Alpha_SYMBOL_UP_S2(Symbol symbol) { _symbol = symbol; } public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice data) { var open_orders = algorithm.Transactions.GetOpenOrders(x=>x.Status == OrderStatus.Submitted); if (!open_orders.Any()) { algorithm.Liquidate(); } if (!open_orders.Any(x=>x.Tag.Contains("SYMBOL_UP_S2_OCO1"))) { Base.SYMBOL_OCO1_UP_S2_IsReady = true; } if (open_orders.Any(x=>x.Tag.Contains("SYMBOL_UP_S2"))) { foreach (var order in open_orders) { if (Base.SYMBOL_OCO1_EO1_UP_S2) Base.SYMBOL_OCO1_EO1_UP_S2_ID = order.Id; if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.SYMBOL_UP_S2_OCO_DELAY_7DAY)) { int SYMBOL_OCO1S1_UP_S2 = 0; for (; SYMBOL_OCO1S1_UP_S2 < Base.SYMBOL_UP_S2_OCO1Sets1.Count; SYMBOL_OCO1S1_UP_S2++) if (Base.SYMBOL_UP_S2_OCO1Sets1[SYMBOL_OCO1S1_UP_S2].InOrders(order.Id)) { Base.SYMBOL_UP_S2_OCO1Sets1[SYMBOL_OCO1S1_UP_S2].TimeOut(); yield return Insight.Price(SYMBOL, TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1); algorithm.MarketOrder(SYMBOL, order.Quantity, false, "SYMBOL_UP_S2_Entry_1__Time out_OCO1"); Base.SYMBOL_UP_S2_OCO1Sets1.Clear(); SYMBOL_OCO1S1_UP_S2 = 0; break; } } } } foreach (var SY1D in D1D.Values) { if (SY1D.BQIsReady && SY1D.WasJustUpdated(algorithm.Time)) { // MarketOpen = algorithm.Securities[SY1D.Symbol].Exchange.Hours.GetNextMarketOpen(algorithm.Time, false); var holdings = algorithm.Portfolio[SY1D.Symbol].Quantity; if (SY1D.BQ[0] != SY1D.BQ[1]) { Base.SymbolCount = SY1D.Symbol.Value.Count(); } if (SY1D.BQM[0].Close != 0) { //algorithm.Debug("High : " + SY1D.BQM[0].High + " Low : " + SY1D.BQM[0].Low + " Time : " + SY1D.BQM[0].Time + " ENDTime : " + SY1D.BQM[0].EndTime); //algorithm.Debug("MarketOpenTime : " + MarketOpen); //algorithm.Debug("holdings : " + holdings); algorithm.Debug("SYMBOL : " + SY1D.Symbol.Value); } //foreach (KeyValuePair<string, SY1D> d1d in D1D) //{ // Console.WriteLine("Clé: {0}, Valeur: {1}", // d1d.Key, d1d.Value); //} if(!algorithm.Portfolio.Invested && holdings != 0) { algorithm.Liquidate(); } DOWM_SYMBOL_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday); DOWT_SYMBOL_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday); DOWW_SYMBOL_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday); DOWTH_SYMBOL_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday); DOWR_SYMBOL_UP_S2 = DOWM_SYMBOL_UP_S2 || DOWT_SYMBOL_UP_S2 || DOWW_SYMBOL_UP_S2 || DOWTH_SYMBOL_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday; if (SY1D.Symbol.Equals(SYMBOL)) { var prices_BID_Open = SY1D.BQ.Select(x => x.Bid.Open).ToList(); var prices_ASK_Open = SY1D.BQ.Select(x => x.Ask.Open).ToList(); var prices_ASK_Close = SY1D.BQ.Select(x => x.Ask.Close).ToList(); // var prices_BID_Close = SY1D.BQ.Select(x => x.Bid.Close).ToList(); // var prices_ASK_Low = SY1D.BQ.Select(x => x.Ask.Low).ToList(); // var prices_BID_Low = SY1D.BQ.Select(x => x.Bid.Low).ToList(); // var prices_ASK_High = SY1D.BQ.Select(x => x.Ask.High).ToList(); // var prices_BID_High = SY1D.BQ.Select(x => x.Bid.High).ToList(); // var pricesM_BID_Open = SY1D.BQM.Select(x => x.Bid.Open).ToList(); var pricesM_ASK_Open = SY1D.BQM.Select(x => x.Ask.Open).ToList(); var pricesM_ASK_Close = SY1D.BQM.Select(x => x.Ask.Close).ToList(); // var pricesM_BID_Close = SY1D.BQM.Select(x => x.Bid.Close).ToList(); // var pricesM_ASK_Low = SY1D.BQM.Select(x => x.Ask.Low).ToList(); // var pricesM_BID_Low = SY1D.BQM.Select(x => x.Bid.Low).ToList(); // var pricesM_ASK_High = SY1D.BQM.Select(x => x.Ask.High).ToList(); // var pricesM_BID_High = SY1D.BQM.Select(x => x.Bid.High).ToList(); // decimal coefS2 = prices_ASK_Close[0] - prices_BID_Close[0]; int coefIntS2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)*0.015m); if (Base.SYMBOL_OCO1_UP_S2_IsReady == false) { Base.SYMBOL_OCO1_UP_S2_Monthly_IsReady = false; } if (algorithm.Time == SY1D.BQM[0].EndTime) { Base.SYMBOL_OCO1_UP_S2_Monthly_IsReady = true; } SYMBOL_Signal_Condition_UP_1 = ( pricesM_BID_Close[0] - pricesM_ASK_Open[0] > 0.5m && SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0m && SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < 0.1m && ( prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m) && prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m) && (pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m)) - prices_BID_Low[0] > 0.01m ) && prices_ASK_Close[0] - prices_BID_Close[0] > 0 && prices_ASK_Close[0] - prices_BID_Close[0] < 0.1m ); if (SYMBOL_Signal_Condition_UP_1) { SYMBOL_UP_S2_SL = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m); } if (SYMBOL_Signal_Condition_UP_1) { SYMBOL_UP_S2_TP1 = Base.Yen_TP_1 ; } if (coefIntS2 > 1) { SYMBOL_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)*0.015m); SYMBOL_quantity_SL_UP_S2 = SYMBOL_quantity_UP_S2; SYMBOL_quantity_TP1_UP_S2 = (int)Math.Floor(SYMBOL_quantity_UP_S2 * 1m); } oco1: if (SYMBOL_Signal_Condition_UP_1 && DOWR_SYMBOL_UP_S2 && Base.SYMBOL_OCO1_UP_S2_IsReady == true && Base.SYMBOL_OCO1_UP_S2_Monthly_IsReady == true) { Base.SYMBOL_OCO1_EO1_UP_S2 = true; yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1); SYMBOL_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, SYMBOL_quantity_TP1_UP_S2, false,"SYMBOL_UP_S2_Entry_TP1_OCO1"); Base.SYMBOL_OCO1_EO1_UP_S2 = false; Base.SYMBOL_OCO1_UP_S2_IsReady = false; if (Base.SYMBOL_OCO1_UP_S2_IsReady == false) break; } yield break; } } } } } } }
using System; using System.Collections.Generic; using System.Linq; using QuantConnect.Data; using QuantConnect.Data.Consolidators; using QuantConnect.Data.Market; using QuantConnect.Indicators; using QuantConnect.Indicators; using QuantConnect.Orders; using QuantConnect.Algorithm.Framework.Alphas; using QuantConnect.Algorithm.Framework.Execution; using QuantConnect.Algorithm.Framework.Portfolio; using QuantConnect.Algorithm.Framework.Selection; namespace QuantConnect { public partial class Base { public static Symbol _SYMBOL; ///oco1 up public static OrderTicket SYMBOL_OCO1_MO1_UP_S2; public static OrderTicket SYMBOL_OCO1_MO2_UP_S2; public static OrderTicket SYMBOL_OCO1_MO3_UP_S2; public static OrderTicket SYMBOL_OCO1_MO4_UP_S2; public static OrderTicket SYMBOL_OCO1_MO5_UP_S2; public static OrderTicket SYMBOL_OCO1_MO6_UP_S2; public static int SYMBOL_OCO1_EO1_UP_S2_ID ; public static int SYMBOL_OCO1_EO2_UP_S2_ID ; public static int SYMBOL_OCO1_EO3_UP_S2_ID ; public static int SYMBOL_OCO1_EO4_UP_S2_ID ; public static int SYMBOL_OCO1_EO5_UP_S2_ID ; public static int SYMBOL_OCO1_EO6_UP_S2_ID ; public static bool SYMBOL_OCO1_EO1_UP_S2 ; public static bool SYMBOL_OCO1_EO2_UP_S2 ; public static bool SYMBOL_OCO1_EO3_UP_S2 ; public static bool SYMBOL_OCO1_EO4_UP_S2 ; public static bool SYMBOL_OCO1_EO5_UP_S2 ; public static bool SYMBOL_OCO1_EO6_UP_S2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_UP_S2> SYMBOL_OOFE_OCO1_UP_S2_1 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_UP_S2> SYMBOL_OOFE_OCO1_UP_S2_2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_UP_S2> SYMBOL_OOFE_OCO1_UP_S2_3 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_UP_S2> SYMBOL_OOFE_OCO1_UP_S2_4 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_UP_S2> SYMBOL_OOFE_OCO1_UP_S2_5 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_UP_S2> SYMBOL_OOFE_OCO1_UP_S2_6 ; public static SYMBOL_OCO1_UP_S2 SYMBOL_PFO_OCO1_UP_S2_1 ; public static SYMBOL_OCO1_UP_S2 SYMBOL_PFO_OCO1_UP_S2_2 ; public static SYMBOL_OCO1_UP_S2 SYMBOL_PFO_OCO1_UP_S2_3 ; public static SYMBOL_OCO1_UP_S2 SYMBOL_PFO_OCO1_UP_S2_4 ; public static SYMBOL_OCO1_UP_S2 SYMBOL_PFO_OCO1_UP_S2_5 ; public static SYMBOL_OCO1_UP_S2 SYMBOL_PFO_OCO1_UP_S2_6 ; public static List<SYMBOL_OCO1_UP_S2> SYMBOL_UP_S2_OCO1Sets1 = new List<SYMBOL_OCO1_UP_S2>(); public static List<SYMBOL_OCO1_UP_S2> SYMBOL_UP_S2_OCO1Sets2 = new List<SYMBOL_OCO1_UP_S2>(); public static List<SYMBOL_OCO1_UP_S2> SYMBOL_UP_S2_OCO1Sets3 = new List<SYMBOL_OCO1_UP_S2>(); public static List<SYMBOL_OCO1_UP_S2> SYMBOL_UP_S2_OCO1Sets4 = new List<SYMBOL_OCO1_UP_S2>(); public static List<SYMBOL_OCO1_UP_S2> SYMBOL_UP_S2_OCO1Sets5 = new List<SYMBOL_OCO1_UP_S2>(); public static List<SYMBOL_OCO1_UP_S2> SYMBOL_UP_S2_OCO1Sets6 = new List<SYMBOL_OCO1_UP_S2>(); public static bool SYMBOL_OCO1_UP_S2_IsReady = true; public static bool SYMBOL_OCO1_UP_S2_Monthly_IsReady = true; //oco1 down public static OrderTicket SYMBOL_OCO1_MO1_DOWN_S2 ; public static OrderTicket SYMBOL_OCO1_MO2_DOWN_S2 ; public static OrderTicket SYMBOL_OCO1_MO3_DOWN_S2 ; public static OrderTicket SYMBOL_OCO1_MO4_DOWN_S2 ; public static OrderTicket SYMBOL_OCO1_MO5_DOWN_S2 ; public static OrderTicket SYMBOL_OCO1_MO6_DOWN_S2 ; public static int SYMBOL_OCO1_EO1_DOWN_S2_ID ; public static int SYMBOL_OCO1_EO2_DOWN_S2_ID ; public static int SYMBOL_OCO1_EO3_DOWN_S2_ID ; public static int SYMBOL_OCO1_EO4_DOWN_S2_ID ; public static int SYMBOL_OCO1_EO5_DOWN_S2_ID ; public static int SYMBOL_OCO1_EO6_DOWN_S2_ID ; public static bool SYMBOL_OCO1_EO1_DOWN_S2 ; public static bool SYMBOL_OCO1_EO2_DOWN_S2 ; public static bool SYMBOL_OCO1_EO3_DOWN_S2 ; public static bool SYMBOL_OCO1_EO4_DOWN_S2 ; public static bool SYMBOL_OCO1_EO5_DOWN_S2 ; public static bool SYMBOL_OCO1_EO6_DOWN_S2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_DOWN_S2> SYMBOL_OOFE_OCO1_DOWN_S2_1 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_DOWN_S2> SYMBOL_OOFE_OCO1_DOWN_S2_2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_DOWN_S2> SYMBOL_OOFE_OCO1_DOWN_S2_3 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_DOWN_S2> SYMBOL_OOFE_OCO1_DOWN_S2_4 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_DOWN_S2> SYMBOL_OOFE_OCO1_DOWN_S2_5 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO1_DOWN_S2> SYMBOL_OOFE_OCO1_DOWN_S2_6 ; public static SYMBOL_OCO1_DOWN_S2 SYMBOL_PFO_OCO1_DOWN_S2_1 ; public static SYMBOL_OCO1_DOWN_S2 SYMBOL_PFO_OCO1_DOWN_S2_2 ; public static SYMBOL_OCO1_DOWN_S2 SYMBOL_PFO_OCO1_DOWN_S2_3 ; public static SYMBOL_OCO1_DOWN_S2 SYMBOL_PFO_OCO1_DOWN_S2_4 ; public static SYMBOL_OCO1_DOWN_S2 SYMBOL_PFO_OCO1_DOWN_S2_5 ; public static SYMBOL_OCO1_DOWN_S2 SYMBOL_PFO_OCO1_DOWN_S2_6 ; public static List<SYMBOL_OCO1_DOWN_S2> SYMBOL_DOWN_S2_OCO1Sets1 = new List<SYMBOL_OCO1_DOWN_S2>(); public static List<SYMBOL_OCO1_DOWN_S2> SYMBOL_DOWN_S2_OCO1Sets2 = new List<SYMBOL_OCO1_DOWN_S2>(); public static List<SYMBOL_OCO1_DOWN_S2> SYMBOL_DOWN_S2_OCO1Sets3 = new List<SYMBOL_OCO1_DOWN_S2>(); public static List<SYMBOL_OCO1_DOWN_S2> SYMBOL_DOWN_S2_OCO1Sets4 = new List<SYMBOL_OCO1_DOWN_S2>(); public static List<SYMBOL_OCO1_DOWN_S2> SYMBOL_DOWN_S2_OCO1Sets5 = new List<SYMBOL_OCO1_DOWN_S2>(); public static List<SYMBOL_OCO1_DOWN_S2> SYMBOL_DOWN_S2_OCO1Sets6 = new List<SYMBOL_OCO1_DOWN_S2>(); public static bool SYMBOL_OCO1_DOWN_S2_IsReady = true; public static bool SYMBOL_OCO1_DOWN_S2_Monthly_IsReady = true; //oco2 up public static OrderTicket SYMBOL_OCO2_MO1_UP_S2 ; public static OrderTicket SYMBOL_OCO2_MO2_UP_S2 ; public static OrderTicket SYMBOL_OCO2_MO3_UP_S2 ; public static OrderTicket SYMBOL_OCO2_MO4_UP_S2 ; public static OrderTicket SYMBOL_OCO2_MO5_UP_S2 ; public static OrderTicket SYMBOL_OCO2_MO6_UP_S2 ; public static int SYMBOL_OCO2_EO1_UP_S2_ID ; public static int SYMBOL_OCO2_EO2_UP_S2_ID ; public static int SYMBOL_OCO2_EO3_UP_S2_ID ; public static int SYMBOL_OCO2_EO4_UP_S2_ID ; public static int SYMBOL_OCO2_EO5_UP_S2_ID ; public static int SYMBOL_OCO2_EO6_UP_S2_ID ; public static bool SYMBOL_OCO2_EO1_UP_S2 ; public static bool SYMBOL_OCO2_EO2_UP_S2 ; public static bool SYMBOL_OCO2_EO3_UP_S2 ; public static bool SYMBOL_OCO2_EO4_UP_S2 ; public static bool SYMBOL_OCO2_EO5_UP_S2 ; public static bool SYMBOL_OCO2_EO6_UP_S2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_UP_S2> SYMBOL_OOFE_OCO2_UP_S2_1 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_UP_S2> SYMBOL_OOFE_OCO2_UP_S2_2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_UP_S2> SYMBOL_OOFE_OCO2_UP_S2_3 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_UP_S2> SYMBOL_OOFE_OCO2_UP_S2_4 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_UP_S2> SYMBOL_OOFE_OCO2_UP_S2_5 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_UP_S2> SYMBOL_OOFE_OCO2_UP_S2_6 ; public static SYMBOL_OCO2_UP_S2 SYMBOL_PFO_OCO2_UP_S2_1 ; public static SYMBOL_OCO2_UP_S2 SYMBOL_PFO_OCO2_UP_S2_2 ; public static SYMBOL_OCO2_UP_S2 SYMBOL_PFO_OCO2_UP_S2_3 ; public static SYMBOL_OCO2_UP_S2 SYMBOL_PFO_OCO2_UP_S2_4 ; public static SYMBOL_OCO2_UP_S2 SYMBOL_PFO_OCO2_UP_S2_5 ; public static SYMBOL_OCO2_UP_S2 SYMBOL_PFO_OCO2_UP_S2_6 ; public static List<SYMBOL_OCO2_UP_S2> SYMBOL_UP_S2_OCO2Sets1 = new List<SYMBOL_OCO2_UP_S2>(); public static List<SYMBOL_OCO2_UP_S2> SYMBOL_UP_S2_OCO2Sets2 = new List<SYMBOL_OCO2_UP_S2>(); public static List<SYMBOL_OCO2_UP_S2> SYMBOL_UP_S2_OCO2Sets3 = new List<SYMBOL_OCO2_UP_S2>(); public static List<SYMBOL_OCO2_UP_S2> SYMBOL_UP_S2_OCO2Sets4 = new List<SYMBOL_OCO2_UP_S2>(); public static List<SYMBOL_OCO2_UP_S2> SYMBOL_UP_S2_OCO2Sets5 = new List<SYMBOL_OCO2_UP_S2>(); public static List<SYMBOL_OCO2_UP_S2> SYMBOL_UP_S2_OCO2Sets6 = new List<SYMBOL_OCO2_UP_S2>(); public static bool SYMBOL_OCO2_UP_S2_IsReady = true; public static bool SYMBOL_OCO2_UP_S2_Monthly_IsReady = true; //oco2 down public static OrderTicket SYMBOL_OCO2_MO1_DOWN_S2 ; public static OrderTicket SYMBOL_OCO2_MO2_DOWN_S2 ; public static OrderTicket SYMBOL_OCO2_MO3_DOWN_S2 ; public static OrderTicket SYMBOL_OCO2_MO4_DOWN_S2 ; public static OrderTicket SYMBOL_OCO2_MO5_DOWN_S2 ; public static OrderTicket SYMBOL_OCO2_MO6_DOWN_S2 ; public static int SYMBOL_OCO2_EO1_DOWN_S2_ID ; public static int SYMBOL_OCO2_EO2_DOWN_S2_ID ; public static int SYMBOL_OCO2_EO3_DOWN_S2_ID ; public static int SYMBOL_OCO2_EO4_DOWN_S2_ID ; public static int SYMBOL_OCO2_EO5_DOWN_S2_ID ; public static int SYMBOL_OCO2_EO6_DOWN_S2_ID ; public static bool SYMBOL_OCO2_EO1_DOWN_S2 ; public static bool SYMBOL_OCO2_EO2_DOWN_S2 ; public static bool SYMBOL_OCO2_EO3_DOWN_S2 ; public static bool SYMBOL_OCO2_EO4_DOWN_S2 ; public static bool SYMBOL_OCO2_EO5_DOWN_S2 ; public static bool SYMBOL_OCO2_EO6_DOWN_S2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_DOWN_S2> SYMBOL_OOFE_OCO2_DOWN_S2_1 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_DOWN_S2> SYMBOL_OOFE_OCO2_DOWN_S2_2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_DOWN_S2> SYMBOL_OOFE_OCO2_DOWN_S2_3 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_DOWN_S2> SYMBOL_OOFE_OCO2_DOWN_S2_4 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_DOWN_S2> SYMBOL_OOFE_OCO2_DOWN_S2_5 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO2_DOWN_S2> SYMBOL_OOFE_OCO2_DOWN_S2_6 ; public static SYMBOL_OCO2_DOWN_S2 SYMBOL_PFO_OCO2_DOWN_S2_1 ; public static SYMBOL_OCO2_DOWN_S2 SYMBOL_PFO_OCO2_DOWN_S2_2 ; public static SYMBOL_OCO2_DOWN_S2 SYMBOL_PFO_OCO2_DOWN_S2_3 ; public static SYMBOL_OCO2_DOWN_S2 SYMBOL_PFO_OCO2_DOWN_S2_4 ; public static SYMBOL_OCO2_DOWN_S2 SYMBOL_PFO_OCO2_DOWN_S2_5 ; public static SYMBOL_OCO2_DOWN_S2 SYMBOL_PFO_OCO2_DOWN_S2_6 ; public static List<SYMBOL_OCO2_DOWN_S2> SYMBOL_DOWN_S2_OCO2Sets1 = new List<SYMBOL_OCO2_DOWN_S2>(); public static List<SYMBOL_OCO2_DOWN_S2> SYMBOL_DOWN_S2_OCO2Sets2 = new List<SYMBOL_OCO2_DOWN_S2>(); public static List<SYMBOL_OCO2_DOWN_S2> SYMBOL_DOWN_S2_OCO2Sets3 = new List<SYMBOL_OCO2_DOWN_S2>(); public static List<SYMBOL_OCO2_DOWN_S2> SYMBOL_DOWN_S2_OCO2Sets4 = new List<SYMBOL_OCO2_DOWN_S2>(); public static List<SYMBOL_OCO2_DOWN_S2> SYMBOL_DOWN_S2_OCO2Sets5 = new List<SYMBOL_OCO2_DOWN_S2>(); public static List<SYMBOL_OCO2_DOWN_S2> SYMBOL_DOWN_S2_OCO2Sets6 = new List<SYMBOL_OCO2_DOWN_S2>(); public static bool SYMBOL_OCO2_DOWN_S2_IsReady = true; public static bool SYMBOL_OCO2_DOWN_S2_Monthly_IsReady = true; //oco3 up public static OrderTicket SYMBOL_OCO3_MO1_UP_S2 ; public static OrderTicket SYMBOL_OCO3_MO2_UP_S2 ; public static OrderTicket SYMBOL_OCO3_MO3_UP_S2 ; public static OrderTicket SYMBOL_OCO3_MO4_UP_S2 ; public static OrderTicket SYMBOL_OCO3_MO5_UP_S2 ; public static OrderTicket SYMBOL_OCO3_MO6_UP_S2 ; public static int SYMBOL_OCO3_EO1_UP_S2_ID ; public static int SYMBOL_OCO3_EO2_UP_S2_ID ; public static int SYMBOL_OCO3_EO3_UP_S2_ID ; public static int SYMBOL_OCO3_EO4_UP_S2_ID ; public static int SYMBOL_OCO3_EO5_UP_S2_ID ; public static int SYMBOL_OCO3_EO6_UP_S2_ID ; public static bool SYMBOL_OCO3_EO1_UP_S2 ; public static bool SYMBOL_OCO3_EO2_UP_S2 ; public static bool SYMBOL_OCO3_EO3_UP_S2 ; public static bool SYMBOL_OCO3_EO4_UP_S2 ; public static bool SYMBOL_OCO3_EO5_UP_S2 ; public static bool SYMBOL_OCO3_EO6_UP_S2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_UP_S2> SYMBOL_OOFE_OCO3_UP_S2_1 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_UP_S2> SYMBOL_OOFE_OCO3_UP_S2_2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_UP_S2> SYMBOL_OOFE_OCO3_UP_S2_3 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_UP_S2> SYMBOL_OOFE_OCO3_UP_S2_4 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_UP_S2> SYMBOL_OOFE_OCO3_UP_S2_5 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_UP_S2> SYMBOL_OOFE_OCO3_UP_S2_6 ; public static SYMBOL_OCO3_UP_S2 SYMBOL_PFO_OCO3_UP_S2_1 ; public static SYMBOL_OCO3_UP_S2 SYMBOL_PFO_OCO3_UP_S2_2 ; public static SYMBOL_OCO3_UP_S2 SYMBOL_PFO_OCO3_UP_S2_3 ; public static SYMBOL_OCO3_UP_S2 SYMBOL_PFO_OCO3_UP_S2_4 ; public static SYMBOL_OCO3_UP_S2 SYMBOL_PFO_OCO3_UP_S2_5 ; public static SYMBOL_OCO3_UP_S2 SYMBOL_PFO_OCO3_UP_S2_6 ; public static List<SYMBOL_OCO3_UP_S2> SYMBOL_UP_S2_OCO3Sets1 = new List<SYMBOL_OCO3_UP_S2>(); public static List<SYMBOL_OCO3_UP_S2> SYMBOL_UP_S2_OCO3Sets2 = new List<SYMBOL_OCO3_UP_S2>(); public static List<SYMBOL_OCO3_UP_S2> SYMBOL_UP_S2_OCO3Sets3 = new List<SYMBOL_OCO3_UP_S2>(); public static List<SYMBOL_OCO3_UP_S2> SYMBOL_UP_S2_OCO3Sets4 = new List<SYMBOL_OCO3_UP_S2>(); public static List<SYMBOL_OCO3_UP_S2> SYMBOL_UP_S2_OCO3Sets5 = new List<SYMBOL_OCO3_UP_S2>(); public static List<SYMBOL_OCO3_UP_S2> SYMBOL_UP_S2_OCO3Sets6 = new List<SYMBOL_OCO3_UP_S2>(); public static bool SYMBOL_OCO3_UP_S2_IsReady = true; public static bool SYMBOL_OCO3_UP_S2_Monthly_IsReady = true; //oco3 down public static OrderTicket SYMBOL_OCO3_MO1_DOWN_S2 ; public static OrderTicket SYMBOL_OCO3_MO2_DOWN_S2 ; public static OrderTicket SYMBOL_OCO3_MO3_DOWN_S2 ; public static OrderTicket SYMBOL_OCO3_MO4_DOWN_S2 ; public static OrderTicket SYMBOL_OCO3_MO5_DOWN_S2 ; public static OrderTicket SYMBOL_OCO3_MO6_DOWN_S2 ; public static int SYMBOL_OCO3_EO1_DOWN_S2_ID ; public static int SYMBOL_OCO3_EO2_DOWN_S2_ID ; public static int SYMBOL_OCO3_EO3_DOWN_S2_ID ; public static int SYMBOL_OCO3_EO4_DOWN_S2_ID ; public static int SYMBOL_OCO3_EO5_DOWN_S2_ID ; public static int SYMBOL_OCO3_EO6_DOWN_S2_ID ; public static bool SYMBOL_OCO3_EO1_DOWN_S2 ; public static bool SYMBOL_OCO3_EO2_DOWN_S2 ; public static bool SYMBOL_OCO3_EO3_DOWN_S2 ; public static bool SYMBOL_OCO3_EO4_DOWN_S2 ; public static bool SYMBOL_OCO3_EO5_DOWN_S2 ; public static bool SYMBOL_OCO3_EO6_DOWN_S2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_DOWN_S2> SYMBOL_OOFE_OCO3_DOWN_S2_1 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_DOWN_S2> SYMBOL_OOFE_OCO3_DOWN_S2_2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_DOWN_S2> SYMBOL_OOFE_OCO3_DOWN_S2_3 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_DOWN_S2> SYMBOL_OOFE_OCO3_DOWN_S2_4 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_DOWN_S2> SYMBOL_OOFE_OCO3_DOWN_S2_5 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO3_DOWN_S2> SYMBOL_OOFE_OCO3_DOWN_S2_6 ; public static SYMBOL_OCO3_DOWN_S2 SYMBOL_PFO_OCO3_DOWN_S2_1 ; public static SYMBOL_OCO3_DOWN_S2 SYMBOL_PFO_OCO3_DOWN_S2_2 ; public static SYMBOL_OCO3_DOWN_S2 SYMBOL_PFO_OCO3_DOWN_S2_3 ; public static SYMBOL_OCO3_DOWN_S2 SYMBOL_PFO_OCO3_DOWN_S2_4 ; public static SYMBOL_OCO3_DOWN_S2 SYMBOL_PFO_OCO3_DOWN_S2_5 ; public static SYMBOL_OCO3_DOWN_S2 SYMBOL_PFO_OCO3_DOWN_S2_6 ; public static List<SYMBOL_OCO3_DOWN_S2> SYMBOL_DOWN_S2_OCO3Sets1 = new List<SYMBOL_OCO3_DOWN_S2>(); public static List<SYMBOL_OCO3_DOWN_S2> SYMBOL_DOWN_S2_OCO3Sets2 = new List<SYMBOL_OCO3_DOWN_S2>(); public static List<SYMBOL_OCO3_DOWN_S2> SYMBOL_DOWN_S2_OCO3Sets3 = new List<SYMBOL_OCO3_DOWN_S2>(); public static List<SYMBOL_OCO3_DOWN_S2> SYMBOL_DOWN_S2_OCO3Sets4 = new List<SYMBOL_OCO3_DOWN_S2>(); public static List<SYMBOL_OCO3_DOWN_S2> SYMBOL_DOWN_S2_OCO3Sets5 = new List<SYMBOL_OCO3_DOWN_S2>(); public static List<SYMBOL_OCO3_DOWN_S2> SYMBOL_DOWN_S2_OCO3Sets6 = new List<SYMBOL_OCO3_DOWN_S2>(); public static bool SYMBOL_OCO3_DOWN_S2_IsReady = true; public static bool SYMBOL_OCO3_DOWN_S2_Monthly_IsReady = true; //oco4 up public static OrderTicket SYMBOL_OCO4_MO1_UP_S2 ; public static OrderTicket SYMBOL_OCO4_MO2_UP_S2 ; public static OrderTicket SYMBOL_OCO4_MO3_UP_S2 ; public static OrderTicket SYMBOL_OCO4_MO4_UP_S2 ; public static OrderTicket SYMBOL_OCO4_MO5_UP_S2 ; public static OrderTicket SYMBOL_OCO4_MO6_UP_S2 ; public static int SYMBOL_OCO4_EO1_UP_S2_ID ; public static int SYMBOL_OCO4_EO2_UP_S2_ID ; public static int SYMBOL_OCO4_EO3_UP_S2_ID ; public static int SYMBOL_OCO4_EO4_UP_S2_ID ; public static int SYMBOL_OCO4_EO5_UP_S2_ID ; public static int SYMBOL_OCO4_EO6_UP_S2_ID ; public static bool SYMBOL_OCO4_EO1_UP_S2 ; public static bool SYMBOL_OCO4_EO2_UP_S2 ; public static bool SYMBOL_OCO4_EO3_UP_S2 ; public static bool SYMBOL_OCO4_EO4_UP_S2 ; public static bool SYMBOL_OCO4_EO5_UP_S2 ; public static bool SYMBOL_OCO4_EO6_UP_S2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_UP_S2> SYMBOL_OOFE_OCO4_UP_S2_1 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_UP_S2> SYMBOL_OOFE_OCO4_UP_S2_2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_UP_S2> SYMBOL_OOFE_OCO4_UP_S2_3 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_UP_S2> SYMBOL_OOFE_OCO4_UP_S2_4 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_UP_S2> SYMBOL_OOFE_OCO4_UP_S2_5 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_UP_S2> SYMBOL_OOFE_OCO4_UP_S2_6 ; public static SYMBOL_OCO4_UP_S2 SYMBOL_PFO_OCO4_UP_S2_1 ; public static SYMBOL_OCO4_UP_S2 SYMBOL_PFO_OCO4_UP_S2_2 ; public static SYMBOL_OCO4_UP_S2 SYMBOL_PFO_OCO4_UP_S2_3 ; public static SYMBOL_OCO4_UP_S2 SYMBOL_PFO_OCO4_UP_S2_4 ; public static SYMBOL_OCO4_UP_S2 SYMBOL_PFO_OCO4_UP_S2_5 ; public static SYMBOL_OCO4_UP_S2 SYMBOL_PFO_OCO4_UP_S2_6 ; public static List<SYMBOL_OCO4_UP_S2> SYMBOL_UP_S2_OCO4Sets1 = new List<SYMBOL_OCO4_UP_S2>(); public static List<SYMBOL_OCO4_UP_S2> SYMBOL_UP_S2_OCO4Sets2 = new List<SYMBOL_OCO4_UP_S2>(); public static List<SYMBOL_OCO4_UP_S2> SYMBOL_UP_S2_OCO4Sets3 = new List<SYMBOL_OCO4_UP_S2>(); public static List<SYMBOL_OCO4_UP_S2> SYMBOL_UP_S2_OCO4Sets4 = new List<SYMBOL_OCO4_UP_S2>(); public static List<SYMBOL_OCO4_UP_S2> SYMBOL_UP_S2_OCO4Sets5 = new List<SYMBOL_OCO4_UP_S2>(); public static List<SYMBOL_OCO4_UP_S2> SYMBOL_UP_S2_OCO4Sets6 = new List<SYMBOL_OCO4_UP_S2>(); public static bool SYMBOL_OCO4_UP_S2_IsReady = true; public static bool SYMBOL_OCO4_UP_S2_Monthly_IsReady = true; //oco4 down public static OrderTicket SYMBOL_OCO4_MO1_DOWN_S2 ; public static OrderTicket SYMBOL_OCO4_MO2_DOWN_S2 ; public static OrderTicket SYMBOL_OCO4_MO3_DOWN_S2 ; public static OrderTicket SYMBOL_OCO4_MO4_DOWN_S2 ; public static OrderTicket SYMBOL_OCO4_MO5_DOWN_S2 ; public static OrderTicket SYMBOL_OCO4_MO6_DOWN_S2 ; public static int SYMBOL_OCO4_EO1_DOWN_S2_ID ; public static int SYMBOL_OCO4_EO2_DOWN_S2_ID ; public static int SYMBOL_OCO4_EO3_DOWN_S2_ID ; public static int SYMBOL_OCO4_EO4_DOWN_S2_ID ; public static int SYMBOL_OCO4_EO5_DOWN_S2_ID ; public static int SYMBOL_OCO4_EO6_DOWN_S2_ID ; public static bool SYMBOL_OCO4_EO1_DOWN_S2 ; public static bool SYMBOL_OCO4_EO2_DOWN_S2 ; public static bool SYMBOL_OCO4_EO3_DOWN_S2 ; public static bool SYMBOL_OCO4_EO4_DOWN_S2 ; public static bool SYMBOL_OCO4_EO5_DOWN_S2 ; public static bool SYMBOL_OCO4_EO6_DOWN_S2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_DOWN_S2> SYMBOL_OOFE_OCO4_DOWN_S2_1 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_DOWN_S2> SYMBOL_OOFE_OCO4_DOWN_S2_2 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_DOWN_S2> SYMBOL_OOFE_OCO4_DOWN_S2_3 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_DOWN_S2> SYMBOL_OOFE_OCO4_DOWN_S2_4 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_DOWN_S2> SYMBOL_OOFE_OCO4_DOWN_S2_5 ; public static Func<QCAlgorithm, string, decimal, decimal, SYMBOL_OCO4_DOWN_S2> SYMBOL_OOFE_OCO4_DOWN_S2_6 ; public static SYMBOL_OCO4_DOWN_S2 SYMBOL_PFO_OCO4_DOWN_S2_1 ; public static SYMBOL_OCO4_DOWN_S2 SYMBOL_PFO_OCO4_DOWN_S2_2 ; public static SYMBOL_OCO4_DOWN_S2 SYMBOL_PFO_OCO4_DOWN_S2_3 ; public static SYMBOL_OCO4_DOWN_S2 SYMBOL_PFO_OCO4_DOWN_S2_4 ; public static SYMBOL_OCO4_DOWN_S2 SYMBOL_PFO_OCO4_DOWN_S2_5 ; public static SYMBOL_OCO4_DOWN_S2 SYMBOL_PFO_OCO4_DOWN_S2_6 ; public static List<SYMBOL_OCO4_DOWN_S2> SYMBOL_DOWN_S2_OCO4Sets1 = new List<SYMBOL_OCO4_DOWN_S2>(); public static List<SYMBOL_OCO4_DOWN_S2> SYMBOL_DOWN_S2_OCO4Sets2 = new List<SYMBOL_OCO4_DOWN_S2>(); public static List<SYMBOL_OCO4_DOWN_S2> SYMBOL_DOWN_S2_OCO4Sets3 = new List<SYMBOL_OCO4_DOWN_S2>(); public static List<SYMBOL_OCO4_DOWN_S2> SYMBOL_DOWN_S2_OCO4Sets4 = new List<SYMBOL_OCO4_DOWN_S2>(); public static List<SYMBOL_OCO4_DOWN_S2> SYMBOL_DOWN_S2_OCO4Sets5 = new List<SYMBOL_OCO4_DOWN_S2>(); public static List<SYMBOL_OCO4_DOWN_S2> SYMBOL_DOWN_S2_OCO4Sets6 = new List<SYMBOL_OCO4_DOWN_S2>(); public static bool SYMBOL_OCO4_DOWN_S2_IsReady = true; public static bool SYMBOL_OCO4_DOWN_S2_Monthly_IsReady = true; //////////////////////////// public static decimal SYMBOL_UP_S2_SL {get; set;} public static decimal SYMBOL_UP_S2_TP1 {get; set;} public static decimal SYMBOL_UP_S2_TP2 {get; set;} public static decimal SYMBOL_UP_S2_TP3 {get; set;} public static decimal SYMBOL_UP_S2_TP4 {get; set;} public static decimal SYMBOL_UP_S2_TP5 {get; set;} public static decimal SYMBOL_UP_S2_TP6 {get; set;} public static decimal SYMBOL_DOWN_S2_SL {get; set;} public static decimal SYMBOL_DOWN_S2_TP1 {get; set;} public static decimal SYMBOL_DOWN_S2_TP2 {get; set;} public static decimal SYMBOL_DOWN_S2_TP3 {get; set;} public static decimal SYMBOL_DOWN_S2_TP4 {get; set;} public static decimal SYMBOL_DOWN_S2_TP5 {get; set;} public static decimal SYMBOL_DOWN_S2_TP6 {get; set;} public static bool SYMBOL_Signal_Condition_UP_1 ; public static bool SYMBOL_Signal_Condition_UP_2 ; public static bool SYMBOL_Signal_Condition_UP_3 ; public static bool SYMBOL_Signal_Condition_DOWN_1 ; public static bool SYMBOL_Signal_Condition_DOWN_2 ; public static bool SYMBOL_Signal_Condition_DOWN_3 ; public static int SYMBOL_UP_S2_OCO_DELAY_30DAY = 10080; public static int SYMBOL_UP_S2_OCO_DELAY_7DAY = 10080; public static int SYMBOL_UP_S2_OCOM_DELAY_DAY = 4320; public static int SYMBOL_UP_S2_OCOT_DELAY_DAY = 2880; public static int SYMBOL_UP_S2_OCOW_DELAY_DAY = 1440; public static int SYMBOL_UP_S2_OCOTH_DELAY_DAY = 720; public static int SYMBOL_DOWN_S2_OCO_DELAY_30DAY = 10080; public static int SYMBOL_DOWN_S2_OCO_DELAY_7DAY = 10080; public static int SYMBOL_DOWN_S2_OCOM_DELAY_DAY = 4320; public static int SYMBOL_DOWN_S2_OCOT_DELAY_DAY = 2880; public static int SYMBOL_DOWN_S2_OCOW_DELAY_DAY = 1440; public static int SYMBOL_DOWN_S2_OCOTH_DELAY_DAY = 720; public static bool DOWR_SYMBOL_UP_S2 ; public static bool DOWM_SYMBOL_UP_S2 ; public static bool DOWT_SYMBOL_UP_S2 ; public static bool DOWW_SYMBOL_UP_S2 ; public static bool DOWTH_SYMBOL_UP_S2 ; public static bool DOWR_SYMBOL_DOWN_S2 ; public static bool DOWM_SYMBOL_DOWN_S2 ; public static bool DOWT_SYMBOL_DOWN_S2 ; public static bool DOWW_SYMBOL_DOWN_S2 ; public static bool DOWTH_SYMBOL_DOWN_S2 ; public static decimal SYMBOL_quantity_UP_S2 ; public static decimal SYMBOL_quantity_SL_UP_S2 ; public static decimal SYMBOL_quantity_TP1_UP_S2 ; public static decimal SYMBOL_quantity_TP2_UP_S2 ; public static decimal SYMBOL_quantity_TP3_UP_S2 ; public static decimal SYMBOL_quantity_TP4_UP_S2 ; public static decimal SYMBOL_quantity_TP5_UP_S2; public static decimal SYMBOL_quantity_TP6_UP_S2 ; public static decimal SYMBOL_quantity_DOWN_S2 ; public static decimal SYMBOL_quantity_SL_DOWN_S2 ; public static decimal SYMBOL_quantity_TP1_DOWN_S2 ; public static decimal SYMBOL_quantity_TP2_DOWN_S2 ; public static decimal SYMBOL_quantity_TP3_DOWN_S2 ; public static decimal SYMBOL_quantity_TP4_DOWN_S2 ; public static decimal SYMBOL_quantity_TP5_DOWN_S2; public static decimal SYMBOL_quantity_TP6_DOWN_S2 ; } }
using System; using System.Collections.Generic; using System.Linq; using QuantConnect.Data; using QuantConnect.Data.Consolidators; using QuantConnect.Data.Market; using QuantConnect.Indicators; using QuantConnect.Orders; using QuantConnect.Algorithm.Framework.Alphas; using QuantConnect.Algorithm.Framework.Execution; using QuantConnect.Algorithm.Framework.Portfolio; using QuantConnect.Algorithm.Framework.Selection; namespace QuantConnect { public struct SYMBOL_UP_S2_OnOrderEvent { private QCAlgorithm _algorithm; public SYMBOL_UP_S2_OnOrderEvent(QCAlgorithm algorithm) { _algorithm = algorithm; } public void OnOrderEvent(QCAlgorithm _algorithm, OrderEvent orderEvent) { var OrderID = _algorithm.Transactions.GetOrderById(orderEvent.OrderId); if (orderEvent.Status == OrderStatus.Filled) { if (OrderID.Tag.StartsWith("SYMBOL OCO1 CANCEL 1 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO2 CANCEL 1 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO3 CANCEL 1 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO4 CANCEL 1 UP S2")) { _algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue SYMBOL S2"); } if (OrderID.Tag.StartsWith("SYMBOL OCO1 CANCEL 2 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO2 CANCEL 2 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO3 CANCEL 2 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO4 CANCEL 2 UP S2")) { _algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue SYMBOL S2"); } if (OrderID.Tag.StartsWith("SYMBOL OCO1 CANCEL 3 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO2 CANCEL 3 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO3 CANCEL 3 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO4 CANCEL 3 UP S2")) { _algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue SYMBOL S2"); } if (OrderID.Tag.StartsWith("SYMBOL OCO1 CANCEL 4 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO2 CANCEL 4 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO3 CANCEL 4 UP S2") || OrderID.Tag.StartsWith("SYMBOL OCO4 CANCEL 4 UP S2")) { _algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue SYMBOL S2"); } } if (Base.SYMBOL_OCO1_EO1_UP_S2) Base.SYMBOL_OCO1_EO1_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO1_EO2_UP_S2) Base.SYMBOL_OCO1_EO2_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO1_EO3_UP_S2) Base.SYMBOL_OCO1_EO3_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO1_EO4_UP_S2) Base.SYMBOL_OCO1_EO4_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO1_EO5_UP_S2) Base.SYMBOL_OCO1_EO5_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO1_EO6_UP_S2) Base.SYMBOL_OCO1_EO6_UP_S2_ID = orderEvent.OrderId; if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled) { if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO1_UP_S2_ID) { Base.SYMBOL_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_UP_S2( algo1.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP1,"TP1_SYMBOL_UP_S2_OCO1"), algo1.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP1_SYMBOL_UP_S2_OCO1")); }; Base.SYMBOL_UP_S2_OCO1Sets1.Add( Base.SYMBOL_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO1_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO2_UP_S2_ID) { Base.SYMBOL_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_UP_S2( algo2.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP2,"TP2_SYMBOL_UP_S2_OCO1"), algo2.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP2_SYMBOL_UP_S2_OCO1")); }; Base.SYMBOL_UP_S2_OCO1Sets2.Add( Base.SYMBOL_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO2_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO3_UP_S2_ID) { Base.SYMBOL_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_UP_S2( algo3.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP3,"TP3_SYMBOL_UP_S2_OCO1"), algo3.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP3_SYMBOL_UP_S2_OCO1")); }; Base.SYMBOL_UP_S2_OCO1Sets3.Add( Base.SYMBOL_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO3_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO4_UP_S2_ID) { Base.SYMBOL_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_UP_S2( algo4.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP4,"TP4_SYMBOL_UP_S2_OCO1"), algo4.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP4_SYMBOL_UP_S2_OCO1")); }; Base.SYMBOL_UP_S2_OCO1Sets4.Add( Base.SYMBOL_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO4_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO5_UP_S2_ID) { Base.SYMBOL_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_UP_S2( algo5.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP5,"TP5_SYMBOL_UP_S2_OCO1"), algo5.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP5_SYMBOL_UP_S2_OCO1")); }; Base.SYMBOL_UP_S2_OCO1Sets5.Add( Base.SYMBOL_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO5_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO6_UP_S2_ID) { Base.SYMBOL_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_UP_S2( algo6.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP6,"TP6_SYMBOL_UP_S2_OCO1"), algo6.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP6_SYMBOL_UP_S2_OCO1")); }; Base.SYMBOL_UP_S2_OCO1Sets6.Add( Base.SYMBOL_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO6_UP_S2_ID = -1; } int SYMBOL_OCO1S1_UP_S2 = 0; for (; SYMBOL_OCO1S1_UP_S2 < Base.SYMBOL_UP_S2_OCO1Sets1.Count; SYMBOL_OCO1S1_UP_S2++) if (Base.SYMBOL_UP_S2_OCO1Sets1[SYMBOL_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO1Sets1[SYMBOL_OCO1S1_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO1Sets1.RemoveAt(SYMBOL_OCO1S1_UP_S2); SYMBOL_OCO1S1_UP_S2 = 0; break; } int SYMBOL_OCO1S2_UP_S2 = 0; for (; SYMBOL_OCO1S2_UP_S2 < Base.SYMBOL_UP_S2_OCO1Sets2.Count; SYMBOL_OCO1S2_UP_S2++) if (Base.SYMBOL_UP_S2_OCO1Sets2[SYMBOL_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO1Sets2[SYMBOL_OCO1S2_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO1Sets2.RemoveAt(SYMBOL_OCO1S2_UP_S2); SYMBOL_OCO1S2_UP_S2 = 0; break; } int SYMBOL_OCO1S3_UP_S2 = 0; for (; SYMBOL_OCO1S3_UP_S2 < Base.SYMBOL_UP_S2_OCO1Sets3.Count; SYMBOL_OCO1S3_UP_S2++) if (Base.SYMBOL_UP_S2_OCO1Sets3[SYMBOL_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO1Sets3[SYMBOL_OCO1S3_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO1Sets3.RemoveAt(SYMBOL_OCO1S3_UP_S2); SYMBOL_OCO1S3_UP_S2 = 0; break; } int SYMBOL_OCO1S4_UP_S2 = 0; for (; SYMBOL_OCO1S4_UP_S2 < Base.SYMBOL_UP_S2_OCO1Sets4.Count; SYMBOL_OCO1S4_UP_S2++) if (Base.SYMBOL_UP_S2_OCO1Sets4[SYMBOL_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO1Sets4[SYMBOL_OCO1S4_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO1Sets4.RemoveAt(SYMBOL_OCO1S4_UP_S2); SYMBOL_OCO1S4_UP_S2 = 0; break; } int SYMBOL_OCO1S5_UP_S2 = 0; for (; SYMBOL_OCO1S5_UP_S2 < Base.SYMBOL_UP_S2_OCO1Sets5.Count; SYMBOL_OCO1S5_UP_S2++) if (Base.SYMBOL_UP_S2_OCO1Sets5[SYMBOL_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO1Sets5[SYMBOL_OCO1S5_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO1Sets5.RemoveAt(SYMBOL_OCO1S5_UP_S2); SYMBOL_OCO1S5_UP_S2 = 0; break; } int SYMBOL_OCO1S6_UP_S2 = 0; for (; SYMBOL_OCO1S6_UP_S2 < Base.SYMBOL_UP_S2_OCO1Sets6.Count; SYMBOL_OCO1S6_UP_S2++) if (Base.SYMBOL_UP_S2_OCO1Sets6[SYMBOL_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO1Sets6[SYMBOL_OCO1S6_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO1Sets6.RemoveAt(SYMBOL_OCO1S6_UP_S2); SYMBOL_OCO1S6_UP_S2 = 0; break; } } if (Base.SYMBOL_OCO2_EO1_UP_S2) Base.SYMBOL_OCO2_EO1_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO2_EO2_UP_S2) Base.SYMBOL_OCO2_EO2_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO2_EO3_UP_S2) Base.SYMBOL_OCO2_EO3_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO2_EO4_UP_S2) Base.SYMBOL_OCO2_EO4_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO2_EO5_UP_S2) Base.SYMBOL_OCO2_EO5_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO2_EO6_UP_S2) Base.SYMBOL_OCO2_EO6_UP_S2_ID = orderEvent.OrderId; if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled) { if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO1_UP_S2_ID) { Base.SYMBOL_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_UP_S2( algo1.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP1,"TP1_SYMBOL_UP_S2_OCO2"), algo1.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP1_SYMBOL_UP_S2_OCO2")); }; Base.SYMBOL_UP_S2_OCO2Sets1.Add( Base.SYMBOL_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO1_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO2_UP_S2_ID) { Base.SYMBOL_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_UP_S2( algo2.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP2,"TP2_SYMBOL_UP_S2_OCO2"), algo2.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP2_SYMBOL_UP_S2_OCO2")); }; Base.SYMBOL_UP_S2_OCO2Sets2.Add( Base.SYMBOL_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO2_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO3_UP_S2_ID) { Base.SYMBOL_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_UP_S2( algo3.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP3,"TP3_SYMBOL_UP_S2_OCO2"), algo3.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP3_SYMBOL_UP_S2_OCO2")); }; Base.SYMBOL_UP_S2_OCO2Sets3.Add( Base.SYMBOL_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO3_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO4_UP_S2_ID) { Base.SYMBOL_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_UP_S2( algo4.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP4,"TP4_SYMBOL_UP_S2_OCO2"), algo4.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP4_SYMBOL_UP_S2_OCO2")); }; Base.SYMBOL_UP_S2_OCO2Sets4.Add( Base.SYMBOL_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO4_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO5_UP_S2_ID) { Base.SYMBOL_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_UP_S2( algo5.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP5,"TP5_SYMBOL_UP_S2_OCO2"), algo5.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP5_SYMBOL_UP_S2_OCO2")); }; Base.SYMBOL_UP_S2_OCO2Sets5.Add( Base.SYMBOL_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO5_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO6_UP_S2_ID) { Base.SYMBOL_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_UP_S2( algo6.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP6,"TP6_SYMBOL_UP_S2_OCO2"), algo6.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP6_SYMBOL_UP_S2_OCO2")); }; Base.SYMBOL_UP_S2_OCO2Sets6.Add( Base.SYMBOL_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO6_UP_S2_ID = -1; } int SYMBOL_OCO2S1_UP_S2 = 0; for (; SYMBOL_OCO2S1_UP_S2 < Base.SYMBOL_UP_S2_OCO2Sets1.Count; SYMBOL_OCO2S1_UP_S2++) if (Base.SYMBOL_UP_S2_OCO2Sets1[SYMBOL_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO2Sets1[SYMBOL_OCO2S1_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO2Sets1.RemoveAt(SYMBOL_OCO2S1_UP_S2); SYMBOL_OCO2S1_UP_S2 = 0; break; } int SYMBOL_OCO2S2_UP_S2 = 0; for (; SYMBOL_OCO2S2_UP_S2 < Base.SYMBOL_UP_S2_OCO2Sets2.Count; SYMBOL_OCO2S2_UP_S2++) if (Base.SYMBOL_UP_S2_OCO2Sets2[SYMBOL_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO2Sets2[SYMBOL_OCO2S2_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO2Sets2.RemoveAt(SYMBOL_OCO2S2_UP_S2); SYMBOL_OCO2S2_UP_S2 = 0; break; } int SYMBOL_OCO2S3_UP_S2 = 0; for (; SYMBOL_OCO2S3_UP_S2 < Base.SYMBOL_UP_S2_OCO2Sets3.Count; SYMBOL_OCO2S3_UP_S2++) if (Base.SYMBOL_UP_S2_OCO2Sets3[SYMBOL_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO2Sets3[SYMBOL_OCO2S3_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO2Sets3.RemoveAt(SYMBOL_OCO2S3_UP_S2); SYMBOL_OCO2S3_UP_S2 = 0; break; } int SYMBOL_OCO2S4_UP_S2 = 0; for (; SYMBOL_OCO2S4_UP_S2 < Base.SYMBOL_UP_S2_OCO2Sets4.Count; SYMBOL_OCO2S4_UP_S2++) if (Base.SYMBOL_UP_S2_OCO2Sets4[SYMBOL_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO2Sets4[SYMBOL_OCO2S4_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO2Sets4.RemoveAt(SYMBOL_OCO2S4_UP_S2); SYMBOL_OCO2S4_UP_S2 = 0; break; } int SYMBOL_OCO2S5_UP_S2 = 0; for (; SYMBOL_OCO2S5_UP_S2 < Base.SYMBOL_UP_S2_OCO2Sets5.Count; SYMBOL_OCO2S5_UP_S2++) if (Base.SYMBOL_UP_S2_OCO2Sets5[SYMBOL_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO2Sets5[SYMBOL_OCO2S5_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO2Sets5.RemoveAt(SYMBOL_OCO2S5_UP_S2); SYMBOL_OCO2S5_UP_S2 = 0; break; } int SYMBOL_OCO2S6_UP_S2 = 0; for (; SYMBOL_OCO2S6_UP_S2 < Base.SYMBOL_UP_S2_OCO2Sets6.Count; SYMBOL_OCO2S6_UP_S2++) if (Base.SYMBOL_UP_S2_OCO2Sets6[SYMBOL_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO2Sets6[SYMBOL_OCO2S6_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO2Sets6.RemoveAt(SYMBOL_OCO2S6_UP_S2); SYMBOL_OCO2S6_UP_S2 = 0; break; } } if (Base.SYMBOL_OCO3_EO1_UP_S2) Base.SYMBOL_OCO3_EO1_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO3_EO2_UP_S2) Base.SYMBOL_OCO3_EO2_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO3_EO3_UP_S2) Base.SYMBOL_OCO3_EO3_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO3_EO4_UP_S2) Base.SYMBOL_OCO3_EO4_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO3_EO5_UP_S2) Base.SYMBOL_OCO3_EO5_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO3_EO6_UP_S2) Base.SYMBOL_OCO3_EO6_UP_S2_ID = orderEvent.OrderId; if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled) { if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO1_UP_S2_ID) { Base.SYMBOL_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_UP_S2( algo1.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP1,"TP1_SYMBOL_UP_S2_OCO3"), algo1.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP1_SYMBOL_UP_S2_OCO3")); }; Base.SYMBOL_UP_S2_OCO3Sets1.Add( Base.SYMBOL_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO1_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO2_UP_S2_ID) { Base.SYMBOL_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_UP_S2( algo2.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP2,"TP2_SYMBOL_UP_S2_OCO3"), algo2.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP2_SYMBOL_UP_S2_OCO3")); }; Base.SYMBOL_UP_S2_OCO3Sets2.Add( Base.SYMBOL_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO2_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO3_UP_S2_ID) { Base.SYMBOL_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_UP_S2( algo3.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP3,"TP3_SYMBOL_UP_S2_OCO3"), algo3.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP3_SYMBOL_UP_S2_OCO3")); }; Base.SYMBOL_UP_S2_OCO3Sets3.Add( Base.SYMBOL_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO3_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO4_UP_S2_ID) { Base.SYMBOL_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_UP_S2( algo4.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP4,"TP4_SYMBOL_UP_S2_OCO3"), algo4.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP4_SYMBOL_UP_S2_OCO3")); }; Base.SYMBOL_UP_S2_OCO3Sets4.Add( Base.SYMBOL_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO4_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO5_UP_S2_ID) { Base.SYMBOL_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_UP_S2( algo5.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP5,"TP5_SYMBOL_UP_S2_OCO3"), algo5.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP5_SYMBOL_UP_S2_OCO3")); }; Base.SYMBOL_UP_S2_OCO3Sets5.Add( Base.SYMBOL_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO5_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO6_UP_S2_ID) { Base.SYMBOL_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_UP_S2( algo6.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP6,"TP6_SYMBOL_UP_S2_OCO3"), algo6.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP6_SYMBOL_UP_S2_OCO3")); }; Base.SYMBOL_UP_S2_OCO3Sets6.Add( Base.SYMBOL_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO6_UP_S2_ID = -1; } int SYMBOL_OCO3S1_UP_S2 = 0; for (; SYMBOL_OCO3S1_UP_S2 < Base.SYMBOL_UP_S2_OCO3Sets1.Count; SYMBOL_OCO3S1_UP_S2++) if (Base.SYMBOL_UP_S2_OCO3Sets1[SYMBOL_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO3Sets1[SYMBOL_OCO3S1_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO3Sets1.RemoveAt(SYMBOL_OCO3S1_UP_S2); SYMBOL_OCO3S1_UP_S2 = 0; break; } int SYMBOL_OCO3S2_UP_S2 = 0; for (; SYMBOL_OCO3S2_UP_S2 < Base.SYMBOL_UP_S2_OCO3Sets2.Count; SYMBOL_OCO3S2_UP_S2++) if (Base.SYMBOL_UP_S2_OCO3Sets2[SYMBOL_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO3Sets2[SYMBOL_OCO3S2_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO3Sets2.RemoveAt(SYMBOL_OCO3S2_UP_S2); SYMBOL_OCO3S2_UP_S2 = 0; break; } int SYMBOL_OCO3S3_UP_S2 = 0; for (; SYMBOL_OCO3S3_UP_S2 < Base.SYMBOL_UP_S2_OCO3Sets3.Count; SYMBOL_OCO3S3_UP_S2++) if (Base.SYMBOL_UP_S2_OCO3Sets3[SYMBOL_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO3Sets3[SYMBOL_OCO3S3_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO3Sets3.RemoveAt(SYMBOL_OCO3S3_UP_S2); SYMBOL_OCO3S3_UP_S2 = 0; break; } int SYMBOL_OCO3S4_UP_S2 = 0; for (; SYMBOL_OCO3S4_UP_S2 < Base.SYMBOL_UP_S2_OCO3Sets4.Count; SYMBOL_OCO3S4_UP_S2++) if (Base.SYMBOL_UP_S2_OCO3Sets4[SYMBOL_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO3Sets4[SYMBOL_OCO3S4_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO3Sets4.RemoveAt(SYMBOL_OCO3S4_UP_S2); SYMBOL_OCO3S4_UP_S2 = 0; break; } int SYMBOL_OCO3S5_UP_S2 = 0; for (; SYMBOL_OCO3S5_UP_S2 < Base.SYMBOL_UP_S2_OCO3Sets5.Count; SYMBOL_OCO3S5_UP_S2++) if (Base.SYMBOL_UP_S2_OCO3Sets5[SYMBOL_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO3Sets5[SYMBOL_OCO3S5_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO3Sets5.RemoveAt(SYMBOL_OCO3S5_UP_S2); SYMBOL_OCO3S5_UP_S2 = 0; break; } int SYMBOL_OCO3S6_UP_S2 = 0; for (; SYMBOL_OCO3S6_UP_S2 < Base.SYMBOL_UP_S2_OCO3Sets6.Count; SYMBOL_OCO3S6_UP_S2++) if (Base.SYMBOL_UP_S2_OCO3Sets6[SYMBOL_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO3Sets6[SYMBOL_OCO3S6_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO3Sets6.RemoveAt(SYMBOL_OCO3S6_UP_S2); SYMBOL_OCO3S6_UP_S2 = 0; break; } } if (Base.SYMBOL_OCO4_EO1_UP_S2) Base.SYMBOL_OCO4_EO1_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO4_EO2_UP_S2) Base.SYMBOL_OCO4_EO2_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO4_EO3_UP_S2) Base.SYMBOL_OCO4_EO3_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO4_EO4_UP_S2) Base.SYMBOL_OCO4_EO4_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO4_EO5_UP_S2) Base.SYMBOL_OCO4_EO5_UP_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO4_EO6_UP_S2) Base.SYMBOL_OCO4_EO6_UP_S2_ID = orderEvent.OrderId; if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled) { if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO1_UP_S2_ID) { Base.SYMBOL_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_UP_S2( algo1.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP1,"TP1_SYMBOL_UP_S2_OCO4"), algo1.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP1_SYMBOL_UP_S2_OCO4")); }; Base.SYMBOL_UP_S2_OCO4Sets1.Add( Base.SYMBOL_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO1_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO2_UP_S2_ID) { Base.SYMBOL_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_UP_S2( algo2.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP2,"TP2_SYMBOL_UP_S2_OCO4"), algo2.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP2_SYMBOL_UP_S2_OCO4")); }; Base.SYMBOL_UP_S2_OCO4Sets2.Add( Base.SYMBOL_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO2_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO3_UP_S2_ID) { Base.SYMBOL_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_UP_S2( algo3.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP3,"TP3_SYMBOL_UP_S2_OCO4"), algo3.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP3_SYMBOL_UP_S2_OCO4")); }; Base.SYMBOL_UP_S2_OCO4Sets3.Add( Base.SYMBOL_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO3_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO4_UP_S2_ID) { Base.SYMBOL_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_UP_S2( algo4.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP4,"TP4_SYMBOL_UP_S2_OCO4"), algo4.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP4_SYMBOL_UP_S2_OCO4")); }; Base.SYMBOL_UP_S2_OCO4Sets4.Add( Base.SYMBOL_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO4_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO5_UP_S2_ID) { Base.SYMBOL_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_UP_S2( algo5.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP5,"TP5_SYMBOL_UP_S2_OCO4"), algo5.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP5_SYMBOL_UP_S2_OCO4")); }; Base.SYMBOL_UP_S2_OCO4Sets5.Add( Base.SYMBOL_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO5_UP_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO6_UP_S2_ID) { Base.SYMBOL_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_UP_S2( algo6.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_UP_S2_TP6,"TP6_SYMBOL_UP_S2_OCO4"), algo6.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_UP_S2_SL,"SL_TP6_SYMBOL_UP_S2_OCO4")); }; Base.SYMBOL_UP_S2_OCO4Sets6.Add( Base.SYMBOL_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO6_UP_S2_ID = -1; } int SYMBOL_OCO4S1_UP_S2 = 0; for (; SYMBOL_OCO4S1_UP_S2 < Base.SYMBOL_UP_S2_OCO4Sets1.Count; SYMBOL_OCO4S1_UP_S2++) if (Base.SYMBOL_UP_S2_OCO4Sets1[SYMBOL_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO4Sets1[SYMBOL_OCO4S1_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO4Sets1.RemoveAt(SYMBOL_OCO4S1_UP_S2); SYMBOL_OCO4S1_UP_S2 = 0; break; } int SYMBOL_OCO4S2_UP_S2 = 0; for (; SYMBOL_OCO4S2_UP_S2 < Base.SYMBOL_UP_S2_OCO4Sets2.Count; SYMBOL_OCO4S2_UP_S2++) if (Base.SYMBOL_UP_S2_OCO4Sets2[SYMBOL_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO4Sets2[SYMBOL_OCO4S2_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO4Sets2.RemoveAt(SYMBOL_OCO4S2_UP_S2); SYMBOL_OCO4S2_UP_S2 = 0; break; } int SYMBOL_OCO4S3_UP_S2 = 0; for (; SYMBOL_OCO4S3_UP_S2 < Base.SYMBOL_UP_S2_OCO4Sets3.Count; SYMBOL_OCO4S3_UP_S2++) if (Base.SYMBOL_UP_S2_OCO4Sets3[SYMBOL_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO4Sets3[SYMBOL_OCO4S3_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO4Sets3.RemoveAt(SYMBOL_OCO4S3_UP_S2); SYMBOL_OCO4S3_UP_S2 = 0; break; } int SYMBOL_OCO4S4_UP_S2 = 0; for (; SYMBOL_OCO4S4_UP_S2 < Base.SYMBOL_UP_S2_OCO4Sets4.Count; SYMBOL_OCO4S4_UP_S2++) if (Base.SYMBOL_UP_S2_OCO4Sets4[SYMBOL_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO4Sets4[SYMBOL_OCO4S4_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO4Sets4.RemoveAt(SYMBOL_OCO4S4_UP_S2); SYMBOL_OCO4S4_UP_S2 = 0; break; } int SYMBOL_OCO4S5_UP_S2 = 0; for (; SYMBOL_OCO4S5_UP_S2 < Base.SYMBOL_UP_S2_OCO4Sets5.Count; SYMBOL_OCO4S5_UP_S2++) if (Base.SYMBOL_UP_S2_OCO4Sets5[SYMBOL_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO4Sets5[SYMBOL_OCO4S5_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO4Sets5.RemoveAt(SYMBOL_OCO4S5_UP_S2); SYMBOL_OCO4S5_UP_S2 = 0; break; } int SYMBOL_OCO4S6_UP_S2 = 0; for (; SYMBOL_OCO4S6_UP_S2 < Base.SYMBOL_UP_S2_OCO4Sets6.Count; SYMBOL_OCO4S6_UP_S2++) if (Base.SYMBOL_UP_S2_OCO4Sets6[SYMBOL_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_UP_S2_OCO4Sets6[SYMBOL_OCO4S6_UP_S2].Filled(); Base.SYMBOL_UP_S2_OCO4Sets6.RemoveAt(SYMBOL_OCO4S6_UP_S2); SYMBOL_OCO4S6_UP_S2 = 0; break; } } } } }
using System.Linq; using System.Collections.Generic; using QuantConnect.Orders; using NodaTime; using NodaTime.TimeZones; namespace QuantConnect { public struct SYMBOL_OCO1_DOWN_S2 { public SYMBOL_OCO1_DOWN_S2(params OrderTicket[] orderTickets) { this.OrderTickets = orderTickets; } private OrderTicket[] OrderTickets { get; set; } public void Filled() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTickets) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_DOWN_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_DOWN_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 1 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_DOWN_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_DOWN_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 2 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_DOWN_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_DOWN_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 3 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_DOWN_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_DOWN_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 4 DOWN S2"); } } } } public void TimeOut() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTickets) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_DOWN_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_DOWN_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 1 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_DOWN_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_DOWN_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 2 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_DOWN_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_DOWN_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 3 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_DOWN_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_DOWN_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 4 DOWN S2 TIMEOUT"); } } } } public bool InOrders(int orderId) { foreach (var orderTicket in this.OrderTickets) if (orderTicket.OrderId == orderId) return true; return false; } } public struct SYMBOL_OCO1_UP_S2 { public SYMBOL_OCO1_UP_S2(params OrderTicket[] orderTicketsUp) { this.OrderTicketsUp = orderTicketsUp; } private OrderTicket[] OrderTicketsUp { get; set; } public void Filled() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsUp) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_UP_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_UP_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 1 UP S2"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_UP_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_UP_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 2 UP S2"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_UP_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_UP_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 3 UP S2"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_UP_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_UP_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 4 UP S2"); } } } } public void TimeOut() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsUp) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_UP_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_UP_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 1 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_UP_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_UP_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 2 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_UP_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_UP_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 3 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_UP_S2_OCO1" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_UP_S2_OCO1")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 4 UP S2 TIMEOUT"); } } } } public bool InOrders(int orderId) { foreach (var orderTicket in this.OrderTicketsUp) if (orderTicket.OrderId == orderId) return true; return false; } } public struct SYMBOL_OCO2_DOWN_S2 { public SYMBOL_OCO2_DOWN_S2(params OrderTicket[] orderTicketsDown) { this.OrderTicketsDown = orderTicketsDown; } private OrderTicket[] OrderTicketsDown { get; set; } public void Filled() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsDown) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_DOWN_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_DOWN_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 1 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_DOWN_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_DOWN_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 2 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_DOWN_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_DOWN_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 3 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_DOWN_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_DOWN_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 4 DOWN S2"); } } } } public void TimeOut() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsDown) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_DOWN_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_DOWN_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 1 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_DOWN_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_DOWN_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 2 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_DOWN_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_DOWN_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 3 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_DOWN_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_DOWN_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO1 CANCEL 4 DOWN S2 TIMEOUT"); } } } } public bool InOrders(int orderId) { foreach (var orderTicket in this.OrderTicketsDown) if (orderTicket.OrderId == orderId) return true; return false; } } public struct SYMBOL_OCO2_UP_S2 { public SYMBOL_OCO2_UP_S2(params OrderTicket[] orderTicketsUp) { this.OrderTicketsUp = orderTicketsUp; } private OrderTicket[] OrderTicketsUp { get; set; } public void Filled() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsUp) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_UP_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_UP_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 1 UP S2"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_UP_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_UP_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 2 UP S2"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_UP_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_UP_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 3 UP S2"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_UP_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_UP_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 4 UP S2"); } } } } public void TimeOut() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsUp) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_UP_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_UP_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 1 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_UP_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_UP_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 2 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_UP_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_UP_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 3 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_UP_S2_OCO2" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_UP_S2_OCO2")) { orderTicket.Cancel("SYMBOL OCO2 CANCEL 4 UP S2 TIMEOUT"); } } } } public bool InOrders(int orderId) { foreach (var orderTicket in this.OrderTicketsUp) if (orderTicket.OrderId == orderId) return true; return false; } } public struct SYMBOL_OCO3_DOWN_S2 { public SYMBOL_OCO3_DOWN_S2(params OrderTicket[] orderTicketsDown) { this.OrderTicketsDown = orderTicketsDown; } private OrderTicket[] OrderTicketsDown { get; set; } public void Filled() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsDown) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_DOWN_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_DOWN_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 1 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_DOWN_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_DOWN_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 2 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_DOWN_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_DOWN_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 3 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_DOWN_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_DOWN_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 4 DOWN S2"); } } } } public void TimeOut() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsDown) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_DOWN_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_DOWN_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 1 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_DOWN_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_DOWN_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 2 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_DOWN_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_DOWN_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 3 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_DOWN_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_DOWN_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 4 DOWN S2 TIMEOUT"); } } } } public bool InOrders(int orderId) { foreach (var orderTicket in this.OrderTicketsDown) if (orderTicket.OrderId == orderId) return true; return false; } } public struct SYMBOL_OCO3_UP_S2 { public SYMBOL_OCO3_UP_S2(params OrderTicket[] orderTicketsUp) { this.OrderTicketsUp = orderTicketsUp; } private OrderTicket[] OrderTicketsUp { get; set; } public void Filled() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsUp) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_UP_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_UP_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 1 UP S2"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_UP_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_UP_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 2 UP S2"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_UP_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_UP_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 3 UP S2"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_UP_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_UP_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 4 UP S2"); } } } } public void TimeOut() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsUp) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_UP_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_UP_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 1 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_UP_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_UP_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 2 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_UP_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_UP_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 3 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_UP_S2_OCO3" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_UP_S2_OCO3")) { orderTicket.Cancel("SYMBOL OCO3 CANCEL 4 UP S2 TIMEOUT"); } } } } public bool InOrders(int orderId) { foreach (var orderTicket in this.OrderTicketsUp) if (orderTicket.OrderId == orderId) return true; return false; } } public struct SYMBOL_OCO4_DOWN_S2 { public SYMBOL_OCO4_DOWN_S2(params OrderTicket[] orderTicketsDown) { this.OrderTicketsDown = orderTicketsDown; } private OrderTicket[] OrderTicketsDown { get; set; } public void Filled() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsDown) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_DOWN_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_DOWN_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 1 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_DOWN_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_DOWN_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 2 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_DOWN_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_DOWN_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 3 DOWN S2"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_DOWN_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_DOWN_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 4 DOWN S2"); } } } } public void TimeOut() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsDown) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_DOWN_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_DOWN_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 1 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_DOWN_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_DOWN_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 2 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_DOWN_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_DOWN_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 3 DOWN S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_DOWN_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_DOWN_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 4 DOWN S2 TIMEOUT"); } } } } public bool InOrders(int orderId) { foreach (var orderTicket in this.OrderTicketsDown) if (orderTicket.OrderId == orderId) return true; return false; } } public struct SYMBOL_OCO4_UP_S2 { public SYMBOL_OCO4_UP_S2(params OrderTicket[] orderTicketsUp) { this.OrderTicketsUp = orderTicketsUp; } private OrderTicket[] OrderTicketsUp { get; set; } public void Filled() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsUp) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_UP_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_UP_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 1 UP S2"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_UP_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_UP_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 2 UP S2"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_UP_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_UP_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 3 UP S2"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_UP_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_UP_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 4 UP S2"); } } } } public void TimeOut() { // Cancel all the outstanding tickets. foreach (var orderTicket in this.OrderTicketsUp) { if (orderTicket.Status == OrderStatus.Submitted) { if(orderTicket.Tag.StartsWith("TP1_SYMBOL_UP_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP1_SYMBOL_UP_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 1 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP2_SYMBOL_UP_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP2_SYMBOL_UP_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 2 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP3_SYMBOL_UP_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP3_SYMBOL_UP_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 3 UP S2 TIMEOUT"); } if(orderTicket.Tag.StartsWith("TP4_SYMBOL_UP_S2_OCO4" ) || orderTicket.Tag.StartsWith("SL_TP4_SYMBOL_UP_S2_OCO4")) { orderTicket.Cancel("SYMBOL OCO4 CANCEL 4 UP S2 TIMEOUT"); } } } } public bool InOrders(int orderId) { foreach (var orderTicket in this.OrderTicketsUp) if (orderTicket.OrderId == orderId) return true; return false; } } }
using System; using System.Collections.Generic; using System.Linq; using QuantConnect.Data; using QuantConnect.Data.Consolidators; using QuantConnect.Data.Market; using QuantConnect.Indicators; using QuantConnect.Orders; using QuantConnect.Algorithm.Framework.Alphas; using QuantConnect.Algorithm.Framework.Execution; using QuantConnect.Algorithm.Framework.Portfolio; using QuantConnect.Algorithm.Framework.Selection; namespace QuantConnect { public struct SYMBOL_DOWN_S2_OnOrderEvent { private QCAlgorithm _algorithm; public SYMBOL_DOWN_S2_OnOrderEvent(QCAlgorithm algorithm) { _algorithm = algorithm; } public void OnOrderEvent(QCAlgorithm _algorithm, OrderEvent orderEvent) { var OrderID = _algorithm.Transactions.GetOrderById(orderEvent.OrderId); if (orderEvent.Status == OrderStatus.Filled) { if (OrderID.Tag.StartsWith("SYMBOL OCO1 CANCEL 1 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO2 CANCEL 1 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO3 CANCEL 1 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO4 CANCEL 1 DOWN S2")) { _algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue SYMBOL S2"); } if (OrderID.Tag.StartsWith("SYMBOL OCO1 CANCEL 2 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO2 CANCEL 2 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO3 CANCEL 2 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO4 CANCEL 2 DOWN S2")) { _algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue SYMBOL S2"); } if (OrderID.Tag.StartsWith("SYMBOL OCO1 CANCEL 3 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO2 CANCEL 3 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO3 CANCEL 3 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO4 CANCEL 3 DOWN S2")) { _algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue SYMBOL S2"); } if (OrderID.Tag.StartsWith("SYMBOL OCO1 CANCEL 4 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO2 CANCEL 4 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO3 CANCEL 4 DOWN S2") || OrderID.Tag.StartsWith("SYMBOL OCO4 CANCEL 4 DOWN S2")) { _algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue SYMBOL S2"); } } if (Base.SYMBOL_OCO1_EO1_DOWN_S2) Base.SYMBOL_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO1_EO2_DOWN_S2) Base.SYMBOL_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO1_EO3_DOWN_S2) Base.SYMBOL_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO1_EO4_DOWN_S2) Base.SYMBOL_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId; if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled) { if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO1_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_DOWN_S2( algo1.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP1_SYMBOL_DOWN_S2_OCO1"), algo1.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP1,"TP1_SYMBOL_DOWN_S2_OCO1")); }; Base.SYMBOL_DOWN_S2_OCO1Sets1.Add( Base.SYMBOL_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO1_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO2_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_DOWN_S2( algo2.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP2_SYMBOL_DOWN_S2_OCO1"), algo2.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP2,"TP2_SYMBOL_DOWN_S2_OCO1")); }; Base.SYMBOL_DOWN_S2_OCO1Sets2.Add( Base.SYMBOL_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO2_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO3_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_DOWN_S2( algo3.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP3_SYMBOL_DOWN_S2_OCO1"), algo3.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP3,"TP3_SYMBOL_DOWN_S2_OCO1")); }; Base.SYMBOL_DOWN_S2_OCO1Sets3.Add( Base.SYMBOL_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO3_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO1_EO4_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO1_DOWN_S2( algo4.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP4_SYMBOL_DOWN_S2_OCO1"), algo4.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP4,"TP4_SYMBOL_DOWN_S2_OCO1")); }; Base.SYMBOL_DOWN_S2_OCO1Sets4.Add( Base.SYMBOL_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO1_EO4_DOWN_S2_ID = -1; } int SYMBOL_OCO1S1_DOWN_S2 = 0; for (; SYMBOL_OCO1S1_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets1.Count; SYMBOL_OCO1S1_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets1[SYMBOL_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO1Sets1[SYMBOL_OCO1S1_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO1Sets1.RemoveAt(SYMBOL_OCO1S1_DOWN_S2); SYMBOL_OCO1S1_DOWN_S2 = 0; break; } int SYMBOL_OCO1S2_DOWN_S2 = 0; for (; SYMBOL_OCO1S2_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets2.Count; SYMBOL_OCO1S2_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets2[SYMBOL_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO1Sets2[SYMBOL_OCO1S2_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO1Sets2.RemoveAt(SYMBOL_OCO1S2_DOWN_S2); SYMBOL_OCO1S2_DOWN_S2 = 0; break; } int SYMBOL_OCO1S3_DOWN_S2 = 0; for (; SYMBOL_OCO1S3_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets3.Count; SYMBOL_OCO1S3_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets3[SYMBOL_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO1Sets3[SYMBOL_OCO1S3_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO1Sets3.RemoveAt(SYMBOL_OCO1S3_DOWN_S2); SYMBOL_OCO1S3_DOWN_S2 = 0; break; } int SYMBOL_OCO1S4_DOWN_S2 = 0; for (; SYMBOL_OCO1S4_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO1Sets4.Count; SYMBOL_OCO1S4_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO1Sets4[SYMBOL_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO1Sets4[SYMBOL_OCO1S4_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO1Sets4.RemoveAt(SYMBOL_OCO1S4_DOWN_S2); SYMBOL_OCO1S4_DOWN_S2 = 0; break; } } if (Base.SYMBOL_OCO2_EO1_DOWN_S2) Base.SYMBOL_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO2_EO2_DOWN_S2) Base.SYMBOL_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO2_EO3_DOWN_S2) Base.SYMBOL_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO2_EO4_DOWN_S2) Base.SYMBOL_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId; if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled) { if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO1_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_DOWN_S2( algo1.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP1_SYMBOL_DOWN_S2_OCO2"), algo1.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP1,"TP1_SYMBOL_DOWN_S2_OCO2")); }; Base.SYMBOL_DOWN_S2_OCO2Sets1.Add( Base.SYMBOL_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO1_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO2_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_DOWN_S2( algo2.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP2_SYMBOL_DOWN_S2_OCO2"), algo2.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP2,"TP2_SYMBOL_DOWN_S2_OCO2")); }; Base.SYMBOL_DOWN_S2_OCO2Sets2.Add( Base.SYMBOL_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO2_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO3_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_DOWN_S2( algo3.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP3_SYMBOL_DOWN_S2_OCO2"), algo3.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP3,"TP3_SYMBOL_DOWN_S2_OCO2")); }; Base.SYMBOL_DOWN_S2_OCO2Sets3.Add( Base.SYMBOL_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO3_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO2_EO4_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO2_DOWN_S2( algo4.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP4_SYMBOL_DOWN_S2_OCO2"), algo4.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP4,"TP4_SYMBOL_DOWN_S2_OCO2")); }; Base.SYMBOL_DOWN_S2_OCO2Sets4.Add( Base.SYMBOL_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO2_EO4_DOWN_S2_ID = -1; } int SYMBOL_OCO2S1_DOWN_S2 = 0; for (; SYMBOL_OCO2S1_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets1.Count; SYMBOL_OCO2S1_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets1[SYMBOL_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO2Sets1[SYMBOL_OCO2S1_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO2Sets1.RemoveAt(SYMBOL_OCO2S1_DOWN_S2); SYMBOL_OCO2S1_DOWN_S2 = 0; break; } int SYMBOL_OCO2S2_DOWN_S2 = 0; for (; SYMBOL_OCO2S2_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets2.Count; SYMBOL_OCO2S2_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets2[SYMBOL_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO2Sets2[SYMBOL_OCO2S2_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO2Sets2.RemoveAt(SYMBOL_OCO2S2_DOWN_S2); SYMBOL_OCO2S2_DOWN_S2 = 0; break; } int SYMBOL_OCO2S3_DOWN_S2 = 0; for (; SYMBOL_OCO2S3_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets3.Count; SYMBOL_OCO2S3_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets3[SYMBOL_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO2Sets3[SYMBOL_OCO2S3_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO2Sets3.RemoveAt(SYMBOL_OCO2S3_DOWN_S2); SYMBOL_OCO2S3_DOWN_S2 = 0; break; } int SYMBOL_OCO2S4_DOWN_S2 = 0; for (; SYMBOL_OCO2S4_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO2Sets4.Count; SYMBOL_OCO2S4_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO2Sets4[SYMBOL_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO2Sets4[SYMBOL_OCO2S4_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO2Sets4.RemoveAt(SYMBOL_OCO2S4_DOWN_S2); SYMBOL_OCO2S4_DOWN_S2 = 0; break; } } if (Base.SYMBOL_OCO3_EO1_DOWN_S2) Base.SYMBOL_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO3_EO2_DOWN_S2) Base.SYMBOL_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO3_EO3_DOWN_S2) Base.SYMBOL_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO3_EO4_DOWN_S2) Base.SYMBOL_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId; if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled) { if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO1_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_DOWN_S2( algo1.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP1_SYMBOL_DOWN_S2_OCO3"), algo1.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP1,"TP1_SYMBOL_DOWN_S2_OCO3")); }; Base.SYMBOL_DOWN_S2_OCO3Sets1.Add( Base.SYMBOL_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO1_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO2_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_DOWN_S2( algo2.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP2_SYMBOL_DOWN_S2_OCO3"), algo2.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP2,"TP2_SYMBOL_DOWN_S2_OCO3")); }; Base.SYMBOL_DOWN_S2_OCO3Sets2.Add( Base.SYMBOL_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO2_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO3_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_DOWN_S2( algo3.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP3_SYMBOL_DOWN_S2_OCO3"), algo3.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP3,"TP3_SYMBOL_DOWN_S2_OCO3")); }; Base.SYMBOL_DOWN_S2_OCO3Sets3.Add( Base.SYMBOL_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO3_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO3_EO4_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO3_DOWN_S2( algo4.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP4_SYMBOL_DOWN_S2_OCO3"), algo4.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP4,"TP4_SYMBOL_DOWN_S2_OCO3")); }; Base.SYMBOL_DOWN_S2_OCO3Sets4.Add( Base.SYMBOL_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO3_EO4_DOWN_S2_ID = -1; } int SYMBOL_OCO3S1_DOWN_S2 = 0; for (; SYMBOL_OCO3S1_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets1.Count; SYMBOL_OCO3S1_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets1[SYMBOL_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO3Sets1[SYMBOL_OCO3S1_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO3Sets1.RemoveAt(SYMBOL_OCO3S1_DOWN_S2); SYMBOL_OCO3S1_DOWN_S2 = 0; break; } int SYMBOL_OCO3S2_DOWN_S2 = 0; for (; SYMBOL_OCO3S2_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets2.Count; SYMBOL_OCO3S2_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets2[SYMBOL_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO3Sets2[SYMBOL_OCO3S2_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO3Sets2.RemoveAt(SYMBOL_OCO3S2_DOWN_S2); SYMBOL_OCO3S2_DOWN_S2 = 0; break; } int SYMBOL_OCO3S3_DOWN_S2 = 0; for (; SYMBOL_OCO3S3_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets3.Count; SYMBOL_OCO3S3_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets3[SYMBOL_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO3Sets3[SYMBOL_OCO3S3_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO3Sets3.RemoveAt(SYMBOL_OCO3S3_DOWN_S2); SYMBOL_OCO3S3_DOWN_S2 = 0; break; } int SYMBOL_OCO3S4_DOWN_S2 = 0; for (; SYMBOL_OCO3S4_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO3Sets4.Count; SYMBOL_OCO3S4_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO3Sets4[SYMBOL_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO3Sets4[SYMBOL_OCO3S4_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO3Sets4.RemoveAt(SYMBOL_OCO3S4_DOWN_S2); SYMBOL_OCO3S4_DOWN_S2 = 0; break; } } if (Base.SYMBOL_OCO4_EO1_DOWN_S2) Base.SYMBOL_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO4_EO2_DOWN_S2) Base.SYMBOL_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO4_EO3_DOWN_S2) Base.SYMBOL_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId; if (Base.SYMBOL_OCO4_EO4_DOWN_S2) Base.SYMBOL_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId; if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled) { if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO1_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_DOWN_S2( algo1.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP1_SYMBOL_DOWN_S2_OCO4"), algo1.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP1,"TP1_SYMBOL_DOWN_S2_OCO4")); }; Base.SYMBOL_DOWN_S2_OCO4Sets1.Add( Base.SYMBOL_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO1_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO2_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_DOWN_S2( algo2.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP2_SYMBOL_DOWN_S2_OCO4"), algo2.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP2,"TP2_SYMBOL_DOWN_S2_OCO4")); }; Base.SYMBOL_DOWN_S2_OCO4Sets2.Add( Base.SYMBOL_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO2_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO3_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_DOWN_S2( algo3.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP3_SYMBOL_DOWN_S2_OCO4"), algo3.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP3,"TP3_SYMBOL_DOWN_S2_OCO4")); }; Base.SYMBOL_DOWN_S2_OCO4Sets3.Add( Base.SYMBOL_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO3_DOWN_S2_ID = -1; } if (orderEvent.OrderId == Base.SYMBOL_OCO4_EO4_DOWN_S2_ID) { Base.SYMBOL_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) => { return new SYMBOL_OCO4_DOWN_S2( algo4.StopMarketOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice + Base.SYMBOL_DOWN_S2_SL,"SL_TP4_SYMBOL_DOWN_S2_OCO4"), algo4.LimitOrder(orderEvent.Symbol, -orderEvent.Quantity, orderEvent.FillPrice - Base.SYMBOL_DOWN_S2_TP4,"TP4_SYMBOL_DOWN_S2_OCO4")); }; Base.SYMBOL_DOWN_S2_OCO4Sets4.Add( Base.SYMBOL_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity)); Base.SYMBOL_OCO4_EO4_DOWN_S2_ID = -1; } int SYMBOL_OCO4S1_DOWN_S2 = 0; for (; SYMBOL_OCO4S1_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets1.Count; SYMBOL_OCO4S1_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets1[SYMBOL_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO4Sets1[SYMBOL_OCO4S1_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO4Sets1.RemoveAt(SYMBOL_OCO4S1_DOWN_S2); SYMBOL_OCO4S1_DOWN_S2 = 0; break; } int SYMBOL_OCO4S2_DOWN_S2 = 0; for (; SYMBOL_OCO4S2_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets2.Count; SYMBOL_OCO4S2_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets2[SYMBOL_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO4Sets2[SYMBOL_OCO4S2_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO4Sets2.RemoveAt(SYMBOL_OCO4S2_DOWN_S2); SYMBOL_OCO4S2_DOWN_S2 = 0; break; } int SYMBOL_OCO4S3_DOWN_S2 = 0; for (; SYMBOL_OCO4S3_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets3.Count; SYMBOL_OCO4S3_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets3[SYMBOL_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO4Sets3[SYMBOL_OCO4S3_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO4Sets3.RemoveAt(SYMBOL_OCO4S3_DOWN_S2); SYMBOL_OCO4S3_DOWN_S2 = 0; break; } int SYMBOL_OCO4S4_DOWN_S2 = 0; for (; SYMBOL_OCO4S4_DOWN_S2 < Base.SYMBOL_DOWN_S2_OCO4Sets4.Count; SYMBOL_OCO4S4_DOWN_S2++) if (Base.SYMBOL_DOWN_S2_OCO4Sets4[SYMBOL_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) { Base.SYMBOL_DOWN_S2_OCO4Sets4[SYMBOL_OCO4S4_DOWN_S2].Filled(); Base.SYMBOL_DOWN_S2_OCO4Sets4.RemoveAt(SYMBOL_OCO4S4_DOWN_S2); SYMBOL_OCO4S4_DOWN_S2 = 0; break; } } } } }
using System; namespace QuantConnect.Data.Consolidators { [Obsolete("CalendarType is obsolete, please use Calendar instead")] public static class CalendarTypee { /// <summary> /// Computes the start of week (previous Monday) of given date/time /// </summary> public static Func<DateTime, CalendarInfo> Weekly => Calendar.Weekly; /// <summary> /// Computes the start of month (1st of the current month) of given date/time /// </summary> public static Func<DateTime, CalendarInfo> Monthly => Calendar.Monthly; public static Func<DateTime, CalendarInfo> Yearly => Calendar.Yearly; public static Func<DateTime, CalendarInfo> Quarterly => Calendar.Quarterly; } }