Overall Statistics
Total Trades
396
Average Win
0.00%
Average Loss
-0.03%
Compounding Annual Return
0.025%
Drawdown
0.000%
Expectancy
0.053
Net Profit
0.254%
Sharpe Ratio
1.26
Probabilistic Sharpe Ratio
79.965%
Loss Rate
1%
Win Rate
99%
Profit-Loss Ratio
0.06
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-0.816
Tracking Error
0.154
Treynor Ratio
1.857
Total Fees
$29.57
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 USDCHF_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public USDCHF_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("USDCHF OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCHF OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCHF OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCHF OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        }
		        
				if (Base.USDCHF_OCO1_EO1_DOWN_S2)
	                Base.USDCHF_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDCHF_OCO1_EO2_DOWN_S2)
	                Base.USDCHF_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO1_EO3_DOWN_S2)
	                Base.USDCHF_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO1_EO4_DOWN_S2)
	                Base.USDCHF_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCHF_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.USDCHF_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP1_USDCHF_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP1,"TP1_USDCHF_DOWN_S2_OCO1"));
		                 };
		                Base.USDCHF_DOWN_S2_OCO1Sets1.Add( Base.USDCHF_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCHF_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP2_USDCHF_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP2,"TP2_USDCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO1Sets2.Add( Base.USDCHF_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP3_USDCHF_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP3,"TP3_USDCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO1Sets3.Add( Base.USDCHF_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP4_USDCHF_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP4,"TP4_USDCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO1Sets4.Add( Base.USDCHF_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int USDCHF_OCO1S1_DOWN_S2 = 0;
	                for (; USDCHF_OCO1S1_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets1.Count; USDCHF_OCO1S1_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO1Sets1[USDCHF_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO1Sets1[USDCHF_OCO1S1_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO1Sets1.RemoveAt(USDCHF_OCO1S1_DOWN_S2);
	                        USDCHF_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDCHF_OCO1S2_DOWN_S2 = 0;
	                for (; USDCHF_OCO1S2_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets2.Count; USDCHF_OCO1S2_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO1Sets2[USDCHF_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO1Sets2[USDCHF_OCO1S2_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO1Sets2.RemoveAt(USDCHF_OCO1S2_DOWN_S2);
	                        USDCHF_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO1S3_DOWN_S2 = 0;
	                for (; USDCHF_OCO1S3_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets3.Count; USDCHF_OCO1S3_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO1Sets3[USDCHF_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO1Sets3[USDCHF_OCO1S3_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO1Sets3.RemoveAt(USDCHF_OCO1S3_DOWN_S2);
	                        USDCHF_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO1S4_DOWN_S2 = 0;
	                for (; USDCHF_OCO1S4_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets4.Count; USDCHF_OCO1S4_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO1Sets4[USDCHF_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO1Sets4[USDCHF_OCO1S4_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO1Sets4.RemoveAt(USDCHF_OCO1S4_DOWN_S2);
	                        USDCHF_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCHF_OCO2_EO1_DOWN_S2)
	                Base.USDCHF_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDCHF_OCO2_EO2_DOWN_S2)
	                Base.USDCHF_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO2_EO3_DOWN_S2)
	                Base.USDCHF_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO2_EO4_DOWN_S2)
	                Base.USDCHF_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCHF_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.USDCHF_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP1_USDCHF_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP1,"TP1_USDCHF_DOWN_S2_OCO2"));
		                 };
		                Base.USDCHF_DOWN_S2_OCO2Sets1.Add( Base.USDCHF_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCHF_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP2_USDCHF_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP2,"TP2_USDCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO2Sets2.Add( Base.USDCHF_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP3_USDCHF_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP3,"TP3_USDCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO2Sets3.Add( Base.USDCHF_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP4_USDCHF_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP4,"TP4_USDCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO2Sets4.Add( Base.USDCHF_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int USDCHF_OCO2S1_DOWN_S2 = 0;
	                for (; USDCHF_OCO2S1_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets1.Count; USDCHF_OCO2S1_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO2Sets1[USDCHF_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO2Sets1[USDCHF_OCO2S1_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO2Sets1.RemoveAt(USDCHF_OCO2S1_DOWN_S2);
	                        USDCHF_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDCHF_OCO2S2_DOWN_S2 = 0;
	                for (; USDCHF_OCO2S2_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets2.Count; USDCHF_OCO2S2_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO2Sets2[USDCHF_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO2Sets2[USDCHF_OCO2S2_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO2Sets2.RemoveAt(USDCHF_OCO2S2_DOWN_S2);
	                        USDCHF_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO2S3_DOWN_S2 = 0;
	                for (; USDCHF_OCO2S3_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets3.Count; USDCHF_OCO2S3_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO2Sets3[USDCHF_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO2Sets3[USDCHF_OCO2S3_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO2Sets3.RemoveAt(USDCHF_OCO2S3_DOWN_S2);
	                        USDCHF_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO2S4_DOWN_S2 = 0;
	                for (; USDCHF_OCO2S4_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets4.Count; USDCHF_OCO2S4_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO2Sets4[USDCHF_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO2Sets4[USDCHF_OCO2S4_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO2Sets4.RemoveAt(USDCHF_OCO2S4_DOWN_S2);
	                        USDCHF_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCHF_OCO3_EO1_DOWN_S2)
	                Base.USDCHF_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDCHF_OCO3_EO2_DOWN_S2)
	                Base.USDCHF_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO3_EO3_DOWN_S2)
	                Base.USDCHF_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO3_EO4_DOWN_S2)
	                Base.USDCHF_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCHF_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.USDCHF_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP1_USDCHF_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP1,"TP1_USDCHF_DOWN_S2_OCO3"));
		                 };
		                Base.USDCHF_DOWN_S2_OCO3Sets1.Add( Base.USDCHF_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCHF_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP2_USDCHF_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP2,"TP2_USDCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO3Sets2.Add( Base.USDCHF_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP3_USDCHF_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP3,"TP3_USDCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO3Sets3.Add( Base.USDCHF_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP4_USDCHF_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP4,"TP4_USDCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO3Sets4.Add( Base.USDCHF_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int USDCHF_OCO3S1_DOWN_S2 = 0;
	                for (; USDCHF_OCO3S1_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets1.Count; USDCHF_OCO3S1_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO3Sets1[USDCHF_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO3Sets1[USDCHF_OCO3S1_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO3Sets1.RemoveAt(USDCHF_OCO3S1_DOWN_S2);
	                        USDCHF_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDCHF_OCO3S2_DOWN_S2 = 0;
	                for (; USDCHF_OCO3S2_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets2.Count; USDCHF_OCO3S2_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO3Sets2[USDCHF_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO3Sets2[USDCHF_OCO3S2_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO3Sets2.RemoveAt(USDCHF_OCO3S2_DOWN_S2);
	                        USDCHF_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO3S3_DOWN_S2 = 0;
	                for (; USDCHF_OCO3S3_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets3.Count; USDCHF_OCO3S3_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO3Sets3[USDCHF_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO3Sets3[USDCHF_OCO3S3_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO3Sets3.RemoveAt(USDCHF_OCO3S3_DOWN_S2);
	                        USDCHF_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO3S4_DOWN_S2 = 0;
	                for (; USDCHF_OCO3S4_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets4.Count; USDCHF_OCO3S4_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO3Sets4[USDCHF_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO3Sets4[USDCHF_OCO3S4_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO3Sets4.RemoveAt(USDCHF_OCO3S4_DOWN_S2);
	                        USDCHF_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCHF_OCO4_EO1_DOWN_S2)
	                Base.USDCHF_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDCHF_OCO4_EO2_DOWN_S2)
	                Base.USDCHF_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO4_EO3_DOWN_S2)
	                Base.USDCHF_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO4_EO4_DOWN_S2)
	                Base.USDCHF_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCHF_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.USDCHF_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP1_USDCHF_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP1,"TP1_USDCHF_DOWN_S2_OCO4"));
		                 };
		                Base.USDCHF_DOWN_S2_OCO4Sets1.Add( Base.USDCHF_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCHF_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP2_USDCHF_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP2,"TP2_USDCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO4Sets2.Add( Base.USDCHF_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP3_USDCHF_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP3,"TP3_USDCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO4Sets3.Add( Base.USDCHF_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_DOWN_S2_SL,"SL_TP4_USDCHF_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_DOWN_S2_TP4,"TP4_USDCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.USDCHF_DOWN_S2_OCO4Sets4.Add( Base.USDCHF_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int USDCHF_OCO4S1_DOWN_S2 = 0;
	                for (; USDCHF_OCO4S1_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets1.Count; USDCHF_OCO4S1_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO4Sets1[USDCHF_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO4Sets1[USDCHF_OCO4S1_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO4Sets1.RemoveAt(USDCHF_OCO4S1_DOWN_S2);
	                        USDCHF_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDCHF_OCO4S2_DOWN_S2 = 0;
	                for (; USDCHF_OCO4S2_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets2.Count; USDCHF_OCO4S2_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO4Sets2[USDCHF_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO4Sets2[USDCHF_OCO4S2_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO4Sets2.RemoveAt(USDCHF_OCO4S2_DOWN_S2);
	                        USDCHF_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO4S3_DOWN_S2 = 0;
	                for (; USDCHF_OCO4S3_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets3.Count; USDCHF_OCO4S3_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO4Sets3[USDCHF_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO4Sets3[USDCHF_OCO4S3_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO4Sets3.RemoveAt(USDCHF_OCO4S3_DOWN_S2);
	                        USDCHF_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO4S4_DOWN_S2 = 0;
	                for (; USDCHF_OCO4S4_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets4.Count; USDCHF_OCO4S4_DOWN_S2++)
	                    if (Base.USDCHF_DOWN_S2_OCO4Sets4[USDCHF_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_DOWN_S2_OCO4Sets4[USDCHF_OCO4S4_DOWN_S2].Filled();
	                        Base.USDCHF_DOWN_S2_OCO4Sets4.RemoveAt(USDCHF_OCO4S4_DOWN_S2);
	                        USDCHF_OCO4S4_DOWN_S2 = 0;
	                        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.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 EURJPY_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURJPY_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("EURJPY OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURJPY OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURJPY OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURJPY OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURJPY OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURJPY OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURJPY OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        }
		        
				if (Base.EURJPY_OCO1_EO1_UP_S2)
	                Base.EURJPY_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURJPY_OCO1_EO2_UP_S2)
	                Base.EURJPY_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO1_EO3_UP_S2)
	                Base.EURJPY_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO1_EO4_UP_S2)
	                Base.EURJPY_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO1_EO5_UP_S2)
	                Base.EURJPY_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO1_EO6_UP_S2)
	                Base.EURJPY_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURJPY_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.EURJPY_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP1,"TP1_EURJPY_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP1_EURJPY_UP_S2_OCO1"));
		                 };
		                Base.EURJPY_UP_S2_OCO1Sets1.Add( Base.EURJPY_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURJPY_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP2,"TP2_EURJPY_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP2_EURJPY_UP_S2_OCO1"));
		                 };
	                    Base.EURJPY_UP_S2_OCO1Sets2.Add( Base.EURJPY_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP3,"TP3_EURJPY_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP3_EURJPY_UP_S2_OCO1"));
		                 };
	                    Base.EURJPY_UP_S2_OCO1Sets3.Add( Base.EURJPY_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP4,"TP4_EURJPY_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP4_EURJPY_UP_S2_OCO1"));
		                 };
	                    Base.EURJPY_UP_S2_OCO1Sets4.Add( Base.EURJPY_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP5,"TP5_EURJPY_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP5_EURJPY_UP_S2_OCO1"));
		                 };
	                    Base.EURJPY_UP_S2_OCO1Sets5.Add( Base.EURJPY_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP6,"TP6_EURJPY_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP6_EURJPY_UP_S2_OCO1"));
		                 };
	                    Base.EURJPY_UP_S2_OCO1Sets6.Add( Base.EURJPY_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURJPY_OCO1S1_UP_S2 = 0;
	                for (; EURJPY_OCO1S1_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets1.Count; EURJPY_OCO1S1_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO1Sets1[EURJPY_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO1Sets1[EURJPY_OCO1S1_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO1Sets1.RemoveAt(EURJPY_OCO1S1_UP_S2);
	                        EURJPY_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURJPY_OCO1S2_UP_S2 = 0;
	                for (; EURJPY_OCO1S2_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets2.Count; EURJPY_OCO1S2_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO1Sets2[EURJPY_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO1Sets2[EURJPY_OCO1S2_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO1Sets2.RemoveAt(EURJPY_OCO1S2_UP_S2);
	                        EURJPY_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO1S3_UP_S2 = 0;
	                for (; EURJPY_OCO1S3_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets3.Count; EURJPY_OCO1S3_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO1Sets3[EURJPY_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO1Sets3[EURJPY_OCO1S3_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO1Sets3.RemoveAt(EURJPY_OCO1S3_UP_S2);
	                        EURJPY_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO1S4_UP_S2 = 0;
	                for (; EURJPY_OCO1S4_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets4.Count; EURJPY_OCO1S4_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO1Sets4[EURJPY_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO1Sets4[EURJPY_OCO1S4_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO1Sets4.RemoveAt(EURJPY_OCO1S4_UP_S2);
	                        EURJPY_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURJPY_OCO1S5_UP_S2 = 0;
	                for (; EURJPY_OCO1S5_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets5.Count; EURJPY_OCO1S5_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO1Sets5[EURJPY_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO1Sets5[EURJPY_OCO1S5_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO1Sets5.RemoveAt(EURJPY_OCO1S5_UP_S2);
	                        EURJPY_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURJPY_OCO1S6_UP_S2 = 0;
	                for (; EURJPY_OCO1S6_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets6.Count; EURJPY_OCO1S6_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO1Sets6[EURJPY_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO1Sets6[EURJPY_OCO1S6_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO1Sets6.RemoveAt(EURJPY_OCO1S6_UP_S2);
	                        EURJPY_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.EURJPY_OCO2_EO1_UP_S2)
	                Base.EURJPY_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURJPY_OCO2_EO2_UP_S2)
	                Base.EURJPY_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO2_EO3_UP_S2)
	                Base.EURJPY_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO2_EO4_UP_S2)
	                Base.EURJPY_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO2_EO5_UP_S2)
	                Base.EURJPY_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO2_EO6_UP_S2)
	                Base.EURJPY_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURJPY_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.EURJPY_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP1,"TP1_EURJPY_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP1_EURJPY_UP_S2_OCO2"));
		                 };
		                Base.EURJPY_UP_S2_OCO2Sets1.Add( Base.EURJPY_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURJPY_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP2,"TP2_EURJPY_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP2_EURJPY_UP_S2_OCO2"));
		                 };
	                    Base.EURJPY_UP_S2_OCO2Sets2.Add( Base.EURJPY_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP3,"TP3_EURJPY_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP3_EURJPY_UP_S2_OCO2"));
		                 };
	                    Base.EURJPY_UP_S2_OCO2Sets3.Add( Base.EURJPY_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP4,"TP4_EURJPY_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP4_EURJPY_UP_S2_OCO2"));
		                 };
	                    Base.EURJPY_UP_S2_OCO2Sets4.Add( Base.EURJPY_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP5,"TP5_EURJPY_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP5_EURJPY_UP_S2_OCO2"));
		                 };
	                    Base.EURJPY_UP_S2_OCO2Sets5.Add( Base.EURJPY_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP6,"TP6_EURJPY_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP6_EURJPY_UP_S2_OCO2"));
		                 };
	                    Base.EURJPY_UP_S2_OCO2Sets6.Add( Base.EURJPY_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURJPY_OCO2S1_UP_S2 = 0;
	                for (; EURJPY_OCO2S1_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets1.Count; EURJPY_OCO2S1_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO2Sets1[EURJPY_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO2Sets1[EURJPY_OCO2S1_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO2Sets1.RemoveAt(EURJPY_OCO2S1_UP_S2);
	                        EURJPY_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURJPY_OCO2S2_UP_S2 = 0;
	                for (; EURJPY_OCO2S2_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets2.Count; EURJPY_OCO2S2_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO2Sets2[EURJPY_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO2Sets2[EURJPY_OCO2S2_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO2Sets2.RemoveAt(EURJPY_OCO2S2_UP_S2);
	                        EURJPY_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO2S3_UP_S2 = 0;
	                for (; EURJPY_OCO2S3_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets3.Count; EURJPY_OCO2S3_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO2Sets3[EURJPY_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO2Sets3[EURJPY_OCO2S3_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO2Sets3.RemoveAt(EURJPY_OCO2S3_UP_S2);
	                        EURJPY_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO2S4_UP_S2 = 0;
	                for (; EURJPY_OCO2S4_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets4.Count; EURJPY_OCO2S4_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO2Sets4[EURJPY_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO2Sets4[EURJPY_OCO2S4_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO2Sets4.RemoveAt(EURJPY_OCO2S4_UP_S2);
	                        EURJPY_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURJPY_OCO2S5_UP_S2 = 0;
	                for (; EURJPY_OCO2S5_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets5.Count; EURJPY_OCO2S5_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO2Sets5[EURJPY_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO2Sets5[EURJPY_OCO2S5_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO2Sets5.RemoveAt(EURJPY_OCO2S5_UP_S2);
	                        EURJPY_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURJPY_OCO2S6_UP_S2 = 0;
	                for (; EURJPY_OCO2S6_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets6.Count; EURJPY_OCO2S6_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO2Sets6[EURJPY_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO2Sets6[EURJPY_OCO2S6_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO2Sets6.RemoveAt(EURJPY_OCO2S6_UP_S2);
	                        EURJPY_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURJPY_OCO3_EO1_UP_S2)
	                Base.EURJPY_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURJPY_OCO3_EO2_UP_S2)
	                Base.EURJPY_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO3_EO3_UP_S2)
	                Base.EURJPY_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO3_EO4_UP_S2)
	                Base.EURJPY_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO3_EO5_UP_S2)
	                Base.EURJPY_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO3_EO6_UP_S2)
	                Base.EURJPY_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURJPY_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.EURJPY_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP1,"TP1_EURJPY_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP1_EURJPY_UP_S2_OCO3"));
		                 };
		                Base.EURJPY_UP_S2_OCO3Sets1.Add( Base.EURJPY_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURJPY_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP2,"TP2_EURJPY_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP2_EURJPY_UP_S2_OCO3"));
		                 };
	                    Base.EURJPY_UP_S2_OCO3Sets2.Add( Base.EURJPY_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP3,"TP3_EURJPY_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP3_EURJPY_UP_S2_OCO3"));
		                 };
	                    Base.EURJPY_UP_S2_OCO3Sets3.Add( Base.EURJPY_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP4,"TP4_EURJPY_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP4_EURJPY_UP_S2_OCO3"));
		                 };
	                    Base.EURJPY_UP_S2_OCO3Sets4.Add( Base.EURJPY_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP5,"TP5_EURJPY_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP5_EURJPY_UP_S2_OCO3"));
		                 };
	                    Base.EURJPY_UP_S2_OCO3Sets5.Add( Base.EURJPY_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP6,"TP6_EURJPY_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP6_EURJPY_UP_S2_OCO3"));
		                 };
	                    Base.EURJPY_UP_S2_OCO3Sets6.Add( Base.EURJPY_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURJPY_OCO3S1_UP_S2 = 0;
	                for (; EURJPY_OCO3S1_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets1.Count; EURJPY_OCO3S1_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO3Sets1[EURJPY_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO3Sets1[EURJPY_OCO3S1_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO3Sets1.RemoveAt(EURJPY_OCO3S1_UP_S2);
	                        EURJPY_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURJPY_OCO3S2_UP_S2 = 0;
	                for (; EURJPY_OCO3S2_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets2.Count; EURJPY_OCO3S2_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO3Sets2[EURJPY_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO3Sets2[EURJPY_OCO3S2_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO3Sets2.RemoveAt(EURJPY_OCO3S2_UP_S2);
	                        EURJPY_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO3S3_UP_S2 = 0;
	                for (; EURJPY_OCO3S3_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets3.Count; EURJPY_OCO3S3_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO3Sets3[EURJPY_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO3Sets3[EURJPY_OCO3S3_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO3Sets3.RemoveAt(EURJPY_OCO3S3_UP_S2);
	                        EURJPY_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO3S4_UP_S2 = 0;
	                for (; EURJPY_OCO3S4_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets4.Count; EURJPY_OCO3S4_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO3Sets4[EURJPY_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO3Sets4[EURJPY_OCO3S4_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO3Sets4.RemoveAt(EURJPY_OCO3S4_UP_S2);
	                        EURJPY_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURJPY_OCO3S5_UP_S2 = 0;
	                for (; EURJPY_OCO3S5_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets5.Count; EURJPY_OCO3S5_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO3Sets5[EURJPY_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO3Sets5[EURJPY_OCO3S5_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO3Sets5.RemoveAt(EURJPY_OCO3S5_UP_S2);
	                        EURJPY_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURJPY_OCO3S6_UP_S2 = 0;
	                for (; EURJPY_OCO3S6_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets6.Count; EURJPY_OCO3S6_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO3Sets6[EURJPY_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO3Sets6[EURJPY_OCO3S6_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO3Sets6.RemoveAt(EURJPY_OCO3S6_UP_S2);
	                        EURJPY_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURJPY_OCO4_EO1_UP_S2)
	                Base.EURJPY_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURJPY_OCO4_EO2_UP_S2)
	                Base.EURJPY_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO4_EO3_UP_S2)
	                Base.EURJPY_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO4_EO4_UP_S2)
	                Base.EURJPY_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO4_EO5_UP_S2)
	                Base.EURJPY_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO4_EO6_UP_S2)
	                Base.EURJPY_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURJPY_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.EURJPY_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP1,"TP1_EURJPY_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP1_EURJPY_UP_S2_OCO4"));
		                 };
		                Base.EURJPY_UP_S2_OCO4Sets1.Add( Base.EURJPY_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURJPY_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP2,"TP2_EURJPY_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP2_EURJPY_UP_S2_OCO4"));
		                 };
	                    Base.EURJPY_UP_S2_OCO4Sets2.Add( Base.EURJPY_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP3,"TP3_EURJPY_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP3_EURJPY_UP_S2_OCO4"));
		                 };
	                    Base.EURJPY_UP_S2_OCO4Sets3.Add( Base.EURJPY_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP4,"TP4_EURJPY_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP4_EURJPY_UP_S2_OCO4"));
		                 };
	                    Base.EURJPY_UP_S2_OCO4Sets4.Add( Base.EURJPY_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP5,"TP5_EURJPY_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP5_EURJPY_UP_S2_OCO4"));
		                 };
	                    Base.EURJPY_UP_S2_OCO4Sets5.Add( Base.EURJPY_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_UP_S2_TP6,"TP6_EURJPY_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_UP_S2_SL,"SL_TP6_EURJPY_UP_S2_OCO4"));
		                 };
	                    Base.EURJPY_UP_S2_OCO4Sets6.Add( Base.EURJPY_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURJPY_OCO4S1_UP_S2 = 0;
	                for (; EURJPY_OCO4S1_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets1.Count; EURJPY_OCO4S1_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO4Sets1[EURJPY_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO4Sets1[EURJPY_OCO4S1_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO4Sets1.RemoveAt(EURJPY_OCO4S1_UP_S2);
	                        EURJPY_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURJPY_OCO4S2_UP_S2 = 0;
	                for (; EURJPY_OCO4S2_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets2.Count; EURJPY_OCO4S2_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO4Sets2[EURJPY_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO4Sets2[EURJPY_OCO4S2_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO4Sets2.RemoveAt(EURJPY_OCO4S2_UP_S2);
	                        EURJPY_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO4S3_UP_S2 = 0;
	                for (; EURJPY_OCO4S3_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets3.Count; EURJPY_OCO4S3_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO4Sets3[EURJPY_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO4Sets3[EURJPY_OCO4S3_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO4Sets3.RemoveAt(EURJPY_OCO4S3_UP_S2);
	                        EURJPY_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO4S4_UP_S2 = 0;
	                for (; EURJPY_OCO4S4_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets4.Count; EURJPY_OCO4S4_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO4Sets4[EURJPY_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO4Sets4[EURJPY_OCO4S4_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO4Sets4.RemoveAt(EURJPY_OCO4S4_UP_S2);
	                        EURJPY_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURJPY_OCO4S5_UP_S2 = 0;
	                for (; EURJPY_OCO4S5_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets5.Count; EURJPY_OCO4S5_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO4Sets5[EURJPY_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO4Sets5[EURJPY_OCO4S5_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO4Sets5.RemoveAt(EURJPY_OCO4S5_UP_S2);
	                        EURJPY_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURJPY_OCO4S6_UP_S2 = 0;
	                for (; EURJPY_OCO4S6_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets6.Count; EURJPY_OCO4S6_UP_S2++)
	                    if (Base.EURJPY_UP_S2_OCO4Sets6[EURJPY_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_UP_S2_OCO4Sets6[EURJPY_OCO4S6_UP_S2].Filled();
	                        Base.EURJPY_UP_S2_OCO4Sets6.RemoveAt(EURJPY_OCO4S6_UP_S2);
	                        EURJPY_OCO4S6_UP_S2 = 0;
	                        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.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 USDCHF_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public USDCHF_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("USDCHF OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCHF OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCHF OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCHF OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCHF OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCHF OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCHF OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCHF OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCHF OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCHF S2");
		        	}
		        }
		        
				if (Base.USDCHF_OCO1_EO1_UP_S2)
	                Base.USDCHF_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDCHF_OCO1_EO2_UP_S2)
	                Base.USDCHF_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO1_EO3_UP_S2)
	                Base.USDCHF_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO1_EO4_UP_S2)
	                Base.USDCHF_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO1_EO5_UP_S2)
	                Base.USDCHF_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO1_EO6_UP_S2)
	                Base.USDCHF_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCHF_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.USDCHF_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP1,"TP1_USDCHF_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP1_USDCHF_UP_S2_OCO1"));
		                 };
		                Base.USDCHF_UP_S2_OCO1Sets1.Add( Base.USDCHF_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCHF_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP2,"TP2_USDCHF_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP2_USDCHF_UP_S2_OCO1"));
		                 };
	                    Base.USDCHF_UP_S2_OCO1Sets2.Add( Base.USDCHF_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP3,"TP3_USDCHF_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP3_USDCHF_UP_S2_OCO1"));
		                 };
	                    Base.USDCHF_UP_S2_OCO1Sets3.Add( Base.USDCHF_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP4,"TP4_USDCHF_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP4_USDCHF_UP_S2_OCO1"));
		                 };
	                    Base.USDCHF_UP_S2_OCO1Sets4.Add( Base.USDCHF_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP5,"TP5_USDCHF_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP5_USDCHF_UP_S2_OCO1"));
		                 };
	                    Base.USDCHF_UP_S2_OCO1Sets5.Add( Base.USDCHF_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP6,"TP6_USDCHF_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP6_USDCHF_UP_S2_OCO1"));
		                 };
	                    Base.USDCHF_UP_S2_OCO1Sets6.Add( Base.USDCHF_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDCHF_OCO1S1_UP_S2 = 0;
	                for (; USDCHF_OCO1S1_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets1.Count; USDCHF_OCO1S1_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO1Sets1[USDCHF_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO1Sets1[USDCHF_OCO1S1_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO1Sets1.RemoveAt(USDCHF_OCO1S1_UP_S2);
	                        USDCHF_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDCHF_OCO1S2_UP_S2 = 0;
	                for (; USDCHF_OCO1S2_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets2.Count; USDCHF_OCO1S2_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO1Sets2[USDCHF_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO1Sets2[USDCHF_OCO1S2_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO1Sets2.RemoveAt(USDCHF_OCO1S2_UP_S2);
	                        USDCHF_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO1S3_UP_S2 = 0;
	                for (; USDCHF_OCO1S3_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets3.Count; USDCHF_OCO1S3_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO1Sets3[USDCHF_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO1Sets3[USDCHF_OCO1S3_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO1Sets3.RemoveAt(USDCHF_OCO1S3_UP_S2);
	                        USDCHF_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO1S4_UP_S2 = 0;
	                for (; USDCHF_OCO1S4_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets4.Count; USDCHF_OCO1S4_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO1Sets4[USDCHF_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO1Sets4[USDCHF_OCO1S4_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO1Sets4.RemoveAt(USDCHF_OCO1S4_UP_S2);
	                        USDCHF_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCHF_OCO1S5_UP_S2 = 0;
	                for (; USDCHF_OCO1S5_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets5.Count; USDCHF_OCO1S5_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO1Sets5[USDCHF_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO1Sets5[USDCHF_OCO1S5_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO1Sets5.RemoveAt(USDCHF_OCO1S5_UP_S2);
	                        USDCHF_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCHF_OCO1S6_UP_S2 = 0;
	                for (; USDCHF_OCO1S6_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets6.Count; USDCHF_OCO1S6_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO1Sets6[USDCHF_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO1Sets6[USDCHF_OCO1S6_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO1Sets6.RemoveAt(USDCHF_OCO1S6_UP_S2);
	                        USDCHF_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.USDCHF_OCO2_EO1_UP_S2)
	                Base.USDCHF_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDCHF_OCO2_EO2_UP_S2)
	                Base.USDCHF_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO2_EO3_UP_S2)
	                Base.USDCHF_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO2_EO4_UP_S2)
	                Base.USDCHF_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO2_EO5_UP_S2)
	                Base.USDCHF_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO2_EO6_UP_S2)
	                Base.USDCHF_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCHF_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.USDCHF_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP1,"TP1_USDCHF_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP1_USDCHF_UP_S2_OCO2"));
		                 };
		                Base.USDCHF_UP_S2_OCO2Sets1.Add( Base.USDCHF_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCHF_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP2,"TP2_USDCHF_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP2_USDCHF_UP_S2_OCO2"));
		                 };
	                    Base.USDCHF_UP_S2_OCO2Sets2.Add( Base.USDCHF_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP3,"TP3_USDCHF_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP3_USDCHF_UP_S2_OCO2"));
		                 };
	                    Base.USDCHF_UP_S2_OCO2Sets3.Add( Base.USDCHF_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP4,"TP4_USDCHF_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP4_USDCHF_UP_S2_OCO2"));
		                 };
	                    Base.USDCHF_UP_S2_OCO2Sets4.Add( Base.USDCHF_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP5,"TP5_USDCHF_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP5_USDCHF_UP_S2_OCO2"));
		                 };
	                    Base.USDCHF_UP_S2_OCO2Sets5.Add( Base.USDCHF_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP6,"TP6_USDCHF_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP6_USDCHF_UP_S2_OCO2"));
		                 };
	                    Base.USDCHF_UP_S2_OCO2Sets6.Add( Base.USDCHF_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDCHF_OCO2S1_UP_S2 = 0;
	                for (; USDCHF_OCO2S1_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets1.Count; USDCHF_OCO2S1_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO2Sets1[USDCHF_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO2Sets1[USDCHF_OCO2S1_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO2Sets1.RemoveAt(USDCHF_OCO2S1_UP_S2);
	                        USDCHF_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDCHF_OCO2S2_UP_S2 = 0;
	                for (; USDCHF_OCO2S2_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets2.Count; USDCHF_OCO2S2_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO2Sets2[USDCHF_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO2Sets2[USDCHF_OCO2S2_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO2Sets2.RemoveAt(USDCHF_OCO2S2_UP_S2);
	                        USDCHF_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO2S3_UP_S2 = 0;
	                for (; USDCHF_OCO2S3_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets3.Count; USDCHF_OCO2S3_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO2Sets3[USDCHF_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO2Sets3[USDCHF_OCO2S3_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO2Sets3.RemoveAt(USDCHF_OCO2S3_UP_S2);
	                        USDCHF_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO2S4_UP_S2 = 0;
	                for (; USDCHF_OCO2S4_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets4.Count; USDCHF_OCO2S4_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO2Sets4[USDCHF_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO2Sets4[USDCHF_OCO2S4_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO2Sets4.RemoveAt(USDCHF_OCO2S4_UP_S2);
	                        USDCHF_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCHF_OCO2S5_UP_S2 = 0;
	                for (; USDCHF_OCO2S5_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets5.Count; USDCHF_OCO2S5_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO2Sets5[USDCHF_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO2Sets5[USDCHF_OCO2S5_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO2Sets5.RemoveAt(USDCHF_OCO2S5_UP_S2);
	                        USDCHF_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCHF_OCO2S6_UP_S2 = 0;
	                for (; USDCHF_OCO2S6_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets6.Count; USDCHF_OCO2S6_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO2Sets6[USDCHF_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO2Sets6[USDCHF_OCO2S6_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO2Sets6.RemoveAt(USDCHF_OCO2S6_UP_S2);
	                        USDCHF_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCHF_OCO3_EO1_UP_S2)
	                Base.USDCHF_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDCHF_OCO3_EO2_UP_S2)
	                Base.USDCHF_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO3_EO3_UP_S2)
	                Base.USDCHF_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO3_EO4_UP_S2)
	                Base.USDCHF_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO3_EO5_UP_S2)
	                Base.USDCHF_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO3_EO6_UP_S2)
	                Base.USDCHF_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCHF_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.USDCHF_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP1,"TP1_USDCHF_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP1_USDCHF_UP_S2_OCO3"));
		                 };
		                Base.USDCHF_UP_S2_OCO3Sets1.Add( Base.USDCHF_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCHF_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP2,"TP2_USDCHF_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP2_USDCHF_UP_S2_OCO3"));
		                 };
	                    Base.USDCHF_UP_S2_OCO3Sets2.Add( Base.USDCHF_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP3,"TP3_USDCHF_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP3_USDCHF_UP_S2_OCO3"));
		                 };
	                    Base.USDCHF_UP_S2_OCO3Sets3.Add( Base.USDCHF_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP4,"TP4_USDCHF_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP4_USDCHF_UP_S2_OCO3"));
		                 };
	                    Base.USDCHF_UP_S2_OCO3Sets4.Add( Base.USDCHF_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP5,"TP5_USDCHF_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP5_USDCHF_UP_S2_OCO3"));
		                 };
	                    Base.USDCHF_UP_S2_OCO3Sets5.Add( Base.USDCHF_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP6,"TP6_USDCHF_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP6_USDCHF_UP_S2_OCO3"));
		                 };
	                    Base.USDCHF_UP_S2_OCO3Sets6.Add( Base.USDCHF_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDCHF_OCO3S1_UP_S2 = 0;
	                for (; USDCHF_OCO3S1_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets1.Count; USDCHF_OCO3S1_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO3Sets1[USDCHF_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO3Sets1[USDCHF_OCO3S1_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO3Sets1.RemoveAt(USDCHF_OCO3S1_UP_S2);
	                        USDCHF_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDCHF_OCO3S2_UP_S2 = 0;
	                for (; USDCHF_OCO3S2_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets2.Count; USDCHF_OCO3S2_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO3Sets2[USDCHF_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO3Sets2[USDCHF_OCO3S2_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO3Sets2.RemoveAt(USDCHF_OCO3S2_UP_S2);
	                        USDCHF_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO3S3_UP_S2 = 0;
	                for (; USDCHF_OCO3S3_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets3.Count; USDCHF_OCO3S3_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO3Sets3[USDCHF_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO3Sets3[USDCHF_OCO3S3_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO3Sets3.RemoveAt(USDCHF_OCO3S3_UP_S2);
	                        USDCHF_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO3S4_UP_S2 = 0;
	                for (; USDCHF_OCO3S4_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets4.Count; USDCHF_OCO3S4_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO3Sets4[USDCHF_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO3Sets4[USDCHF_OCO3S4_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO3Sets4.RemoveAt(USDCHF_OCO3S4_UP_S2);
	                        USDCHF_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCHF_OCO3S5_UP_S2 = 0;
	                for (; USDCHF_OCO3S5_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets5.Count; USDCHF_OCO3S5_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO3Sets5[USDCHF_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO3Sets5[USDCHF_OCO3S5_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO3Sets5.RemoveAt(USDCHF_OCO3S5_UP_S2);
	                        USDCHF_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCHF_OCO3S6_UP_S2 = 0;
	                for (; USDCHF_OCO3S6_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets6.Count; USDCHF_OCO3S6_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO3Sets6[USDCHF_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO3Sets6[USDCHF_OCO3S6_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO3Sets6.RemoveAt(USDCHF_OCO3S6_UP_S2);
	                        USDCHF_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCHF_OCO4_EO1_UP_S2)
	                Base.USDCHF_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDCHF_OCO4_EO2_UP_S2)
	                Base.USDCHF_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO4_EO3_UP_S2)
	                Base.USDCHF_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO4_EO4_UP_S2)
	                Base.USDCHF_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO4_EO5_UP_S2)
	                Base.USDCHF_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCHF_OCO4_EO6_UP_S2)
	                Base.USDCHF_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCHF_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.USDCHF_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP1,"TP1_USDCHF_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP1_USDCHF_UP_S2_OCO4"));
		                 };
		                Base.USDCHF_UP_S2_OCO4Sets1.Add( Base.USDCHF_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCHF_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP2,"TP2_USDCHF_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP2_USDCHF_UP_S2_OCO4"));
		                 };
	                    Base.USDCHF_UP_S2_OCO4Sets2.Add( Base.USDCHF_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP3,"TP3_USDCHF_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP3_USDCHF_UP_S2_OCO4"));
		                 };
	                    Base.USDCHF_UP_S2_OCO4Sets3.Add( Base.USDCHF_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP4,"TP4_USDCHF_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP4_USDCHF_UP_S2_OCO4"));
		                 };
	                    Base.USDCHF_UP_S2_OCO4Sets4.Add( Base.USDCHF_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP5,"TP5_USDCHF_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP5_USDCHF_UP_S2_OCO4"));
		                 };
	                    Base.USDCHF_UP_S2_OCO4Sets5.Add( Base.USDCHF_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCHF_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.USDCHF_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCHF_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCHF_UP_S2_TP6,"TP6_USDCHF_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCHF_UP_S2_SL,"SL_TP6_USDCHF_UP_S2_OCO4"));
		                 };
	                    Base.USDCHF_UP_S2_OCO4Sets6.Add( Base.USDCHF_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCHF_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDCHF_OCO4S1_UP_S2 = 0;
	                for (; USDCHF_OCO4S1_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets1.Count; USDCHF_OCO4S1_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO4Sets1[USDCHF_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO4Sets1[USDCHF_OCO4S1_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO4Sets1.RemoveAt(USDCHF_OCO4S1_UP_S2);
	                        USDCHF_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDCHF_OCO4S2_UP_S2 = 0;
	                for (; USDCHF_OCO4S2_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets2.Count; USDCHF_OCO4S2_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO4Sets2[USDCHF_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO4Sets2[USDCHF_OCO4S2_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO4Sets2.RemoveAt(USDCHF_OCO4S2_UP_S2);
	                        USDCHF_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO4S3_UP_S2 = 0;
	                for (; USDCHF_OCO4S3_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets3.Count; USDCHF_OCO4S3_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO4Sets3[USDCHF_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO4Sets3[USDCHF_OCO4S3_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO4Sets3.RemoveAt(USDCHF_OCO4S3_UP_S2);
	                        USDCHF_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCHF_OCO4S4_UP_S2 = 0;
	                for (; USDCHF_OCO4S4_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets4.Count; USDCHF_OCO4S4_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO4Sets4[USDCHF_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO4Sets4[USDCHF_OCO4S4_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO4Sets4.RemoveAt(USDCHF_OCO4S4_UP_S2);
	                        USDCHF_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCHF_OCO4S5_UP_S2 = 0;
	                for (; USDCHF_OCO4S5_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets5.Count; USDCHF_OCO4S5_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO4Sets5[USDCHF_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO4Sets5[USDCHF_OCO4S5_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO4Sets5.RemoveAt(USDCHF_OCO4S5_UP_S2);
	                        USDCHF_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCHF_OCO4S6_UP_S2 = 0;
	                for (; USDCHF_OCO4S6_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets6.Count; USDCHF_OCO4S6_UP_S2++)
	                    if (Base.USDCHF_UP_S2_OCO4Sets6[USDCHF_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCHF_UP_S2_OCO4Sets6[USDCHF_OCO4S6_UP_S2].Filled();
	                        Base.USDCHF_UP_S2_OCO4Sets6.RemoveAt(USDCHF_OCO4S6_UP_S2);
	                        USDCHF_OCO4S6_UP_S2 = 0;
	                        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 _GBPUSD;
		
    	///oco1 up
    	public static OrderTicket GBPUSD_OCO1_MO1_UP_S2;
    	public static OrderTicket GBPUSD_OCO1_MO2_UP_S2;
    	public static OrderTicket GBPUSD_OCO1_MO3_UP_S2;
    	public static OrderTicket GBPUSD_OCO1_MO4_UP_S2;
    	public static OrderTicket GBPUSD_OCO1_MO5_UP_S2;
    	public static OrderTicket GBPUSD_OCO1_MO6_UP_S2;
    	
    	public static int GBPUSD_OCO1_EO1_UP_S2_ID ;
        public static int GBPUSD_OCO1_EO2_UP_S2_ID ;
        public static int GBPUSD_OCO1_EO3_UP_S2_ID ;
        public static int GBPUSD_OCO1_EO4_UP_S2_ID ;
        public static int GBPUSD_OCO1_EO5_UP_S2_ID ;
        public static int GBPUSD_OCO1_EO6_UP_S2_ID ;
        
        public static bool GBPUSD_OCO1_EO1_UP_S2 ;
        public static bool GBPUSD_OCO1_EO2_UP_S2 ;
        public static bool GBPUSD_OCO1_EO3_UP_S2 ;
        public static bool GBPUSD_OCO1_EO4_UP_S2 ;
        public static bool GBPUSD_OCO1_EO5_UP_S2 ;
        public static bool GBPUSD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_UP_S2> GBPUSD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_UP_S2> GBPUSD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_UP_S2> GBPUSD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_UP_S2> GBPUSD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_UP_S2> GBPUSD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_UP_S2> GBPUSD_OOFE_OCO1_UP_S2_6 ;
        
        public static GBPUSD_OCO1_UP_S2 GBPUSD_PFO_OCO1_UP_S2_1 ;
        public static GBPUSD_OCO1_UP_S2 GBPUSD_PFO_OCO1_UP_S2_2 ;
        public static GBPUSD_OCO1_UP_S2 GBPUSD_PFO_OCO1_UP_S2_3 ;
        public static GBPUSD_OCO1_UP_S2 GBPUSD_PFO_OCO1_UP_S2_4 ;
        public static GBPUSD_OCO1_UP_S2 GBPUSD_PFO_OCO1_UP_S2_5 ;
        public static GBPUSD_OCO1_UP_S2 GBPUSD_PFO_OCO1_UP_S2_6 ;
        
        public static List<GBPUSD_OCO1_UP_S2> GBPUSD_UP_S2_OCO1Sets1 = new List<GBPUSD_OCO1_UP_S2>();
        public static List<GBPUSD_OCO1_UP_S2> GBPUSD_UP_S2_OCO1Sets2 = new List<GBPUSD_OCO1_UP_S2>();
        public static List<GBPUSD_OCO1_UP_S2> GBPUSD_UP_S2_OCO1Sets3 = new List<GBPUSD_OCO1_UP_S2>();
        public static List<GBPUSD_OCO1_UP_S2> GBPUSD_UP_S2_OCO1Sets4 = new List<GBPUSD_OCO1_UP_S2>();
        public static List<GBPUSD_OCO1_UP_S2> GBPUSD_UP_S2_OCO1Sets5 = new List<GBPUSD_OCO1_UP_S2>();
        public static List<GBPUSD_OCO1_UP_S2> GBPUSD_UP_S2_OCO1Sets6 = new List<GBPUSD_OCO1_UP_S2>();
        
        public static bool GBPUSD_OCO1_UP_S2_IsReady = true;
        public static bool GBPUSD_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket GBPUSD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int GBPUSD_OCO1_EO1_DOWN_S2_ID ;
        public static int GBPUSD_OCO1_EO2_DOWN_S2_ID ;
        public static int GBPUSD_OCO1_EO3_DOWN_S2_ID ;
        public static int GBPUSD_OCO1_EO4_DOWN_S2_ID ;
        public static int GBPUSD_OCO1_EO5_DOWN_S2_ID ;
        public static int GBPUSD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool GBPUSD_OCO1_EO1_DOWN_S2 ;
        public static bool GBPUSD_OCO1_EO2_DOWN_S2 ;
        public static bool GBPUSD_OCO1_EO3_DOWN_S2 ;
        public static bool GBPUSD_OCO1_EO4_DOWN_S2 ;
        public static bool GBPUSD_OCO1_EO5_DOWN_S2 ;
        public static bool GBPUSD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_DOWN_S2> GBPUSD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_DOWN_S2> GBPUSD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_DOWN_S2> GBPUSD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_DOWN_S2> GBPUSD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_DOWN_S2> GBPUSD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO1_DOWN_S2> GBPUSD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static GBPUSD_OCO1_DOWN_S2 GBPUSD_PFO_OCO1_DOWN_S2_1 ;
        public static GBPUSD_OCO1_DOWN_S2 GBPUSD_PFO_OCO1_DOWN_S2_2 ;
        public static GBPUSD_OCO1_DOWN_S2 GBPUSD_PFO_OCO1_DOWN_S2_3 ;
        public static GBPUSD_OCO1_DOWN_S2 GBPUSD_PFO_OCO1_DOWN_S2_4 ;
        public static GBPUSD_OCO1_DOWN_S2 GBPUSD_PFO_OCO1_DOWN_S2_5 ;
        public static GBPUSD_OCO1_DOWN_S2 GBPUSD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<GBPUSD_OCO1_DOWN_S2> GBPUSD_DOWN_S2_OCO1Sets1 = new List<GBPUSD_OCO1_DOWN_S2>();
        public static List<GBPUSD_OCO1_DOWN_S2> GBPUSD_DOWN_S2_OCO1Sets2 = new List<GBPUSD_OCO1_DOWN_S2>();
        public static List<GBPUSD_OCO1_DOWN_S2> GBPUSD_DOWN_S2_OCO1Sets3 = new List<GBPUSD_OCO1_DOWN_S2>();
        public static List<GBPUSD_OCO1_DOWN_S2> GBPUSD_DOWN_S2_OCO1Sets4 = new List<GBPUSD_OCO1_DOWN_S2>();
        public static List<GBPUSD_OCO1_DOWN_S2> GBPUSD_DOWN_S2_OCO1Sets5 = new List<GBPUSD_OCO1_DOWN_S2>();
        public static List<GBPUSD_OCO1_DOWN_S2> GBPUSD_DOWN_S2_OCO1Sets6 = new List<GBPUSD_OCO1_DOWN_S2>();
        
        public static bool GBPUSD_OCO1_DOWN_S2_IsReady = true;
        public static bool GBPUSD_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket GBPUSD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO6_UP_S2 ;
    	
    	public static int GBPUSD_OCO2_EO1_UP_S2_ID ;
        public static int GBPUSD_OCO2_EO2_UP_S2_ID ;
        public static int GBPUSD_OCO2_EO3_UP_S2_ID ;
        public static int GBPUSD_OCO2_EO4_UP_S2_ID ;
        public static int GBPUSD_OCO2_EO5_UP_S2_ID ;
        public static int GBPUSD_OCO2_EO6_UP_S2_ID ;
        
        public static bool GBPUSD_OCO2_EO1_UP_S2 ;
        public static bool GBPUSD_OCO2_EO2_UP_S2 ;
        public static bool GBPUSD_OCO2_EO3_UP_S2 ;
        public static bool GBPUSD_OCO2_EO4_UP_S2 ;
        public static bool GBPUSD_OCO2_EO5_UP_S2 ;
        public static bool GBPUSD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_UP_S2> GBPUSD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_UP_S2> GBPUSD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_UP_S2> GBPUSD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_UP_S2> GBPUSD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_UP_S2> GBPUSD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_UP_S2> GBPUSD_OOFE_OCO2_UP_S2_6 ;
        
        public static GBPUSD_OCO2_UP_S2 GBPUSD_PFO_OCO2_UP_S2_1 ;
        public static GBPUSD_OCO2_UP_S2 GBPUSD_PFO_OCO2_UP_S2_2 ;
        public static GBPUSD_OCO2_UP_S2 GBPUSD_PFO_OCO2_UP_S2_3 ;
        public static GBPUSD_OCO2_UP_S2 GBPUSD_PFO_OCO2_UP_S2_4 ;
        public static GBPUSD_OCO2_UP_S2 GBPUSD_PFO_OCO2_UP_S2_5 ;
        public static GBPUSD_OCO2_UP_S2 GBPUSD_PFO_OCO2_UP_S2_6 ;
        
        public static List<GBPUSD_OCO2_UP_S2> GBPUSD_UP_S2_OCO2Sets1 = new List<GBPUSD_OCO2_UP_S2>();
        public static List<GBPUSD_OCO2_UP_S2> GBPUSD_UP_S2_OCO2Sets2 = new List<GBPUSD_OCO2_UP_S2>();
        public static List<GBPUSD_OCO2_UP_S2> GBPUSD_UP_S2_OCO2Sets3 = new List<GBPUSD_OCO2_UP_S2>();
        public static List<GBPUSD_OCO2_UP_S2> GBPUSD_UP_S2_OCO2Sets4 = new List<GBPUSD_OCO2_UP_S2>();
        public static List<GBPUSD_OCO2_UP_S2> GBPUSD_UP_S2_OCO2Sets5 = new List<GBPUSD_OCO2_UP_S2>();
        public static List<GBPUSD_OCO2_UP_S2> GBPUSD_UP_S2_OCO2Sets6 = new List<GBPUSD_OCO2_UP_S2>();
        
        public static bool GBPUSD_OCO2_UP_S2_IsReady = true;
        public static bool GBPUSD_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket GBPUSD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int GBPUSD_OCO2_EO1_DOWN_S2_ID ;
        public static int GBPUSD_OCO2_EO2_DOWN_S2_ID ;
        public static int GBPUSD_OCO2_EO3_DOWN_S2_ID ;
        public static int GBPUSD_OCO2_EO4_DOWN_S2_ID ;
        public static int GBPUSD_OCO2_EO5_DOWN_S2_ID ;
        public static int GBPUSD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool GBPUSD_OCO2_EO1_DOWN_S2 ;
        public static bool GBPUSD_OCO2_EO2_DOWN_S2 ;
        public static bool GBPUSD_OCO2_EO3_DOWN_S2 ;
        public static bool GBPUSD_OCO2_EO4_DOWN_S2 ;
        public static bool GBPUSD_OCO2_EO5_DOWN_S2 ;
        public static bool GBPUSD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_DOWN_S2> GBPUSD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_DOWN_S2> GBPUSD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_DOWN_S2> GBPUSD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_DOWN_S2> GBPUSD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_DOWN_S2> GBPUSD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO2_DOWN_S2> GBPUSD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static GBPUSD_OCO2_DOWN_S2 GBPUSD_PFO_OCO2_DOWN_S2_1 ;
        public static GBPUSD_OCO2_DOWN_S2 GBPUSD_PFO_OCO2_DOWN_S2_2 ;
        public static GBPUSD_OCO2_DOWN_S2 GBPUSD_PFO_OCO2_DOWN_S2_3 ;
        public static GBPUSD_OCO2_DOWN_S2 GBPUSD_PFO_OCO2_DOWN_S2_4 ;
        public static GBPUSD_OCO2_DOWN_S2 GBPUSD_PFO_OCO2_DOWN_S2_5 ;
        public static GBPUSD_OCO2_DOWN_S2 GBPUSD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<GBPUSD_OCO2_DOWN_S2> GBPUSD_DOWN_S2_OCO2Sets1 = new List<GBPUSD_OCO2_DOWN_S2>();
        public static List<GBPUSD_OCO2_DOWN_S2> GBPUSD_DOWN_S2_OCO2Sets2 = new List<GBPUSD_OCO2_DOWN_S2>();
        public static List<GBPUSD_OCO2_DOWN_S2> GBPUSD_DOWN_S2_OCO2Sets3 = new List<GBPUSD_OCO2_DOWN_S2>();
        public static List<GBPUSD_OCO2_DOWN_S2> GBPUSD_DOWN_S2_OCO2Sets4 = new List<GBPUSD_OCO2_DOWN_S2>();
        public static List<GBPUSD_OCO2_DOWN_S2> GBPUSD_DOWN_S2_OCO2Sets5 = new List<GBPUSD_OCO2_DOWN_S2>();
        public static List<GBPUSD_OCO2_DOWN_S2> GBPUSD_DOWN_S2_OCO2Sets6 = new List<GBPUSD_OCO2_DOWN_S2>();
        
        public static bool GBPUSD_OCO2_DOWN_S2_IsReady = true;
        public static bool GBPUSD_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket GBPUSD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO6_UP_S2 ;
    	
    	public static int GBPUSD_OCO3_EO1_UP_S2_ID ;
        public static int GBPUSD_OCO3_EO2_UP_S2_ID ;
        public static int GBPUSD_OCO3_EO3_UP_S2_ID ;
        public static int GBPUSD_OCO3_EO4_UP_S2_ID ;
        public static int GBPUSD_OCO3_EO5_UP_S2_ID ;
        public static int GBPUSD_OCO3_EO6_UP_S2_ID ;
        
        public static bool GBPUSD_OCO3_EO1_UP_S2 ;
        public static bool GBPUSD_OCO3_EO2_UP_S2 ;
        public static bool GBPUSD_OCO3_EO3_UP_S2 ;
        public static bool GBPUSD_OCO3_EO4_UP_S2 ;
        public static bool GBPUSD_OCO3_EO5_UP_S2 ;
        public static bool GBPUSD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_UP_S2> GBPUSD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_UP_S2> GBPUSD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_UP_S2> GBPUSD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_UP_S2> GBPUSD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_UP_S2> GBPUSD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_UP_S2> GBPUSD_OOFE_OCO3_UP_S2_6 ;
        
        public static GBPUSD_OCO3_UP_S2 GBPUSD_PFO_OCO3_UP_S2_1 ;
        public static GBPUSD_OCO3_UP_S2 GBPUSD_PFO_OCO3_UP_S2_2 ;
        public static GBPUSD_OCO3_UP_S2 GBPUSD_PFO_OCO3_UP_S2_3 ;
        public static GBPUSD_OCO3_UP_S2 GBPUSD_PFO_OCO3_UP_S2_4 ;
        public static GBPUSD_OCO3_UP_S2 GBPUSD_PFO_OCO3_UP_S2_5 ;
        public static GBPUSD_OCO3_UP_S2 GBPUSD_PFO_OCO3_UP_S2_6 ;
        
        public static List<GBPUSD_OCO3_UP_S2> GBPUSD_UP_S2_OCO3Sets1 = new List<GBPUSD_OCO3_UP_S2>();
        public static List<GBPUSD_OCO3_UP_S2> GBPUSD_UP_S2_OCO3Sets2 = new List<GBPUSD_OCO3_UP_S2>();
        public static List<GBPUSD_OCO3_UP_S2> GBPUSD_UP_S2_OCO3Sets3 = new List<GBPUSD_OCO3_UP_S2>();
        public static List<GBPUSD_OCO3_UP_S2> GBPUSD_UP_S2_OCO3Sets4 = new List<GBPUSD_OCO3_UP_S2>();
        public static List<GBPUSD_OCO3_UP_S2> GBPUSD_UP_S2_OCO3Sets5 = new List<GBPUSD_OCO3_UP_S2>();
        public static List<GBPUSD_OCO3_UP_S2> GBPUSD_UP_S2_OCO3Sets6 = new List<GBPUSD_OCO3_UP_S2>();
        
        public static bool GBPUSD_OCO3_UP_S2_IsReady = true;
        public static bool GBPUSD_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket GBPUSD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int GBPUSD_OCO3_EO1_DOWN_S2_ID ;
        public static int GBPUSD_OCO3_EO2_DOWN_S2_ID ;
        public static int GBPUSD_OCO3_EO3_DOWN_S2_ID ;
        public static int GBPUSD_OCO3_EO4_DOWN_S2_ID ;
        public static int GBPUSD_OCO3_EO5_DOWN_S2_ID ;
        public static int GBPUSD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool GBPUSD_OCO3_EO1_DOWN_S2 ;
        public static bool GBPUSD_OCO3_EO2_DOWN_S2 ;
        public static bool GBPUSD_OCO3_EO3_DOWN_S2 ;
        public static bool GBPUSD_OCO3_EO4_DOWN_S2 ;
        public static bool GBPUSD_OCO3_EO5_DOWN_S2 ;
        public static bool GBPUSD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_DOWN_S2> GBPUSD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_DOWN_S2> GBPUSD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_DOWN_S2> GBPUSD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_DOWN_S2> GBPUSD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_DOWN_S2> GBPUSD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO3_DOWN_S2> GBPUSD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static GBPUSD_OCO3_DOWN_S2 GBPUSD_PFO_OCO3_DOWN_S2_1 ;
        public static GBPUSD_OCO3_DOWN_S2 GBPUSD_PFO_OCO3_DOWN_S2_2 ;
        public static GBPUSD_OCO3_DOWN_S2 GBPUSD_PFO_OCO3_DOWN_S2_3 ;
        public static GBPUSD_OCO3_DOWN_S2 GBPUSD_PFO_OCO3_DOWN_S2_4 ;
        public static GBPUSD_OCO3_DOWN_S2 GBPUSD_PFO_OCO3_DOWN_S2_5 ;
        public static GBPUSD_OCO3_DOWN_S2 GBPUSD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<GBPUSD_OCO3_DOWN_S2> GBPUSD_DOWN_S2_OCO3Sets1 = new List<GBPUSD_OCO3_DOWN_S2>();
        public static List<GBPUSD_OCO3_DOWN_S2> GBPUSD_DOWN_S2_OCO3Sets2 = new List<GBPUSD_OCO3_DOWN_S2>();
        public static List<GBPUSD_OCO3_DOWN_S2> GBPUSD_DOWN_S2_OCO3Sets3 = new List<GBPUSD_OCO3_DOWN_S2>();
        public static List<GBPUSD_OCO3_DOWN_S2> GBPUSD_DOWN_S2_OCO3Sets4 = new List<GBPUSD_OCO3_DOWN_S2>();
        public static List<GBPUSD_OCO3_DOWN_S2> GBPUSD_DOWN_S2_OCO3Sets5 = new List<GBPUSD_OCO3_DOWN_S2>();
        public static List<GBPUSD_OCO3_DOWN_S2> GBPUSD_DOWN_S2_OCO3Sets6 = new List<GBPUSD_OCO3_DOWN_S2>();
        
        public static bool GBPUSD_OCO3_DOWN_S2_IsReady = true;
        public static bool GBPUSD_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket GBPUSD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO6_UP_S2 ;
    	
    	public static int GBPUSD_OCO4_EO1_UP_S2_ID ;
        public static int GBPUSD_OCO4_EO2_UP_S2_ID ;
        public static int GBPUSD_OCO4_EO3_UP_S2_ID ;
        public static int GBPUSD_OCO4_EO4_UP_S2_ID ;
        public static int GBPUSD_OCO4_EO5_UP_S2_ID ;
        public static int GBPUSD_OCO4_EO6_UP_S2_ID ;
        
        public static bool GBPUSD_OCO4_EO1_UP_S2 ;
        public static bool GBPUSD_OCO4_EO2_UP_S2 ;
        public static bool GBPUSD_OCO4_EO3_UP_S2 ;
        public static bool GBPUSD_OCO4_EO4_UP_S2 ;
        public static bool GBPUSD_OCO4_EO5_UP_S2 ;
        public static bool GBPUSD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_UP_S2> GBPUSD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_UP_S2> GBPUSD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_UP_S2> GBPUSD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_UP_S2> GBPUSD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_UP_S2> GBPUSD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_UP_S2> GBPUSD_OOFE_OCO4_UP_S2_6 ;
        
        public static GBPUSD_OCO4_UP_S2 GBPUSD_PFO_OCO4_UP_S2_1 ;
        public static GBPUSD_OCO4_UP_S2 GBPUSD_PFO_OCO4_UP_S2_2 ;
        public static GBPUSD_OCO4_UP_S2 GBPUSD_PFO_OCO4_UP_S2_3 ;
        public static GBPUSD_OCO4_UP_S2 GBPUSD_PFO_OCO4_UP_S2_4 ;
        public static GBPUSD_OCO4_UP_S2 GBPUSD_PFO_OCO4_UP_S2_5 ;
        public static GBPUSD_OCO4_UP_S2 GBPUSD_PFO_OCO4_UP_S2_6 ;
        
        public static List<GBPUSD_OCO4_UP_S2> GBPUSD_UP_S2_OCO4Sets1 = new List<GBPUSD_OCO4_UP_S2>();
        public static List<GBPUSD_OCO4_UP_S2> GBPUSD_UP_S2_OCO4Sets2 = new List<GBPUSD_OCO4_UP_S2>();
        public static List<GBPUSD_OCO4_UP_S2> GBPUSD_UP_S2_OCO4Sets3 = new List<GBPUSD_OCO4_UP_S2>();
        public static List<GBPUSD_OCO4_UP_S2> GBPUSD_UP_S2_OCO4Sets4 = new List<GBPUSD_OCO4_UP_S2>();
        public static List<GBPUSD_OCO4_UP_S2> GBPUSD_UP_S2_OCO4Sets5 = new List<GBPUSD_OCO4_UP_S2>();
        public static List<GBPUSD_OCO4_UP_S2> GBPUSD_UP_S2_OCO4Sets6 = new List<GBPUSD_OCO4_UP_S2>();
        
        public static bool GBPUSD_OCO4_UP_S2_IsReady = true;
        public static bool GBPUSD_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket GBPUSD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket GBPUSD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int GBPUSD_OCO4_EO1_DOWN_S2_ID ;
        public static int GBPUSD_OCO4_EO2_DOWN_S2_ID ;
        public static int GBPUSD_OCO4_EO3_DOWN_S2_ID ;
        public static int GBPUSD_OCO4_EO4_DOWN_S2_ID ;
        public static int GBPUSD_OCO4_EO5_DOWN_S2_ID ;
        public static int GBPUSD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool GBPUSD_OCO4_EO1_DOWN_S2 ;
        public static bool GBPUSD_OCO4_EO2_DOWN_S2 ;
        public static bool GBPUSD_OCO4_EO3_DOWN_S2 ;
        public static bool GBPUSD_OCO4_EO4_DOWN_S2 ;
        public static bool GBPUSD_OCO4_EO5_DOWN_S2 ;
        public static bool GBPUSD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_DOWN_S2> GBPUSD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_DOWN_S2> GBPUSD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_DOWN_S2> GBPUSD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_DOWN_S2> GBPUSD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_DOWN_S2> GBPUSD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPUSD_OCO4_DOWN_S2> GBPUSD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static GBPUSD_OCO4_DOWN_S2 GBPUSD_PFO_OCO4_DOWN_S2_1 ;
        public static GBPUSD_OCO4_DOWN_S2 GBPUSD_PFO_OCO4_DOWN_S2_2 ;
        public static GBPUSD_OCO4_DOWN_S2 GBPUSD_PFO_OCO4_DOWN_S2_3 ;
        public static GBPUSD_OCO4_DOWN_S2 GBPUSD_PFO_OCO4_DOWN_S2_4 ;
        public static GBPUSD_OCO4_DOWN_S2 GBPUSD_PFO_OCO4_DOWN_S2_5 ;
        public static GBPUSD_OCO4_DOWN_S2 GBPUSD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<GBPUSD_OCO4_DOWN_S2> GBPUSD_DOWN_S2_OCO4Sets1 = new List<GBPUSD_OCO4_DOWN_S2>();
        public static List<GBPUSD_OCO4_DOWN_S2> GBPUSD_DOWN_S2_OCO4Sets2 = new List<GBPUSD_OCO4_DOWN_S2>();
        public static List<GBPUSD_OCO4_DOWN_S2> GBPUSD_DOWN_S2_OCO4Sets3 = new List<GBPUSD_OCO4_DOWN_S2>();
        public static List<GBPUSD_OCO4_DOWN_S2> GBPUSD_DOWN_S2_OCO4Sets4 = new List<GBPUSD_OCO4_DOWN_S2>();
        public static List<GBPUSD_OCO4_DOWN_S2> GBPUSD_DOWN_S2_OCO4Sets5 = new List<GBPUSD_OCO4_DOWN_S2>();
        public static List<GBPUSD_OCO4_DOWN_S2> GBPUSD_DOWN_S2_OCO4Sets6 = new List<GBPUSD_OCO4_DOWN_S2>();
        
        public static bool GBPUSD_OCO4_DOWN_S2_IsReady = true;
        public static bool GBPUSD_OCO4_DOWN_S2_Monthly_IsReady = true;

        
////////////////////////////
		public static decimal GBPUSD_UP_S2_SL {get; set;}
		public static decimal GBPUSD_UP_S2_TP1 {get; set;}
		public static decimal GBPUSD_UP_S2_TP2 {get; set;}
		public static decimal GBPUSD_UP_S2_TP3 {get; set;}
		public static decimal GBPUSD_UP_S2_TP4 {get; set;}
		public static decimal GBPUSD_UP_S2_TP5 {get; set;}
		public static decimal GBPUSD_UP_S2_TP6 {get; set;}
		
		public static decimal GBPUSD_DOWN_S2_SL {get; set;}
		public static decimal GBPUSD_DOWN_S2_TP1 {get; set;}
		public static decimal GBPUSD_DOWN_S2_TP2 {get; set;}
		public static decimal GBPUSD_DOWN_S2_TP3 {get; set;}
		public static decimal GBPUSD_DOWN_S2_TP4 {get; set;}
		public static decimal GBPUSD_DOWN_S2_TP5 {get; set;}
		public static decimal GBPUSD_DOWN_S2_TP6 {get; set;}

        public static bool GBPUSD_Signal_Condition_UP_1 ;
        public static bool GBPUSD_Signal_Condition_UP_2 ;
        public static bool GBPUSD_Signal_Condition_UP_3 ;
        
        public static bool GBPUSD_Signal_Condition_DOWN_1 ;
        public static bool GBPUSD_Signal_Condition_DOWN_2 ;
        public static bool GBPUSD_Signal_Condition_DOWN_3 ;
        
        public static int GBPUSD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int GBPUSD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPUSD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPUSD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPUSD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int GBPUSD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int GBPUSD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPUSD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPUSD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPUSD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_GBPUSD_UP_S2 ;
        public static bool DOWM_GBPUSD_UP_S2 ;
        public static bool DOWT_GBPUSD_UP_S2 ;
        public static bool DOWW_GBPUSD_UP_S2 ;
        public static bool DOWTH_GBPUSD_UP_S2 ;
        
		public static bool DOWR_GBPUSD_DOWN_S2 ;
        public static bool DOWM_GBPUSD_DOWN_S2 ;
        public static bool DOWT_GBPUSD_DOWN_S2 ;
        public static bool DOWW_GBPUSD_DOWN_S2 ;
        public static bool DOWTH_GBPUSD_DOWN_S2 ;
        
        
		public static int GBPUSD_quantity_UP_S2 ;
		public static int GBPUSD_quantity_SL_UP_S2 ;
		public static int GBPUSD_quantity_TP1_UP_S2 ;
		public static int GBPUSD_quantity_TP2_UP_S2 ;
		public static int GBPUSD_quantity_TP3_UP_S2 ;
		public static int GBPUSD_quantity_TP4_UP_S2 ;
		public static int GBPUSD_quantity_TP5_UP_S2;
		public static int GBPUSD_quantity_TP6_UP_S2 ;
		
		public static int GBPUSD_quantity_DOWN_S2 ;
		public static int GBPUSD_quantity_SL_DOWN_S2 ;
		public static int GBPUSD_quantity_TP1_DOWN_S2 ;
		public static int GBPUSD_quantity_TP2_DOWN_S2 ;
		public static int GBPUSD_quantity_TP3_DOWN_S2 ;
		public static int GBPUSD_quantity_TP4_DOWN_S2 ;
		public static int GBPUSD_quantity_TP5_DOWN_S2;
		public static int GBPUSD_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.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 _AUDCHF;
		
    	///oco1 up
    	public static OrderTicket AUDCHF_OCO1_MO1_UP_S2;
    	public static OrderTicket AUDCHF_OCO1_MO2_UP_S2;
    	public static OrderTicket AUDCHF_OCO1_MO3_UP_S2;
    	public static OrderTicket AUDCHF_OCO1_MO4_UP_S2;
    	public static OrderTicket AUDCHF_OCO1_MO5_UP_S2;
    	public static OrderTicket AUDCHF_OCO1_MO6_UP_S2;
    	
    	public static int AUDCHF_OCO1_EO1_UP_S2_ID ;
        public static int AUDCHF_OCO1_EO2_UP_S2_ID ;
        public static int AUDCHF_OCO1_EO3_UP_S2_ID ;
        public static int AUDCHF_OCO1_EO4_UP_S2_ID ;
        public static int AUDCHF_OCO1_EO5_UP_S2_ID ;
        public static int AUDCHF_OCO1_EO6_UP_S2_ID ;
        
        public static bool AUDCHF_OCO1_EO1_UP_S2 ;
        public static bool AUDCHF_OCO1_EO2_UP_S2 ;
        public static bool AUDCHF_OCO1_EO3_UP_S2 ;
        public static bool AUDCHF_OCO1_EO4_UP_S2 ;
        public static bool AUDCHF_OCO1_EO5_UP_S2 ;
        public static bool AUDCHF_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_UP_S2> AUDCHF_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_UP_S2> AUDCHF_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_UP_S2> AUDCHF_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_UP_S2> AUDCHF_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_UP_S2> AUDCHF_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_UP_S2> AUDCHF_OOFE_OCO1_UP_S2_6 ;
        
        public static AUDCHF_OCO1_UP_S2 AUDCHF_PFO_OCO1_UP_S2_1 ;
        public static AUDCHF_OCO1_UP_S2 AUDCHF_PFO_OCO1_UP_S2_2 ;
        public static AUDCHF_OCO1_UP_S2 AUDCHF_PFO_OCO1_UP_S2_3 ;
        public static AUDCHF_OCO1_UP_S2 AUDCHF_PFO_OCO1_UP_S2_4 ;
        public static AUDCHF_OCO1_UP_S2 AUDCHF_PFO_OCO1_UP_S2_5 ;
        public static AUDCHF_OCO1_UP_S2 AUDCHF_PFO_OCO1_UP_S2_6 ;
        
        public static List<AUDCHF_OCO1_UP_S2> AUDCHF_UP_S2_OCO1Sets1 = new List<AUDCHF_OCO1_UP_S2>();
        public static List<AUDCHF_OCO1_UP_S2> AUDCHF_UP_S2_OCO1Sets2 = new List<AUDCHF_OCO1_UP_S2>();
        public static List<AUDCHF_OCO1_UP_S2> AUDCHF_UP_S2_OCO1Sets3 = new List<AUDCHF_OCO1_UP_S2>();
        public static List<AUDCHF_OCO1_UP_S2> AUDCHF_UP_S2_OCO1Sets4 = new List<AUDCHF_OCO1_UP_S2>();
        public static List<AUDCHF_OCO1_UP_S2> AUDCHF_UP_S2_OCO1Sets5 = new List<AUDCHF_OCO1_UP_S2>();
        public static List<AUDCHF_OCO1_UP_S2> AUDCHF_UP_S2_OCO1Sets6 = new List<AUDCHF_OCO1_UP_S2>();
        
        public static bool AUDCHF_OCO1_UP_S2_IsReady = true;
		public static bool AUDCHF_OCO1_UP_S2_Monthly_IsReady = true;
        
        //oco1 down
		public static OrderTicket AUDCHF_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO1_MO6_DOWN_S2 ;
    	
    	public static int AUDCHF_OCO1_EO1_DOWN_S2_ID ;
        public static int AUDCHF_OCO1_EO2_DOWN_S2_ID ;
        public static int AUDCHF_OCO1_EO3_DOWN_S2_ID ;
        public static int AUDCHF_OCO1_EO4_DOWN_S2_ID ;
        public static int AUDCHF_OCO1_EO5_DOWN_S2_ID ;
        public static int AUDCHF_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool AUDCHF_OCO1_EO1_DOWN_S2 ;
        public static bool AUDCHF_OCO1_EO2_DOWN_S2 ;
        public static bool AUDCHF_OCO1_EO3_DOWN_S2 ;
        public static bool AUDCHF_OCO1_EO4_DOWN_S2 ;
        public static bool AUDCHF_OCO1_EO5_DOWN_S2 ;
        public static bool AUDCHF_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_DOWN_S2> AUDCHF_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_DOWN_S2> AUDCHF_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_DOWN_S2> AUDCHF_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_DOWN_S2> AUDCHF_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_DOWN_S2> AUDCHF_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO1_DOWN_S2> AUDCHF_OOFE_OCO1_DOWN_S2_6 ;
        
        public static AUDCHF_OCO1_DOWN_S2 AUDCHF_PFO_OCO1_DOWN_S2_1 ;
        public static AUDCHF_OCO1_DOWN_S2 AUDCHF_PFO_OCO1_DOWN_S2_2 ;
        public static AUDCHF_OCO1_DOWN_S2 AUDCHF_PFO_OCO1_DOWN_S2_3 ;
        public static AUDCHF_OCO1_DOWN_S2 AUDCHF_PFO_OCO1_DOWN_S2_4 ;
        public static AUDCHF_OCO1_DOWN_S2 AUDCHF_PFO_OCO1_DOWN_S2_5 ;
        public static AUDCHF_OCO1_DOWN_S2 AUDCHF_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<AUDCHF_OCO1_DOWN_S2> AUDCHF_DOWN_S2_OCO1Sets1 = new List<AUDCHF_OCO1_DOWN_S2>();
        public static List<AUDCHF_OCO1_DOWN_S2> AUDCHF_DOWN_S2_OCO1Sets2 = new List<AUDCHF_OCO1_DOWN_S2>();
        public static List<AUDCHF_OCO1_DOWN_S2> AUDCHF_DOWN_S2_OCO1Sets3 = new List<AUDCHF_OCO1_DOWN_S2>();
        public static List<AUDCHF_OCO1_DOWN_S2> AUDCHF_DOWN_S2_OCO1Sets4 = new List<AUDCHF_OCO1_DOWN_S2>();
        public static List<AUDCHF_OCO1_DOWN_S2> AUDCHF_DOWN_S2_OCO1Sets5 = new List<AUDCHF_OCO1_DOWN_S2>();
        public static List<AUDCHF_OCO1_DOWN_S2> AUDCHF_DOWN_S2_OCO1Sets6 = new List<AUDCHF_OCO1_DOWN_S2>();
        
        public static bool AUDCHF_OCO1_DOWN_S2_IsReady = true;
		public static bool AUDCHF_OCO1_DOWN_S2_Monthly_IsReady = true;
        
        //oco2 up
        public static OrderTicket AUDCHF_OCO2_MO1_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO2_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO3_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO4_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO5_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO6_UP_S2 ;
    	
    	public static int AUDCHF_OCO2_EO1_UP_S2_ID ;
        public static int AUDCHF_OCO2_EO2_UP_S2_ID ;
        public static int AUDCHF_OCO2_EO3_UP_S2_ID ;
        public static int AUDCHF_OCO2_EO4_UP_S2_ID ;
        public static int AUDCHF_OCO2_EO5_UP_S2_ID ;
        public static int AUDCHF_OCO2_EO6_UP_S2_ID ;
        
        public static bool AUDCHF_OCO2_EO1_UP_S2 ;
        public static bool AUDCHF_OCO2_EO2_UP_S2 ;
        public static bool AUDCHF_OCO2_EO3_UP_S2 ;
        public static bool AUDCHF_OCO2_EO4_UP_S2 ;
        public static bool AUDCHF_OCO2_EO5_UP_S2 ;
        public static bool AUDCHF_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_UP_S2> AUDCHF_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_UP_S2> AUDCHF_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_UP_S2> AUDCHF_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_UP_S2> AUDCHF_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_UP_S2> AUDCHF_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_UP_S2> AUDCHF_OOFE_OCO2_UP_S2_6 ;
        
        public static AUDCHF_OCO2_UP_S2 AUDCHF_PFO_OCO2_UP_S2_1 ;
        public static AUDCHF_OCO2_UP_S2 AUDCHF_PFO_OCO2_UP_S2_2 ;
        public static AUDCHF_OCO2_UP_S2 AUDCHF_PFO_OCO2_UP_S2_3 ;
        public static AUDCHF_OCO2_UP_S2 AUDCHF_PFO_OCO2_UP_S2_4 ;
        public static AUDCHF_OCO2_UP_S2 AUDCHF_PFO_OCO2_UP_S2_5 ;
        public static AUDCHF_OCO2_UP_S2 AUDCHF_PFO_OCO2_UP_S2_6 ;
        
        public static List<AUDCHF_OCO2_UP_S2> AUDCHF_UP_S2_OCO2Sets1 = new List<AUDCHF_OCO2_UP_S2>();
        public static List<AUDCHF_OCO2_UP_S2> AUDCHF_UP_S2_OCO2Sets2 = new List<AUDCHF_OCO2_UP_S2>();
        public static List<AUDCHF_OCO2_UP_S2> AUDCHF_UP_S2_OCO2Sets3 = new List<AUDCHF_OCO2_UP_S2>();
        public static List<AUDCHF_OCO2_UP_S2> AUDCHF_UP_S2_OCO2Sets4 = new List<AUDCHF_OCO2_UP_S2>();
        public static List<AUDCHF_OCO2_UP_S2> AUDCHF_UP_S2_OCO2Sets5 = new List<AUDCHF_OCO2_UP_S2>();
        public static List<AUDCHF_OCO2_UP_S2> AUDCHF_UP_S2_OCO2Sets6 = new List<AUDCHF_OCO2_UP_S2>();
        
        public static bool AUDCHF_OCO2_UP_S2_IsReady = true;
		public static bool AUDCHF_OCO2_UP_S2_Monthly_IsReady = true;
        
        //oco2 down
        public static OrderTicket AUDCHF_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO2_MO6_DOWN_S2 ;
    	
    	public static int AUDCHF_OCO2_EO1_DOWN_S2_ID ;
        public static int AUDCHF_OCO2_EO2_DOWN_S2_ID ;
        public static int AUDCHF_OCO2_EO3_DOWN_S2_ID ;
        public static int AUDCHF_OCO2_EO4_DOWN_S2_ID ;
        public static int AUDCHF_OCO2_EO5_DOWN_S2_ID ;
        public static int AUDCHF_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool AUDCHF_OCO2_EO1_DOWN_S2 ;
        public static bool AUDCHF_OCO2_EO2_DOWN_S2 ;
        public static bool AUDCHF_OCO2_EO3_DOWN_S2 ;
        public static bool AUDCHF_OCO2_EO4_DOWN_S2 ;
        public static bool AUDCHF_OCO2_EO5_DOWN_S2 ;
        public static bool AUDCHF_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_DOWN_S2> AUDCHF_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_DOWN_S2> AUDCHF_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_DOWN_S2> AUDCHF_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_DOWN_S2> AUDCHF_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_DOWN_S2> AUDCHF_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO2_DOWN_S2> AUDCHF_OOFE_OCO2_DOWN_S2_6 ;
        
        public static AUDCHF_OCO2_DOWN_S2 AUDCHF_PFO_OCO2_DOWN_S2_1 ;
        public static AUDCHF_OCO2_DOWN_S2 AUDCHF_PFO_OCO2_DOWN_S2_2 ;
        public static AUDCHF_OCO2_DOWN_S2 AUDCHF_PFO_OCO2_DOWN_S2_3 ;
        public static AUDCHF_OCO2_DOWN_S2 AUDCHF_PFO_OCO2_DOWN_S2_4 ;
        public static AUDCHF_OCO2_DOWN_S2 AUDCHF_PFO_OCO2_DOWN_S2_5 ;
        public static AUDCHF_OCO2_DOWN_S2 AUDCHF_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<AUDCHF_OCO2_DOWN_S2> AUDCHF_DOWN_S2_OCO2Sets1 = new List<AUDCHF_OCO2_DOWN_S2>();
        public static List<AUDCHF_OCO2_DOWN_S2> AUDCHF_DOWN_S2_OCO2Sets2 = new List<AUDCHF_OCO2_DOWN_S2>();
        public static List<AUDCHF_OCO2_DOWN_S2> AUDCHF_DOWN_S2_OCO2Sets3 = new List<AUDCHF_OCO2_DOWN_S2>();
        public static List<AUDCHF_OCO2_DOWN_S2> AUDCHF_DOWN_S2_OCO2Sets4 = new List<AUDCHF_OCO2_DOWN_S2>();
        public static List<AUDCHF_OCO2_DOWN_S2> AUDCHF_DOWN_S2_OCO2Sets5 = new List<AUDCHF_OCO2_DOWN_S2>();
        public static List<AUDCHF_OCO2_DOWN_S2> AUDCHF_DOWN_S2_OCO2Sets6 = new List<AUDCHF_OCO2_DOWN_S2>();
        
        public static bool AUDCHF_OCO2_DOWN_S2_IsReady = true;
		public static bool AUDCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
        
        //oco3 up
        public static OrderTicket AUDCHF_OCO3_MO1_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO2_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO3_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO4_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO5_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO6_UP_S2 ;
    	
    	public static int AUDCHF_OCO3_EO1_UP_S2_ID ;
        public static int AUDCHF_OCO3_EO2_UP_S2_ID ;
        public static int AUDCHF_OCO3_EO3_UP_S2_ID ;
        public static int AUDCHF_OCO3_EO4_UP_S2_ID ;
        public static int AUDCHF_OCO3_EO5_UP_S2_ID ;
        public static int AUDCHF_OCO3_EO6_UP_S2_ID ;
        
        public static bool AUDCHF_OCO3_EO1_UP_S2 ;
        public static bool AUDCHF_OCO3_EO2_UP_S2 ;
        public static bool AUDCHF_OCO3_EO3_UP_S2 ;
        public static bool AUDCHF_OCO3_EO4_UP_S2 ;
        public static bool AUDCHF_OCO3_EO5_UP_S2 ;
        public static bool AUDCHF_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_UP_S2> AUDCHF_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_UP_S2> AUDCHF_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_UP_S2> AUDCHF_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_UP_S2> AUDCHF_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_UP_S2> AUDCHF_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_UP_S2> AUDCHF_OOFE_OCO3_UP_S2_6 ;
        
        public static AUDCHF_OCO3_UP_S2 AUDCHF_PFO_OCO3_UP_S2_1 ;
        public static AUDCHF_OCO3_UP_S2 AUDCHF_PFO_OCO3_UP_S2_2 ;
        public static AUDCHF_OCO3_UP_S2 AUDCHF_PFO_OCO3_UP_S2_3 ;
        public static AUDCHF_OCO3_UP_S2 AUDCHF_PFO_OCO3_UP_S2_4 ;
        public static AUDCHF_OCO3_UP_S2 AUDCHF_PFO_OCO3_UP_S2_5 ;
        public static AUDCHF_OCO3_UP_S2 AUDCHF_PFO_OCO3_UP_S2_6 ;
        
        public static List<AUDCHF_OCO3_UP_S2> AUDCHF_UP_S2_OCO3Sets1 = new List<AUDCHF_OCO3_UP_S2>();
        public static List<AUDCHF_OCO3_UP_S2> AUDCHF_UP_S2_OCO3Sets2 = new List<AUDCHF_OCO3_UP_S2>();
        public static List<AUDCHF_OCO3_UP_S2> AUDCHF_UP_S2_OCO3Sets3 = new List<AUDCHF_OCO3_UP_S2>();
        public static List<AUDCHF_OCO3_UP_S2> AUDCHF_UP_S2_OCO3Sets4 = new List<AUDCHF_OCO3_UP_S2>();
        public static List<AUDCHF_OCO3_UP_S2> AUDCHF_UP_S2_OCO3Sets5 = new List<AUDCHF_OCO3_UP_S2>();
        public static List<AUDCHF_OCO3_UP_S2> AUDCHF_UP_S2_OCO3Sets6 = new List<AUDCHF_OCO3_UP_S2>();
        
        public static bool AUDCHF_OCO3_UP_S2_IsReady = true;
		public static bool AUDCHF_OCO3_UP_S2_Monthly_IsReady = true;
        
        //oco3 down
        public static OrderTicket AUDCHF_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO3_MO6_DOWN_S2 ;
    	
    	public static int AUDCHF_OCO3_EO1_DOWN_S2_ID ;
        public static int AUDCHF_OCO3_EO2_DOWN_S2_ID ;
        public static int AUDCHF_OCO3_EO3_DOWN_S2_ID ;
        public static int AUDCHF_OCO3_EO4_DOWN_S2_ID ;
        public static int AUDCHF_OCO3_EO5_DOWN_S2_ID ;
        public static int AUDCHF_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool AUDCHF_OCO3_EO1_DOWN_S2 ;
        public static bool AUDCHF_OCO3_EO2_DOWN_S2 ;
        public static bool AUDCHF_OCO3_EO3_DOWN_S2 ;
        public static bool AUDCHF_OCO3_EO4_DOWN_S2 ;
        public static bool AUDCHF_OCO3_EO5_DOWN_S2 ;
        public static bool AUDCHF_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_DOWN_S2> AUDCHF_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_DOWN_S2> AUDCHF_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_DOWN_S2> AUDCHF_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_DOWN_S2> AUDCHF_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_DOWN_S2> AUDCHF_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO3_DOWN_S2> AUDCHF_OOFE_OCO3_DOWN_S2_6 ;
        
        public static AUDCHF_OCO3_DOWN_S2 AUDCHF_PFO_OCO3_DOWN_S2_1 ;
        public static AUDCHF_OCO3_DOWN_S2 AUDCHF_PFO_OCO3_DOWN_S2_2 ;
        public static AUDCHF_OCO3_DOWN_S2 AUDCHF_PFO_OCO3_DOWN_S2_3 ;
        public static AUDCHF_OCO3_DOWN_S2 AUDCHF_PFO_OCO3_DOWN_S2_4 ;
        public static AUDCHF_OCO3_DOWN_S2 AUDCHF_PFO_OCO3_DOWN_S2_5 ;
        public static AUDCHF_OCO3_DOWN_S2 AUDCHF_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<AUDCHF_OCO3_DOWN_S2> AUDCHF_DOWN_S2_OCO3Sets1 = new List<AUDCHF_OCO3_DOWN_S2>();
        public static List<AUDCHF_OCO3_DOWN_S2> AUDCHF_DOWN_S2_OCO3Sets2 = new List<AUDCHF_OCO3_DOWN_S2>();
        public static List<AUDCHF_OCO3_DOWN_S2> AUDCHF_DOWN_S2_OCO3Sets3 = new List<AUDCHF_OCO3_DOWN_S2>();
        public static List<AUDCHF_OCO3_DOWN_S2> AUDCHF_DOWN_S2_OCO3Sets4 = new List<AUDCHF_OCO3_DOWN_S2>();
        public static List<AUDCHF_OCO3_DOWN_S2> AUDCHF_DOWN_S2_OCO3Sets5 = new List<AUDCHF_OCO3_DOWN_S2>();
        public static List<AUDCHF_OCO3_DOWN_S2> AUDCHF_DOWN_S2_OCO3Sets6 = new List<AUDCHF_OCO3_DOWN_S2>();
        
        public static bool AUDCHF_OCO3_DOWN_S2_IsReady = true;
		public static bool AUDCHF_OCO3_DOWN_S2_Monthly_IsReady = true;
        
        //oco4 up
        public static OrderTicket AUDCHF_OCO4_MO1_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO2_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO3_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO4_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO5_UP_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO6_UP_S2 ;
    	
    	public static int AUDCHF_OCO4_EO1_UP_S2_ID ;
        public static int AUDCHF_OCO4_EO2_UP_S2_ID ;
        public static int AUDCHF_OCO4_EO3_UP_S2_ID ;
        public static int AUDCHF_OCO4_EO4_UP_S2_ID ;
        public static int AUDCHF_OCO4_EO5_UP_S2_ID ;
        public static int AUDCHF_OCO4_EO6_UP_S2_ID ;
        
        public static bool AUDCHF_OCO4_EO1_UP_S2 ;
        public static bool AUDCHF_OCO4_EO2_UP_S2 ;
        public static bool AUDCHF_OCO4_EO3_UP_S2 ;
        public static bool AUDCHF_OCO4_EO4_UP_S2 ;
        public static bool AUDCHF_OCO4_EO5_UP_S2 ;
        public static bool AUDCHF_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_UP_S2> AUDCHF_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_UP_S2> AUDCHF_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_UP_S2> AUDCHF_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_UP_S2> AUDCHF_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_UP_S2> AUDCHF_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_UP_S2> AUDCHF_OOFE_OCO4_UP_S2_6 ;
        
        public static AUDCHF_OCO4_UP_S2 AUDCHF_PFO_OCO4_UP_S2_1 ;
        public static AUDCHF_OCO4_UP_S2 AUDCHF_PFO_OCO4_UP_S2_2 ;
        public static AUDCHF_OCO4_UP_S2 AUDCHF_PFO_OCO4_UP_S2_3 ;
        public static AUDCHF_OCO4_UP_S2 AUDCHF_PFO_OCO4_UP_S2_4 ;
        public static AUDCHF_OCO4_UP_S2 AUDCHF_PFO_OCO4_UP_S2_5 ;
        public static AUDCHF_OCO4_UP_S2 AUDCHF_PFO_OCO4_UP_S2_6 ;
        
        public static List<AUDCHF_OCO4_UP_S2> AUDCHF_UP_S2_OCO4Sets1 = new List<AUDCHF_OCO4_UP_S2>();
        public static List<AUDCHF_OCO4_UP_S2> AUDCHF_UP_S2_OCO4Sets2 = new List<AUDCHF_OCO4_UP_S2>();
        public static List<AUDCHF_OCO4_UP_S2> AUDCHF_UP_S2_OCO4Sets3 = new List<AUDCHF_OCO4_UP_S2>();
        public static List<AUDCHF_OCO4_UP_S2> AUDCHF_UP_S2_OCO4Sets4 = new List<AUDCHF_OCO4_UP_S2>();
        public static List<AUDCHF_OCO4_UP_S2> AUDCHF_UP_S2_OCO4Sets5 = new List<AUDCHF_OCO4_UP_S2>();
        public static List<AUDCHF_OCO4_UP_S2> AUDCHF_UP_S2_OCO4Sets6 = new List<AUDCHF_OCO4_UP_S2>();
        
        public static bool AUDCHF_OCO4_UP_S2_IsReady = true;
        public static bool AUDCHF_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket AUDCHF_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket AUDCHF_OCO4_MO6_DOWN_S2 ;
    	
    	public static int AUDCHF_OCO4_EO1_DOWN_S2_ID ;
        public static int AUDCHF_OCO4_EO2_DOWN_S2_ID ;
        public static int AUDCHF_OCO4_EO3_DOWN_S2_ID ;
        public static int AUDCHF_OCO4_EO4_DOWN_S2_ID ;
        public static int AUDCHF_OCO4_EO5_DOWN_S2_ID ;
        public static int AUDCHF_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool AUDCHF_OCO4_EO1_DOWN_S2 ;
        public static bool AUDCHF_OCO4_EO2_DOWN_S2 ;
        public static bool AUDCHF_OCO4_EO3_DOWN_S2 ;
        public static bool AUDCHF_OCO4_EO4_DOWN_S2 ;
        public static bool AUDCHF_OCO4_EO5_DOWN_S2 ;
        public static bool AUDCHF_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_DOWN_S2> AUDCHF_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_DOWN_S2> AUDCHF_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_DOWN_S2> AUDCHF_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_DOWN_S2> AUDCHF_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_DOWN_S2> AUDCHF_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCHF_OCO4_DOWN_S2> AUDCHF_OOFE_OCO4_DOWN_S2_6 ;
        
        public static AUDCHF_OCO4_DOWN_S2 AUDCHF_PFO_OCO4_DOWN_S2_1 ;
        public static AUDCHF_OCO4_DOWN_S2 AUDCHF_PFO_OCO4_DOWN_S2_2 ;
        public static AUDCHF_OCO4_DOWN_S2 AUDCHF_PFO_OCO4_DOWN_S2_3 ;
        public static AUDCHF_OCO4_DOWN_S2 AUDCHF_PFO_OCO4_DOWN_S2_4 ;
        public static AUDCHF_OCO4_DOWN_S2 AUDCHF_PFO_OCO4_DOWN_S2_5 ;
        public static AUDCHF_OCO4_DOWN_S2 AUDCHF_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<AUDCHF_OCO4_DOWN_S2> AUDCHF_DOWN_S2_OCO4Sets1 = new List<AUDCHF_OCO4_DOWN_S2>();
        public static List<AUDCHF_OCO4_DOWN_S2> AUDCHF_DOWN_S2_OCO4Sets2 = new List<AUDCHF_OCO4_DOWN_S2>();
        public static List<AUDCHF_OCO4_DOWN_S2> AUDCHF_DOWN_S2_OCO4Sets3 = new List<AUDCHF_OCO4_DOWN_S2>();
        public static List<AUDCHF_OCO4_DOWN_S2> AUDCHF_DOWN_S2_OCO4Sets4 = new List<AUDCHF_OCO4_DOWN_S2>();
        public static List<AUDCHF_OCO4_DOWN_S2> AUDCHF_DOWN_S2_OCO4Sets5 = new List<AUDCHF_OCO4_DOWN_S2>();
        public static List<AUDCHF_OCO4_DOWN_S2> AUDCHF_DOWN_S2_OCO4Sets6 = new List<AUDCHF_OCO4_DOWN_S2>();
        
        public static bool AUDCHF_OCO4_DOWN_S2_IsReady = true;
        public static bool AUDCHF_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal AUDCHF_UP_S2_SL {get; set;}
		public static decimal AUDCHF_UP_S2_TP1 {get; set;}
		public static decimal AUDCHF_UP_S2_TP2 {get; set;}
		public static decimal AUDCHF_UP_S2_TP3 {get; set;}
		public static decimal AUDCHF_UP_S2_TP4 {get; set;}
		public static decimal AUDCHF_UP_S2_TP5 {get; set;}
		public static decimal AUDCHF_UP_S2_TP6 {get; set;}
		
		public static decimal AUDCHF_DOWN_S2_SL {get; set;}
		public static decimal AUDCHF_DOWN_S2_TP1 {get; set;}
		public static decimal AUDCHF_DOWN_S2_TP2 {get; set;}
		public static decimal AUDCHF_DOWN_S2_TP3 {get; set;}
		public static decimal AUDCHF_DOWN_S2_TP4 {get; set;}
		public static decimal AUDCHF_DOWN_S2_TP5 {get; set;}
		public static decimal AUDCHF_DOWN_S2_TP6 {get; set;}

        public static bool AUDCHF_Signal_Condition_UP_1 ;
        public static bool AUDCHF_Signal_Condition_UP_2 ;
        public static bool AUDCHF_Signal_Condition_UP_3 ;
        public static bool AUDCHF_Signal_Condition_DOWN_S2 ;
        
        public static int AUDCHF_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int AUDCHF_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDCHF_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDCHF_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDCHF_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int AUDCHF_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int AUDCHF_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDCHF_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDCHF_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDCHF_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_AUDCHF_UP_S2 ;
        public static bool DOWM_AUDCHF_UP_S2 ;
        public static bool DOWT_AUDCHF_UP_S2 ;
        public static bool DOWW_AUDCHF_UP_S2 ;
        public static bool DOWTH_AUDCHF_UP_S2 ;
        
		public static bool DOWR_AUDCHF_DOWN_S2 ;
        public static bool DOWM_AUDCHF_DOWN_S2 ;
        public static bool DOWT_AUDCHF_DOWN_S2 ;
        public static bool DOWW_AUDCHF_DOWN_S2 ;
        public static bool DOWTH_AUDCHF_DOWN_S2 ;
        
        
		public static int AUDCHF_quantity_UP_S2 ;
		public static int AUDCHF_quantity_SL_UP_S2 ;
		public static int AUDCHF_quantity_TP1_UP_S2 ;
		public static int AUDCHF_quantity_TP2_UP_S2 ;
		public static int AUDCHF_quantity_TP3_UP_S2 ;
		public static int AUDCHF_quantity_TP4_UP_S2 ;
		public static int AUDCHF_quantity_TP5_UP_S2;
		public static int AUDCHF_quantity_TP6_UP_S2 ;
		
		public static int AUDCHF_quantity_DOWN_S2 ;
		public static int AUDCHF_quantity_SL_DOWN_S2 ;
		public static int AUDCHF_quantity_TP1_DOWN_S2 ;
		public static int AUDCHF_quantity_TP2_DOWN_S2 ;
		public static int AUDCHF_quantity_TP3_DOWN_S2 ;
		public static int AUDCHF_quantity_TP4_DOWN_S2 ;
		public static int AUDCHF_quantity_TP5_DOWN_S2;
		public static int AUDCHF_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 EURJPY_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURJPY_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("EURJPY OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURJPY OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURJPY OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURJPY OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURJPY OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURJPY OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURJPY S2");
		        	}
		        }
		        
				if (Base.EURJPY_OCO1_EO1_DOWN_S2)
	                Base.EURJPY_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURJPY_OCO1_EO2_DOWN_S2)
	                Base.EURJPY_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO1_EO3_DOWN_S2)
	                Base.EURJPY_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO1_EO4_DOWN_S2)
	                Base.EURJPY_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURJPY_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.EURJPY_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP1_EURJPY_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP1,"TP1_EURJPY_DOWN_S2_OCO1"));
		                 };
		                Base.EURJPY_DOWN_S2_OCO1Sets1.Add( Base.EURJPY_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURJPY_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP2_EURJPY_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP2,"TP2_EURJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO1Sets2.Add( Base.EURJPY_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP3_EURJPY_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP3,"TP3_EURJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO1Sets3.Add( Base.EURJPY_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP4_EURJPY_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP4,"TP4_EURJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO1Sets4.Add( Base.EURJPY_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURJPY_OCO1S1_DOWN_S2 = 0;
	                for (; EURJPY_OCO1S1_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets1.Count; EURJPY_OCO1S1_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO1Sets1[EURJPY_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO1Sets1[EURJPY_OCO1S1_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO1Sets1.RemoveAt(EURJPY_OCO1S1_DOWN_S2);
	                        EURJPY_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURJPY_OCO1S2_DOWN_S2 = 0;
	                for (; EURJPY_OCO1S2_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets2.Count; EURJPY_OCO1S2_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO1Sets2[EURJPY_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO1Sets2[EURJPY_OCO1S2_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO1Sets2.RemoveAt(EURJPY_OCO1S2_DOWN_S2);
	                        EURJPY_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO1S3_DOWN_S2 = 0;
	                for (; EURJPY_OCO1S3_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets3.Count; EURJPY_OCO1S3_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO1Sets3[EURJPY_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO1Sets3[EURJPY_OCO1S3_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO1Sets3.RemoveAt(EURJPY_OCO1S3_DOWN_S2);
	                        EURJPY_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO1S4_DOWN_S2 = 0;
	                for (; EURJPY_OCO1S4_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets4.Count; EURJPY_OCO1S4_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO1Sets4[EURJPY_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO1Sets4[EURJPY_OCO1S4_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO1Sets4.RemoveAt(EURJPY_OCO1S4_DOWN_S2);
	                        EURJPY_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURJPY_OCO2_EO1_DOWN_S2)
	                Base.EURJPY_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURJPY_OCO2_EO2_DOWN_S2)
	                Base.EURJPY_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO2_EO3_DOWN_S2)
	                Base.EURJPY_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO2_EO4_DOWN_S2)
	                Base.EURJPY_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURJPY_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.EURJPY_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP1_EURJPY_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP1,"TP1_EURJPY_DOWN_S2_OCO2"));
		                 };
		                Base.EURJPY_DOWN_S2_OCO2Sets1.Add( Base.EURJPY_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURJPY_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP2_EURJPY_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP2,"TP2_EURJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO2Sets2.Add( Base.EURJPY_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP3_EURJPY_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP3,"TP3_EURJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO2Sets3.Add( Base.EURJPY_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP4_EURJPY_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP4,"TP4_EURJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO2Sets4.Add( Base.EURJPY_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURJPY_OCO2S1_DOWN_S2 = 0;
	                for (; EURJPY_OCO2S1_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets1.Count; EURJPY_OCO2S1_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO2Sets1[EURJPY_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO2Sets1[EURJPY_OCO2S1_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO2Sets1.RemoveAt(EURJPY_OCO2S1_DOWN_S2);
	                        EURJPY_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURJPY_OCO2S2_DOWN_S2 = 0;
	                for (; EURJPY_OCO2S2_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets2.Count; EURJPY_OCO2S2_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO2Sets2[EURJPY_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO2Sets2[EURJPY_OCO2S2_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO2Sets2.RemoveAt(EURJPY_OCO2S2_DOWN_S2);
	                        EURJPY_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO2S3_DOWN_S2 = 0;
	                for (; EURJPY_OCO2S3_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets3.Count; EURJPY_OCO2S3_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO2Sets3[EURJPY_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO2Sets3[EURJPY_OCO2S3_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO2Sets3.RemoveAt(EURJPY_OCO2S3_DOWN_S2);
	                        EURJPY_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO2S4_DOWN_S2 = 0;
	                for (; EURJPY_OCO2S4_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets4.Count; EURJPY_OCO2S4_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO2Sets4[EURJPY_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO2Sets4[EURJPY_OCO2S4_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO2Sets4.RemoveAt(EURJPY_OCO2S4_DOWN_S2);
	                        EURJPY_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURJPY_OCO3_EO1_DOWN_S2)
	                Base.EURJPY_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURJPY_OCO3_EO2_DOWN_S2)
	                Base.EURJPY_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO3_EO3_DOWN_S2)
	                Base.EURJPY_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO3_EO4_DOWN_S2)
	                Base.EURJPY_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURJPY_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.EURJPY_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP1_EURJPY_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP1,"TP1_EURJPY_DOWN_S2_OCO3"));
		                 };
		                Base.EURJPY_DOWN_S2_OCO3Sets1.Add( Base.EURJPY_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURJPY_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP2_EURJPY_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP2,"TP2_EURJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO3Sets2.Add( Base.EURJPY_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP3_EURJPY_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP3,"TP3_EURJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO3Sets3.Add( Base.EURJPY_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP4_EURJPY_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP4,"TP4_EURJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO3Sets4.Add( Base.EURJPY_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURJPY_OCO3S1_DOWN_S2 = 0;
	                for (; EURJPY_OCO3S1_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets1.Count; EURJPY_OCO3S1_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO3Sets1[EURJPY_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO3Sets1[EURJPY_OCO3S1_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO3Sets1.RemoveAt(EURJPY_OCO3S1_DOWN_S2);
	                        EURJPY_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURJPY_OCO3S2_DOWN_S2 = 0;
	                for (; EURJPY_OCO3S2_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets2.Count; EURJPY_OCO3S2_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO3Sets2[EURJPY_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO3Sets2[EURJPY_OCO3S2_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO3Sets2.RemoveAt(EURJPY_OCO3S2_DOWN_S2);
	                        EURJPY_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO3S3_DOWN_S2 = 0;
	                for (; EURJPY_OCO3S3_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets3.Count; EURJPY_OCO3S3_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO3Sets3[EURJPY_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO3Sets3[EURJPY_OCO3S3_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO3Sets3.RemoveAt(EURJPY_OCO3S3_DOWN_S2);
	                        EURJPY_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO3S4_DOWN_S2 = 0;
	                for (; EURJPY_OCO3S4_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets4.Count; EURJPY_OCO3S4_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO3Sets4[EURJPY_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO3Sets4[EURJPY_OCO3S4_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO3Sets4.RemoveAt(EURJPY_OCO3S4_DOWN_S2);
	                        EURJPY_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURJPY_OCO4_EO1_DOWN_S2)
	                Base.EURJPY_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURJPY_OCO4_EO2_DOWN_S2)
	                Base.EURJPY_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO4_EO3_DOWN_S2)
	                Base.EURJPY_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURJPY_OCO4_EO4_DOWN_S2)
	                Base.EURJPY_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURJPY_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.EURJPY_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP1_EURJPY_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP1,"TP1_EURJPY_DOWN_S2_OCO4"));
		                 };
		                Base.EURJPY_DOWN_S2_OCO4Sets1.Add( Base.EURJPY_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURJPY_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP2_EURJPY_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP2,"TP2_EURJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO4Sets2.Add( Base.EURJPY_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP3_EURJPY_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP3,"TP3_EURJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO4Sets3.Add( Base.EURJPY_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURJPY_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURJPY_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURJPY_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURJPY_DOWN_S2_SL,"SL_TP4_EURJPY_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURJPY_DOWN_S2_TP4,"TP4_EURJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.EURJPY_DOWN_S2_OCO4Sets4.Add( Base.EURJPY_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURJPY_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURJPY_OCO4S1_DOWN_S2 = 0;
	                for (; EURJPY_OCO4S1_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets1.Count; EURJPY_OCO4S1_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO4Sets1[EURJPY_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO4Sets1[EURJPY_OCO4S1_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO4Sets1.RemoveAt(EURJPY_OCO4S1_DOWN_S2);
	                        EURJPY_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURJPY_OCO4S2_DOWN_S2 = 0;
	                for (; EURJPY_OCO4S2_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets2.Count; EURJPY_OCO4S2_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO4Sets2[EURJPY_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO4Sets2[EURJPY_OCO4S2_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO4Sets2.RemoveAt(EURJPY_OCO4S2_DOWN_S2);
	                        EURJPY_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO4S3_DOWN_S2 = 0;
	                for (; EURJPY_OCO4S3_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets3.Count; EURJPY_OCO4S3_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO4Sets3[EURJPY_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO4Sets3[EURJPY_OCO4S3_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO4Sets3.RemoveAt(EURJPY_OCO4S3_DOWN_S2);
	                        EURJPY_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURJPY_OCO4S4_DOWN_S2 = 0;
	                for (; EURJPY_OCO4S4_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets4.Count; EURJPY_OCO4S4_DOWN_S2++)
	                    if (Base.EURJPY_DOWN_S2_OCO4Sets4[EURJPY_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURJPY_DOWN_S2_OCO4Sets4[EURJPY_OCO4S4_DOWN_S2].Filled();
	                        Base.EURJPY_DOWN_S2_OCO4Sets4.RemoveAt(EURJPY_OCO4S4_DOWN_S2);
	                        EURJPY_OCO4S4_DOWN_S2 = 0;
	                        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 _GBPNZD;
		
    	///oco1 up
    	public static OrderTicket GBPNZD_OCO1_MO1_UP_S2;
    	public static OrderTicket GBPNZD_OCO1_MO2_UP_S2;
    	public static OrderTicket GBPNZD_OCO1_MO3_UP_S2;
    	public static OrderTicket GBPNZD_OCO1_MO4_UP_S2;
    	public static OrderTicket GBPNZD_OCO1_MO5_UP_S2;
    	public static OrderTicket GBPNZD_OCO1_MO6_UP_S2;
    	
    	public static int GBPNZD_OCO1_EO1_UP_S2_ID ;
        public static int GBPNZD_OCO1_EO2_UP_S2_ID ;
        public static int GBPNZD_OCO1_EO3_UP_S2_ID ;
        public static int GBPNZD_OCO1_EO4_UP_S2_ID ;
        public static int GBPNZD_OCO1_EO5_UP_S2_ID ;
        public static int GBPNZD_OCO1_EO6_UP_S2_ID ;
        
        public static bool GBPNZD_OCO1_EO1_UP_S2 ;
        public static bool GBPNZD_OCO1_EO2_UP_S2 ;
        public static bool GBPNZD_OCO1_EO3_UP_S2 ;
        public static bool GBPNZD_OCO1_EO4_UP_S2 ;
        public static bool GBPNZD_OCO1_EO5_UP_S2 ;
        public static bool GBPNZD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_UP_S2> GBPNZD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_UP_S2> GBPNZD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_UP_S2> GBPNZD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_UP_S2> GBPNZD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_UP_S2> GBPNZD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_UP_S2> GBPNZD_OOFE_OCO1_UP_S2_6 ;
        
        public static GBPNZD_OCO1_UP_S2 GBPNZD_PFO_OCO1_UP_S2_1 ;
        public static GBPNZD_OCO1_UP_S2 GBPNZD_PFO_OCO1_UP_S2_2 ;
        public static GBPNZD_OCO1_UP_S2 GBPNZD_PFO_OCO1_UP_S2_3 ;
        public static GBPNZD_OCO1_UP_S2 GBPNZD_PFO_OCO1_UP_S2_4 ;
        public static GBPNZD_OCO1_UP_S2 GBPNZD_PFO_OCO1_UP_S2_5 ;
        public static GBPNZD_OCO1_UP_S2 GBPNZD_PFO_OCO1_UP_S2_6 ;
        
        public static List<GBPNZD_OCO1_UP_S2> GBPNZD_UP_S2_OCO1Sets1 = new List<GBPNZD_OCO1_UP_S2>();
        public static List<GBPNZD_OCO1_UP_S2> GBPNZD_UP_S2_OCO1Sets2 = new List<GBPNZD_OCO1_UP_S2>();
        public static List<GBPNZD_OCO1_UP_S2> GBPNZD_UP_S2_OCO1Sets3 = new List<GBPNZD_OCO1_UP_S2>();
        public static List<GBPNZD_OCO1_UP_S2> GBPNZD_UP_S2_OCO1Sets4 = new List<GBPNZD_OCO1_UP_S2>();
        public static List<GBPNZD_OCO1_UP_S2> GBPNZD_UP_S2_OCO1Sets5 = new List<GBPNZD_OCO1_UP_S2>();
        public static List<GBPNZD_OCO1_UP_S2> GBPNZD_UP_S2_OCO1Sets6 = new List<GBPNZD_OCO1_UP_S2>();
        
        public static bool GBPNZD_OCO1_UP_S2_IsReady = true;
        public static bool GBPNZD_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket GBPNZD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int GBPNZD_OCO1_EO1_DOWN_S2_ID ;
        public static int GBPNZD_OCO1_EO2_DOWN_S2_ID ;
        public static int GBPNZD_OCO1_EO3_DOWN_S2_ID ;
        public static int GBPNZD_OCO1_EO4_DOWN_S2_ID ;
        public static int GBPNZD_OCO1_EO5_DOWN_S2_ID ;
        public static int GBPNZD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool GBPNZD_OCO1_EO1_DOWN_S2 ;
        public static bool GBPNZD_OCO1_EO2_DOWN_S2 ;
        public static bool GBPNZD_OCO1_EO3_DOWN_S2 ;
        public static bool GBPNZD_OCO1_EO4_DOWN_S2 ;
        public static bool GBPNZD_OCO1_EO5_DOWN_S2 ;
        public static bool GBPNZD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_DOWN_S2> GBPNZD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_DOWN_S2> GBPNZD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_DOWN_S2> GBPNZD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_DOWN_S2> GBPNZD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_DOWN_S2> GBPNZD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO1_DOWN_S2> GBPNZD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static GBPNZD_OCO1_DOWN_S2 GBPNZD_PFO_OCO1_DOWN_S2_1 ;
        public static GBPNZD_OCO1_DOWN_S2 GBPNZD_PFO_OCO1_DOWN_S2_2 ;
        public static GBPNZD_OCO1_DOWN_S2 GBPNZD_PFO_OCO1_DOWN_S2_3 ;
        public static GBPNZD_OCO1_DOWN_S2 GBPNZD_PFO_OCO1_DOWN_S2_4 ;
        public static GBPNZD_OCO1_DOWN_S2 GBPNZD_PFO_OCO1_DOWN_S2_5 ;
        public static GBPNZD_OCO1_DOWN_S2 GBPNZD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<GBPNZD_OCO1_DOWN_S2> GBPNZD_DOWN_S2_OCO1Sets1 = new List<GBPNZD_OCO1_DOWN_S2>();
        public static List<GBPNZD_OCO1_DOWN_S2> GBPNZD_DOWN_S2_OCO1Sets2 = new List<GBPNZD_OCO1_DOWN_S2>();
        public static List<GBPNZD_OCO1_DOWN_S2> GBPNZD_DOWN_S2_OCO1Sets3 = new List<GBPNZD_OCO1_DOWN_S2>();
        public static List<GBPNZD_OCO1_DOWN_S2> GBPNZD_DOWN_S2_OCO1Sets4 = new List<GBPNZD_OCO1_DOWN_S2>();
        public static List<GBPNZD_OCO1_DOWN_S2> GBPNZD_DOWN_S2_OCO1Sets5 = new List<GBPNZD_OCO1_DOWN_S2>();
        public static List<GBPNZD_OCO1_DOWN_S2> GBPNZD_DOWN_S2_OCO1Sets6 = new List<GBPNZD_OCO1_DOWN_S2>();
        
        public static bool GBPNZD_OCO1_DOWN_S2_IsReady = true;
        public static bool GBPNZD_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket GBPNZD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO6_UP_S2 ;
    	
    	public static int GBPNZD_OCO2_EO1_UP_S2_ID ;
        public static int GBPNZD_OCO2_EO2_UP_S2_ID ;
        public static int GBPNZD_OCO2_EO3_UP_S2_ID ;
        public static int GBPNZD_OCO2_EO4_UP_S2_ID ;
        public static int GBPNZD_OCO2_EO5_UP_S2_ID ;
        public static int GBPNZD_OCO2_EO6_UP_S2_ID ;
        
        public static bool GBPNZD_OCO2_EO1_UP_S2 ;
        public static bool GBPNZD_OCO2_EO2_UP_S2 ;
        public static bool GBPNZD_OCO2_EO3_UP_S2 ;
        public static bool GBPNZD_OCO2_EO4_UP_S2 ;
        public static bool GBPNZD_OCO2_EO5_UP_S2 ;
        public static bool GBPNZD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_UP_S2> GBPNZD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_UP_S2> GBPNZD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_UP_S2> GBPNZD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_UP_S2> GBPNZD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_UP_S2> GBPNZD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_UP_S2> GBPNZD_OOFE_OCO2_UP_S2_6 ;
        
        public static GBPNZD_OCO2_UP_S2 GBPNZD_PFO_OCO2_UP_S2_1 ;
        public static GBPNZD_OCO2_UP_S2 GBPNZD_PFO_OCO2_UP_S2_2 ;
        public static GBPNZD_OCO2_UP_S2 GBPNZD_PFO_OCO2_UP_S2_3 ;
        public static GBPNZD_OCO2_UP_S2 GBPNZD_PFO_OCO2_UP_S2_4 ;
        public static GBPNZD_OCO2_UP_S2 GBPNZD_PFO_OCO2_UP_S2_5 ;
        public static GBPNZD_OCO2_UP_S2 GBPNZD_PFO_OCO2_UP_S2_6 ;
        
        public static List<GBPNZD_OCO2_UP_S2> GBPNZD_UP_S2_OCO2Sets1 = new List<GBPNZD_OCO2_UP_S2>();
        public static List<GBPNZD_OCO2_UP_S2> GBPNZD_UP_S2_OCO2Sets2 = new List<GBPNZD_OCO2_UP_S2>();
        public static List<GBPNZD_OCO2_UP_S2> GBPNZD_UP_S2_OCO2Sets3 = new List<GBPNZD_OCO2_UP_S2>();
        public static List<GBPNZD_OCO2_UP_S2> GBPNZD_UP_S2_OCO2Sets4 = new List<GBPNZD_OCO2_UP_S2>();
        public static List<GBPNZD_OCO2_UP_S2> GBPNZD_UP_S2_OCO2Sets5 = new List<GBPNZD_OCO2_UP_S2>();
        public static List<GBPNZD_OCO2_UP_S2> GBPNZD_UP_S2_OCO2Sets6 = new List<GBPNZD_OCO2_UP_S2>();
        
        public static bool GBPNZD_OCO2_UP_S2_IsReady = true;
        public static bool GBPNZD_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket GBPNZD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int GBPNZD_OCO2_EO1_DOWN_S2_ID ;
        public static int GBPNZD_OCO2_EO2_DOWN_S2_ID ;
        public static int GBPNZD_OCO2_EO3_DOWN_S2_ID ;
        public static int GBPNZD_OCO2_EO4_DOWN_S2_ID ;
        public static int GBPNZD_OCO2_EO5_DOWN_S2_ID ;
        public static int GBPNZD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool GBPNZD_OCO2_EO1_DOWN_S2 ;
        public static bool GBPNZD_OCO2_EO2_DOWN_S2 ;
        public static bool GBPNZD_OCO2_EO3_DOWN_S2 ;
        public static bool GBPNZD_OCO2_EO4_DOWN_S2 ;
        public static bool GBPNZD_OCO2_EO5_DOWN_S2 ;
        public static bool GBPNZD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_DOWN_S2> GBPNZD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_DOWN_S2> GBPNZD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_DOWN_S2> GBPNZD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_DOWN_S2> GBPNZD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_DOWN_S2> GBPNZD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO2_DOWN_S2> GBPNZD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static GBPNZD_OCO2_DOWN_S2 GBPNZD_PFO_OCO2_DOWN_S2_1 ;
        public static GBPNZD_OCO2_DOWN_S2 GBPNZD_PFO_OCO2_DOWN_S2_2 ;
        public static GBPNZD_OCO2_DOWN_S2 GBPNZD_PFO_OCO2_DOWN_S2_3 ;
        public static GBPNZD_OCO2_DOWN_S2 GBPNZD_PFO_OCO2_DOWN_S2_4 ;
        public static GBPNZD_OCO2_DOWN_S2 GBPNZD_PFO_OCO2_DOWN_S2_5 ;
        public static GBPNZD_OCO2_DOWN_S2 GBPNZD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<GBPNZD_OCO2_DOWN_S2> GBPNZD_DOWN_S2_OCO2Sets1 = new List<GBPNZD_OCO2_DOWN_S2>();
        public static List<GBPNZD_OCO2_DOWN_S2> GBPNZD_DOWN_S2_OCO2Sets2 = new List<GBPNZD_OCO2_DOWN_S2>();
        public static List<GBPNZD_OCO2_DOWN_S2> GBPNZD_DOWN_S2_OCO2Sets3 = new List<GBPNZD_OCO2_DOWN_S2>();
        public static List<GBPNZD_OCO2_DOWN_S2> GBPNZD_DOWN_S2_OCO2Sets4 = new List<GBPNZD_OCO2_DOWN_S2>();
        public static List<GBPNZD_OCO2_DOWN_S2> GBPNZD_DOWN_S2_OCO2Sets5 = new List<GBPNZD_OCO2_DOWN_S2>();
        public static List<GBPNZD_OCO2_DOWN_S2> GBPNZD_DOWN_S2_OCO2Sets6 = new List<GBPNZD_OCO2_DOWN_S2>();
        
        public static bool GBPNZD_OCO2_DOWN_S2_IsReady = true;
        public static bool GBPNZD_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket GBPNZD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO6_UP_S2 ;
    	
    	public static int GBPNZD_OCO3_EO1_UP_S2_ID ;
        public static int GBPNZD_OCO3_EO2_UP_S2_ID ;
        public static int GBPNZD_OCO3_EO3_UP_S2_ID ;
        public static int GBPNZD_OCO3_EO4_UP_S2_ID ;
        public static int GBPNZD_OCO3_EO5_UP_S2_ID ;
        public static int GBPNZD_OCO3_EO6_UP_S2_ID ;
        
        public static bool GBPNZD_OCO3_EO1_UP_S2 ;
        public static bool GBPNZD_OCO3_EO2_UP_S2 ;
        public static bool GBPNZD_OCO3_EO3_UP_S2 ;
        public static bool GBPNZD_OCO3_EO4_UP_S2 ;
        public static bool GBPNZD_OCO3_EO5_UP_S2 ;
        public static bool GBPNZD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_UP_S2> GBPNZD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_UP_S2> GBPNZD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_UP_S2> GBPNZD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_UP_S2> GBPNZD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_UP_S2> GBPNZD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_UP_S2> GBPNZD_OOFE_OCO3_UP_S2_6 ;
        
        public static GBPNZD_OCO3_UP_S2 GBPNZD_PFO_OCO3_UP_S2_1 ;
        public static GBPNZD_OCO3_UP_S2 GBPNZD_PFO_OCO3_UP_S2_2 ;
        public static GBPNZD_OCO3_UP_S2 GBPNZD_PFO_OCO3_UP_S2_3 ;
        public static GBPNZD_OCO3_UP_S2 GBPNZD_PFO_OCO3_UP_S2_4 ;
        public static GBPNZD_OCO3_UP_S2 GBPNZD_PFO_OCO3_UP_S2_5 ;
        public static GBPNZD_OCO3_UP_S2 GBPNZD_PFO_OCO3_UP_S2_6 ;
        
        public static List<GBPNZD_OCO3_UP_S2> GBPNZD_UP_S2_OCO3Sets1 = new List<GBPNZD_OCO3_UP_S2>();
        public static List<GBPNZD_OCO3_UP_S2> GBPNZD_UP_S2_OCO3Sets2 = new List<GBPNZD_OCO3_UP_S2>();
        public static List<GBPNZD_OCO3_UP_S2> GBPNZD_UP_S2_OCO3Sets3 = new List<GBPNZD_OCO3_UP_S2>();
        public static List<GBPNZD_OCO3_UP_S2> GBPNZD_UP_S2_OCO3Sets4 = new List<GBPNZD_OCO3_UP_S2>();
        public static List<GBPNZD_OCO3_UP_S2> GBPNZD_UP_S2_OCO3Sets5 = new List<GBPNZD_OCO3_UP_S2>();
        public static List<GBPNZD_OCO3_UP_S2> GBPNZD_UP_S2_OCO3Sets6 = new List<GBPNZD_OCO3_UP_S2>();
        
        public static bool GBPNZD_OCO3_UP_S2_IsReady = true;
        public static bool GBPNZD_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket GBPNZD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int GBPNZD_OCO3_EO1_DOWN_S2_ID ;
        public static int GBPNZD_OCO3_EO2_DOWN_S2_ID ;
        public static int GBPNZD_OCO3_EO3_DOWN_S2_ID ;
        public static int GBPNZD_OCO3_EO4_DOWN_S2_ID ;
        public static int GBPNZD_OCO3_EO5_DOWN_S2_ID ;
        public static int GBPNZD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool GBPNZD_OCO3_EO1_DOWN_S2 ;
        public static bool GBPNZD_OCO3_EO2_DOWN_S2 ;
        public static bool GBPNZD_OCO3_EO3_DOWN_S2 ;
        public static bool GBPNZD_OCO3_EO4_DOWN_S2 ;
        public static bool GBPNZD_OCO3_EO5_DOWN_S2 ;
        public static bool GBPNZD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_DOWN_S2> GBPNZD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_DOWN_S2> GBPNZD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_DOWN_S2> GBPNZD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_DOWN_S2> GBPNZD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_DOWN_S2> GBPNZD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO3_DOWN_S2> GBPNZD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static GBPNZD_OCO3_DOWN_S2 GBPNZD_PFO_OCO3_DOWN_S2_1 ;
        public static GBPNZD_OCO3_DOWN_S2 GBPNZD_PFO_OCO3_DOWN_S2_2 ;
        public static GBPNZD_OCO3_DOWN_S2 GBPNZD_PFO_OCO3_DOWN_S2_3 ;
        public static GBPNZD_OCO3_DOWN_S2 GBPNZD_PFO_OCO3_DOWN_S2_4 ;
        public static GBPNZD_OCO3_DOWN_S2 GBPNZD_PFO_OCO3_DOWN_S2_5 ;
        public static GBPNZD_OCO3_DOWN_S2 GBPNZD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<GBPNZD_OCO3_DOWN_S2> GBPNZD_DOWN_S2_OCO3Sets1 = new List<GBPNZD_OCO3_DOWN_S2>();
        public static List<GBPNZD_OCO3_DOWN_S2> GBPNZD_DOWN_S2_OCO3Sets2 = new List<GBPNZD_OCO3_DOWN_S2>();
        public static List<GBPNZD_OCO3_DOWN_S2> GBPNZD_DOWN_S2_OCO3Sets3 = new List<GBPNZD_OCO3_DOWN_S2>();
        public static List<GBPNZD_OCO3_DOWN_S2> GBPNZD_DOWN_S2_OCO3Sets4 = new List<GBPNZD_OCO3_DOWN_S2>();
        public static List<GBPNZD_OCO3_DOWN_S2> GBPNZD_DOWN_S2_OCO3Sets5 = new List<GBPNZD_OCO3_DOWN_S2>();
        public static List<GBPNZD_OCO3_DOWN_S2> GBPNZD_DOWN_S2_OCO3Sets6 = new List<GBPNZD_OCO3_DOWN_S2>();
        
        public static bool GBPNZD_OCO3_DOWN_S2_IsReady = true;
        public static bool GBPNZD_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket GBPNZD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO6_UP_S2 ;
    	
    	public static int GBPNZD_OCO4_EO1_UP_S2_ID ;
        public static int GBPNZD_OCO4_EO2_UP_S2_ID ;
        public static int GBPNZD_OCO4_EO3_UP_S2_ID ;
        public static int GBPNZD_OCO4_EO4_UP_S2_ID ;
        public static int GBPNZD_OCO4_EO5_UP_S2_ID ;
        public static int GBPNZD_OCO4_EO6_UP_S2_ID ;
        
        public static bool GBPNZD_OCO4_EO1_UP_S2 ;
        public static bool GBPNZD_OCO4_EO2_UP_S2 ;
        public static bool GBPNZD_OCO4_EO3_UP_S2 ;
        public static bool GBPNZD_OCO4_EO4_UP_S2 ;
        public static bool GBPNZD_OCO4_EO5_UP_S2 ;
        public static bool GBPNZD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_UP_S2> GBPNZD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_UP_S2> GBPNZD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_UP_S2> GBPNZD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_UP_S2> GBPNZD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_UP_S2> GBPNZD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_UP_S2> GBPNZD_OOFE_OCO4_UP_S2_6 ;
        
        public static GBPNZD_OCO4_UP_S2 GBPNZD_PFO_OCO4_UP_S2_1 ;
        public static GBPNZD_OCO4_UP_S2 GBPNZD_PFO_OCO4_UP_S2_2 ;
        public static GBPNZD_OCO4_UP_S2 GBPNZD_PFO_OCO4_UP_S2_3 ;
        public static GBPNZD_OCO4_UP_S2 GBPNZD_PFO_OCO4_UP_S2_4 ;
        public static GBPNZD_OCO4_UP_S2 GBPNZD_PFO_OCO4_UP_S2_5 ;
        public static GBPNZD_OCO4_UP_S2 GBPNZD_PFO_OCO4_UP_S2_6 ;
        
        public static List<GBPNZD_OCO4_UP_S2> GBPNZD_UP_S2_OCO4Sets1 = new List<GBPNZD_OCO4_UP_S2>();
        public static List<GBPNZD_OCO4_UP_S2> GBPNZD_UP_S2_OCO4Sets2 = new List<GBPNZD_OCO4_UP_S2>();
        public static List<GBPNZD_OCO4_UP_S2> GBPNZD_UP_S2_OCO4Sets3 = new List<GBPNZD_OCO4_UP_S2>();
        public static List<GBPNZD_OCO4_UP_S2> GBPNZD_UP_S2_OCO4Sets4 = new List<GBPNZD_OCO4_UP_S2>();
        public static List<GBPNZD_OCO4_UP_S2> GBPNZD_UP_S2_OCO4Sets5 = new List<GBPNZD_OCO4_UP_S2>();
        public static List<GBPNZD_OCO4_UP_S2> GBPNZD_UP_S2_OCO4Sets6 = new List<GBPNZD_OCO4_UP_S2>();
        
        public static bool GBPNZD_OCO4_UP_S2_IsReady = true;
        public static bool GBPNZD_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket GBPNZD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket GBPNZD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int GBPNZD_OCO4_EO1_DOWN_S2_ID ;
        public static int GBPNZD_OCO4_EO2_DOWN_S2_ID ;
        public static int GBPNZD_OCO4_EO3_DOWN_S2_ID ;
        public static int GBPNZD_OCO4_EO4_DOWN_S2_ID ;
        public static int GBPNZD_OCO4_EO5_DOWN_S2_ID ;
        public static int GBPNZD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool GBPNZD_OCO4_EO1_DOWN_S2 ;
        public static bool GBPNZD_OCO4_EO2_DOWN_S2 ;
        public static bool GBPNZD_OCO4_EO3_DOWN_S2 ;
        public static bool GBPNZD_OCO4_EO4_DOWN_S2 ;
        public static bool GBPNZD_OCO4_EO5_DOWN_S2 ;
        public static bool GBPNZD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_DOWN_S2> GBPNZD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_DOWN_S2> GBPNZD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_DOWN_S2> GBPNZD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_DOWN_S2> GBPNZD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_DOWN_S2> GBPNZD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPNZD_OCO4_DOWN_S2> GBPNZD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static GBPNZD_OCO4_DOWN_S2 GBPNZD_PFO_OCO4_DOWN_S2_1 ;
        public static GBPNZD_OCO4_DOWN_S2 GBPNZD_PFO_OCO4_DOWN_S2_2 ;
        public static GBPNZD_OCO4_DOWN_S2 GBPNZD_PFO_OCO4_DOWN_S2_3 ;
        public static GBPNZD_OCO4_DOWN_S2 GBPNZD_PFO_OCO4_DOWN_S2_4 ;
        public static GBPNZD_OCO4_DOWN_S2 GBPNZD_PFO_OCO4_DOWN_S2_5 ;
        public static GBPNZD_OCO4_DOWN_S2 GBPNZD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<GBPNZD_OCO4_DOWN_S2> GBPNZD_DOWN_S2_OCO4Sets1 = new List<GBPNZD_OCO4_DOWN_S2>();
        public static List<GBPNZD_OCO4_DOWN_S2> GBPNZD_DOWN_S2_OCO4Sets2 = new List<GBPNZD_OCO4_DOWN_S2>();
        public static List<GBPNZD_OCO4_DOWN_S2> GBPNZD_DOWN_S2_OCO4Sets3 = new List<GBPNZD_OCO4_DOWN_S2>();
        public static List<GBPNZD_OCO4_DOWN_S2> GBPNZD_DOWN_S2_OCO4Sets4 = new List<GBPNZD_OCO4_DOWN_S2>();
        public static List<GBPNZD_OCO4_DOWN_S2> GBPNZD_DOWN_S2_OCO4Sets5 = new List<GBPNZD_OCO4_DOWN_S2>();
        public static List<GBPNZD_OCO4_DOWN_S2> GBPNZD_DOWN_S2_OCO4Sets6 = new List<GBPNZD_OCO4_DOWN_S2>();
        
        public static bool GBPNZD_OCO4_DOWN_S2_IsReady = true;
        public static bool GBPNZD_OCO4_DOWN_S2_Monthly_IsReady = true;

        
////////////////////////////
		public static decimal GBPNZD_UP_S2_SL {get; set;}
		public static decimal GBPNZD_UP_S2_TP1 {get; set;}
		public static decimal GBPNZD_UP_S2_TP2 {get; set;}
		public static decimal GBPNZD_UP_S2_TP3 {get; set;}
		public static decimal GBPNZD_UP_S2_TP4 {get; set;}
		public static decimal GBPNZD_UP_S2_TP5 {get; set;}
		public static decimal GBPNZD_UP_S2_TP6 {get; set;}
		
		public static decimal GBPNZD_DOWN_S2_SL {get; set;}
		public static decimal GBPNZD_DOWN_S2_TP1 {get; set;}
		public static decimal GBPNZD_DOWN_S2_TP2 {get; set;}
		public static decimal GBPNZD_DOWN_S2_TP3 {get; set;}
		public static decimal GBPNZD_DOWN_S2_TP4 {get; set;}
		public static decimal GBPNZD_DOWN_S2_TP5 {get; set;}
		public static decimal GBPNZD_DOWN_S2_TP6 {get; set;}

        public static bool GBPNZD_Signal_Condition_UP_1 ;
        public static bool GBPNZD_Signal_Condition_UP_2 ;
        public static bool GBPNZD_Signal_Condition_UP_3 ;
        
        public static bool GBPNZD_Signal_Condition_DOWN_1 ;
        public static bool GBPNZD_Signal_Condition_DOWN_2 ;
        public static bool GBPNZD_Signal_Condition_DOWN_3 ;
        
        public static int GBPNZD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int GBPNZD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPNZD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPNZD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPNZD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int GBPNZD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int GBPNZD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPNZD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPNZD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPNZD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_GBPNZD_UP_S2 ;
        public static bool DOWM_GBPNZD_UP_S2 ;
        public static bool DOWT_GBPNZD_UP_S2 ;
        public static bool DOWW_GBPNZD_UP_S2 ;
        public static bool DOWTH_GBPNZD_UP_S2 ;
        
		public static bool DOWR_GBPNZD_DOWN_S2 ;
        public static bool DOWM_GBPNZD_DOWN_S2 ;
        public static bool DOWT_GBPNZD_DOWN_S2 ;
        public static bool DOWW_GBPNZD_DOWN_S2 ;
        public static bool DOWTH_GBPNZD_DOWN_S2 ;
        
        
		public static int GBPNZD_quantity_UP_S2 ;
		public static int GBPNZD_quantity_SL_UP_S2 ;
		public static int GBPNZD_quantity_TP1_UP_S2 ;
		public static int GBPNZD_quantity_TP2_UP_S2 ;
		public static int GBPNZD_quantity_TP3_UP_S2 ;
		public static int GBPNZD_quantity_TP4_UP_S2 ;
		public static int GBPNZD_quantity_TP5_UP_S2;
		public static int GBPNZD_quantity_TP6_UP_S2 ;
		
		public static int GBPNZD_quantity_DOWN_S2 ;
		public static int GBPNZD_quantity_SL_DOWN_S2 ;
		public static int GBPNZD_quantity_TP1_DOWN_S2 ;
		public static int GBPNZD_quantity_TP2_DOWN_S2 ;
		public static int GBPNZD_quantity_TP3_DOWN_S2 ;
		public static int GBPNZD_quantity_TP4_DOWN_S2 ;
		public static int GBPNZD_quantity_TP5_DOWN_S2;
		public static int GBPNZD_quantity_TP6_DOWN_S2 ;
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURNZD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURNZD_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("EURNZD_DOWN_S2_OCO1")))
			{
				Base.EURNZD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURNZD_DOWN_S2_OCO2")))
			{
				Base.EURNZD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURNZD_DOWN_S2_OCO3")))
			{
				Base.EURNZD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURNZD_DOWN_S2_OCO4")))
			{
				Base.EURNZD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURNZD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.EURNZD_OCO1_EO1_DOWN_S2)
	                Base.EURNZD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURNZD_OCO1_EO2_DOWN_S2)
	                Base.EURNZD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO1_EO3_DOWN_S2)
	                Base.EURNZD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO1_EO4_DOWN_S2)
	                Base.EURNZD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO1_EO5_DOWN_S2)
	                Base.EURNZD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO1_EO6_DOWN_S2)
	                Base.EURNZD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURNZD_OCO1S1_DOWN_S2 = 0;
		                for (; EURNZD_OCO1S1_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets1.Count; EURNZD_OCO1S1_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO1Sets1[EURNZD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO1Sets1[EURNZD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.EURNZD_DOWN_S2_OCO1Sets1.Clear();
		                        EURNZD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURNZD_OCO1S2_DOWN_S2 = 0;
		                for (; EURNZD_OCO1S2_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets2.Count; EURNZD_OCO1S2_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO1Sets2[EURNZD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO1Sets2[EURNZD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.EURNZD_DOWN_S2_OCO1Sets2.Clear();
		                        EURNZD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO1S3_DOWN_S2 = 0;
		                for (; EURNZD_OCO1S3_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets3.Count; EURNZD_OCO1S3_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO1Sets3[EURNZD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO1Sets3[EURNZD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.EURNZD_DOWN_S2_OCO1Sets3.Clear();
		                        EURNZD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO1S4_DOWN_S2 = 0;
		                for (; EURNZD_OCO1S4_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets4.Count; EURNZD_OCO1S4_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO1Sets4[EURNZD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO1Sets4[EURNZD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.EURNZD_DOWN_S2_OCO1Sets4.Clear();
		                        EURNZD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO1S5_DOWN_S2 = 0;
		                for (; EURNZD_OCO1S5_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets5.Count; EURNZD_OCO1S5_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO1Sets5[EURNZD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO1Sets5[EURNZD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.EURNZD_DOWN_S2_OCO1Sets5.Clear();
		                        EURNZD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO1S6_DOWN_S2 = 0;
		                for (; EURNZD_OCO1S6_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets6.Count; EURNZD_OCO1S6_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO1Sets6[EURNZD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO1Sets6[EURNZD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.EURNZD_DOWN_S2_OCO1Sets6.Clear();
		                        EURNZD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURNZD_OCO2_EO1_DOWN_S2)
	                Base.EURNZD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURNZD_OCO2_EO2_DOWN_S2)
	                Base.EURNZD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO2_EO3_DOWN_S2)
	                Base.EURNZD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO2_EO4_DOWN_S2)
	                Base.EURNZD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO2_EO5_DOWN_S2)
	                Base.EURNZD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO2_EO6_DOWN_S2)
	                Base.EURNZD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURNZD_OCO2S1_DOWN_S2 = 0;
		                for (; EURNZD_OCO2S1_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets1.Count; EURNZD_OCO2S1_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO2Sets1[EURNZD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO2Sets1[EURNZD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.EURNZD_DOWN_S2_OCO2Sets1.Clear();
		                        EURNZD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURNZD_OCO2S2_DOWN_S2 = 0;
		                for (; EURNZD_OCO2S2_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets2.Count; EURNZD_OCO2S2_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO2Sets2[EURNZD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO2Sets2[EURNZD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.EURNZD_DOWN_S2_OCO2Sets2.Clear();
		                        EURNZD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO2S3_DOWN_S2 = 0;
		                for (; EURNZD_OCO2S3_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets3.Count; EURNZD_OCO2S3_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO2Sets3[EURNZD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO2Sets3[EURNZD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.EURNZD_DOWN_S2_OCO2Sets3.Clear();
		                        EURNZD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO2S4_DOWN_S2 = 0;
		                for (; EURNZD_OCO2S4_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets4.Count; EURNZD_OCO2S4_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO2Sets4[EURNZD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO2Sets4[EURNZD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.EURNZD_DOWN_S2_OCO2Sets4.Clear();
		                        EURNZD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO2S5_DOWN_S2 = 0;
		                for (; EURNZD_OCO2S5_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets5.Count; EURNZD_OCO2S5_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO2Sets5[EURNZD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO2Sets5[EURNZD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.EURNZD_DOWN_S2_OCO2Sets5.Clear();
		                        EURNZD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO2S6_DOWN_S2 = 0;
		                for (; EURNZD_OCO2S6_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets6.Count; EURNZD_OCO2S6_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO2Sets6[EURNZD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO2Sets6[EURNZD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.EURNZD_DOWN_S2_OCO2Sets6.Clear();
		                        EURNZD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURNZD_OCO3_EO1_DOWN_S2)
	                Base.EURNZD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURNZD_OCO3_EO2_DOWN_S2)
	                Base.EURNZD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO3_EO3_DOWN_S2)
	                Base.EURNZD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO3_EO4_DOWN_S2)
	                Base.EURNZD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO3_EO5_DOWN_S2)
	                Base.EURNZD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO3_EO6_DOWN_S2)
	                Base.EURNZD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURNZD_OCO3S1_DOWN_S2 = 0;
		                for (; EURNZD_OCO3S1_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets1.Count; EURNZD_OCO3S1_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO3Sets1[EURNZD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO3Sets1[EURNZD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.EURNZD_DOWN_S2_OCO3Sets1.Clear();
		                        EURNZD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURNZD_OCO3S2_DOWN_S2 = 0;
		                for (; EURNZD_OCO3S2_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets2.Count; EURNZD_OCO3S2_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO3Sets2[EURNZD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO3Sets2[EURNZD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.EURNZD_DOWN_S2_OCO3Sets2.Clear();
		                        EURNZD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO3S3_DOWN_S2 = 0;
		                for (; EURNZD_OCO3S3_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets3.Count; EURNZD_OCO3S3_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO3Sets3[EURNZD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO3Sets3[EURNZD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.EURNZD_DOWN_S2_OCO3Sets3.Clear();
		                        EURNZD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO3S4_DOWN_S2 = 0;
		                for (; EURNZD_OCO3S4_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets4.Count; EURNZD_OCO3S4_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO3Sets4[EURNZD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO3Sets4[EURNZD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.EURNZD_DOWN_S2_OCO3Sets4.Clear();
		                        EURNZD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO3S5_DOWN_S2 = 0;
		                for (; EURNZD_OCO3S5_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets5.Count; EURNZD_OCO3S5_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO3Sets5[EURNZD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO3Sets5[EURNZD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.EURNZD_DOWN_S2_OCO3Sets5.Clear();
		                        EURNZD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO3S6_DOWN_S2 = 0;
		                for (; EURNZD_OCO3S6_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets6.Count; EURNZD_OCO3S6_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO3Sets6[EURNZD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO3Sets6[EURNZD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.EURNZD_DOWN_S2_OCO3Sets6.Clear();
		                        EURNZD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURNZD_OCO4_EO1_DOWN_S2)
	                Base.EURNZD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURNZD_OCO4_EO2_DOWN_S2)
	                Base.EURNZD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO4_EO3_DOWN_S2)
	                Base.EURNZD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO4_EO4_DOWN_S2)
	                Base.EURNZD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO4_EO5_DOWN_S2)
	                Base.EURNZD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO4_EO6_DOWN_S2)
	                Base.EURNZD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURNZD_OCO4S1_DOWN_S2 = 0;
		                for (; EURNZD_OCO4S1_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets1.Count; EURNZD_OCO4S1_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO4Sets1[EURNZD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO4Sets1[EURNZD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.EURNZD_DOWN_S2_OCO4Sets1.Clear();
		                        EURNZD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURNZD_OCO4S2_DOWN_S2 = 0;
		                for (; EURNZD_OCO4S2_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets2.Count; EURNZD_OCO4S2_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO4Sets2[EURNZD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO4Sets2[EURNZD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.EURNZD_DOWN_S2_OCO4Sets2.Clear();
		                        EURNZD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO4S3_DOWN_S2 = 0;
		                for (; EURNZD_OCO4S3_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets3.Count; EURNZD_OCO4S3_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO4Sets3[EURNZD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO4Sets3[EURNZD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.EURNZD_DOWN_S2_OCO4Sets3.Clear();
		                        EURNZD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO4S4_DOWN_S2 = 0;
		                for (; EURNZD_OCO4S4_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets4.Count; EURNZD_OCO4S4_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO4Sets4[EURNZD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO4Sets4[EURNZD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.EURNZD_DOWN_S2_OCO4Sets4.Clear();
		                        EURNZD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO4S5_DOWN_S2 = 0;
		                for (; EURNZD_OCO4S5_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets5.Count; EURNZD_OCO4S5_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO4Sets5[EURNZD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO4Sets5[EURNZD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.EURNZD_DOWN_S2_OCO4Sets5.Clear();
		                        EURNZD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO4S6_DOWN_S2 = 0;
		                for (; EURNZD_OCO4S6_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets6.Count; EURNZD_OCO4S6_DOWN_S2++)
		                    if (Base.EURNZD_DOWN_S2_OCO4Sets6[EURNZD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_DOWN_S2_OCO4Sets6[EURNZD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.EURNZD_DOWN_S2_OCO4Sets6.Clear();
		                        EURNZD_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();
	            	}
	            	
					DOWM_EURNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURNZD_DOWN_S2 = DOWM_EURNZD_DOWN_S2 || DOWT_EURNZD_DOWN_S2 || DOWW_EURNZD_DOWN_S2 || DOWTH_EURNZD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURNZD"))
	            	{
	            		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.EURNZD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.EURNZD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.EURNZD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.EURNZD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.EURNZD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURNZD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURNZD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURNZD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURNZD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURNZD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURNZD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURNZD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	EURNZD_Signal_Condition_DOWN_S2 =  
	                									(
	                										//ricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.04m &&
	                										
	                										//prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//prices_ASK_High[0] > pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[0] > prices_ASK_Close[0] * 0.02m &&

	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										
	                										//prices_BID_Close[0] - prices_ASK_Open[0] > 0 &&
 	                										
	                										prices_BID_Open[0] > pricesM_ASK_High[0] && 
	                										prices_ASK_Close[0] < pricesM_ASK_High[0] && 
	                										
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.0005m
	                									);
	                									
	                    EURNZD_DOWN_S2_SL  =  0.005m;
	                    EURNZD_DOWN_S2_TP1 =  0.02m;
	                    EURNZD_DOWN_S2_TP2 =  EURNZD_DOWN_S2_SL * 0;
	                    EURNZD_DOWN_S2_TP3 =  EURNZD_DOWN_S2_SL * 0;
	                    EURNZD_DOWN_S2_TP4 =  EURNZD_DOWN_S2_SL * 0;
	                    EURNZD_DOWN_S2_TP5 =  EURNZD_DOWN_S2_SL * 0;
	                    EURNZD_DOWN_S2_TP6 =  EURNZD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURNZD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURNZD_quantity_SL_DOWN_S2 = EURNZD_quantity_DOWN_S2;
	                    EURNZD_quantity_TP1_DOWN_S2 = (int)Math.Floor(EURNZD_quantity_DOWN_S2 * 1m);
	                    EURNZD_quantity_TP2_DOWN_S2 = (int)Math.Floor(EURNZD_quantity_TP1_DOWN_S2 * 0m);
	                    EURNZD_quantity_TP3_DOWN_S2 = (int)Math.Floor(EURNZD_quantity_TP2_DOWN_S2 * 0m);
	                    EURNZD_quantity_TP4_DOWN_S2 = (int)Math.Floor(EURNZD_quantity_TP3_DOWN_S2 * 0m);
	                    EURNZD_quantity_TP5_DOWN_S2 = (int)Math.Floor(EURNZD_quantity_TP4_DOWN_S2 * 0m);
	                    EURNZD_quantity_TP6_DOWN_S2 = (int)Math.Floor(EURNZD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (EURNZD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURNZD_DOWN_S2 && 
	                    Base.EURNZD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.EURNZD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURNZD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP1_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.EURNZD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.EURNZD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP2_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.EURNZD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.EURNZD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP3_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.EURNZD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.EURNZD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP4_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.EURNZD_OCO1_EO4_DOWN_S2 = false;

							Base.EURNZD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.EURNZD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (EURNZD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURNZD_DOWN_S2 && 
	                    Base.EURNZD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.EURNZD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURNZD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURNZD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP1_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.EURNZD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.EURNZD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP2_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.EURNZD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.EURNZD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP3_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.EURNZD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.EURNZD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP4_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.EURNZD_OCO2_EO4_DOWN_S2 = false;

							Base.EURNZD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.EURNZD_OCO2_DOWN_S2_IsReady == false && Base.EURNZD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (EURNZD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURNZD_DOWN_S2 &&
	                    Base.EURNZD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.EURNZD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURNZD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURNZD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURNZD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP1_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.EURNZD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.EURNZD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP2_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.EURNZD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.EURNZD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP3_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.EURNZD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.EURNZD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP4_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.EURNZD_OCO3_EO4_DOWN_S2 = false;

							Base.EURNZD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.EURNZD_OCO3_DOWN_S2_IsReady == false && Base.EURNZD_OCO2_DOWN_S2_IsReady == false && Base.EURNZD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (EURNZD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURNZD_DOWN_S2 && 
	                    Base.EURNZD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.EURNZD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURNZD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURNZD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.EURNZD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURNZD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP1_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.EURNZD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.EURNZD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP2_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.EURNZD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.EURNZD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP3_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.EURNZD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.EURNZD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURNZD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP4_DOWN_S2, false,"EURNZD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.EURNZD_OCO4_EO4_DOWN_S2 = false;

							Base.EURNZD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.EURNZD_OCO4_DOWN_S2_IsReady == false && Base.EURNZD_OCO3_DOWN_S2_IsReady == false && Base.EURNZD_OCO2_DOWN_S2_IsReady == false && Base.EURNZD_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
    {
    	
    	public static Symbol _GBPJPY;
		
    	///oco1 up
    	public static OrderTicket GBPJPY_OCO1_MO1_UP_S2;
    	public static OrderTicket GBPJPY_OCO1_MO2_UP_S2;
    	public static OrderTicket GBPJPY_OCO1_MO3_UP_S2;
    	public static OrderTicket GBPJPY_OCO1_MO4_UP_S2;
    	public static OrderTicket GBPJPY_OCO1_MO5_UP_S2;
    	public static OrderTicket GBPJPY_OCO1_MO6_UP_S2;
    	
    	public static int GBPJPY_OCO1_EO1_UP_S2_ID ;
        public static int GBPJPY_OCO1_EO2_UP_S2_ID ;
        public static int GBPJPY_OCO1_EO3_UP_S2_ID ;
        public static int GBPJPY_OCO1_EO4_UP_S2_ID ;
        public static int GBPJPY_OCO1_EO5_UP_S2_ID ;
        public static int GBPJPY_OCO1_EO6_UP_S2_ID ;
        
        public static bool GBPJPY_OCO1_EO1_UP_S2 ;
        public static bool GBPJPY_OCO1_EO2_UP_S2 ;
        public static bool GBPJPY_OCO1_EO3_UP_S2 ;
        public static bool GBPJPY_OCO1_EO4_UP_S2 ;
        public static bool GBPJPY_OCO1_EO5_UP_S2 ;
        public static bool GBPJPY_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_UP_S2> GBPJPY_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_UP_S2> GBPJPY_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_UP_S2> GBPJPY_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_UP_S2> GBPJPY_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_UP_S2> GBPJPY_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_UP_S2> GBPJPY_OOFE_OCO1_UP_S2_6 ;
        
        public static GBPJPY_OCO1_UP_S2 GBPJPY_PFO_OCO1_UP_S2_1 ;
        public static GBPJPY_OCO1_UP_S2 GBPJPY_PFO_OCO1_UP_S2_2 ;
        public static GBPJPY_OCO1_UP_S2 GBPJPY_PFO_OCO1_UP_S2_3 ;
        public static GBPJPY_OCO1_UP_S2 GBPJPY_PFO_OCO1_UP_S2_4 ;
        public static GBPJPY_OCO1_UP_S2 GBPJPY_PFO_OCO1_UP_S2_5 ;
        public static GBPJPY_OCO1_UP_S2 GBPJPY_PFO_OCO1_UP_S2_6 ;
        
        public static List<GBPJPY_OCO1_UP_S2> GBPJPY_UP_S2_OCO1Sets1 = new List<GBPJPY_OCO1_UP_S2>();
        public static List<GBPJPY_OCO1_UP_S2> GBPJPY_UP_S2_OCO1Sets2 = new List<GBPJPY_OCO1_UP_S2>();
        public static List<GBPJPY_OCO1_UP_S2> GBPJPY_UP_S2_OCO1Sets3 = new List<GBPJPY_OCO1_UP_S2>();
        public static List<GBPJPY_OCO1_UP_S2> GBPJPY_UP_S2_OCO1Sets4 = new List<GBPJPY_OCO1_UP_S2>();
        public static List<GBPJPY_OCO1_UP_S2> GBPJPY_UP_S2_OCO1Sets5 = new List<GBPJPY_OCO1_UP_S2>();
        public static List<GBPJPY_OCO1_UP_S2> GBPJPY_UP_S2_OCO1Sets6 = new List<GBPJPY_OCO1_UP_S2>();
        
        public static bool GBPJPY_OCO1_UP_S2_IsReady = true;
        public static bool GBPJPY_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket GBPJPY_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO1_MO6_DOWN_S2 ;
    	
    	public static int GBPJPY_OCO1_EO1_DOWN_S2_ID ;
        public static int GBPJPY_OCO1_EO2_DOWN_S2_ID ;
        public static int GBPJPY_OCO1_EO3_DOWN_S2_ID ;
        public static int GBPJPY_OCO1_EO4_DOWN_S2_ID ;
        public static int GBPJPY_OCO1_EO5_DOWN_S2_ID ;
        public static int GBPJPY_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool GBPJPY_OCO1_EO1_DOWN_S2 ;
        public static bool GBPJPY_OCO1_EO2_DOWN_S2 ;
        public static bool GBPJPY_OCO1_EO3_DOWN_S2 ;
        public static bool GBPJPY_OCO1_EO4_DOWN_S2 ;
        public static bool GBPJPY_OCO1_EO5_DOWN_S2 ;
        public static bool GBPJPY_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_DOWN_S2> GBPJPY_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_DOWN_S2> GBPJPY_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_DOWN_S2> GBPJPY_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_DOWN_S2> GBPJPY_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_DOWN_S2> GBPJPY_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO1_DOWN_S2> GBPJPY_OOFE_OCO1_DOWN_S2_6 ;
        
        public static GBPJPY_OCO1_DOWN_S2 GBPJPY_PFO_OCO1_DOWN_S2_1 ;
        public static GBPJPY_OCO1_DOWN_S2 GBPJPY_PFO_OCO1_DOWN_S2_2 ;
        public static GBPJPY_OCO1_DOWN_S2 GBPJPY_PFO_OCO1_DOWN_S2_3 ;
        public static GBPJPY_OCO1_DOWN_S2 GBPJPY_PFO_OCO1_DOWN_S2_4 ;
        public static GBPJPY_OCO1_DOWN_S2 GBPJPY_PFO_OCO1_DOWN_S2_5 ;
        public static GBPJPY_OCO1_DOWN_S2 GBPJPY_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<GBPJPY_OCO1_DOWN_S2> GBPJPY_DOWN_S2_OCO1Sets1 = new List<GBPJPY_OCO1_DOWN_S2>();
        public static List<GBPJPY_OCO1_DOWN_S2> GBPJPY_DOWN_S2_OCO1Sets2 = new List<GBPJPY_OCO1_DOWN_S2>();
        public static List<GBPJPY_OCO1_DOWN_S2> GBPJPY_DOWN_S2_OCO1Sets3 = new List<GBPJPY_OCO1_DOWN_S2>();
        public static List<GBPJPY_OCO1_DOWN_S2> GBPJPY_DOWN_S2_OCO1Sets4 = new List<GBPJPY_OCO1_DOWN_S2>();
        public static List<GBPJPY_OCO1_DOWN_S2> GBPJPY_DOWN_S2_OCO1Sets5 = new List<GBPJPY_OCO1_DOWN_S2>();
        public static List<GBPJPY_OCO1_DOWN_S2> GBPJPY_DOWN_S2_OCO1Sets6 = new List<GBPJPY_OCO1_DOWN_S2>();
        
        public static bool GBPJPY_OCO1_DOWN_S2_IsReady = true;
		public static bool GBPJPY_OCO1_DOWN_S2_Monthly_IsReady = true;
        
        //oco2 up
        public static OrderTicket GBPJPY_OCO2_MO1_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO2_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO3_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO4_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO5_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO6_UP_S2 ;
    	
    	public static int GBPJPY_OCO2_EO1_UP_S2_ID ;
        public static int GBPJPY_OCO2_EO2_UP_S2_ID ;
        public static int GBPJPY_OCO2_EO3_UP_S2_ID ;
        public static int GBPJPY_OCO2_EO4_UP_S2_ID ;
        public static int GBPJPY_OCO2_EO5_UP_S2_ID ;
        public static int GBPJPY_OCO2_EO6_UP_S2_ID ;
        
        public static bool GBPJPY_OCO2_EO1_UP_S2 ;
        public static bool GBPJPY_OCO2_EO2_UP_S2 ;
        public static bool GBPJPY_OCO2_EO3_UP_S2 ;
        public static bool GBPJPY_OCO2_EO4_UP_S2 ;
        public static bool GBPJPY_OCO2_EO5_UP_S2 ;
        public static bool GBPJPY_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_UP_S2> GBPJPY_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_UP_S2> GBPJPY_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_UP_S2> GBPJPY_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_UP_S2> GBPJPY_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_UP_S2> GBPJPY_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_UP_S2> GBPJPY_OOFE_OCO2_UP_S2_6 ;
        
        public static GBPJPY_OCO2_UP_S2 GBPJPY_PFO_OCO2_UP_S2_1 ;
        public static GBPJPY_OCO2_UP_S2 GBPJPY_PFO_OCO2_UP_S2_2 ;
        public static GBPJPY_OCO2_UP_S2 GBPJPY_PFO_OCO2_UP_S2_3 ;
        public static GBPJPY_OCO2_UP_S2 GBPJPY_PFO_OCO2_UP_S2_4 ;
        public static GBPJPY_OCO2_UP_S2 GBPJPY_PFO_OCO2_UP_S2_5 ;
        public static GBPJPY_OCO2_UP_S2 GBPJPY_PFO_OCO2_UP_S2_6 ;
        
        public static List<GBPJPY_OCO2_UP_S2> GBPJPY_UP_S2_OCO2Sets1 = new List<GBPJPY_OCO2_UP_S2>();
        public static List<GBPJPY_OCO2_UP_S2> GBPJPY_UP_S2_OCO2Sets2 = new List<GBPJPY_OCO2_UP_S2>();
        public static List<GBPJPY_OCO2_UP_S2> GBPJPY_UP_S2_OCO2Sets3 = new List<GBPJPY_OCO2_UP_S2>();
        public static List<GBPJPY_OCO2_UP_S2> GBPJPY_UP_S2_OCO2Sets4 = new List<GBPJPY_OCO2_UP_S2>();
        public static List<GBPJPY_OCO2_UP_S2> GBPJPY_UP_S2_OCO2Sets5 = new List<GBPJPY_OCO2_UP_S2>();
        public static List<GBPJPY_OCO2_UP_S2> GBPJPY_UP_S2_OCO2Sets6 = new List<GBPJPY_OCO2_UP_S2>();
        
        public static bool GBPJPY_OCO2_UP_S2_IsReady = true;
		public static bool GBPJPY_OCO2_UP_S2_Monthly_IsReady = true;
        
        //oco2 down
        public static OrderTicket GBPJPY_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO2_MO6_DOWN_S2 ;
    	
    	public static int GBPJPY_OCO2_EO1_DOWN_S2_ID ;
        public static int GBPJPY_OCO2_EO2_DOWN_S2_ID ;
        public static int GBPJPY_OCO2_EO3_DOWN_S2_ID ;
        public static int GBPJPY_OCO2_EO4_DOWN_S2_ID ;
        public static int GBPJPY_OCO2_EO5_DOWN_S2_ID ;
        public static int GBPJPY_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool GBPJPY_OCO2_EO1_DOWN_S2 ;
        public static bool GBPJPY_OCO2_EO2_DOWN_S2 ;
        public static bool GBPJPY_OCO2_EO3_DOWN_S2 ;
        public static bool GBPJPY_OCO2_EO4_DOWN_S2 ;
        public static bool GBPJPY_OCO2_EO5_DOWN_S2 ;
        public static bool GBPJPY_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_DOWN_S2> GBPJPY_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_DOWN_S2> GBPJPY_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_DOWN_S2> GBPJPY_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_DOWN_S2> GBPJPY_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_DOWN_S2> GBPJPY_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO2_DOWN_S2> GBPJPY_OOFE_OCO2_DOWN_S2_6 ;
        
        public static GBPJPY_OCO2_DOWN_S2 GBPJPY_PFO_OCO2_DOWN_S2_1 ;
        public static GBPJPY_OCO2_DOWN_S2 GBPJPY_PFO_OCO2_DOWN_S2_2 ;
        public static GBPJPY_OCO2_DOWN_S2 GBPJPY_PFO_OCO2_DOWN_S2_3 ;
        public static GBPJPY_OCO2_DOWN_S2 GBPJPY_PFO_OCO2_DOWN_S2_4 ;
        public static GBPJPY_OCO2_DOWN_S2 GBPJPY_PFO_OCO2_DOWN_S2_5 ;
        public static GBPJPY_OCO2_DOWN_S2 GBPJPY_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<GBPJPY_OCO2_DOWN_S2> GBPJPY_DOWN_S2_OCO2Sets1 = new List<GBPJPY_OCO2_DOWN_S2>();
        public static List<GBPJPY_OCO2_DOWN_S2> GBPJPY_DOWN_S2_OCO2Sets2 = new List<GBPJPY_OCO2_DOWN_S2>();
        public static List<GBPJPY_OCO2_DOWN_S2> GBPJPY_DOWN_S2_OCO2Sets3 = new List<GBPJPY_OCO2_DOWN_S2>();
        public static List<GBPJPY_OCO2_DOWN_S2> GBPJPY_DOWN_S2_OCO2Sets4 = new List<GBPJPY_OCO2_DOWN_S2>();
        public static List<GBPJPY_OCO2_DOWN_S2> GBPJPY_DOWN_S2_OCO2Sets5 = new List<GBPJPY_OCO2_DOWN_S2>();
        public static List<GBPJPY_OCO2_DOWN_S2> GBPJPY_DOWN_S2_OCO2Sets6 = new List<GBPJPY_OCO2_DOWN_S2>();
        
        public static bool GBPJPY_OCO2_DOWN_S2_IsReady = true;
		public static bool GBPJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
        
        //oco3 up
        public static OrderTicket GBPJPY_OCO3_MO1_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO2_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO3_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO4_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO5_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO6_UP_S2 ;
    	
    	public static int GBPJPY_OCO3_EO1_UP_S2_ID ;
        public static int GBPJPY_OCO3_EO2_UP_S2_ID ;
        public static int GBPJPY_OCO3_EO3_UP_S2_ID ;
        public static int GBPJPY_OCO3_EO4_UP_S2_ID ;
        public static int GBPJPY_OCO3_EO5_UP_S2_ID ;
        public static int GBPJPY_OCO3_EO6_UP_S2_ID ;
        
        public static bool GBPJPY_OCO3_EO1_UP_S2 ;
        public static bool GBPJPY_OCO3_EO2_UP_S2 ;
        public static bool GBPJPY_OCO3_EO3_UP_S2 ;
        public static bool GBPJPY_OCO3_EO4_UP_S2 ;
        public static bool GBPJPY_OCO3_EO5_UP_S2 ;
        public static bool GBPJPY_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_UP_S2> GBPJPY_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_UP_S2> GBPJPY_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_UP_S2> GBPJPY_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_UP_S2> GBPJPY_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_UP_S2> GBPJPY_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_UP_S2> GBPJPY_OOFE_OCO3_UP_S2_6 ;
        
        public static GBPJPY_OCO3_UP_S2 GBPJPY_PFO_OCO3_UP_S2_1 ;
        public static GBPJPY_OCO3_UP_S2 GBPJPY_PFO_OCO3_UP_S2_2 ;
        public static GBPJPY_OCO3_UP_S2 GBPJPY_PFO_OCO3_UP_S2_3 ;
        public static GBPJPY_OCO3_UP_S2 GBPJPY_PFO_OCO3_UP_S2_4 ;
        public static GBPJPY_OCO3_UP_S2 GBPJPY_PFO_OCO3_UP_S2_5 ;
        public static GBPJPY_OCO3_UP_S2 GBPJPY_PFO_OCO3_UP_S2_6 ;
        
        public static List<GBPJPY_OCO3_UP_S2> GBPJPY_UP_S2_OCO3Sets1 = new List<GBPJPY_OCO3_UP_S2>();
        public static List<GBPJPY_OCO3_UP_S2> GBPJPY_UP_S2_OCO3Sets2 = new List<GBPJPY_OCO3_UP_S2>();
        public static List<GBPJPY_OCO3_UP_S2> GBPJPY_UP_S2_OCO3Sets3 = new List<GBPJPY_OCO3_UP_S2>();
        public static List<GBPJPY_OCO3_UP_S2> GBPJPY_UP_S2_OCO3Sets4 = new List<GBPJPY_OCO3_UP_S2>();
        public static List<GBPJPY_OCO3_UP_S2> GBPJPY_UP_S2_OCO3Sets5 = new List<GBPJPY_OCO3_UP_S2>();
        public static List<GBPJPY_OCO3_UP_S2> GBPJPY_UP_S2_OCO3Sets6 = new List<GBPJPY_OCO3_UP_S2>();
        
        public static bool GBPJPY_OCO3_UP_S2_IsReady = true;
		public static bool GBPJPY_OCO3_UP_S2_Monthly_IsReady = true;
        
        //oco3 down
        public static OrderTicket GBPJPY_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO3_MO6_DOWN_S2 ;
    	
    	public static int GBPJPY_OCO3_EO1_DOWN_S2_ID ;
        public static int GBPJPY_OCO3_EO2_DOWN_S2_ID ;
        public static int GBPJPY_OCO3_EO3_DOWN_S2_ID ;
        public static int GBPJPY_OCO3_EO4_DOWN_S2_ID ;
        public static int GBPJPY_OCO3_EO5_DOWN_S2_ID ;
        public static int GBPJPY_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool GBPJPY_OCO3_EO1_DOWN_S2 ;
        public static bool GBPJPY_OCO3_EO2_DOWN_S2 ;
        public static bool GBPJPY_OCO3_EO3_DOWN_S2 ;
        public static bool GBPJPY_OCO3_EO4_DOWN_S2 ;
        public static bool GBPJPY_OCO3_EO5_DOWN_S2 ;
        public static bool GBPJPY_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_DOWN_S2> GBPJPY_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_DOWN_S2> GBPJPY_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_DOWN_S2> GBPJPY_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_DOWN_S2> GBPJPY_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_DOWN_S2> GBPJPY_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO3_DOWN_S2> GBPJPY_OOFE_OCO3_DOWN_S2_6 ;
        
        public static GBPJPY_OCO3_DOWN_S2 GBPJPY_PFO_OCO3_DOWN_S2_1 ;
        public static GBPJPY_OCO3_DOWN_S2 GBPJPY_PFO_OCO3_DOWN_S2_2 ;
        public static GBPJPY_OCO3_DOWN_S2 GBPJPY_PFO_OCO3_DOWN_S2_3 ;
        public static GBPJPY_OCO3_DOWN_S2 GBPJPY_PFO_OCO3_DOWN_S2_4 ;
        public static GBPJPY_OCO3_DOWN_S2 GBPJPY_PFO_OCO3_DOWN_S2_5 ;
        public static GBPJPY_OCO3_DOWN_S2 GBPJPY_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<GBPJPY_OCO3_DOWN_S2> GBPJPY_DOWN_S2_OCO3Sets1 = new List<GBPJPY_OCO3_DOWN_S2>();
        public static List<GBPJPY_OCO3_DOWN_S2> GBPJPY_DOWN_S2_OCO3Sets2 = new List<GBPJPY_OCO3_DOWN_S2>();
        public static List<GBPJPY_OCO3_DOWN_S2> GBPJPY_DOWN_S2_OCO3Sets3 = new List<GBPJPY_OCO3_DOWN_S2>();
        public static List<GBPJPY_OCO3_DOWN_S2> GBPJPY_DOWN_S2_OCO3Sets4 = new List<GBPJPY_OCO3_DOWN_S2>();
        public static List<GBPJPY_OCO3_DOWN_S2> GBPJPY_DOWN_S2_OCO3Sets5 = new List<GBPJPY_OCO3_DOWN_S2>();
        public static List<GBPJPY_OCO3_DOWN_S2> GBPJPY_DOWN_S2_OCO3Sets6 = new List<GBPJPY_OCO3_DOWN_S2>();
        
        public static bool GBPJPY_OCO3_DOWN_S2_IsReady = true;
		public static bool GBPJPY_OCO3_DOWN_S2_Monthly_IsReady = true;
        
        //oco4 up
        public static OrderTicket GBPJPY_OCO4_MO1_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO2_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO3_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO4_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO5_UP_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO6_UP_S2 ;
    	
    	public static int GBPJPY_OCO4_EO1_UP_S2_ID ;
        public static int GBPJPY_OCO4_EO2_UP_S2_ID ;
        public static int GBPJPY_OCO4_EO3_UP_S2_ID ;
        public static int GBPJPY_OCO4_EO4_UP_S2_ID ;
        public static int GBPJPY_OCO4_EO5_UP_S2_ID ;
        public static int GBPJPY_OCO4_EO6_UP_S2_ID ;
        
        public static bool GBPJPY_OCO4_EO1_UP_S2 ;
        public static bool GBPJPY_OCO4_EO2_UP_S2 ;
        public static bool GBPJPY_OCO4_EO3_UP_S2 ;
        public static bool GBPJPY_OCO4_EO4_UP_S2 ;
        public static bool GBPJPY_OCO4_EO5_UP_S2 ;
        public static bool GBPJPY_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_UP_S2> GBPJPY_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_UP_S2> GBPJPY_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_UP_S2> GBPJPY_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_UP_S2> GBPJPY_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_UP_S2> GBPJPY_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_UP_S2> GBPJPY_OOFE_OCO4_UP_S2_6 ;
        
        public static GBPJPY_OCO4_UP_S2 GBPJPY_PFO_OCO4_UP_S2_1 ;
        public static GBPJPY_OCO4_UP_S2 GBPJPY_PFO_OCO4_UP_S2_2 ;
        public static GBPJPY_OCO4_UP_S2 GBPJPY_PFO_OCO4_UP_S2_3 ;
        public static GBPJPY_OCO4_UP_S2 GBPJPY_PFO_OCO4_UP_S2_4 ;
        public static GBPJPY_OCO4_UP_S2 GBPJPY_PFO_OCO4_UP_S2_5 ;
        public static GBPJPY_OCO4_UP_S2 GBPJPY_PFO_OCO4_UP_S2_6 ;
        
        public static List<GBPJPY_OCO4_UP_S2> GBPJPY_UP_S2_OCO4Sets1 = new List<GBPJPY_OCO4_UP_S2>();
        public static List<GBPJPY_OCO4_UP_S2> GBPJPY_UP_S2_OCO4Sets2 = new List<GBPJPY_OCO4_UP_S2>();
        public static List<GBPJPY_OCO4_UP_S2> GBPJPY_UP_S2_OCO4Sets3 = new List<GBPJPY_OCO4_UP_S2>();
        public static List<GBPJPY_OCO4_UP_S2> GBPJPY_UP_S2_OCO4Sets4 = new List<GBPJPY_OCO4_UP_S2>();
        public static List<GBPJPY_OCO4_UP_S2> GBPJPY_UP_S2_OCO4Sets5 = new List<GBPJPY_OCO4_UP_S2>();
        public static List<GBPJPY_OCO4_UP_S2> GBPJPY_UP_S2_OCO4Sets6 = new List<GBPJPY_OCO4_UP_S2>();
        
        public static bool GBPJPY_OCO4_UP_S2_IsReady = true;
		public static bool GBPJPY_OCO4_UP_S2_Monthly_IsReady = true;
        
        //oco4 down
        public static OrderTicket GBPJPY_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket GBPJPY_OCO4_MO6_DOWN_S2 ;
    	
    	public static int GBPJPY_OCO4_EO1_DOWN_S2_ID ;
        public static int GBPJPY_OCO4_EO2_DOWN_S2_ID ;
        public static int GBPJPY_OCO4_EO3_DOWN_S2_ID ;
        public static int GBPJPY_OCO4_EO4_DOWN_S2_ID ;
        public static int GBPJPY_OCO4_EO5_DOWN_S2_ID ;
        public static int GBPJPY_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool GBPJPY_OCO4_EO1_DOWN_S2 ;
        public static bool GBPJPY_OCO4_EO2_DOWN_S2 ;
        public static bool GBPJPY_OCO4_EO3_DOWN_S2 ;
        public static bool GBPJPY_OCO4_EO4_DOWN_S2 ;
        public static bool GBPJPY_OCO4_EO5_DOWN_S2 ;
        public static bool GBPJPY_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_DOWN_S2> GBPJPY_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_DOWN_S2> GBPJPY_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_DOWN_S2> GBPJPY_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_DOWN_S2> GBPJPY_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_DOWN_S2> GBPJPY_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPJPY_OCO4_DOWN_S2> GBPJPY_OOFE_OCO4_DOWN_S2_6 ;
        
        public static GBPJPY_OCO4_DOWN_S2 GBPJPY_PFO_OCO4_DOWN_S2_1 ;
        public static GBPJPY_OCO4_DOWN_S2 GBPJPY_PFO_OCO4_DOWN_S2_2 ;
        public static GBPJPY_OCO4_DOWN_S2 GBPJPY_PFO_OCO4_DOWN_S2_3 ;
        public static GBPJPY_OCO4_DOWN_S2 GBPJPY_PFO_OCO4_DOWN_S2_4 ;
        public static GBPJPY_OCO4_DOWN_S2 GBPJPY_PFO_OCO4_DOWN_S2_5 ;
        public static GBPJPY_OCO4_DOWN_S2 GBPJPY_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<GBPJPY_OCO4_DOWN_S2> GBPJPY_DOWN_S2_OCO4Sets1 = new List<GBPJPY_OCO4_DOWN_S2>();
        public static List<GBPJPY_OCO4_DOWN_S2> GBPJPY_DOWN_S2_OCO4Sets2 = new List<GBPJPY_OCO4_DOWN_S2>();
        public static List<GBPJPY_OCO4_DOWN_S2> GBPJPY_DOWN_S2_OCO4Sets3 = new List<GBPJPY_OCO4_DOWN_S2>();
        public static List<GBPJPY_OCO4_DOWN_S2> GBPJPY_DOWN_S2_OCO4Sets4 = new List<GBPJPY_OCO4_DOWN_S2>();
        public static List<GBPJPY_OCO4_DOWN_S2> GBPJPY_DOWN_S2_OCO4Sets5 = new List<GBPJPY_OCO4_DOWN_S2>();
        public static List<GBPJPY_OCO4_DOWN_S2> GBPJPY_DOWN_S2_OCO4Sets6 = new List<GBPJPY_OCO4_DOWN_S2>();
        
        public static bool GBPJPY_OCO4_DOWN_S2_IsReady = true;
		public static bool GBPJPY_OCO4_DOWN_S2_Monthly_IsReady = true;
        
        
////////////////////////////
		public static decimal GBPJPY_UP_S2_SL {get; set;}
		public static decimal GBPJPY_UP_S2_TP1 {get; set;}
		public static decimal GBPJPY_UP_S2_TP2 {get; set;}
		public static decimal GBPJPY_UP_S2_TP3 {get; set;}
		public static decimal GBPJPY_UP_S2_TP4 {get; set;}
		public static decimal GBPJPY_UP_S2_TP5 {get; set;}
		public static decimal GBPJPY_UP_S2_TP6 {get; set;}
		
		public static decimal GBPJPY_DOWN_S2_SL {get; set;}
		public static decimal GBPJPY_DOWN_S2_TP1 {get; set;}
		public static decimal GBPJPY_DOWN_S2_TP2 {get; set;}
		public static decimal GBPJPY_DOWN_S2_TP3 {get; set;}
		public static decimal GBPJPY_DOWN_S2_TP4 {get; set;}
		public static decimal GBPJPY_DOWN_S2_TP5 {get; set;}
		public static decimal GBPJPY_DOWN_S2_TP6 {get; set;}

        public static bool GBPJPY_Signal_Condition_UP_1 ;
        public static bool GBPJPY_Signal_Condition_UP_2 ;
        public static bool GBPJPY_Signal_Condition_UP_3 ;
        public static bool GBPJPY_Signal_Condition_DOWN_S2 ;
        
        public static int GBPJPY_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int GBPJPY_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPJPY_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPJPY_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPJPY_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int GBPJPY_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int GBPJPY_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPJPY_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPJPY_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPJPY_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_GBPJPY_UP_S2 ;
        public static bool DOWM_GBPJPY_UP_S2 ;
        public static bool DOWT_GBPJPY_UP_S2 ;
        public static bool DOWW_GBPJPY_UP_S2 ;
        public static bool DOWTH_GBPJPY_UP_S2 ;
        
		public static bool DOWR_GBPJPY_DOWN_S2 ;
        public static bool DOWM_GBPJPY_DOWN_S2 ;
        public static bool DOWT_GBPJPY_DOWN_S2 ;
        public static bool DOWW_GBPJPY_DOWN_S2 ;
        public static bool DOWTH_GBPJPY_DOWN_S2 ;
        
        
		public static int GBPJPY_quantity_UP_S2 ;
		public static int GBPJPY_quantity_SL_UP_S2 ;
		public static int GBPJPY_quantity_TP1_UP_S2 ;
		public static int GBPJPY_quantity_TP2_UP_S2 ;
		public static int GBPJPY_quantity_TP3_UP_S2 ;
		public static int GBPJPY_quantity_TP4_UP_S2 ;
		public static int GBPJPY_quantity_TP5_UP_S2;
		public static int GBPJPY_quantity_TP6_UP_S2 ;
		
		public static int GBPJPY_quantity_DOWN_S2 ;
		public static int GBPJPY_quantity_SL_DOWN_S2 ;
		public static int GBPJPY_quantity_TP1_DOWN_S2 ;
		public static int GBPJPY_quantity_TP2_DOWN_S2 ;
		public static int GBPJPY_quantity_TP3_DOWN_S2 ;
		public static int GBPJPY_quantity_TP4_DOWN_S2 ;
		public static int GBPJPY_quantity_TP5_DOWN_S2;
		public static int GBPJPY_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.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 _USDCAD;
		
    	///oco1 up
    	public static OrderTicket USDCAD_OCO1_MO1_UP_S2;
    	public static OrderTicket USDCAD_OCO1_MO2_UP_S2;
    	public static OrderTicket USDCAD_OCO1_MO3_UP_S2;
    	public static OrderTicket USDCAD_OCO1_MO4_UP_S2;
    	public static OrderTicket USDCAD_OCO1_MO5_UP_S2;
    	public static OrderTicket USDCAD_OCO1_MO6_UP_S2;
    	
    	public static int USDCAD_OCO1_EO1_UP_S2_ID ;
        public static int USDCAD_OCO1_EO2_UP_S2_ID ;
        public static int USDCAD_OCO1_EO3_UP_S2_ID ;
        public static int USDCAD_OCO1_EO4_UP_S2_ID ;
        public static int USDCAD_OCO1_EO5_UP_S2_ID ;
        public static int USDCAD_OCO1_EO6_UP_S2_ID ;
        
        public static bool USDCAD_OCO1_EO1_UP_S2 ;
        public static bool USDCAD_OCO1_EO2_UP_S2 ;
        public static bool USDCAD_OCO1_EO3_UP_S2 ;
        public static bool USDCAD_OCO1_EO4_UP_S2 ;
        public static bool USDCAD_OCO1_EO5_UP_S2 ;
        public static bool USDCAD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_UP_S2> USDCAD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_UP_S2> USDCAD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_UP_S2> USDCAD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_UP_S2> USDCAD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_UP_S2> USDCAD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_UP_S2> USDCAD_OOFE_OCO1_UP_S2_6 ;
        
        public static USDCAD_OCO1_UP_S2 USDCAD_PFO_OCO1_UP_S2_1 ;
        public static USDCAD_OCO1_UP_S2 USDCAD_PFO_OCO1_UP_S2_2 ;
        public static USDCAD_OCO1_UP_S2 USDCAD_PFO_OCO1_UP_S2_3 ;
        public static USDCAD_OCO1_UP_S2 USDCAD_PFO_OCO1_UP_S2_4 ;
        public static USDCAD_OCO1_UP_S2 USDCAD_PFO_OCO1_UP_S2_5 ;
        public static USDCAD_OCO1_UP_S2 USDCAD_PFO_OCO1_UP_S2_6 ;
        
        public static List<USDCAD_OCO1_UP_S2> USDCAD_UP_S2_OCO1Sets1 = new List<USDCAD_OCO1_UP_S2>();
        public static List<USDCAD_OCO1_UP_S2> USDCAD_UP_S2_OCO1Sets2 = new List<USDCAD_OCO1_UP_S2>();
        public static List<USDCAD_OCO1_UP_S2> USDCAD_UP_S2_OCO1Sets3 = new List<USDCAD_OCO1_UP_S2>();
        public static List<USDCAD_OCO1_UP_S2> USDCAD_UP_S2_OCO1Sets4 = new List<USDCAD_OCO1_UP_S2>();
        public static List<USDCAD_OCO1_UP_S2> USDCAD_UP_S2_OCO1Sets5 = new List<USDCAD_OCO1_UP_S2>();
        public static List<USDCAD_OCO1_UP_S2> USDCAD_UP_S2_OCO1Sets6 = new List<USDCAD_OCO1_UP_S2>();
        
        public static bool USDCAD_OCO1_UP_S2_IsReady = true;
        public static bool USDCAD_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket USDCAD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int USDCAD_OCO1_EO1_DOWN_S2_ID ;
        public static int USDCAD_OCO1_EO2_DOWN_S2_ID ;
        public static int USDCAD_OCO1_EO3_DOWN_S2_ID ;
        public static int USDCAD_OCO1_EO4_DOWN_S2_ID ;
        public static int USDCAD_OCO1_EO5_DOWN_S2_ID ;
        public static int USDCAD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool USDCAD_OCO1_EO1_DOWN_S2 ;
        public static bool USDCAD_OCO1_EO2_DOWN_S2 ;
        public static bool USDCAD_OCO1_EO3_DOWN_S2 ;
        public static bool USDCAD_OCO1_EO4_DOWN_S2 ;
        public static bool USDCAD_OCO1_EO5_DOWN_S2 ;
        public static bool USDCAD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_DOWN_S2> USDCAD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_DOWN_S2> USDCAD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_DOWN_S2> USDCAD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_DOWN_S2> USDCAD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_DOWN_S2> USDCAD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO1_DOWN_S2> USDCAD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static USDCAD_OCO1_DOWN_S2 USDCAD_PFO_OCO1_DOWN_S2_1 ;
        public static USDCAD_OCO1_DOWN_S2 USDCAD_PFO_OCO1_DOWN_S2_2 ;
        public static USDCAD_OCO1_DOWN_S2 USDCAD_PFO_OCO1_DOWN_S2_3 ;
        public static USDCAD_OCO1_DOWN_S2 USDCAD_PFO_OCO1_DOWN_S2_4 ;
        public static USDCAD_OCO1_DOWN_S2 USDCAD_PFO_OCO1_DOWN_S2_5 ;
        public static USDCAD_OCO1_DOWN_S2 USDCAD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<USDCAD_OCO1_DOWN_S2> USDCAD_DOWN_S2_OCO1Sets1 = new List<USDCAD_OCO1_DOWN_S2>();
        public static List<USDCAD_OCO1_DOWN_S2> USDCAD_DOWN_S2_OCO1Sets2 = new List<USDCAD_OCO1_DOWN_S2>();
        public static List<USDCAD_OCO1_DOWN_S2> USDCAD_DOWN_S2_OCO1Sets3 = new List<USDCAD_OCO1_DOWN_S2>();
        public static List<USDCAD_OCO1_DOWN_S2> USDCAD_DOWN_S2_OCO1Sets4 = new List<USDCAD_OCO1_DOWN_S2>();
        public static List<USDCAD_OCO1_DOWN_S2> USDCAD_DOWN_S2_OCO1Sets5 = new List<USDCAD_OCO1_DOWN_S2>();
        public static List<USDCAD_OCO1_DOWN_S2> USDCAD_DOWN_S2_OCO1Sets6 = new List<USDCAD_OCO1_DOWN_S2>();
        
        public static bool USDCAD_OCO1_DOWN_S2_IsReady = true;
        public static bool USDCAD_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket USDCAD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO6_UP_S2 ;
    	
    	public static int USDCAD_OCO2_EO1_UP_S2_ID ;
        public static int USDCAD_OCO2_EO2_UP_S2_ID ;
        public static int USDCAD_OCO2_EO3_UP_S2_ID ;
        public static int USDCAD_OCO2_EO4_UP_S2_ID ;
        public static int USDCAD_OCO2_EO5_UP_S2_ID ;
        public static int USDCAD_OCO2_EO6_UP_S2_ID ;
        
        public static bool USDCAD_OCO2_EO1_UP_S2 ;
        public static bool USDCAD_OCO2_EO2_UP_S2 ;
        public static bool USDCAD_OCO2_EO3_UP_S2 ;
        public static bool USDCAD_OCO2_EO4_UP_S2 ;
        public static bool USDCAD_OCO2_EO5_UP_S2 ;
        public static bool USDCAD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_UP_S2> USDCAD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_UP_S2> USDCAD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_UP_S2> USDCAD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_UP_S2> USDCAD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_UP_S2> USDCAD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_UP_S2> USDCAD_OOFE_OCO2_UP_S2_6 ;
        
        public static USDCAD_OCO2_UP_S2 USDCAD_PFO_OCO2_UP_S2_1 ;
        public static USDCAD_OCO2_UP_S2 USDCAD_PFO_OCO2_UP_S2_2 ;
        public static USDCAD_OCO2_UP_S2 USDCAD_PFO_OCO2_UP_S2_3 ;
        public static USDCAD_OCO2_UP_S2 USDCAD_PFO_OCO2_UP_S2_4 ;
        public static USDCAD_OCO2_UP_S2 USDCAD_PFO_OCO2_UP_S2_5 ;
        public static USDCAD_OCO2_UP_S2 USDCAD_PFO_OCO2_UP_S2_6 ;
        
        public static List<USDCAD_OCO2_UP_S2> USDCAD_UP_S2_OCO2Sets1 = new List<USDCAD_OCO2_UP_S2>();
        public static List<USDCAD_OCO2_UP_S2> USDCAD_UP_S2_OCO2Sets2 = new List<USDCAD_OCO2_UP_S2>();
        public static List<USDCAD_OCO2_UP_S2> USDCAD_UP_S2_OCO2Sets3 = new List<USDCAD_OCO2_UP_S2>();
        public static List<USDCAD_OCO2_UP_S2> USDCAD_UP_S2_OCO2Sets4 = new List<USDCAD_OCO2_UP_S2>();
        public static List<USDCAD_OCO2_UP_S2> USDCAD_UP_S2_OCO2Sets5 = new List<USDCAD_OCO2_UP_S2>();
        public static List<USDCAD_OCO2_UP_S2> USDCAD_UP_S2_OCO2Sets6 = new List<USDCAD_OCO2_UP_S2>();
        
        public static bool USDCAD_OCO2_UP_S2_IsReady = true;
        public static bool USDCAD_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket USDCAD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int USDCAD_OCO2_EO1_DOWN_S2_ID ;
        public static int USDCAD_OCO2_EO2_DOWN_S2_ID ;
        public static int USDCAD_OCO2_EO3_DOWN_S2_ID ;
        public static int USDCAD_OCO2_EO4_DOWN_S2_ID ;
        public static int USDCAD_OCO2_EO5_DOWN_S2_ID ;
        public static int USDCAD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool USDCAD_OCO2_EO1_DOWN_S2 ;
        public static bool USDCAD_OCO2_EO2_DOWN_S2 ;
        public static bool USDCAD_OCO2_EO3_DOWN_S2 ;
        public static bool USDCAD_OCO2_EO4_DOWN_S2 ;
        public static bool USDCAD_OCO2_EO5_DOWN_S2 ;
        public static bool USDCAD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_DOWN_S2> USDCAD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_DOWN_S2> USDCAD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_DOWN_S2> USDCAD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_DOWN_S2> USDCAD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_DOWN_S2> USDCAD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO2_DOWN_S2> USDCAD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static USDCAD_OCO2_DOWN_S2 USDCAD_PFO_OCO2_DOWN_S2_1 ;
        public static USDCAD_OCO2_DOWN_S2 USDCAD_PFO_OCO2_DOWN_S2_2 ;
        public static USDCAD_OCO2_DOWN_S2 USDCAD_PFO_OCO2_DOWN_S2_3 ;
        public static USDCAD_OCO2_DOWN_S2 USDCAD_PFO_OCO2_DOWN_S2_4 ;
        public static USDCAD_OCO2_DOWN_S2 USDCAD_PFO_OCO2_DOWN_S2_5 ;
        public static USDCAD_OCO2_DOWN_S2 USDCAD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<USDCAD_OCO2_DOWN_S2> USDCAD_DOWN_S2_OCO2Sets1 = new List<USDCAD_OCO2_DOWN_S2>();
        public static List<USDCAD_OCO2_DOWN_S2> USDCAD_DOWN_S2_OCO2Sets2 = new List<USDCAD_OCO2_DOWN_S2>();
        public static List<USDCAD_OCO2_DOWN_S2> USDCAD_DOWN_S2_OCO2Sets3 = new List<USDCAD_OCO2_DOWN_S2>();
        public static List<USDCAD_OCO2_DOWN_S2> USDCAD_DOWN_S2_OCO2Sets4 = new List<USDCAD_OCO2_DOWN_S2>();
        public static List<USDCAD_OCO2_DOWN_S2> USDCAD_DOWN_S2_OCO2Sets5 = new List<USDCAD_OCO2_DOWN_S2>();
        public static List<USDCAD_OCO2_DOWN_S2> USDCAD_DOWN_S2_OCO2Sets6 = new List<USDCAD_OCO2_DOWN_S2>();
        
        public static bool USDCAD_OCO2_DOWN_S2_IsReady = true;
        public static bool USDCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket USDCAD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO6_UP_S2 ;
    	
    	public static int USDCAD_OCO3_EO1_UP_S2_ID ;
        public static int USDCAD_OCO3_EO2_UP_S2_ID ;
        public static int USDCAD_OCO3_EO3_UP_S2_ID ;
        public static int USDCAD_OCO3_EO4_UP_S2_ID ;
        public static int USDCAD_OCO3_EO5_UP_S2_ID ;
        public static int USDCAD_OCO3_EO6_UP_S2_ID ;
        
        public static bool USDCAD_OCO3_EO1_UP_S2 ;
        public static bool USDCAD_OCO3_EO2_UP_S2 ;
        public static bool USDCAD_OCO3_EO3_UP_S2 ;
        public static bool USDCAD_OCO3_EO4_UP_S2 ;
        public static bool USDCAD_OCO3_EO5_UP_S2 ;
        public static bool USDCAD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_UP_S2> USDCAD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_UP_S2> USDCAD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_UP_S2> USDCAD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_UP_S2> USDCAD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_UP_S2> USDCAD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_UP_S2> USDCAD_OOFE_OCO3_UP_S2_6 ;
        
        public static USDCAD_OCO3_UP_S2 USDCAD_PFO_OCO3_UP_S2_1 ;
        public static USDCAD_OCO3_UP_S2 USDCAD_PFO_OCO3_UP_S2_2 ;
        public static USDCAD_OCO3_UP_S2 USDCAD_PFO_OCO3_UP_S2_3 ;
        public static USDCAD_OCO3_UP_S2 USDCAD_PFO_OCO3_UP_S2_4 ;
        public static USDCAD_OCO3_UP_S2 USDCAD_PFO_OCO3_UP_S2_5 ;
        public static USDCAD_OCO3_UP_S2 USDCAD_PFO_OCO3_UP_S2_6 ;
        
        public static List<USDCAD_OCO3_UP_S2> USDCAD_UP_S2_OCO3Sets1 = new List<USDCAD_OCO3_UP_S2>();
        public static List<USDCAD_OCO3_UP_S2> USDCAD_UP_S2_OCO3Sets2 = new List<USDCAD_OCO3_UP_S2>();
        public static List<USDCAD_OCO3_UP_S2> USDCAD_UP_S2_OCO3Sets3 = new List<USDCAD_OCO3_UP_S2>();
        public static List<USDCAD_OCO3_UP_S2> USDCAD_UP_S2_OCO3Sets4 = new List<USDCAD_OCO3_UP_S2>();
        public static List<USDCAD_OCO3_UP_S2> USDCAD_UP_S2_OCO3Sets5 = new List<USDCAD_OCO3_UP_S2>();
        public static List<USDCAD_OCO3_UP_S2> USDCAD_UP_S2_OCO3Sets6 = new List<USDCAD_OCO3_UP_S2>();
        
        public static bool USDCAD_OCO3_UP_S2_IsReady = true;
        public static bool USDCAD_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket USDCAD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int USDCAD_OCO3_EO1_DOWN_S2_ID ;
        public static int USDCAD_OCO3_EO2_DOWN_S2_ID ;
        public static int USDCAD_OCO3_EO3_DOWN_S2_ID ;
        public static int USDCAD_OCO3_EO4_DOWN_S2_ID ;
        public static int USDCAD_OCO3_EO5_DOWN_S2_ID ;
        public static int USDCAD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool USDCAD_OCO3_EO1_DOWN_S2 ;
        public static bool USDCAD_OCO3_EO2_DOWN_S2 ;
        public static bool USDCAD_OCO3_EO3_DOWN_S2 ;
        public static bool USDCAD_OCO3_EO4_DOWN_S2 ;
        public static bool USDCAD_OCO3_EO5_DOWN_S2 ;
        public static bool USDCAD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_DOWN_S2> USDCAD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_DOWN_S2> USDCAD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_DOWN_S2> USDCAD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_DOWN_S2> USDCAD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_DOWN_S2> USDCAD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO3_DOWN_S2> USDCAD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static USDCAD_OCO3_DOWN_S2 USDCAD_PFO_OCO3_DOWN_S2_1 ;
        public static USDCAD_OCO3_DOWN_S2 USDCAD_PFO_OCO3_DOWN_S2_2 ;
        public static USDCAD_OCO3_DOWN_S2 USDCAD_PFO_OCO3_DOWN_S2_3 ;
        public static USDCAD_OCO3_DOWN_S2 USDCAD_PFO_OCO3_DOWN_S2_4 ;
        public static USDCAD_OCO3_DOWN_S2 USDCAD_PFO_OCO3_DOWN_S2_5 ;
        public static USDCAD_OCO3_DOWN_S2 USDCAD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<USDCAD_OCO3_DOWN_S2> USDCAD_DOWN_S2_OCO3Sets1 = new List<USDCAD_OCO3_DOWN_S2>();
        public static List<USDCAD_OCO3_DOWN_S2> USDCAD_DOWN_S2_OCO3Sets2 = new List<USDCAD_OCO3_DOWN_S2>();
        public static List<USDCAD_OCO3_DOWN_S2> USDCAD_DOWN_S2_OCO3Sets3 = new List<USDCAD_OCO3_DOWN_S2>();
        public static List<USDCAD_OCO3_DOWN_S2> USDCAD_DOWN_S2_OCO3Sets4 = new List<USDCAD_OCO3_DOWN_S2>();
        public static List<USDCAD_OCO3_DOWN_S2> USDCAD_DOWN_S2_OCO3Sets5 = new List<USDCAD_OCO3_DOWN_S2>();
        public static List<USDCAD_OCO3_DOWN_S2> USDCAD_DOWN_S2_OCO3Sets6 = new List<USDCAD_OCO3_DOWN_S2>();
        
        public static bool USDCAD_OCO3_DOWN_S2_IsReady = true;
        public static bool USDCAD_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket USDCAD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO6_UP_S2 ;
    	
    	public static int USDCAD_OCO4_EO1_UP_S2_ID ;
        public static int USDCAD_OCO4_EO2_UP_S2_ID ;
        public static int USDCAD_OCO4_EO3_UP_S2_ID ;
        public static int USDCAD_OCO4_EO4_UP_S2_ID ;
        public static int USDCAD_OCO4_EO5_UP_S2_ID ;
        public static int USDCAD_OCO4_EO6_UP_S2_ID ;
        
        public static bool USDCAD_OCO4_EO1_UP_S2 ;
        public static bool USDCAD_OCO4_EO2_UP_S2 ;
        public static bool USDCAD_OCO4_EO3_UP_S2 ;
        public static bool USDCAD_OCO4_EO4_UP_S2 ;
        public static bool USDCAD_OCO4_EO5_UP_S2 ;
        public static bool USDCAD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_UP_S2> USDCAD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_UP_S2> USDCAD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_UP_S2> USDCAD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_UP_S2> USDCAD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_UP_S2> USDCAD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_UP_S2> USDCAD_OOFE_OCO4_UP_S2_6 ;
        
        public static USDCAD_OCO4_UP_S2 USDCAD_PFO_OCO4_UP_S2_1 ;
        public static USDCAD_OCO4_UP_S2 USDCAD_PFO_OCO4_UP_S2_2 ;
        public static USDCAD_OCO4_UP_S2 USDCAD_PFO_OCO4_UP_S2_3 ;
        public static USDCAD_OCO4_UP_S2 USDCAD_PFO_OCO4_UP_S2_4 ;
        public static USDCAD_OCO4_UP_S2 USDCAD_PFO_OCO4_UP_S2_5 ;
        public static USDCAD_OCO4_UP_S2 USDCAD_PFO_OCO4_UP_S2_6 ;
        
        public static List<USDCAD_OCO4_UP_S2> USDCAD_UP_S2_OCO4Sets1 = new List<USDCAD_OCO4_UP_S2>();
        public static List<USDCAD_OCO4_UP_S2> USDCAD_UP_S2_OCO4Sets2 = new List<USDCAD_OCO4_UP_S2>();
        public static List<USDCAD_OCO4_UP_S2> USDCAD_UP_S2_OCO4Sets3 = new List<USDCAD_OCO4_UP_S2>();
        public static List<USDCAD_OCO4_UP_S2> USDCAD_UP_S2_OCO4Sets4 = new List<USDCAD_OCO4_UP_S2>();
        public static List<USDCAD_OCO4_UP_S2> USDCAD_UP_S2_OCO4Sets5 = new List<USDCAD_OCO4_UP_S2>();
        public static List<USDCAD_OCO4_UP_S2> USDCAD_UP_S2_OCO4Sets6 = new List<USDCAD_OCO4_UP_S2>();
        
        public static bool USDCAD_OCO4_UP_S2_IsReady = true;
        public static bool USDCAD_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket USDCAD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket USDCAD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int USDCAD_OCO4_EO1_DOWN_S2_ID ;
        public static int USDCAD_OCO4_EO2_DOWN_S2_ID ;
        public static int USDCAD_OCO4_EO3_DOWN_S2_ID ;
        public static int USDCAD_OCO4_EO4_DOWN_S2_ID ;
        public static int USDCAD_OCO4_EO5_DOWN_S2_ID ;
        public static int USDCAD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool USDCAD_OCO4_EO1_DOWN_S2 ;
        public static bool USDCAD_OCO4_EO2_DOWN_S2 ;
        public static bool USDCAD_OCO4_EO3_DOWN_S2 ;
        public static bool USDCAD_OCO4_EO4_DOWN_S2 ;
        public static bool USDCAD_OCO4_EO5_DOWN_S2 ;
        public static bool USDCAD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_DOWN_S2> USDCAD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_DOWN_S2> USDCAD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_DOWN_S2> USDCAD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_DOWN_S2> USDCAD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_DOWN_S2> USDCAD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCAD_OCO4_DOWN_S2> USDCAD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static USDCAD_OCO4_DOWN_S2 USDCAD_PFO_OCO4_DOWN_S2_1 ;
        public static USDCAD_OCO4_DOWN_S2 USDCAD_PFO_OCO4_DOWN_S2_2 ;
        public static USDCAD_OCO4_DOWN_S2 USDCAD_PFO_OCO4_DOWN_S2_3 ;
        public static USDCAD_OCO4_DOWN_S2 USDCAD_PFO_OCO4_DOWN_S2_4 ;
        public static USDCAD_OCO4_DOWN_S2 USDCAD_PFO_OCO4_DOWN_S2_5 ;
        public static USDCAD_OCO4_DOWN_S2 USDCAD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<USDCAD_OCO4_DOWN_S2> USDCAD_DOWN_S2_OCO4Sets1 = new List<USDCAD_OCO4_DOWN_S2>();
        public static List<USDCAD_OCO4_DOWN_S2> USDCAD_DOWN_S2_OCO4Sets2 = new List<USDCAD_OCO4_DOWN_S2>();
        public static List<USDCAD_OCO4_DOWN_S2> USDCAD_DOWN_S2_OCO4Sets3 = new List<USDCAD_OCO4_DOWN_S2>();
        public static List<USDCAD_OCO4_DOWN_S2> USDCAD_DOWN_S2_OCO4Sets4 = new List<USDCAD_OCO4_DOWN_S2>();
        public static List<USDCAD_OCO4_DOWN_S2> USDCAD_DOWN_S2_OCO4Sets5 = new List<USDCAD_OCO4_DOWN_S2>();
        public static List<USDCAD_OCO4_DOWN_S2> USDCAD_DOWN_S2_OCO4Sets6 = new List<USDCAD_OCO4_DOWN_S2>();
        
        public static bool USDCAD_OCO4_DOWN_S2_IsReady = true;
        public static bool USDCAD_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal USDCAD_UP_S2_SL {get; set;}
		public static decimal USDCAD_UP_S2_TP1 {get; set;}
		public static decimal USDCAD_UP_S2_TP2 {get; set;}
		public static decimal USDCAD_UP_S2_TP3 {get; set;}
		public static decimal USDCAD_UP_S2_TP4 {get; set;}
		public static decimal USDCAD_UP_S2_TP5 {get; set;}
		public static decimal USDCAD_UP_S2_TP6 {get; set;}
		
		public static decimal USDCAD_DOWN_S2_SL {get; set;}
		public static decimal USDCAD_DOWN_S2_TP1 {get; set;}
		public static decimal USDCAD_DOWN_S2_TP2 {get; set;}
		public static decimal USDCAD_DOWN_S2_TP3 {get; set;}
		public static decimal USDCAD_DOWN_S2_TP4 {get; set;}
		public static decimal USDCAD_DOWN_S2_TP5 {get; set;}
		public static decimal USDCAD_DOWN_S2_TP6 {get; set;}

        public static bool USDCAD_Signal_Condition_UP_1 ;
        public static bool USDCAD_Signal_Condition_UP_2 ;
        public static bool USDCAD_Signal_Condition_UP_3 ;
        
        public static bool USDCAD_Signal_Condition_DOWN_1 ;
        public static bool USDCAD_Signal_Condition_DOWN_2 ;
        public static bool USDCAD_Signal_Condition_DOWN_3 ;
        
        public static int USDCAD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int USDCAD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int USDCAD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int USDCAD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int USDCAD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int USDCAD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int USDCAD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int USDCAD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int USDCAD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int USDCAD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_USDCAD_UP_S2 ;
        public static bool DOWM_USDCAD_UP_S2 ;
        public static bool DOWT_USDCAD_UP_S2 ;
        public static bool DOWW_USDCAD_UP_S2 ;
        public static bool DOWTH_USDCAD_UP_S2 ;
        
		public static bool DOWR_USDCAD_DOWN_S2 ;
        public static bool DOWM_USDCAD_DOWN_S2 ;
        public static bool DOWT_USDCAD_DOWN_S2 ;
        public static bool DOWW_USDCAD_DOWN_S2 ;
        public static bool DOWTH_USDCAD_DOWN_S2 ;
        
        
		public static int USDCAD_quantity_UP_S2 ;
		public static int USDCAD_quantity_SL_UP_S2 ;
		public static int USDCAD_quantity_TP1_UP_S2 ;
		public static int USDCAD_quantity_TP2_UP_S2 ;
		public static int USDCAD_quantity_TP3_UP_S2 ;
		public static int USDCAD_quantity_TP4_UP_S2 ;
		public static int USDCAD_quantity_TP5_UP_S2;
		public static int USDCAD_quantity_TP6_UP_S2 ;
		
		public static int USDCAD_quantity_DOWN_S2 ;
		public static int USDCAD_quantity_SL_DOWN_S2 ;
		public static int USDCAD_quantity_TP1_DOWN_S2 ;
		public static int USDCAD_quantity_TP2_DOWN_S2 ;
		public static int USDCAD_quantity_TP3_DOWN_S2 ;
		public static int USDCAD_quantity_TP4_DOWN_S2 ;
		public static int USDCAD_quantity_TP5_DOWN_S2;
		public static int USDCAD_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.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 _GBPCHF;
		
    	///oco1 up
    	public static OrderTicket GBPCHF_OCO1_MO1_UP_S2;
    	public static OrderTicket GBPCHF_OCO1_MO2_UP_S2;
    	public static OrderTicket GBPCHF_OCO1_MO3_UP_S2;
    	public static OrderTicket GBPCHF_OCO1_MO4_UP_S2;
    	public static OrderTicket GBPCHF_OCO1_MO5_UP_S2;
    	public static OrderTicket GBPCHF_OCO1_MO6_UP_S2;
    	
    	public static int GBPCHF_OCO1_EO1_UP_S2_ID ;
        public static int GBPCHF_OCO1_EO2_UP_S2_ID ;
        public static int GBPCHF_OCO1_EO3_UP_S2_ID ;
        public static int GBPCHF_OCO1_EO4_UP_S2_ID ;
        public static int GBPCHF_OCO1_EO5_UP_S2_ID ;
        public static int GBPCHF_OCO1_EO6_UP_S2_ID ;
        
        public static bool GBPCHF_OCO1_EO1_UP_S2 ;
        public static bool GBPCHF_OCO1_EO2_UP_S2 ;
        public static bool GBPCHF_OCO1_EO3_UP_S2 ;
        public static bool GBPCHF_OCO1_EO4_UP_S2 ;
        public static bool GBPCHF_OCO1_EO5_UP_S2 ;
        public static bool GBPCHF_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_UP_S2> GBPCHF_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_UP_S2> GBPCHF_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_UP_S2> GBPCHF_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_UP_S2> GBPCHF_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_UP_S2> GBPCHF_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_UP_S2> GBPCHF_OOFE_OCO1_UP_S2_6 ;
        
        public static GBPCHF_OCO1_UP_S2 GBPCHF_PFO_OCO1_UP_S2_1 ;
        public static GBPCHF_OCO1_UP_S2 GBPCHF_PFO_OCO1_UP_S2_2 ;
        public static GBPCHF_OCO1_UP_S2 GBPCHF_PFO_OCO1_UP_S2_3 ;
        public static GBPCHF_OCO1_UP_S2 GBPCHF_PFO_OCO1_UP_S2_4 ;
        public static GBPCHF_OCO1_UP_S2 GBPCHF_PFO_OCO1_UP_S2_5 ;
        public static GBPCHF_OCO1_UP_S2 GBPCHF_PFO_OCO1_UP_S2_6 ;
        
        public static List<GBPCHF_OCO1_UP_S2> GBPCHF_UP_S2_OCO1Sets1 = new List<GBPCHF_OCO1_UP_S2>();
        public static List<GBPCHF_OCO1_UP_S2> GBPCHF_UP_S2_OCO1Sets2 = new List<GBPCHF_OCO1_UP_S2>();
        public static List<GBPCHF_OCO1_UP_S2> GBPCHF_UP_S2_OCO1Sets3 = new List<GBPCHF_OCO1_UP_S2>();
        public static List<GBPCHF_OCO1_UP_S2> GBPCHF_UP_S2_OCO1Sets4 = new List<GBPCHF_OCO1_UP_S2>();
        public static List<GBPCHF_OCO1_UP_S2> GBPCHF_UP_S2_OCO1Sets5 = new List<GBPCHF_OCO1_UP_S2>();
        public static List<GBPCHF_OCO1_UP_S2> GBPCHF_UP_S2_OCO1Sets6 = new List<GBPCHF_OCO1_UP_S2>();
        
        public static bool GBPCHF_OCO1_UP_S2_IsReady = true;
		public static bool GBPCHF_OCO1_UP_S2_Monthly_IsReady = true;
        
        //oco1 down
		public static OrderTicket GBPCHF_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO1_MO6_DOWN_S2 ;
    	
    	public static int GBPCHF_OCO1_EO1_DOWN_S2_ID ;
        public static int GBPCHF_OCO1_EO2_DOWN_S2_ID ;
        public static int GBPCHF_OCO1_EO3_DOWN_S2_ID ;
        public static int GBPCHF_OCO1_EO4_DOWN_S2_ID ;
        public static int GBPCHF_OCO1_EO5_DOWN_S2_ID ;
        public static int GBPCHF_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool GBPCHF_OCO1_EO1_DOWN_S2 ;
        public static bool GBPCHF_OCO1_EO2_DOWN_S2 ;
        public static bool GBPCHF_OCO1_EO3_DOWN_S2 ;
        public static bool GBPCHF_OCO1_EO4_DOWN_S2 ;
        public static bool GBPCHF_OCO1_EO5_DOWN_S2 ;
        public static bool GBPCHF_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_DOWN_S2> GBPCHF_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_DOWN_S2> GBPCHF_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_DOWN_S2> GBPCHF_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_DOWN_S2> GBPCHF_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_DOWN_S2> GBPCHF_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO1_DOWN_S2> GBPCHF_OOFE_OCO1_DOWN_S2_6 ;
        
        public static GBPCHF_OCO1_DOWN_S2 GBPCHF_PFO_OCO1_DOWN_S2_1 ;
        public static GBPCHF_OCO1_DOWN_S2 GBPCHF_PFO_OCO1_DOWN_S2_2 ;
        public static GBPCHF_OCO1_DOWN_S2 GBPCHF_PFO_OCO1_DOWN_S2_3 ;
        public static GBPCHF_OCO1_DOWN_S2 GBPCHF_PFO_OCO1_DOWN_S2_4 ;
        public static GBPCHF_OCO1_DOWN_S2 GBPCHF_PFO_OCO1_DOWN_S2_5 ;
        public static GBPCHF_OCO1_DOWN_S2 GBPCHF_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<GBPCHF_OCO1_DOWN_S2> GBPCHF_DOWN_S2_OCO1Sets1 = new List<GBPCHF_OCO1_DOWN_S2>();
        public static List<GBPCHF_OCO1_DOWN_S2> GBPCHF_DOWN_S2_OCO1Sets2 = new List<GBPCHF_OCO1_DOWN_S2>();
        public static List<GBPCHF_OCO1_DOWN_S2> GBPCHF_DOWN_S2_OCO1Sets3 = new List<GBPCHF_OCO1_DOWN_S2>();
        public static List<GBPCHF_OCO1_DOWN_S2> GBPCHF_DOWN_S2_OCO1Sets4 = new List<GBPCHF_OCO1_DOWN_S2>();
        public static List<GBPCHF_OCO1_DOWN_S2> GBPCHF_DOWN_S2_OCO1Sets5 = new List<GBPCHF_OCO1_DOWN_S2>();
        public static List<GBPCHF_OCO1_DOWN_S2> GBPCHF_DOWN_S2_OCO1Sets6 = new List<GBPCHF_OCO1_DOWN_S2>();
        
        public static bool GBPCHF_OCO1_DOWN_S2_IsReady = true;
		public static bool GBPCHF_OCO1_DOWN_S2_Monthly_IsReady = true;
        
        //oco2 up
        public static OrderTicket GBPCHF_OCO2_MO1_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO2_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO3_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO4_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO5_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO6_UP_S2 ;
    	
    	public static int GBPCHF_OCO2_EO1_UP_S2_ID ;
        public static int GBPCHF_OCO2_EO2_UP_S2_ID ;
        public static int GBPCHF_OCO2_EO3_UP_S2_ID ;
        public static int GBPCHF_OCO2_EO4_UP_S2_ID ;
        public static int GBPCHF_OCO2_EO5_UP_S2_ID ;
        public static int GBPCHF_OCO2_EO6_UP_S2_ID ;
        
        public static bool GBPCHF_OCO2_EO1_UP_S2 ;
        public static bool GBPCHF_OCO2_EO2_UP_S2 ;
        public static bool GBPCHF_OCO2_EO3_UP_S2 ;
        public static bool GBPCHF_OCO2_EO4_UP_S2 ;
        public static bool GBPCHF_OCO2_EO5_UP_S2 ;
        public static bool GBPCHF_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_UP_S2> GBPCHF_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_UP_S2> GBPCHF_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_UP_S2> GBPCHF_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_UP_S2> GBPCHF_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_UP_S2> GBPCHF_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_UP_S2> GBPCHF_OOFE_OCO2_UP_S2_6 ;
        
        public static GBPCHF_OCO2_UP_S2 GBPCHF_PFO_OCO2_UP_S2_1 ;
        public static GBPCHF_OCO2_UP_S2 GBPCHF_PFO_OCO2_UP_S2_2 ;
        public static GBPCHF_OCO2_UP_S2 GBPCHF_PFO_OCO2_UP_S2_3 ;
        public static GBPCHF_OCO2_UP_S2 GBPCHF_PFO_OCO2_UP_S2_4 ;
        public static GBPCHF_OCO2_UP_S2 GBPCHF_PFO_OCO2_UP_S2_5 ;
        public static GBPCHF_OCO2_UP_S2 GBPCHF_PFO_OCO2_UP_S2_6 ;
        
        public static List<GBPCHF_OCO2_UP_S2> GBPCHF_UP_S2_OCO2Sets1 = new List<GBPCHF_OCO2_UP_S2>();
        public static List<GBPCHF_OCO2_UP_S2> GBPCHF_UP_S2_OCO2Sets2 = new List<GBPCHF_OCO2_UP_S2>();
        public static List<GBPCHF_OCO2_UP_S2> GBPCHF_UP_S2_OCO2Sets3 = new List<GBPCHF_OCO2_UP_S2>();
        public static List<GBPCHF_OCO2_UP_S2> GBPCHF_UP_S2_OCO2Sets4 = new List<GBPCHF_OCO2_UP_S2>();
        public static List<GBPCHF_OCO2_UP_S2> GBPCHF_UP_S2_OCO2Sets5 = new List<GBPCHF_OCO2_UP_S2>();
        public static List<GBPCHF_OCO2_UP_S2> GBPCHF_UP_S2_OCO2Sets6 = new List<GBPCHF_OCO2_UP_S2>();
        
        public static bool GBPCHF_OCO2_UP_S2_IsReady = true;
		public static bool GBPCHF_OCO2_UP_S2_Monthly_IsReady = true;
        
        //oco2 down
        public static OrderTicket GBPCHF_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO2_MO6_DOWN_S2 ;
    	
    	public static int GBPCHF_OCO2_EO1_DOWN_S2_ID ;
        public static int GBPCHF_OCO2_EO2_DOWN_S2_ID ;
        public static int GBPCHF_OCO2_EO3_DOWN_S2_ID ;
        public static int GBPCHF_OCO2_EO4_DOWN_S2_ID ;
        public static int GBPCHF_OCO2_EO5_DOWN_S2_ID ;
        public static int GBPCHF_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool GBPCHF_OCO2_EO1_DOWN_S2 ;
        public static bool GBPCHF_OCO2_EO2_DOWN_S2 ;
        public static bool GBPCHF_OCO2_EO3_DOWN_S2 ;
        public static bool GBPCHF_OCO2_EO4_DOWN_S2 ;
        public static bool GBPCHF_OCO2_EO5_DOWN_S2 ;
        public static bool GBPCHF_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_DOWN_S2> GBPCHF_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_DOWN_S2> GBPCHF_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_DOWN_S2> GBPCHF_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_DOWN_S2> GBPCHF_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_DOWN_S2> GBPCHF_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO2_DOWN_S2> GBPCHF_OOFE_OCO2_DOWN_S2_6 ;
        
        public static GBPCHF_OCO2_DOWN_S2 GBPCHF_PFO_OCO2_DOWN_S2_1 ;
        public static GBPCHF_OCO2_DOWN_S2 GBPCHF_PFO_OCO2_DOWN_S2_2 ;
        public static GBPCHF_OCO2_DOWN_S2 GBPCHF_PFO_OCO2_DOWN_S2_3 ;
        public static GBPCHF_OCO2_DOWN_S2 GBPCHF_PFO_OCO2_DOWN_S2_4 ;
        public static GBPCHF_OCO2_DOWN_S2 GBPCHF_PFO_OCO2_DOWN_S2_5 ;
        public static GBPCHF_OCO2_DOWN_S2 GBPCHF_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<GBPCHF_OCO2_DOWN_S2> GBPCHF_DOWN_S2_OCO2Sets1 = new List<GBPCHF_OCO2_DOWN_S2>();
        public static List<GBPCHF_OCO2_DOWN_S2> GBPCHF_DOWN_S2_OCO2Sets2 = new List<GBPCHF_OCO2_DOWN_S2>();
        public static List<GBPCHF_OCO2_DOWN_S2> GBPCHF_DOWN_S2_OCO2Sets3 = new List<GBPCHF_OCO2_DOWN_S2>();
        public static List<GBPCHF_OCO2_DOWN_S2> GBPCHF_DOWN_S2_OCO2Sets4 = new List<GBPCHF_OCO2_DOWN_S2>();
        public static List<GBPCHF_OCO2_DOWN_S2> GBPCHF_DOWN_S2_OCO2Sets5 = new List<GBPCHF_OCO2_DOWN_S2>();
        public static List<GBPCHF_OCO2_DOWN_S2> GBPCHF_DOWN_S2_OCO2Sets6 = new List<GBPCHF_OCO2_DOWN_S2>();
        
        public static bool GBPCHF_OCO2_DOWN_S2_IsReady = true;
		public static bool GBPCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
        
        //oco3 up
        public static OrderTicket GBPCHF_OCO3_MO1_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO2_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO3_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO4_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO5_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO6_UP_S2 ;
    	
    	public static int GBPCHF_OCO3_EO1_UP_S2_ID ;
        public static int GBPCHF_OCO3_EO2_UP_S2_ID ;
        public static int GBPCHF_OCO3_EO3_UP_S2_ID ;
        public static int GBPCHF_OCO3_EO4_UP_S2_ID ;
        public static int GBPCHF_OCO3_EO5_UP_S2_ID ;
        public static int GBPCHF_OCO3_EO6_UP_S2_ID ;
        
        public static bool GBPCHF_OCO3_EO1_UP_S2 ;
        public static bool GBPCHF_OCO3_EO2_UP_S2 ;
        public static bool GBPCHF_OCO3_EO3_UP_S2 ;
        public static bool GBPCHF_OCO3_EO4_UP_S2 ;
        public static bool GBPCHF_OCO3_EO5_UP_S2 ;
        public static bool GBPCHF_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_UP_S2> GBPCHF_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_UP_S2> GBPCHF_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_UP_S2> GBPCHF_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_UP_S2> GBPCHF_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_UP_S2> GBPCHF_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_UP_S2> GBPCHF_OOFE_OCO3_UP_S2_6 ;
        
        public static GBPCHF_OCO3_UP_S2 GBPCHF_PFO_OCO3_UP_S2_1 ;
        public static GBPCHF_OCO3_UP_S2 GBPCHF_PFO_OCO3_UP_S2_2 ;
        public static GBPCHF_OCO3_UP_S2 GBPCHF_PFO_OCO3_UP_S2_3 ;
        public static GBPCHF_OCO3_UP_S2 GBPCHF_PFO_OCO3_UP_S2_4 ;
        public static GBPCHF_OCO3_UP_S2 GBPCHF_PFO_OCO3_UP_S2_5 ;
        public static GBPCHF_OCO3_UP_S2 GBPCHF_PFO_OCO3_UP_S2_6 ;
        
        public static List<GBPCHF_OCO3_UP_S2> GBPCHF_UP_S2_OCO3Sets1 = new List<GBPCHF_OCO3_UP_S2>();
        public static List<GBPCHF_OCO3_UP_S2> GBPCHF_UP_S2_OCO3Sets2 = new List<GBPCHF_OCO3_UP_S2>();
        public static List<GBPCHF_OCO3_UP_S2> GBPCHF_UP_S2_OCO3Sets3 = new List<GBPCHF_OCO3_UP_S2>();
        public static List<GBPCHF_OCO3_UP_S2> GBPCHF_UP_S2_OCO3Sets4 = new List<GBPCHF_OCO3_UP_S2>();
        public static List<GBPCHF_OCO3_UP_S2> GBPCHF_UP_S2_OCO3Sets5 = new List<GBPCHF_OCO3_UP_S2>();
        public static List<GBPCHF_OCO3_UP_S2> GBPCHF_UP_S2_OCO3Sets6 = new List<GBPCHF_OCO3_UP_S2>();
        
        public static bool GBPCHF_OCO3_UP_S2_IsReady = true;
		public static bool GBPCHF_OCO3_UP_S2_Monthly_IsReady = true;
        
        //oco3 down
        public static OrderTicket GBPCHF_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO3_MO6_DOWN_S2 ;
    	
    	public static int GBPCHF_OCO3_EO1_DOWN_S2_ID ;
        public static int GBPCHF_OCO3_EO2_DOWN_S2_ID ;
        public static int GBPCHF_OCO3_EO3_DOWN_S2_ID ;
        public static int GBPCHF_OCO3_EO4_DOWN_S2_ID ;
        public static int GBPCHF_OCO3_EO5_DOWN_S2_ID ;
        public static int GBPCHF_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool GBPCHF_OCO3_EO1_DOWN_S2 ;
        public static bool GBPCHF_OCO3_EO2_DOWN_S2 ;
        public static bool GBPCHF_OCO3_EO3_DOWN_S2 ;
        public static bool GBPCHF_OCO3_EO4_DOWN_S2 ;
        public static bool GBPCHF_OCO3_EO5_DOWN_S2 ;
        public static bool GBPCHF_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_DOWN_S2> GBPCHF_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_DOWN_S2> GBPCHF_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_DOWN_S2> GBPCHF_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_DOWN_S2> GBPCHF_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_DOWN_S2> GBPCHF_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO3_DOWN_S2> GBPCHF_OOFE_OCO3_DOWN_S2_6 ;
        
        public static GBPCHF_OCO3_DOWN_S2 GBPCHF_PFO_OCO3_DOWN_S2_1 ;
        public static GBPCHF_OCO3_DOWN_S2 GBPCHF_PFO_OCO3_DOWN_S2_2 ;
        public static GBPCHF_OCO3_DOWN_S2 GBPCHF_PFO_OCO3_DOWN_S2_3 ;
        public static GBPCHF_OCO3_DOWN_S2 GBPCHF_PFO_OCO3_DOWN_S2_4 ;
        public static GBPCHF_OCO3_DOWN_S2 GBPCHF_PFO_OCO3_DOWN_S2_5 ;
        public static GBPCHF_OCO3_DOWN_S2 GBPCHF_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<GBPCHF_OCO3_DOWN_S2> GBPCHF_DOWN_S2_OCO3Sets1 = new List<GBPCHF_OCO3_DOWN_S2>();
        public static List<GBPCHF_OCO3_DOWN_S2> GBPCHF_DOWN_S2_OCO3Sets2 = new List<GBPCHF_OCO3_DOWN_S2>();
        public static List<GBPCHF_OCO3_DOWN_S2> GBPCHF_DOWN_S2_OCO3Sets3 = new List<GBPCHF_OCO3_DOWN_S2>();
        public static List<GBPCHF_OCO3_DOWN_S2> GBPCHF_DOWN_S2_OCO3Sets4 = new List<GBPCHF_OCO3_DOWN_S2>();
        public static List<GBPCHF_OCO3_DOWN_S2> GBPCHF_DOWN_S2_OCO3Sets5 = new List<GBPCHF_OCO3_DOWN_S2>();
        public static List<GBPCHF_OCO3_DOWN_S2> GBPCHF_DOWN_S2_OCO3Sets6 = new List<GBPCHF_OCO3_DOWN_S2>();
        
        public static bool GBPCHF_OCO3_DOWN_S2_IsReady = true;
		public static bool GBPCHF_OCO3_DOWN_S2_Monthly_IsReady = true;
        
        //oco4 up
        public static OrderTicket GBPCHF_OCO4_MO1_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO2_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO3_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO4_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO5_UP_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO6_UP_S2 ;
    	
    	public static int GBPCHF_OCO4_EO1_UP_S2_ID ;
        public static int GBPCHF_OCO4_EO2_UP_S2_ID ;
        public static int GBPCHF_OCO4_EO3_UP_S2_ID ;
        public static int GBPCHF_OCO4_EO4_UP_S2_ID ;
        public static int GBPCHF_OCO4_EO5_UP_S2_ID ;
        public static int GBPCHF_OCO4_EO6_UP_S2_ID ;
        
        public static bool GBPCHF_OCO4_EO1_UP_S2 ;
        public static bool GBPCHF_OCO4_EO2_UP_S2 ;
        public static bool GBPCHF_OCO4_EO3_UP_S2 ;
        public static bool GBPCHF_OCO4_EO4_UP_S2 ;
        public static bool GBPCHF_OCO4_EO5_UP_S2 ;
        public static bool GBPCHF_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_UP_S2> GBPCHF_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_UP_S2> GBPCHF_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_UP_S2> GBPCHF_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_UP_S2> GBPCHF_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_UP_S2> GBPCHF_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_UP_S2> GBPCHF_OOFE_OCO4_UP_S2_6 ;
        
        public static GBPCHF_OCO4_UP_S2 GBPCHF_PFO_OCO4_UP_S2_1 ;
        public static GBPCHF_OCO4_UP_S2 GBPCHF_PFO_OCO4_UP_S2_2 ;
        public static GBPCHF_OCO4_UP_S2 GBPCHF_PFO_OCO4_UP_S2_3 ;
        public static GBPCHF_OCO4_UP_S2 GBPCHF_PFO_OCO4_UP_S2_4 ;
        public static GBPCHF_OCO4_UP_S2 GBPCHF_PFO_OCO4_UP_S2_5 ;
        public static GBPCHF_OCO4_UP_S2 GBPCHF_PFO_OCO4_UP_S2_6 ;
        
        public static List<GBPCHF_OCO4_UP_S2> GBPCHF_UP_S2_OCO4Sets1 = new List<GBPCHF_OCO4_UP_S2>();
        public static List<GBPCHF_OCO4_UP_S2> GBPCHF_UP_S2_OCO4Sets2 = new List<GBPCHF_OCO4_UP_S2>();
        public static List<GBPCHF_OCO4_UP_S2> GBPCHF_UP_S2_OCO4Sets3 = new List<GBPCHF_OCO4_UP_S2>();
        public static List<GBPCHF_OCO4_UP_S2> GBPCHF_UP_S2_OCO4Sets4 = new List<GBPCHF_OCO4_UP_S2>();
        public static List<GBPCHF_OCO4_UP_S2> GBPCHF_UP_S2_OCO4Sets5 = new List<GBPCHF_OCO4_UP_S2>();
        public static List<GBPCHF_OCO4_UP_S2> GBPCHF_UP_S2_OCO4Sets6 = new List<GBPCHF_OCO4_UP_S2>();
        
        public static bool GBPCHF_OCO4_UP_S2_IsReady = true;
		public static bool GBPCHF_OCO4_UP_S2_Monthly_IsReady = true;
        
        //oco4 down
        public static OrderTicket GBPCHF_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket GBPCHF_OCO4_MO6_DOWN_S2 ;
    	
    	public static int GBPCHF_OCO4_EO1_DOWN_S2_ID ;
        public static int GBPCHF_OCO4_EO2_DOWN_S2_ID ;
        public static int GBPCHF_OCO4_EO3_DOWN_S2_ID ;
        public static int GBPCHF_OCO4_EO4_DOWN_S2_ID ;
        public static int GBPCHF_OCO4_EO5_DOWN_S2_ID ;
        public static int GBPCHF_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool GBPCHF_OCO4_EO1_DOWN_S2 ;
        public static bool GBPCHF_OCO4_EO2_DOWN_S2 ;
        public static bool GBPCHF_OCO4_EO3_DOWN_S2 ;
        public static bool GBPCHF_OCO4_EO4_DOWN_S2 ;
        public static bool GBPCHF_OCO4_EO5_DOWN_S2 ;
        public static bool GBPCHF_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_DOWN_S2> GBPCHF_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_DOWN_S2> GBPCHF_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_DOWN_S2> GBPCHF_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_DOWN_S2> GBPCHF_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_DOWN_S2> GBPCHF_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCHF_OCO4_DOWN_S2> GBPCHF_OOFE_OCO4_DOWN_S2_6 ;
        
        public static GBPCHF_OCO4_DOWN_S2 GBPCHF_PFO_OCO4_DOWN_S2_1 ;
        public static GBPCHF_OCO4_DOWN_S2 GBPCHF_PFO_OCO4_DOWN_S2_2 ;
        public static GBPCHF_OCO4_DOWN_S2 GBPCHF_PFO_OCO4_DOWN_S2_3 ;
        public static GBPCHF_OCO4_DOWN_S2 GBPCHF_PFO_OCO4_DOWN_S2_4 ;
        public static GBPCHF_OCO4_DOWN_S2 GBPCHF_PFO_OCO4_DOWN_S2_5 ;
        public static GBPCHF_OCO4_DOWN_S2 GBPCHF_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<GBPCHF_OCO4_DOWN_S2> GBPCHF_DOWN_S2_OCO4Sets1 = new List<GBPCHF_OCO4_DOWN_S2>();
        public static List<GBPCHF_OCO4_DOWN_S2> GBPCHF_DOWN_S2_OCO4Sets2 = new List<GBPCHF_OCO4_DOWN_S2>();
        public static List<GBPCHF_OCO4_DOWN_S2> GBPCHF_DOWN_S2_OCO4Sets3 = new List<GBPCHF_OCO4_DOWN_S2>();
        public static List<GBPCHF_OCO4_DOWN_S2> GBPCHF_DOWN_S2_OCO4Sets4 = new List<GBPCHF_OCO4_DOWN_S2>();
        public static List<GBPCHF_OCO4_DOWN_S2> GBPCHF_DOWN_S2_OCO4Sets5 = new List<GBPCHF_OCO4_DOWN_S2>();
        public static List<GBPCHF_OCO4_DOWN_S2> GBPCHF_DOWN_S2_OCO4Sets6 = new List<GBPCHF_OCO4_DOWN_S2>();
        
        public static bool GBPCHF_OCO4_DOWN_S2_IsReady = true;
		public static bool GBPCHF_OCO4_DOWN_S2_Monthly_IsReady = true;
        
        
////////////////////////////
		public static decimal GBPCHF_UP_S2_SL {get; set;}
		public static decimal GBPCHF_UP_S2_TP1 {get; set;}
		public static decimal GBPCHF_UP_S2_TP2 {get; set;}
		public static decimal GBPCHF_UP_S2_TP3 {get; set;}
		public static decimal GBPCHF_UP_S2_TP4 {get; set;}
		public static decimal GBPCHF_UP_S2_TP5 {get; set;}
		public static decimal GBPCHF_UP_S2_TP6 {get; set;}
		
		public static decimal GBPCHF_DOWN_S2_SL {get; set;}
		public static decimal GBPCHF_DOWN_S2_TP1 {get; set;}
		public static decimal GBPCHF_DOWN_S2_TP2 {get; set;}
		public static decimal GBPCHF_DOWN_S2_TP3 {get; set;}
		public static decimal GBPCHF_DOWN_S2_TP4 {get; set;}
		public static decimal GBPCHF_DOWN_S2_TP5 {get; set;}
		public static decimal GBPCHF_DOWN_S2_TP6 {get; set;}

        public static bool GBPCHF_Signal_Condition_UP_1 ;
        public static bool GBPCHF_Signal_Condition_UP_2 ;
        public static bool GBPCHF_Signal_Condition_UP_3 ;
        public static bool GBPCHF_Signal_Condition_DOWN_S2 ;
        
        public static int GBPCHF_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int GBPCHF_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPCHF_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPCHF_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPCHF_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int GBPCHF_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int GBPCHF_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPCHF_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPCHF_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPCHF_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_GBPCHF_UP_S2 ;
        public static bool DOWM_GBPCHF_UP_S2 ;
        public static bool DOWT_GBPCHF_UP_S2 ;
        public static bool DOWW_GBPCHF_UP_S2 ;
        public static bool DOWTH_GBPCHF_UP_S2 ;
        
		public static bool DOWR_GBPCHF_DOWN_S2 ;
        public static bool DOWM_GBPCHF_DOWN_S2 ;
        public static bool DOWT_GBPCHF_DOWN_S2 ;
        public static bool DOWW_GBPCHF_DOWN_S2 ;
        public static bool DOWTH_GBPCHF_DOWN_S2 ;
        
        
		public static int GBPCHF_quantity_UP_S2 ;
		public static int GBPCHF_quantity_SL_UP_S2 ;
		public static int GBPCHF_quantity_TP1_UP_S2 ;
		public static int GBPCHF_quantity_TP2_UP_S2 ;
		public static int GBPCHF_quantity_TP3_UP_S2 ;
		public static int GBPCHF_quantity_TP4_UP_S2 ;
		public static int GBPCHF_quantity_TP5_UP_S2;
		public static int GBPCHF_quantity_TP6_UP_S2 ;
		
		public static int GBPCHF_quantity_DOWN_S2 ;
		public static int GBPCHF_quantity_SL_DOWN_S2 ;
		public static int GBPCHF_quantity_TP1_DOWN_S2 ;
		public static int GBPCHF_quantity_TP2_DOWN_S2 ;
		public static int GBPCHF_quantity_TP3_DOWN_S2 ;
		public static int GBPCHF_quantity_TP4_DOWN_S2 ;
		public static int GBPCHF_quantity_TP5_DOWN_S2;
		public static int GBPCHF_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.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 _AUDNZD;
		
    	///oco1 up
    	public static OrderTicket AUDNZD_OCO1_MO1_UP_S2;
    	public static OrderTicket AUDNZD_OCO1_MO2_UP_S2;
    	public static OrderTicket AUDNZD_OCO1_MO3_UP_S2;
    	public static OrderTicket AUDNZD_OCO1_MO4_UP_S2;
    	public static OrderTicket AUDNZD_OCO1_MO5_UP_S2;
    	public static OrderTicket AUDNZD_OCO1_MO6_UP_S2;
    	
    	public static int AUDNZD_OCO1_EO1_UP_S2_ID ;
        public static int AUDNZD_OCO1_EO2_UP_S2_ID ;
        public static int AUDNZD_OCO1_EO3_UP_S2_ID ;
        public static int AUDNZD_OCO1_EO4_UP_S2_ID ;
        public static int AUDNZD_OCO1_EO5_UP_S2_ID ;
        public static int AUDNZD_OCO1_EO6_UP_S2_ID ;
        
        public static bool AUDNZD_OCO1_EO1_UP_S2 ;
        public static bool AUDNZD_OCO1_EO2_UP_S2 ;
        public static bool AUDNZD_OCO1_EO3_UP_S2 ;
        public static bool AUDNZD_OCO1_EO4_UP_S2 ;
        public static bool AUDNZD_OCO1_EO5_UP_S2 ;
        public static bool AUDNZD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_UP_S2> AUDNZD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_UP_S2> AUDNZD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_UP_S2> AUDNZD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_UP_S2> AUDNZD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_UP_S2> AUDNZD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_UP_S2> AUDNZD_OOFE_OCO1_UP_S2_6 ;
        
        public static AUDNZD_OCO1_UP_S2 AUDNZD_PFO_OCO1_UP_S2_1 ;
        public static AUDNZD_OCO1_UP_S2 AUDNZD_PFO_OCO1_UP_S2_2 ;
        public static AUDNZD_OCO1_UP_S2 AUDNZD_PFO_OCO1_UP_S2_3 ;
        public static AUDNZD_OCO1_UP_S2 AUDNZD_PFO_OCO1_UP_S2_4 ;
        public static AUDNZD_OCO1_UP_S2 AUDNZD_PFO_OCO1_UP_S2_5 ;
        public static AUDNZD_OCO1_UP_S2 AUDNZD_PFO_OCO1_UP_S2_6 ;
        
        public static List<AUDNZD_OCO1_UP_S2> AUDNZD_UP_S2_OCO1Sets1 = new List<AUDNZD_OCO1_UP_S2>();
        public static List<AUDNZD_OCO1_UP_S2> AUDNZD_UP_S2_OCO1Sets2 = new List<AUDNZD_OCO1_UP_S2>();
        public static List<AUDNZD_OCO1_UP_S2> AUDNZD_UP_S2_OCO1Sets3 = new List<AUDNZD_OCO1_UP_S2>();
        public static List<AUDNZD_OCO1_UP_S2> AUDNZD_UP_S2_OCO1Sets4 = new List<AUDNZD_OCO1_UP_S2>();
        public static List<AUDNZD_OCO1_UP_S2> AUDNZD_UP_S2_OCO1Sets5 = new List<AUDNZD_OCO1_UP_S2>();
        public static List<AUDNZD_OCO1_UP_S2> AUDNZD_UP_S2_OCO1Sets6 = new List<AUDNZD_OCO1_UP_S2>();
        
        public static bool AUDNZD_OCO1_UP_S2_IsReady = true;
		public static bool AUDNZD_OCO1_UP_S2_Monthly_IsReady = true;
        
        //oco1 down
		public static OrderTicket AUDNZD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int AUDNZD_OCO1_EO1_DOWN_S2_ID ;
        public static int AUDNZD_OCO1_EO2_DOWN_S2_ID ;
        public static int AUDNZD_OCO1_EO3_DOWN_S2_ID ;
        public static int AUDNZD_OCO1_EO4_DOWN_S2_ID ;
        public static int AUDNZD_OCO1_EO5_DOWN_S2_ID ;
        public static int AUDNZD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool AUDNZD_OCO1_EO1_DOWN_S2 ;
        public static bool AUDNZD_OCO1_EO2_DOWN_S2 ;
        public static bool AUDNZD_OCO1_EO3_DOWN_S2 ;
        public static bool AUDNZD_OCO1_EO4_DOWN_S2 ;
        public static bool AUDNZD_OCO1_EO5_DOWN_S2 ;
        public static bool AUDNZD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_DOWN_S2> AUDNZD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_DOWN_S2> AUDNZD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_DOWN_S2> AUDNZD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_DOWN_S2> AUDNZD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_DOWN_S2> AUDNZD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO1_DOWN_S2> AUDNZD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static AUDNZD_OCO1_DOWN_S2 AUDNZD_PFO_OCO1_DOWN_S2_1 ;
        public static AUDNZD_OCO1_DOWN_S2 AUDNZD_PFO_OCO1_DOWN_S2_2 ;
        public static AUDNZD_OCO1_DOWN_S2 AUDNZD_PFO_OCO1_DOWN_S2_3 ;
        public static AUDNZD_OCO1_DOWN_S2 AUDNZD_PFO_OCO1_DOWN_S2_4 ;
        public static AUDNZD_OCO1_DOWN_S2 AUDNZD_PFO_OCO1_DOWN_S2_5 ;
        public static AUDNZD_OCO1_DOWN_S2 AUDNZD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<AUDNZD_OCO1_DOWN_S2> AUDNZD_DOWN_S2_OCO1Sets1 = new List<AUDNZD_OCO1_DOWN_S2>();
        public static List<AUDNZD_OCO1_DOWN_S2> AUDNZD_DOWN_S2_OCO1Sets2 = new List<AUDNZD_OCO1_DOWN_S2>();
        public static List<AUDNZD_OCO1_DOWN_S2> AUDNZD_DOWN_S2_OCO1Sets3 = new List<AUDNZD_OCO1_DOWN_S2>();
        public static List<AUDNZD_OCO1_DOWN_S2> AUDNZD_DOWN_S2_OCO1Sets4 = new List<AUDNZD_OCO1_DOWN_S2>();
        public static List<AUDNZD_OCO1_DOWN_S2> AUDNZD_DOWN_S2_OCO1Sets5 = new List<AUDNZD_OCO1_DOWN_S2>();
        public static List<AUDNZD_OCO1_DOWN_S2> AUDNZD_DOWN_S2_OCO1Sets6 = new List<AUDNZD_OCO1_DOWN_S2>();
        
        public static bool AUDNZD_OCO1_DOWN_S2_IsReady = true;
		public static bool AUDNZD_OCO1_DOWN_S2_Monthly_IsReady = true;
        
        //oco2 up
        public static OrderTicket AUDNZD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO6_UP_S2 ;
    	
    	public static int AUDNZD_OCO2_EO1_UP_S2_ID ;
        public static int AUDNZD_OCO2_EO2_UP_S2_ID ;
        public static int AUDNZD_OCO2_EO3_UP_S2_ID ;
        public static int AUDNZD_OCO2_EO4_UP_S2_ID ;
        public static int AUDNZD_OCO2_EO5_UP_S2_ID ;
        public static int AUDNZD_OCO2_EO6_UP_S2_ID ;
        
        public static bool AUDNZD_OCO2_EO1_UP_S2 ;
        public static bool AUDNZD_OCO2_EO2_UP_S2 ;
        public static bool AUDNZD_OCO2_EO3_UP_S2 ;
        public static bool AUDNZD_OCO2_EO4_UP_S2 ;
        public static bool AUDNZD_OCO2_EO5_UP_S2 ;
        public static bool AUDNZD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_UP_S2> AUDNZD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_UP_S2> AUDNZD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_UP_S2> AUDNZD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_UP_S2> AUDNZD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_UP_S2> AUDNZD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_UP_S2> AUDNZD_OOFE_OCO2_UP_S2_6 ;
        
        public static AUDNZD_OCO2_UP_S2 AUDNZD_PFO_OCO2_UP_S2_1 ;
        public static AUDNZD_OCO2_UP_S2 AUDNZD_PFO_OCO2_UP_S2_2 ;
        public static AUDNZD_OCO2_UP_S2 AUDNZD_PFO_OCO2_UP_S2_3 ;
        public static AUDNZD_OCO2_UP_S2 AUDNZD_PFO_OCO2_UP_S2_4 ;
        public static AUDNZD_OCO2_UP_S2 AUDNZD_PFO_OCO2_UP_S2_5 ;
        public static AUDNZD_OCO2_UP_S2 AUDNZD_PFO_OCO2_UP_S2_6 ;
        
        public static List<AUDNZD_OCO2_UP_S2> AUDNZD_UP_S2_OCO2Sets1 = new List<AUDNZD_OCO2_UP_S2>();
        public static List<AUDNZD_OCO2_UP_S2> AUDNZD_UP_S2_OCO2Sets2 = new List<AUDNZD_OCO2_UP_S2>();
        public static List<AUDNZD_OCO2_UP_S2> AUDNZD_UP_S2_OCO2Sets3 = new List<AUDNZD_OCO2_UP_S2>();
        public static List<AUDNZD_OCO2_UP_S2> AUDNZD_UP_S2_OCO2Sets4 = new List<AUDNZD_OCO2_UP_S2>();
        public static List<AUDNZD_OCO2_UP_S2> AUDNZD_UP_S2_OCO2Sets5 = new List<AUDNZD_OCO2_UP_S2>();
        public static List<AUDNZD_OCO2_UP_S2> AUDNZD_UP_S2_OCO2Sets6 = new List<AUDNZD_OCO2_UP_S2>();
        
        public static bool AUDNZD_OCO2_UP_S2_IsReady = true;
		public static bool AUDNZD_OCO2_UP_S2_Monthly_IsReady = true;
        
        //oco2 down
        public static OrderTicket AUDNZD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int AUDNZD_OCO2_EO1_DOWN_S2_ID ;
        public static int AUDNZD_OCO2_EO2_DOWN_S2_ID ;
        public static int AUDNZD_OCO2_EO3_DOWN_S2_ID ;
        public static int AUDNZD_OCO2_EO4_DOWN_S2_ID ;
        public static int AUDNZD_OCO2_EO5_DOWN_S2_ID ;
        public static int AUDNZD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool AUDNZD_OCO2_EO1_DOWN_S2 ;
        public static bool AUDNZD_OCO2_EO2_DOWN_S2 ;
        public static bool AUDNZD_OCO2_EO3_DOWN_S2 ;
        public static bool AUDNZD_OCO2_EO4_DOWN_S2 ;
        public static bool AUDNZD_OCO2_EO5_DOWN_S2 ;
        public static bool AUDNZD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_DOWN_S2> AUDNZD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_DOWN_S2> AUDNZD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_DOWN_S2> AUDNZD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_DOWN_S2> AUDNZD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_DOWN_S2> AUDNZD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO2_DOWN_S2> AUDNZD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static AUDNZD_OCO2_DOWN_S2 AUDNZD_PFO_OCO2_DOWN_S2_1 ;
        public static AUDNZD_OCO2_DOWN_S2 AUDNZD_PFO_OCO2_DOWN_S2_2 ;
        public static AUDNZD_OCO2_DOWN_S2 AUDNZD_PFO_OCO2_DOWN_S2_3 ;
        public static AUDNZD_OCO2_DOWN_S2 AUDNZD_PFO_OCO2_DOWN_S2_4 ;
        public static AUDNZD_OCO2_DOWN_S2 AUDNZD_PFO_OCO2_DOWN_S2_5 ;
        public static AUDNZD_OCO2_DOWN_S2 AUDNZD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<AUDNZD_OCO2_DOWN_S2> AUDNZD_DOWN_S2_OCO2Sets1 = new List<AUDNZD_OCO2_DOWN_S2>();
        public static List<AUDNZD_OCO2_DOWN_S2> AUDNZD_DOWN_S2_OCO2Sets2 = new List<AUDNZD_OCO2_DOWN_S2>();
        public static List<AUDNZD_OCO2_DOWN_S2> AUDNZD_DOWN_S2_OCO2Sets3 = new List<AUDNZD_OCO2_DOWN_S2>();
        public static List<AUDNZD_OCO2_DOWN_S2> AUDNZD_DOWN_S2_OCO2Sets4 = new List<AUDNZD_OCO2_DOWN_S2>();
        public static List<AUDNZD_OCO2_DOWN_S2> AUDNZD_DOWN_S2_OCO2Sets5 = new List<AUDNZD_OCO2_DOWN_S2>();
        public static List<AUDNZD_OCO2_DOWN_S2> AUDNZD_DOWN_S2_OCO2Sets6 = new List<AUDNZD_OCO2_DOWN_S2>();
        
        public static bool AUDNZD_OCO2_DOWN_S2_IsReady = true;
		public static bool AUDNZD_OCO2_DOWN_S2_Monthly_IsReady = true;
        
        //oco3 up
        public static OrderTicket AUDNZD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO6_UP_S2 ;
    	
    	public static int AUDNZD_OCO3_EO1_UP_S2_ID ;
        public static int AUDNZD_OCO3_EO2_UP_S2_ID ;
        public static int AUDNZD_OCO3_EO3_UP_S2_ID ;
        public static int AUDNZD_OCO3_EO4_UP_S2_ID ;
        public static int AUDNZD_OCO3_EO5_UP_S2_ID ;
        public static int AUDNZD_OCO3_EO6_UP_S2_ID ;
        
        public static bool AUDNZD_OCO3_EO1_UP_S2 ;
        public static bool AUDNZD_OCO3_EO2_UP_S2 ;
        public static bool AUDNZD_OCO3_EO3_UP_S2 ;
        public static bool AUDNZD_OCO3_EO4_UP_S2 ;
        public static bool AUDNZD_OCO3_EO5_UP_S2 ;
        public static bool AUDNZD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_UP_S2> AUDNZD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_UP_S2> AUDNZD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_UP_S2> AUDNZD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_UP_S2> AUDNZD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_UP_S2> AUDNZD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_UP_S2> AUDNZD_OOFE_OCO3_UP_S2_6 ;
        
        public static AUDNZD_OCO3_UP_S2 AUDNZD_PFO_OCO3_UP_S2_1 ;
        public static AUDNZD_OCO3_UP_S2 AUDNZD_PFO_OCO3_UP_S2_2 ;
        public static AUDNZD_OCO3_UP_S2 AUDNZD_PFO_OCO3_UP_S2_3 ;
        public static AUDNZD_OCO3_UP_S2 AUDNZD_PFO_OCO3_UP_S2_4 ;
        public static AUDNZD_OCO3_UP_S2 AUDNZD_PFO_OCO3_UP_S2_5 ;
        public static AUDNZD_OCO3_UP_S2 AUDNZD_PFO_OCO3_UP_S2_6 ;
        
        public static List<AUDNZD_OCO3_UP_S2> AUDNZD_UP_S2_OCO3Sets1 = new List<AUDNZD_OCO3_UP_S2>();
        public static List<AUDNZD_OCO3_UP_S2> AUDNZD_UP_S2_OCO3Sets2 = new List<AUDNZD_OCO3_UP_S2>();
        public static List<AUDNZD_OCO3_UP_S2> AUDNZD_UP_S2_OCO3Sets3 = new List<AUDNZD_OCO3_UP_S2>();
        public static List<AUDNZD_OCO3_UP_S2> AUDNZD_UP_S2_OCO3Sets4 = new List<AUDNZD_OCO3_UP_S2>();
        public static List<AUDNZD_OCO3_UP_S2> AUDNZD_UP_S2_OCO3Sets5 = new List<AUDNZD_OCO3_UP_S2>();
        public static List<AUDNZD_OCO3_UP_S2> AUDNZD_UP_S2_OCO3Sets6 = new List<AUDNZD_OCO3_UP_S2>();
        
        public static bool AUDNZD_OCO3_UP_S2_IsReady = true;
		public static bool AUDNZD_OCO3_UP_S2_Monthly_IsReady = true;
        
        //oco3 down
        public static OrderTicket AUDNZD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int AUDNZD_OCO3_EO1_DOWN_S2_ID ;
        public static int AUDNZD_OCO3_EO2_DOWN_S2_ID ;
        public static int AUDNZD_OCO3_EO3_DOWN_S2_ID ;
        public static int AUDNZD_OCO3_EO4_DOWN_S2_ID ;
        public static int AUDNZD_OCO3_EO5_DOWN_S2_ID ;
        public static int AUDNZD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool AUDNZD_OCO3_EO1_DOWN_S2 ;
        public static bool AUDNZD_OCO3_EO2_DOWN_S2 ;
        public static bool AUDNZD_OCO3_EO3_DOWN_S2 ;
        public static bool AUDNZD_OCO3_EO4_DOWN_S2 ;
        public static bool AUDNZD_OCO3_EO5_DOWN_S2 ;
        public static bool AUDNZD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_DOWN_S2> AUDNZD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_DOWN_S2> AUDNZD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_DOWN_S2> AUDNZD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_DOWN_S2> AUDNZD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_DOWN_S2> AUDNZD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO3_DOWN_S2> AUDNZD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static AUDNZD_OCO3_DOWN_S2 AUDNZD_PFO_OCO3_DOWN_S2_1 ;
        public static AUDNZD_OCO3_DOWN_S2 AUDNZD_PFO_OCO3_DOWN_S2_2 ;
        public static AUDNZD_OCO3_DOWN_S2 AUDNZD_PFO_OCO3_DOWN_S2_3 ;
        public static AUDNZD_OCO3_DOWN_S2 AUDNZD_PFO_OCO3_DOWN_S2_4 ;
        public static AUDNZD_OCO3_DOWN_S2 AUDNZD_PFO_OCO3_DOWN_S2_5 ;
        public static AUDNZD_OCO3_DOWN_S2 AUDNZD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<AUDNZD_OCO3_DOWN_S2> AUDNZD_DOWN_S2_OCO3Sets1 = new List<AUDNZD_OCO3_DOWN_S2>();
        public static List<AUDNZD_OCO3_DOWN_S2> AUDNZD_DOWN_S2_OCO3Sets2 = new List<AUDNZD_OCO3_DOWN_S2>();
        public static List<AUDNZD_OCO3_DOWN_S2> AUDNZD_DOWN_S2_OCO3Sets3 = new List<AUDNZD_OCO3_DOWN_S2>();
        public static List<AUDNZD_OCO3_DOWN_S2> AUDNZD_DOWN_S2_OCO3Sets4 = new List<AUDNZD_OCO3_DOWN_S2>();
        public static List<AUDNZD_OCO3_DOWN_S2> AUDNZD_DOWN_S2_OCO3Sets5 = new List<AUDNZD_OCO3_DOWN_S2>();
        public static List<AUDNZD_OCO3_DOWN_S2> AUDNZD_DOWN_S2_OCO3Sets6 = new List<AUDNZD_OCO3_DOWN_S2>();
        
        public static bool AUDNZD_OCO3_DOWN_S2_IsReady = true;
		public static bool AUDNZD_OCO3_DOWN_S2_Monthly_IsReady = true;
        
        //oco4 up
        public static OrderTicket AUDNZD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO6_UP_S2 ;
    	
    	public static int AUDNZD_OCO4_EO1_UP_S2_ID ;
        public static int AUDNZD_OCO4_EO2_UP_S2_ID ;
        public static int AUDNZD_OCO4_EO3_UP_S2_ID ;
        public static int AUDNZD_OCO4_EO4_UP_S2_ID ;
        public static int AUDNZD_OCO4_EO5_UP_S2_ID ;
        public static int AUDNZD_OCO4_EO6_UP_S2_ID ;
        
        public static bool AUDNZD_OCO4_EO1_UP_S2 ;
        public static bool AUDNZD_OCO4_EO2_UP_S2 ;
        public static bool AUDNZD_OCO4_EO3_UP_S2 ;
        public static bool AUDNZD_OCO4_EO4_UP_S2 ;
        public static bool AUDNZD_OCO4_EO5_UP_S2 ;
        public static bool AUDNZD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_UP_S2> AUDNZD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_UP_S2> AUDNZD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_UP_S2> AUDNZD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_UP_S2> AUDNZD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_UP_S2> AUDNZD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_UP_S2> AUDNZD_OOFE_OCO4_UP_S2_6 ;
        
        public static AUDNZD_OCO4_UP_S2 AUDNZD_PFO_OCO4_UP_S2_1 ;
        public static AUDNZD_OCO4_UP_S2 AUDNZD_PFO_OCO4_UP_S2_2 ;
        public static AUDNZD_OCO4_UP_S2 AUDNZD_PFO_OCO4_UP_S2_3 ;
        public static AUDNZD_OCO4_UP_S2 AUDNZD_PFO_OCO4_UP_S2_4 ;
        public static AUDNZD_OCO4_UP_S2 AUDNZD_PFO_OCO4_UP_S2_5 ;
        public static AUDNZD_OCO4_UP_S2 AUDNZD_PFO_OCO4_UP_S2_6 ;
        
        public static List<AUDNZD_OCO4_UP_S2> AUDNZD_UP_S2_OCO4Sets1 = new List<AUDNZD_OCO4_UP_S2>();
        public static List<AUDNZD_OCO4_UP_S2> AUDNZD_UP_S2_OCO4Sets2 = new List<AUDNZD_OCO4_UP_S2>();
        public static List<AUDNZD_OCO4_UP_S2> AUDNZD_UP_S2_OCO4Sets3 = new List<AUDNZD_OCO4_UP_S2>();
        public static List<AUDNZD_OCO4_UP_S2> AUDNZD_UP_S2_OCO4Sets4 = new List<AUDNZD_OCO4_UP_S2>();
        public static List<AUDNZD_OCO4_UP_S2> AUDNZD_UP_S2_OCO4Sets5 = new List<AUDNZD_OCO4_UP_S2>();
        public static List<AUDNZD_OCO4_UP_S2> AUDNZD_UP_S2_OCO4Sets6 = new List<AUDNZD_OCO4_UP_S2>();
        
        public static bool AUDNZD_OCO4_UP_S2_IsReady = true;
		public static bool AUDNZD_OCO4_UP_S2_Monthly_IsReady = true;
        
        //oco4 down
        public static OrderTicket AUDNZD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket AUDNZD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int AUDNZD_OCO4_EO1_DOWN_S2_ID ;
        public static int AUDNZD_OCO4_EO2_DOWN_S2_ID ;
        public static int AUDNZD_OCO4_EO3_DOWN_S2_ID ;
        public static int AUDNZD_OCO4_EO4_DOWN_S2_ID ;
        public static int AUDNZD_OCO4_EO5_DOWN_S2_ID ;
        public static int AUDNZD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool AUDNZD_OCO4_EO1_DOWN_S2 ;
        public static bool AUDNZD_OCO4_EO2_DOWN_S2 ;
        public static bool AUDNZD_OCO4_EO3_DOWN_S2 ;
        public static bool AUDNZD_OCO4_EO4_DOWN_S2 ;
        public static bool AUDNZD_OCO4_EO5_DOWN_S2 ;
        public static bool AUDNZD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_DOWN_S2> AUDNZD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_DOWN_S2> AUDNZD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_DOWN_S2> AUDNZD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_DOWN_S2> AUDNZD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_DOWN_S2> AUDNZD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDNZD_OCO4_DOWN_S2> AUDNZD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static AUDNZD_OCO4_DOWN_S2 AUDNZD_PFO_OCO4_DOWN_S2_1 ;
        public static AUDNZD_OCO4_DOWN_S2 AUDNZD_PFO_OCO4_DOWN_S2_2 ;
        public static AUDNZD_OCO4_DOWN_S2 AUDNZD_PFO_OCO4_DOWN_S2_3 ;
        public static AUDNZD_OCO4_DOWN_S2 AUDNZD_PFO_OCO4_DOWN_S2_4 ;
        public static AUDNZD_OCO4_DOWN_S2 AUDNZD_PFO_OCO4_DOWN_S2_5 ;
        public static AUDNZD_OCO4_DOWN_S2 AUDNZD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<AUDNZD_OCO4_DOWN_S2> AUDNZD_DOWN_S2_OCO4Sets1 = new List<AUDNZD_OCO4_DOWN_S2>();
        public static List<AUDNZD_OCO4_DOWN_S2> AUDNZD_DOWN_S2_OCO4Sets2 = new List<AUDNZD_OCO4_DOWN_S2>();
        public static List<AUDNZD_OCO4_DOWN_S2> AUDNZD_DOWN_S2_OCO4Sets3 = new List<AUDNZD_OCO4_DOWN_S2>();
        public static List<AUDNZD_OCO4_DOWN_S2> AUDNZD_DOWN_S2_OCO4Sets4 = new List<AUDNZD_OCO4_DOWN_S2>();
        public static List<AUDNZD_OCO4_DOWN_S2> AUDNZD_DOWN_S2_OCO4Sets5 = new List<AUDNZD_OCO4_DOWN_S2>();
        public static List<AUDNZD_OCO4_DOWN_S2> AUDNZD_DOWN_S2_OCO4Sets6 = new List<AUDNZD_OCO4_DOWN_S2>();
        
        public static bool AUDNZD_OCO4_DOWN_S2_IsReady = true;
		public static bool AUDNZD_OCO4_DOWN_S2_Monthly_IsReady = true;
        
        
////////////////////////////
		public static decimal AUDNZD_UP_S2_SL {get; set;}
		public static decimal AUDNZD_UP_S2_TP1 {get; set;}
		public static decimal AUDNZD_UP_S2_TP2 {get; set;}
		public static decimal AUDNZD_UP_S2_TP3 {get; set;}
		public static decimal AUDNZD_UP_S2_TP4 {get; set;}
		public static decimal AUDNZD_UP_S2_TP5 {get; set;}
		public static decimal AUDNZD_UP_S2_TP6 {get; set;}
		
		public static decimal AUDNZD_DOWN_S2_SL {get; set;}
		public static decimal AUDNZD_DOWN_S2_TP1 {get; set;}
		public static decimal AUDNZD_DOWN_S2_TP2 {get; set;}
		public static decimal AUDNZD_DOWN_S2_TP3 {get; set;}
		public static decimal AUDNZD_DOWN_S2_TP4 {get; set;}
		public static decimal AUDNZD_DOWN_S2_TP5 {get; set;}
		public static decimal AUDNZD_DOWN_S2_TP6 {get; set;}

        public static bool AUDNZD_Signal_Condition_UP_1 ;
        public static bool AUDNZD_Signal_Condition_UP_2 ;
        public static bool AUDNZD_Signal_Condition_UP_3 ;
        public static bool AUDNZD_Signal_Condition_DOWN_S2 ;
        
        public static int AUDNZD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int AUDNZD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDNZD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDNZD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDNZD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int AUDNZD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int AUDNZD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDNZD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDNZD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDNZD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_AUDNZD_UP_S2 ;
        public static bool DOWM_AUDNZD_UP_S2 ;
        public static bool DOWT_AUDNZD_UP_S2 ;
        public static bool DOWW_AUDNZD_UP_S2 ;
        public static bool DOWTH_AUDNZD_UP_S2 ;
        
		public static bool DOWR_AUDNZD_DOWN_S2 ;
        public static bool DOWM_AUDNZD_DOWN_S2 ;
        public static bool DOWT_AUDNZD_DOWN_S2 ;
        public static bool DOWW_AUDNZD_DOWN_S2 ;
        public static bool DOWTH_AUDNZD_DOWN_S2 ;
        
        
		public static int AUDNZD_quantity_UP_S2 ;
		public static int AUDNZD_quantity_SL_UP_S2 ;
		public static int AUDNZD_quantity_TP1_UP_S2 ;
		public static int AUDNZD_quantity_TP2_UP_S2 ;
		public static int AUDNZD_quantity_TP3_UP_S2 ;
		public static int AUDNZD_quantity_TP4_UP_S2 ;
		public static int AUDNZD_quantity_TP5_UP_S2;
		public static int AUDNZD_quantity_TP6_UP_S2 ;
		
		public static int AUDNZD_quantity_DOWN_S2 ;
		public static int AUDNZD_quantity_SL_DOWN_S2 ;
		public static int AUDNZD_quantity_TP1_DOWN_S2 ;
		public static int AUDNZD_quantity_TP2_DOWN_S2 ;
		public static int AUDNZD_quantity_TP3_DOWN_S2 ;
		public static int AUDNZD_quantity_TP4_DOWN_S2 ;
		public static int AUDNZD_quantity_TP5_DOWN_S2;
		public static int AUDNZD_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.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 _GBPCAD;
		
    	///oco1 up
    	public static OrderTicket GBPCAD_OCO1_MO1_UP_S2;
    	public static OrderTicket GBPCAD_OCO1_MO2_UP_S2;
    	public static OrderTicket GBPCAD_OCO1_MO3_UP_S2;
    	public static OrderTicket GBPCAD_OCO1_MO4_UP_S2;
    	public static OrderTicket GBPCAD_OCO1_MO5_UP_S2;
    	public static OrderTicket GBPCAD_OCO1_MO6_UP_S2;
    	
    	public static int GBPCAD_OCO1_EO1_UP_S2_ID ;
        public static int GBPCAD_OCO1_EO2_UP_S2_ID ;
        public static int GBPCAD_OCO1_EO3_UP_S2_ID ;
        public static int GBPCAD_OCO1_EO4_UP_S2_ID ;
        public static int GBPCAD_OCO1_EO5_UP_S2_ID ;
        public static int GBPCAD_OCO1_EO6_UP_S2_ID ;
        
        public static bool GBPCAD_OCO1_EO1_UP_S2 ;
        public static bool GBPCAD_OCO1_EO2_UP_S2 ;
        public static bool GBPCAD_OCO1_EO3_UP_S2 ;
        public static bool GBPCAD_OCO1_EO4_UP_S2 ;
        public static bool GBPCAD_OCO1_EO5_UP_S2 ;
        public static bool GBPCAD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_UP_S2> GBPCAD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_UP_S2> GBPCAD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_UP_S2> GBPCAD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_UP_S2> GBPCAD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_UP_S2> GBPCAD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_UP_S2> GBPCAD_OOFE_OCO1_UP_S2_6 ;
        
        public static GBPCAD_OCO1_UP_S2 GBPCAD_PFO_OCO1_UP_S2_1 ;
        public static GBPCAD_OCO1_UP_S2 GBPCAD_PFO_OCO1_UP_S2_2 ;
        public static GBPCAD_OCO1_UP_S2 GBPCAD_PFO_OCO1_UP_S2_3 ;
        public static GBPCAD_OCO1_UP_S2 GBPCAD_PFO_OCO1_UP_S2_4 ;
        public static GBPCAD_OCO1_UP_S2 GBPCAD_PFO_OCO1_UP_S2_5 ;
        public static GBPCAD_OCO1_UP_S2 GBPCAD_PFO_OCO1_UP_S2_6 ;
        
        public static List<GBPCAD_OCO1_UP_S2> GBPCAD_UP_S2_OCO1Sets1 = new List<GBPCAD_OCO1_UP_S2>();
        public static List<GBPCAD_OCO1_UP_S2> GBPCAD_UP_S2_OCO1Sets2 = new List<GBPCAD_OCO1_UP_S2>();
        public static List<GBPCAD_OCO1_UP_S2> GBPCAD_UP_S2_OCO1Sets3 = new List<GBPCAD_OCO1_UP_S2>();
        public static List<GBPCAD_OCO1_UP_S2> GBPCAD_UP_S2_OCO1Sets4 = new List<GBPCAD_OCO1_UP_S2>();
        public static List<GBPCAD_OCO1_UP_S2> GBPCAD_UP_S2_OCO1Sets5 = new List<GBPCAD_OCO1_UP_S2>();
        public static List<GBPCAD_OCO1_UP_S2> GBPCAD_UP_S2_OCO1Sets6 = new List<GBPCAD_OCO1_UP_S2>();
        
        public static bool GBPCAD_OCO1_UP_S2_IsReady = true;
		public static bool GBPCAD_OCO1_UP_S2_Monthly_IsReady = true;
        
        //oco1 down
		public static OrderTicket GBPCAD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int GBPCAD_OCO1_EO1_DOWN_S2_ID ;
        public static int GBPCAD_OCO1_EO2_DOWN_S2_ID ;
        public static int GBPCAD_OCO1_EO3_DOWN_S2_ID ;
        public static int GBPCAD_OCO1_EO4_DOWN_S2_ID ;
        public static int GBPCAD_OCO1_EO5_DOWN_S2_ID ;
        public static int GBPCAD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool GBPCAD_OCO1_EO1_DOWN_S2 ;
        public static bool GBPCAD_OCO1_EO2_DOWN_S2 ;
        public static bool GBPCAD_OCO1_EO3_DOWN_S2 ;
        public static bool GBPCAD_OCO1_EO4_DOWN_S2 ;
        public static bool GBPCAD_OCO1_EO5_DOWN_S2 ;
        public static bool GBPCAD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_DOWN_S2> GBPCAD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_DOWN_S2> GBPCAD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_DOWN_S2> GBPCAD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_DOWN_S2> GBPCAD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_DOWN_S2> GBPCAD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO1_DOWN_S2> GBPCAD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static GBPCAD_OCO1_DOWN_S2 GBPCAD_PFO_OCO1_DOWN_S2_1 ;
        public static GBPCAD_OCO1_DOWN_S2 GBPCAD_PFO_OCO1_DOWN_S2_2 ;
        public static GBPCAD_OCO1_DOWN_S2 GBPCAD_PFO_OCO1_DOWN_S2_3 ;
        public static GBPCAD_OCO1_DOWN_S2 GBPCAD_PFO_OCO1_DOWN_S2_4 ;
        public static GBPCAD_OCO1_DOWN_S2 GBPCAD_PFO_OCO1_DOWN_S2_5 ;
        public static GBPCAD_OCO1_DOWN_S2 GBPCAD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<GBPCAD_OCO1_DOWN_S2> GBPCAD_DOWN_S2_OCO1Sets1 = new List<GBPCAD_OCO1_DOWN_S2>();
        public static List<GBPCAD_OCO1_DOWN_S2> GBPCAD_DOWN_S2_OCO1Sets2 = new List<GBPCAD_OCO1_DOWN_S2>();
        public static List<GBPCAD_OCO1_DOWN_S2> GBPCAD_DOWN_S2_OCO1Sets3 = new List<GBPCAD_OCO1_DOWN_S2>();
        public static List<GBPCAD_OCO1_DOWN_S2> GBPCAD_DOWN_S2_OCO1Sets4 = new List<GBPCAD_OCO1_DOWN_S2>();
        public static List<GBPCAD_OCO1_DOWN_S2> GBPCAD_DOWN_S2_OCO1Sets5 = new List<GBPCAD_OCO1_DOWN_S2>();
        public static List<GBPCAD_OCO1_DOWN_S2> GBPCAD_DOWN_S2_OCO1Sets6 = new List<GBPCAD_OCO1_DOWN_S2>();
        
        public static bool GBPCAD_OCO1_DOWN_S2_IsReady = true;
		public static bool GBPCAD_OCO1_DOWN_S2_Monthly_IsReady = true;
        
        //oco2 up
        public static OrderTicket GBPCAD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO6_UP_S2 ;
    	
    	public static int GBPCAD_OCO2_EO1_UP_S2_ID ;
        public static int GBPCAD_OCO2_EO2_UP_S2_ID ;
        public static int GBPCAD_OCO2_EO3_UP_S2_ID ;
        public static int GBPCAD_OCO2_EO4_UP_S2_ID ;
        public static int GBPCAD_OCO2_EO5_UP_S2_ID ;
        public static int GBPCAD_OCO2_EO6_UP_S2_ID ;
        
        public static bool GBPCAD_OCO2_EO1_UP_S2 ;
        public static bool GBPCAD_OCO2_EO2_UP_S2 ;
        public static bool GBPCAD_OCO2_EO3_UP_S2 ;
        public static bool GBPCAD_OCO2_EO4_UP_S2 ;
        public static bool GBPCAD_OCO2_EO5_UP_S2 ;
        public static bool GBPCAD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_UP_S2> GBPCAD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_UP_S2> GBPCAD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_UP_S2> GBPCAD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_UP_S2> GBPCAD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_UP_S2> GBPCAD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_UP_S2> GBPCAD_OOFE_OCO2_UP_S2_6 ;
        
        public static GBPCAD_OCO2_UP_S2 GBPCAD_PFO_OCO2_UP_S2_1 ;
        public static GBPCAD_OCO2_UP_S2 GBPCAD_PFO_OCO2_UP_S2_2 ;
        public static GBPCAD_OCO2_UP_S2 GBPCAD_PFO_OCO2_UP_S2_3 ;
        public static GBPCAD_OCO2_UP_S2 GBPCAD_PFO_OCO2_UP_S2_4 ;
        public static GBPCAD_OCO2_UP_S2 GBPCAD_PFO_OCO2_UP_S2_5 ;
        public static GBPCAD_OCO2_UP_S2 GBPCAD_PFO_OCO2_UP_S2_6 ;
        
        public static List<GBPCAD_OCO2_UP_S2> GBPCAD_UP_S2_OCO2Sets1 = new List<GBPCAD_OCO2_UP_S2>();
        public static List<GBPCAD_OCO2_UP_S2> GBPCAD_UP_S2_OCO2Sets2 = new List<GBPCAD_OCO2_UP_S2>();
        public static List<GBPCAD_OCO2_UP_S2> GBPCAD_UP_S2_OCO2Sets3 = new List<GBPCAD_OCO2_UP_S2>();
        public static List<GBPCAD_OCO2_UP_S2> GBPCAD_UP_S2_OCO2Sets4 = new List<GBPCAD_OCO2_UP_S2>();
        public static List<GBPCAD_OCO2_UP_S2> GBPCAD_UP_S2_OCO2Sets5 = new List<GBPCAD_OCO2_UP_S2>();
        public static List<GBPCAD_OCO2_UP_S2> GBPCAD_UP_S2_OCO2Sets6 = new List<GBPCAD_OCO2_UP_S2>();
        
        public static bool GBPCAD_OCO2_UP_S2_IsReady = true;
		public static bool GBPCAD_OCO2_UP_S2_Monthly_IsReady = true;
        
        //oco2 down
        public static OrderTicket GBPCAD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int GBPCAD_OCO2_EO1_DOWN_S2_ID ;
        public static int GBPCAD_OCO2_EO2_DOWN_S2_ID ;
        public static int GBPCAD_OCO2_EO3_DOWN_S2_ID ;
        public static int GBPCAD_OCO2_EO4_DOWN_S2_ID ;
        public static int GBPCAD_OCO2_EO5_DOWN_S2_ID ;
        public static int GBPCAD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool GBPCAD_OCO2_EO1_DOWN_S2 ;
        public static bool GBPCAD_OCO2_EO2_DOWN_S2 ;
        public static bool GBPCAD_OCO2_EO3_DOWN_S2 ;
        public static bool GBPCAD_OCO2_EO4_DOWN_S2 ;
        public static bool GBPCAD_OCO2_EO5_DOWN_S2 ;
        public static bool GBPCAD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_DOWN_S2> GBPCAD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_DOWN_S2> GBPCAD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_DOWN_S2> GBPCAD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_DOWN_S2> GBPCAD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_DOWN_S2> GBPCAD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO2_DOWN_S2> GBPCAD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static GBPCAD_OCO2_DOWN_S2 GBPCAD_PFO_OCO2_DOWN_S2_1 ;
        public static GBPCAD_OCO2_DOWN_S2 GBPCAD_PFO_OCO2_DOWN_S2_2 ;
        public static GBPCAD_OCO2_DOWN_S2 GBPCAD_PFO_OCO2_DOWN_S2_3 ;
        public static GBPCAD_OCO2_DOWN_S2 GBPCAD_PFO_OCO2_DOWN_S2_4 ;
        public static GBPCAD_OCO2_DOWN_S2 GBPCAD_PFO_OCO2_DOWN_S2_5 ;
        public static GBPCAD_OCO2_DOWN_S2 GBPCAD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<GBPCAD_OCO2_DOWN_S2> GBPCAD_DOWN_S2_OCO2Sets1 = new List<GBPCAD_OCO2_DOWN_S2>();
        public static List<GBPCAD_OCO2_DOWN_S2> GBPCAD_DOWN_S2_OCO2Sets2 = new List<GBPCAD_OCO2_DOWN_S2>();
        public static List<GBPCAD_OCO2_DOWN_S2> GBPCAD_DOWN_S2_OCO2Sets3 = new List<GBPCAD_OCO2_DOWN_S2>();
        public static List<GBPCAD_OCO2_DOWN_S2> GBPCAD_DOWN_S2_OCO2Sets4 = new List<GBPCAD_OCO2_DOWN_S2>();
        public static List<GBPCAD_OCO2_DOWN_S2> GBPCAD_DOWN_S2_OCO2Sets5 = new List<GBPCAD_OCO2_DOWN_S2>();
        public static List<GBPCAD_OCO2_DOWN_S2> GBPCAD_DOWN_S2_OCO2Sets6 = new List<GBPCAD_OCO2_DOWN_S2>();
        
        public static bool GBPCAD_OCO2_DOWN_S2_IsReady = true;
		public static bool GBPCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
        
        //oco3 up
        public static OrderTicket GBPCAD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO6_UP_S2 ;
    	
    	public static int GBPCAD_OCO3_EO1_UP_S2_ID ;
        public static int GBPCAD_OCO3_EO2_UP_S2_ID ;
        public static int GBPCAD_OCO3_EO3_UP_S2_ID ;
        public static int GBPCAD_OCO3_EO4_UP_S2_ID ;
        public static int GBPCAD_OCO3_EO5_UP_S2_ID ;
        public static int GBPCAD_OCO3_EO6_UP_S2_ID ;
        
        public static bool GBPCAD_OCO3_EO1_UP_S2 ;
        public static bool GBPCAD_OCO3_EO2_UP_S2 ;
        public static bool GBPCAD_OCO3_EO3_UP_S2 ;
        public static bool GBPCAD_OCO3_EO4_UP_S2 ;
        public static bool GBPCAD_OCO3_EO5_UP_S2 ;
        public static bool GBPCAD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_UP_S2> GBPCAD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_UP_S2> GBPCAD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_UP_S2> GBPCAD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_UP_S2> GBPCAD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_UP_S2> GBPCAD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_UP_S2> GBPCAD_OOFE_OCO3_UP_S2_6 ;
        
        public static GBPCAD_OCO3_UP_S2 GBPCAD_PFO_OCO3_UP_S2_1 ;
        public static GBPCAD_OCO3_UP_S2 GBPCAD_PFO_OCO3_UP_S2_2 ;
        public static GBPCAD_OCO3_UP_S2 GBPCAD_PFO_OCO3_UP_S2_3 ;
        public static GBPCAD_OCO3_UP_S2 GBPCAD_PFO_OCO3_UP_S2_4 ;
        public static GBPCAD_OCO3_UP_S2 GBPCAD_PFO_OCO3_UP_S2_5 ;
        public static GBPCAD_OCO3_UP_S2 GBPCAD_PFO_OCO3_UP_S2_6 ;
        
        public static List<GBPCAD_OCO3_UP_S2> GBPCAD_UP_S2_OCO3Sets1 = new List<GBPCAD_OCO3_UP_S2>();
        public static List<GBPCAD_OCO3_UP_S2> GBPCAD_UP_S2_OCO3Sets2 = new List<GBPCAD_OCO3_UP_S2>();
        public static List<GBPCAD_OCO3_UP_S2> GBPCAD_UP_S2_OCO3Sets3 = new List<GBPCAD_OCO3_UP_S2>();
        public static List<GBPCAD_OCO3_UP_S2> GBPCAD_UP_S2_OCO3Sets4 = new List<GBPCAD_OCO3_UP_S2>();
        public static List<GBPCAD_OCO3_UP_S2> GBPCAD_UP_S2_OCO3Sets5 = new List<GBPCAD_OCO3_UP_S2>();
        public static List<GBPCAD_OCO3_UP_S2> GBPCAD_UP_S2_OCO3Sets6 = new List<GBPCAD_OCO3_UP_S2>();
        
        public static bool GBPCAD_OCO3_UP_S2_IsReady = true;
		public static bool GBPCAD_OCO3_UP_S2_Monthly_IsReady = true;
        
        //oco3 down
        public static OrderTicket GBPCAD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int GBPCAD_OCO3_EO1_DOWN_S2_ID ;
        public static int GBPCAD_OCO3_EO2_DOWN_S2_ID ;
        public static int GBPCAD_OCO3_EO3_DOWN_S2_ID ;
        public static int GBPCAD_OCO3_EO4_DOWN_S2_ID ;
        public static int GBPCAD_OCO3_EO5_DOWN_S2_ID ;
        public static int GBPCAD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool GBPCAD_OCO3_EO1_DOWN_S2 ;
        public static bool GBPCAD_OCO3_EO2_DOWN_S2 ;
        public static bool GBPCAD_OCO3_EO3_DOWN_S2 ;
        public static bool GBPCAD_OCO3_EO4_DOWN_S2 ;
        public static bool GBPCAD_OCO3_EO5_DOWN_S2 ;
        public static bool GBPCAD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_DOWN_S2> GBPCAD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_DOWN_S2> GBPCAD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_DOWN_S2> GBPCAD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_DOWN_S2> GBPCAD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_DOWN_S2> GBPCAD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO3_DOWN_S2> GBPCAD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static GBPCAD_OCO3_DOWN_S2 GBPCAD_PFO_OCO3_DOWN_S2_1 ;
        public static GBPCAD_OCO3_DOWN_S2 GBPCAD_PFO_OCO3_DOWN_S2_2 ;
        public static GBPCAD_OCO3_DOWN_S2 GBPCAD_PFO_OCO3_DOWN_S2_3 ;
        public static GBPCAD_OCO3_DOWN_S2 GBPCAD_PFO_OCO3_DOWN_S2_4 ;
        public static GBPCAD_OCO3_DOWN_S2 GBPCAD_PFO_OCO3_DOWN_S2_5 ;
        public static GBPCAD_OCO3_DOWN_S2 GBPCAD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<GBPCAD_OCO3_DOWN_S2> GBPCAD_DOWN_S2_OCO3Sets1 = new List<GBPCAD_OCO3_DOWN_S2>();
        public static List<GBPCAD_OCO3_DOWN_S2> GBPCAD_DOWN_S2_OCO3Sets2 = new List<GBPCAD_OCO3_DOWN_S2>();
        public static List<GBPCAD_OCO3_DOWN_S2> GBPCAD_DOWN_S2_OCO3Sets3 = new List<GBPCAD_OCO3_DOWN_S2>();
        public static List<GBPCAD_OCO3_DOWN_S2> GBPCAD_DOWN_S2_OCO3Sets4 = new List<GBPCAD_OCO3_DOWN_S2>();
        public static List<GBPCAD_OCO3_DOWN_S2> GBPCAD_DOWN_S2_OCO3Sets5 = new List<GBPCAD_OCO3_DOWN_S2>();
        public static List<GBPCAD_OCO3_DOWN_S2> GBPCAD_DOWN_S2_OCO3Sets6 = new List<GBPCAD_OCO3_DOWN_S2>();
        
        public static bool GBPCAD_OCO3_DOWN_S2_IsReady = true;
		public static bool GBPCAD_OCO3_DOWN_S2_Monthly_IsReady = true;
        
        //oco4 up
        public static OrderTicket GBPCAD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO6_UP_S2 ;
    	
    	public static int GBPCAD_OCO4_EO1_UP_S2_ID ;
        public static int GBPCAD_OCO4_EO2_UP_S2_ID ;
        public static int GBPCAD_OCO4_EO3_UP_S2_ID ;
        public static int GBPCAD_OCO4_EO4_UP_S2_ID ;
        public static int GBPCAD_OCO4_EO5_UP_S2_ID ;
        public static int GBPCAD_OCO4_EO6_UP_S2_ID ;
        
        public static bool GBPCAD_OCO4_EO1_UP_S2 ;
        public static bool GBPCAD_OCO4_EO2_UP_S2 ;
        public static bool GBPCAD_OCO4_EO3_UP_S2 ;
        public static bool GBPCAD_OCO4_EO4_UP_S2 ;
        public static bool GBPCAD_OCO4_EO5_UP_S2 ;
        public static bool GBPCAD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_UP_S2> GBPCAD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_UP_S2> GBPCAD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_UP_S2> GBPCAD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_UP_S2> GBPCAD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_UP_S2> GBPCAD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_UP_S2> GBPCAD_OOFE_OCO4_UP_S2_6 ;
        
        public static GBPCAD_OCO4_UP_S2 GBPCAD_PFO_OCO4_UP_S2_1 ;
        public static GBPCAD_OCO4_UP_S2 GBPCAD_PFO_OCO4_UP_S2_2 ;
        public static GBPCAD_OCO4_UP_S2 GBPCAD_PFO_OCO4_UP_S2_3 ;
        public static GBPCAD_OCO4_UP_S2 GBPCAD_PFO_OCO4_UP_S2_4 ;
        public static GBPCAD_OCO4_UP_S2 GBPCAD_PFO_OCO4_UP_S2_5 ;
        public static GBPCAD_OCO4_UP_S2 GBPCAD_PFO_OCO4_UP_S2_6 ;
        
        public static List<GBPCAD_OCO4_UP_S2> GBPCAD_UP_S2_OCO4Sets1 = new List<GBPCAD_OCO4_UP_S2>();
        public static List<GBPCAD_OCO4_UP_S2> GBPCAD_UP_S2_OCO4Sets2 = new List<GBPCAD_OCO4_UP_S2>();
        public static List<GBPCAD_OCO4_UP_S2> GBPCAD_UP_S2_OCO4Sets3 = new List<GBPCAD_OCO4_UP_S2>();
        public static List<GBPCAD_OCO4_UP_S2> GBPCAD_UP_S2_OCO4Sets4 = new List<GBPCAD_OCO4_UP_S2>();
        public static List<GBPCAD_OCO4_UP_S2> GBPCAD_UP_S2_OCO4Sets5 = new List<GBPCAD_OCO4_UP_S2>();
        public static List<GBPCAD_OCO4_UP_S2> GBPCAD_UP_S2_OCO4Sets6 = new List<GBPCAD_OCO4_UP_S2>();
        
        public static bool GBPCAD_OCO4_UP_S2_IsReady = true;
		public static bool GBPCAD_OCO4_UP_S2_Monthly_IsReady = true;
        
        //oco4 down
        public static OrderTicket GBPCAD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket GBPCAD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int GBPCAD_OCO4_EO1_DOWN_S2_ID ;
        public static int GBPCAD_OCO4_EO2_DOWN_S2_ID ;
        public static int GBPCAD_OCO4_EO3_DOWN_S2_ID ;
        public static int GBPCAD_OCO4_EO4_DOWN_S2_ID ;
        public static int GBPCAD_OCO4_EO5_DOWN_S2_ID ;
        public static int GBPCAD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool GBPCAD_OCO4_EO1_DOWN_S2 ;
        public static bool GBPCAD_OCO4_EO2_DOWN_S2 ;
        public static bool GBPCAD_OCO4_EO3_DOWN_S2 ;
        public static bool GBPCAD_OCO4_EO4_DOWN_S2 ;
        public static bool GBPCAD_OCO4_EO5_DOWN_S2 ;
        public static bool GBPCAD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_DOWN_S2> GBPCAD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_DOWN_S2> GBPCAD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_DOWN_S2> GBPCAD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_DOWN_S2> GBPCAD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_DOWN_S2> GBPCAD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPCAD_OCO4_DOWN_S2> GBPCAD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static GBPCAD_OCO4_DOWN_S2 GBPCAD_PFO_OCO4_DOWN_S2_1 ;
        public static GBPCAD_OCO4_DOWN_S2 GBPCAD_PFO_OCO4_DOWN_S2_2 ;
        public static GBPCAD_OCO4_DOWN_S2 GBPCAD_PFO_OCO4_DOWN_S2_3 ;
        public static GBPCAD_OCO4_DOWN_S2 GBPCAD_PFO_OCO4_DOWN_S2_4 ;
        public static GBPCAD_OCO4_DOWN_S2 GBPCAD_PFO_OCO4_DOWN_S2_5 ;
        public static GBPCAD_OCO4_DOWN_S2 GBPCAD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<GBPCAD_OCO4_DOWN_S2> GBPCAD_DOWN_S2_OCO4Sets1 = new List<GBPCAD_OCO4_DOWN_S2>();
        public static List<GBPCAD_OCO4_DOWN_S2> GBPCAD_DOWN_S2_OCO4Sets2 = new List<GBPCAD_OCO4_DOWN_S2>();
        public static List<GBPCAD_OCO4_DOWN_S2> GBPCAD_DOWN_S2_OCO4Sets3 = new List<GBPCAD_OCO4_DOWN_S2>();
        public static List<GBPCAD_OCO4_DOWN_S2> GBPCAD_DOWN_S2_OCO4Sets4 = new List<GBPCAD_OCO4_DOWN_S2>();
        public static List<GBPCAD_OCO4_DOWN_S2> GBPCAD_DOWN_S2_OCO4Sets5 = new List<GBPCAD_OCO4_DOWN_S2>();
        public static List<GBPCAD_OCO4_DOWN_S2> GBPCAD_DOWN_S2_OCO4Sets6 = new List<GBPCAD_OCO4_DOWN_S2>();
        
        public static bool GBPCAD_OCO4_DOWN_S2_IsReady = true;
		public static bool GBPCAD_OCO4_DOWN_S2_Monthly_IsReady = true;
        
        
////////////////////////////
		public static decimal GBPCAD_UP_S2_SL {get; set;}
		public static decimal GBPCAD_UP_S2_TP1 {get; set;}
		public static decimal GBPCAD_UP_S2_TP2 {get; set;}
		public static decimal GBPCAD_UP_S2_TP3 {get; set;}
		public static decimal GBPCAD_UP_S2_TP4 {get; set;}
		public static decimal GBPCAD_UP_S2_TP5 {get; set;}
		public static decimal GBPCAD_UP_S2_TP6 {get; set;}
		
		public static decimal GBPCAD_DOWN_S2_SL {get; set;}
		public static decimal GBPCAD_DOWN_S2_TP1 {get; set;}
		public static decimal GBPCAD_DOWN_S2_TP2 {get; set;}
		public static decimal GBPCAD_DOWN_S2_TP3 {get; set;}
		public static decimal GBPCAD_DOWN_S2_TP4 {get; set;}
		public static decimal GBPCAD_DOWN_S2_TP5 {get; set;}
		public static decimal GBPCAD_DOWN_S2_TP6 {get; set;}

        public static bool GBPCAD_Signal_Condition_UP_1 ;
        public static bool GBPCAD_Signal_Condition_UP_2 ;
        public static bool GBPCAD_Signal_Condition_UP_3 ;
        public static bool GBPCAD_Signal_Condition_DOWN_S2 ;
        
        public static int GBPCAD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int GBPCAD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPCAD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPCAD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPCAD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int GBPCAD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int GBPCAD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPCAD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPCAD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPCAD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_GBPCAD_UP_S2 ;
        public static bool DOWM_GBPCAD_UP_S2 ;
        public static bool DOWT_GBPCAD_UP_S2 ;
        public static bool DOWW_GBPCAD_UP_S2 ;
        public static bool DOWTH_GBPCAD_UP_S2 ;
        
		public static bool DOWR_GBPCAD_DOWN_S2 ;
        public static bool DOWM_GBPCAD_DOWN_S2 ;
        public static bool DOWT_GBPCAD_DOWN_S2 ;
        public static bool DOWW_GBPCAD_DOWN_S2 ;
        public static bool DOWTH_GBPCAD_DOWN_S2 ;
        
        
		public static int GBPCAD_quantity_UP_S2 ;
		public static int GBPCAD_quantity_SL_UP_S2 ;
		public static int GBPCAD_quantity_TP1_UP_S2 ;
		public static int GBPCAD_quantity_TP2_UP_S2 ;
		public static int GBPCAD_quantity_TP3_UP_S2 ;
		public static int GBPCAD_quantity_TP4_UP_S2 ;
		public static int GBPCAD_quantity_TP5_UP_S2;
		public static int GBPCAD_quantity_TP6_UP_S2 ;
		
		public static int GBPCAD_quantity_DOWN_S2 ;
		public static int GBPCAD_quantity_SL_DOWN_S2 ;
		public static int GBPCAD_quantity_TP1_DOWN_S2 ;
		public static int GBPCAD_quantity_TP2_DOWN_S2 ;
		public static int GBPCAD_quantity_TP3_DOWN_S2 ;
		public static int GBPCAD_quantity_TP4_DOWN_S2 ;
		public static int GBPCAD_quantity_TP5_DOWN_S2;
		public static int GBPCAD_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.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 _GBPAUD;
		
    	///oco1 up
    	public static OrderTicket GBPAUD_OCO1_MO1_UP_S2;
    	public static OrderTicket GBPAUD_OCO1_MO2_UP_S2;
    	public static OrderTicket GBPAUD_OCO1_MO3_UP_S2;
    	public static OrderTicket GBPAUD_OCO1_MO4_UP_S2;
    	public static OrderTicket GBPAUD_OCO1_MO5_UP_S2;
    	public static OrderTicket GBPAUD_OCO1_MO6_UP_S2;
    	
    	public static int GBPAUD_OCO1_EO1_UP_S2_ID ;
        public static int GBPAUD_OCO1_EO2_UP_S2_ID ;
        public static int GBPAUD_OCO1_EO3_UP_S2_ID ;
        public static int GBPAUD_OCO1_EO4_UP_S2_ID ;
        public static int GBPAUD_OCO1_EO5_UP_S2_ID ;
        public static int GBPAUD_OCO1_EO6_UP_S2_ID ;
        
        public static bool GBPAUD_OCO1_EO1_UP_S2 ;
        public static bool GBPAUD_OCO1_EO2_UP_S2 ;
        public static bool GBPAUD_OCO1_EO3_UP_S2 ;
        public static bool GBPAUD_OCO1_EO4_UP_S2 ;
        public static bool GBPAUD_OCO1_EO5_UP_S2 ;
        public static bool GBPAUD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_UP_S2> GBPAUD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_UP_S2> GBPAUD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_UP_S2> GBPAUD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_UP_S2> GBPAUD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_UP_S2> GBPAUD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_UP_S2> GBPAUD_OOFE_OCO1_UP_S2_6 ;
        
        public static GBPAUD_OCO1_UP_S2 GBPAUD_PFO_OCO1_UP_S2_1 ;
        public static GBPAUD_OCO1_UP_S2 GBPAUD_PFO_OCO1_UP_S2_2 ;
        public static GBPAUD_OCO1_UP_S2 GBPAUD_PFO_OCO1_UP_S2_3 ;
        public static GBPAUD_OCO1_UP_S2 GBPAUD_PFO_OCO1_UP_S2_4 ;
        public static GBPAUD_OCO1_UP_S2 GBPAUD_PFO_OCO1_UP_S2_5 ;
        public static GBPAUD_OCO1_UP_S2 GBPAUD_PFO_OCO1_UP_S2_6 ;
        
        public static List<GBPAUD_OCO1_UP_S2> GBPAUD_UP_S2_OCO1Sets1 = new List<GBPAUD_OCO1_UP_S2>();
        public static List<GBPAUD_OCO1_UP_S2> GBPAUD_UP_S2_OCO1Sets2 = new List<GBPAUD_OCO1_UP_S2>();
        public static List<GBPAUD_OCO1_UP_S2> GBPAUD_UP_S2_OCO1Sets3 = new List<GBPAUD_OCO1_UP_S2>();
        public static List<GBPAUD_OCO1_UP_S2> GBPAUD_UP_S2_OCO1Sets4 = new List<GBPAUD_OCO1_UP_S2>();
        public static List<GBPAUD_OCO1_UP_S2> GBPAUD_UP_S2_OCO1Sets5 = new List<GBPAUD_OCO1_UP_S2>();
        public static List<GBPAUD_OCO1_UP_S2> GBPAUD_UP_S2_OCO1Sets6 = new List<GBPAUD_OCO1_UP_S2>();
        
        public static bool GBPAUD_OCO1_UP_S2_IsReady = true;
		public static bool GBPAUD_OCO1_UP_S2_Monthly_IsReady = true;
        
        //oco1 down
		public static OrderTicket GBPAUD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int GBPAUD_OCO1_EO1_DOWN_S2_ID ;
        public static int GBPAUD_OCO1_EO2_DOWN_S2_ID ;
        public static int GBPAUD_OCO1_EO3_DOWN_S2_ID ;
        public static int GBPAUD_OCO1_EO4_DOWN_S2_ID ;
        public static int GBPAUD_OCO1_EO5_DOWN_S2_ID ;
        public static int GBPAUD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool GBPAUD_OCO1_EO1_DOWN_S2 ;
        public static bool GBPAUD_OCO1_EO2_DOWN_S2 ;
        public static bool GBPAUD_OCO1_EO3_DOWN_S2 ;
        public static bool GBPAUD_OCO1_EO4_DOWN_S2 ;
        public static bool GBPAUD_OCO1_EO5_DOWN_S2 ;
        public static bool GBPAUD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_DOWN_S2> GBPAUD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_DOWN_S2> GBPAUD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_DOWN_S2> GBPAUD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_DOWN_S2> GBPAUD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_DOWN_S2> GBPAUD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO1_DOWN_S2> GBPAUD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static GBPAUD_OCO1_DOWN_S2 GBPAUD_PFO_OCO1_DOWN_S2_1 ;
        public static GBPAUD_OCO1_DOWN_S2 GBPAUD_PFO_OCO1_DOWN_S2_2 ;
        public static GBPAUD_OCO1_DOWN_S2 GBPAUD_PFO_OCO1_DOWN_S2_3 ;
        public static GBPAUD_OCO1_DOWN_S2 GBPAUD_PFO_OCO1_DOWN_S2_4 ;
        public static GBPAUD_OCO1_DOWN_S2 GBPAUD_PFO_OCO1_DOWN_S2_5 ;
        public static GBPAUD_OCO1_DOWN_S2 GBPAUD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<GBPAUD_OCO1_DOWN_S2> GBPAUD_DOWN_S2_OCO1Sets1 = new List<GBPAUD_OCO1_DOWN_S2>();
        public static List<GBPAUD_OCO1_DOWN_S2> GBPAUD_DOWN_S2_OCO1Sets2 = new List<GBPAUD_OCO1_DOWN_S2>();
        public static List<GBPAUD_OCO1_DOWN_S2> GBPAUD_DOWN_S2_OCO1Sets3 = new List<GBPAUD_OCO1_DOWN_S2>();
        public static List<GBPAUD_OCO1_DOWN_S2> GBPAUD_DOWN_S2_OCO1Sets4 = new List<GBPAUD_OCO1_DOWN_S2>();
        public static List<GBPAUD_OCO1_DOWN_S2> GBPAUD_DOWN_S2_OCO1Sets5 = new List<GBPAUD_OCO1_DOWN_S2>();
        public static List<GBPAUD_OCO1_DOWN_S2> GBPAUD_DOWN_S2_OCO1Sets6 = new List<GBPAUD_OCO1_DOWN_S2>();
        
        public static bool GBPAUD_OCO1_DOWN_S2_IsReady = true;
		public static bool GBPAUD_OCO1_DOWN_S2_Monthly_IsReady = true;
        
        //oco2 up
        public static OrderTicket GBPAUD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO6_UP_S2 ;
    	
    	public static int GBPAUD_OCO2_EO1_UP_S2_ID ;
        public static int GBPAUD_OCO2_EO2_UP_S2_ID ;
        public static int GBPAUD_OCO2_EO3_UP_S2_ID ;
        public static int GBPAUD_OCO2_EO4_UP_S2_ID ;
        public static int GBPAUD_OCO2_EO5_UP_S2_ID ;
        public static int GBPAUD_OCO2_EO6_UP_S2_ID ;
        
        public static bool GBPAUD_OCO2_EO1_UP_S2 ;
        public static bool GBPAUD_OCO2_EO2_UP_S2 ;
        public static bool GBPAUD_OCO2_EO3_UP_S2 ;
        public static bool GBPAUD_OCO2_EO4_UP_S2 ;
        public static bool GBPAUD_OCO2_EO5_UP_S2 ;
        public static bool GBPAUD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_UP_S2> GBPAUD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_UP_S2> GBPAUD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_UP_S2> GBPAUD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_UP_S2> GBPAUD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_UP_S2> GBPAUD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_UP_S2> GBPAUD_OOFE_OCO2_UP_S2_6 ;
        
        public static GBPAUD_OCO2_UP_S2 GBPAUD_PFO_OCO2_UP_S2_1 ;
        public static GBPAUD_OCO2_UP_S2 GBPAUD_PFO_OCO2_UP_S2_2 ;
        public static GBPAUD_OCO2_UP_S2 GBPAUD_PFO_OCO2_UP_S2_3 ;
        public static GBPAUD_OCO2_UP_S2 GBPAUD_PFO_OCO2_UP_S2_4 ;
        public static GBPAUD_OCO2_UP_S2 GBPAUD_PFO_OCO2_UP_S2_5 ;
        public static GBPAUD_OCO2_UP_S2 GBPAUD_PFO_OCO2_UP_S2_6 ;
        
        public static List<GBPAUD_OCO2_UP_S2> GBPAUD_UP_S2_OCO2Sets1 = new List<GBPAUD_OCO2_UP_S2>();
        public static List<GBPAUD_OCO2_UP_S2> GBPAUD_UP_S2_OCO2Sets2 = new List<GBPAUD_OCO2_UP_S2>();
        public static List<GBPAUD_OCO2_UP_S2> GBPAUD_UP_S2_OCO2Sets3 = new List<GBPAUD_OCO2_UP_S2>();
        public static List<GBPAUD_OCO2_UP_S2> GBPAUD_UP_S2_OCO2Sets4 = new List<GBPAUD_OCO2_UP_S2>();
        public static List<GBPAUD_OCO2_UP_S2> GBPAUD_UP_S2_OCO2Sets5 = new List<GBPAUD_OCO2_UP_S2>();
        public static List<GBPAUD_OCO2_UP_S2> GBPAUD_UP_S2_OCO2Sets6 = new List<GBPAUD_OCO2_UP_S2>();
        
        public static bool GBPAUD_OCO2_UP_S2_IsReady = true;
		public static bool GBPAUD_OCO2_UP_S2_Monthly_IsReady = true;
        
        //oco2 down
        public static OrderTicket GBPAUD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int GBPAUD_OCO2_EO1_DOWN_S2_ID ;
        public static int GBPAUD_OCO2_EO2_DOWN_S2_ID ;
        public static int GBPAUD_OCO2_EO3_DOWN_S2_ID ;
        public static int GBPAUD_OCO2_EO4_DOWN_S2_ID ;
        public static int GBPAUD_OCO2_EO5_DOWN_S2_ID ;
        public static int GBPAUD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool GBPAUD_OCO2_EO1_DOWN_S2 ;
        public static bool GBPAUD_OCO2_EO2_DOWN_S2 ;
        public static bool GBPAUD_OCO2_EO3_DOWN_S2 ;
        public static bool GBPAUD_OCO2_EO4_DOWN_S2 ;
        public static bool GBPAUD_OCO2_EO5_DOWN_S2 ;
        public static bool GBPAUD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_DOWN_S2> GBPAUD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_DOWN_S2> GBPAUD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_DOWN_S2> GBPAUD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_DOWN_S2> GBPAUD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_DOWN_S2> GBPAUD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO2_DOWN_S2> GBPAUD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static GBPAUD_OCO2_DOWN_S2 GBPAUD_PFO_OCO2_DOWN_S2_1 ;
        public static GBPAUD_OCO2_DOWN_S2 GBPAUD_PFO_OCO2_DOWN_S2_2 ;
        public static GBPAUD_OCO2_DOWN_S2 GBPAUD_PFO_OCO2_DOWN_S2_3 ;
        public static GBPAUD_OCO2_DOWN_S2 GBPAUD_PFO_OCO2_DOWN_S2_4 ;
        public static GBPAUD_OCO2_DOWN_S2 GBPAUD_PFO_OCO2_DOWN_S2_5 ;
        public static GBPAUD_OCO2_DOWN_S2 GBPAUD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<GBPAUD_OCO2_DOWN_S2> GBPAUD_DOWN_S2_OCO2Sets1 = new List<GBPAUD_OCO2_DOWN_S2>();
        public static List<GBPAUD_OCO2_DOWN_S2> GBPAUD_DOWN_S2_OCO2Sets2 = new List<GBPAUD_OCO2_DOWN_S2>();
        public static List<GBPAUD_OCO2_DOWN_S2> GBPAUD_DOWN_S2_OCO2Sets3 = new List<GBPAUD_OCO2_DOWN_S2>();
        public static List<GBPAUD_OCO2_DOWN_S2> GBPAUD_DOWN_S2_OCO2Sets4 = new List<GBPAUD_OCO2_DOWN_S2>();
        public static List<GBPAUD_OCO2_DOWN_S2> GBPAUD_DOWN_S2_OCO2Sets5 = new List<GBPAUD_OCO2_DOWN_S2>();
        public static List<GBPAUD_OCO2_DOWN_S2> GBPAUD_DOWN_S2_OCO2Sets6 = new List<GBPAUD_OCO2_DOWN_S2>();
        
        public static bool GBPAUD_OCO2_DOWN_S2_IsReady = true;
		public static bool GBPAUD_OCO2_DOWN_S2_Monthly_IsReady = true;
        
        //oco3 up
        public static OrderTicket GBPAUD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO6_UP_S2 ;
    	
    	public static int GBPAUD_OCO3_EO1_UP_S2_ID ;
        public static int GBPAUD_OCO3_EO2_UP_S2_ID ;
        public static int GBPAUD_OCO3_EO3_UP_S2_ID ;
        public static int GBPAUD_OCO3_EO4_UP_S2_ID ;
        public static int GBPAUD_OCO3_EO5_UP_S2_ID ;
        public static int GBPAUD_OCO3_EO6_UP_S2_ID ;
        
        public static bool GBPAUD_OCO3_EO1_UP_S2 ;
        public static bool GBPAUD_OCO3_EO2_UP_S2 ;
        public static bool GBPAUD_OCO3_EO3_UP_S2 ;
        public static bool GBPAUD_OCO3_EO4_UP_S2 ;
        public static bool GBPAUD_OCO3_EO5_UP_S2 ;
        public static bool GBPAUD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_UP_S2> GBPAUD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_UP_S2> GBPAUD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_UP_S2> GBPAUD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_UP_S2> GBPAUD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_UP_S2> GBPAUD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_UP_S2> GBPAUD_OOFE_OCO3_UP_S2_6 ;
        
        public static GBPAUD_OCO3_UP_S2 GBPAUD_PFO_OCO3_UP_S2_1 ;
        public static GBPAUD_OCO3_UP_S2 GBPAUD_PFO_OCO3_UP_S2_2 ;
        public static GBPAUD_OCO3_UP_S2 GBPAUD_PFO_OCO3_UP_S2_3 ;
        public static GBPAUD_OCO3_UP_S2 GBPAUD_PFO_OCO3_UP_S2_4 ;
        public static GBPAUD_OCO3_UP_S2 GBPAUD_PFO_OCO3_UP_S2_5 ;
        public static GBPAUD_OCO3_UP_S2 GBPAUD_PFO_OCO3_UP_S2_6 ;
        
        public static List<GBPAUD_OCO3_UP_S2> GBPAUD_UP_S2_OCO3Sets1 = new List<GBPAUD_OCO3_UP_S2>();
        public static List<GBPAUD_OCO3_UP_S2> GBPAUD_UP_S2_OCO3Sets2 = new List<GBPAUD_OCO3_UP_S2>();
        public static List<GBPAUD_OCO3_UP_S2> GBPAUD_UP_S2_OCO3Sets3 = new List<GBPAUD_OCO3_UP_S2>();
        public static List<GBPAUD_OCO3_UP_S2> GBPAUD_UP_S2_OCO3Sets4 = new List<GBPAUD_OCO3_UP_S2>();
        public static List<GBPAUD_OCO3_UP_S2> GBPAUD_UP_S2_OCO3Sets5 = new List<GBPAUD_OCO3_UP_S2>();
        public static List<GBPAUD_OCO3_UP_S2> GBPAUD_UP_S2_OCO3Sets6 = new List<GBPAUD_OCO3_UP_S2>();
        
        public static bool GBPAUD_OCO3_UP_S2_IsReady = true;
		public static bool GBPAUD_OCO3_UP_S2_Monthly_IsReady = true;
        
        //oco3 down
        public static OrderTicket GBPAUD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int GBPAUD_OCO3_EO1_DOWN_S2_ID ;
        public static int GBPAUD_OCO3_EO2_DOWN_S2_ID ;
        public static int GBPAUD_OCO3_EO3_DOWN_S2_ID ;
        public static int GBPAUD_OCO3_EO4_DOWN_S2_ID ;
        public static int GBPAUD_OCO3_EO5_DOWN_S2_ID ;
        public static int GBPAUD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool GBPAUD_OCO3_EO1_DOWN_S2 ;
        public static bool GBPAUD_OCO3_EO2_DOWN_S2 ;
        public static bool GBPAUD_OCO3_EO3_DOWN_S2 ;
        public static bool GBPAUD_OCO3_EO4_DOWN_S2 ;
        public static bool GBPAUD_OCO3_EO5_DOWN_S2 ;
        public static bool GBPAUD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_DOWN_S2> GBPAUD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_DOWN_S2> GBPAUD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_DOWN_S2> GBPAUD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_DOWN_S2> GBPAUD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_DOWN_S2> GBPAUD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO3_DOWN_S2> GBPAUD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static GBPAUD_OCO3_DOWN_S2 GBPAUD_PFO_OCO3_DOWN_S2_1 ;
        public static GBPAUD_OCO3_DOWN_S2 GBPAUD_PFO_OCO3_DOWN_S2_2 ;
        public static GBPAUD_OCO3_DOWN_S2 GBPAUD_PFO_OCO3_DOWN_S2_3 ;
        public static GBPAUD_OCO3_DOWN_S2 GBPAUD_PFO_OCO3_DOWN_S2_4 ;
        public static GBPAUD_OCO3_DOWN_S2 GBPAUD_PFO_OCO3_DOWN_S2_5 ;
        public static GBPAUD_OCO3_DOWN_S2 GBPAUD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<GBPAUD_OCO3_DOWN_S2> GBPAUD_DOWN_S2_OCO3Sets1 = new List<GBPAUD_OCO3_DOWN_S2>();
        public static List<GBPAUD_OCO3_DOWN_S2> GBPAUD_DOWN_S2_OCO3Sets2 = new List<GBPAUD_OCO3_DOWN_S2>();
        public static List<GBPAUD_OCO3_DOWN_S2> GBPAUD_DOWN_S2_OCO3Sets3 = new List<GBPAUD_OCO3_DOWN_S2>();
        public static List<GBPAUD_OCO3_DOWN_S2> GBPAUD_DOWN_S2_OCO3Sets4 = new List<GBPAUD_OCO3_DOWN_S2>();
        public static List<GBPAUD_OCO3_DOWN_S2> GBPAUD_DOWN_S2_OCO3Sets5 = new List<GBPAUD_OCO3_DOWN_S2>();
        public static List<GBPAUD_OCO3_DOWN_S2> GBPAUD_DOWN_S2_OCO3Sets6 = new List<GBPAUD_OCO3_DOWN_S2>();
        
        public static bool GBPAUD_OCO3_DOWN_S2_IsReady = true;
		public static bool GBPAUD_OCO3_DOWN_S2_Monthly_IsReady = true;
        
        //oco4 up
        public static OrderTicket GBPAUD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO6_UP_S2 ;
    	
    	public static int GBPAUD_OCO4_EO1_UP_S2_ID ;
        public static int GBPAUD_OCO4_EO2_UP_S2_ID ;
        public static int GBPAUD_OCO4_EO3_UP_S2_ID ;
        public static int GBPAUD_OCO4_EO4_UP_S2_ID ;
        public static int GBPAUD_OCO4_EO5_UP_S2_ID ;
        public static int GBPAUD_OCO4_EO6_UP_S2_ID ;
        
        public static bool GBPAUD_OCO4_EO1_UP_S2 ;
        public static bool GBPAUD_OCO4_EO2_UP_S2 ;
        public static bool GBPAUD_OCO4_EO3_UP_S2 ;
        public static bool GBPAUD_OCO4_EO4_UP_S2 ;
        public static bool GBPAUD_OCO4_EO5_UP_S2 ;
        public static bool GBPAUD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_UP_S2> GBPAUD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_UP_S2> GBPAUD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_UP_S2> GBPAUD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_UP_S2> GBPAUD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_UP_S2> GBPAUD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_UP_S2> GBPAUD_OOFE_OCO4_UP_S2_6 ;
        
        public static GBPAUD_OCO4_UP_S2 GBPAUD_PFO_OCO4_UP_S2_1 ;
        public static GBPAUD_OCO4_UP_S2 GBPAUD_PFO_OCO4_UP_S2_2 ;
        public static GBPAUD_OCO4_UP_S2 GBPAUD_PFO_OCO4_UP_S2_3 ;
        public static GBPAUD_OCO4_UP_S2 GBPAUD_PFO_OCO4_UP_S2_4 ;
        public static GBPAUD_OCO4_UP_S2 GBPAUD_PFO_OCO4_UP_S2_5 ;
        public static GBPAUD_OCO4_UP_S2 GBPAUD_PFO_OCO4_UP_S2_6 ;
        
        public static List<GBPAUD_OCO4_UP_S2> GBPAUD_UP_S2_OCO4Sets1 = new List<GBPAUD_OCO4_UP_S2>();
        public static List<GBPAUD_OCO4_UP_S2> GBPAUD_UP_S2_OCO4Sets2 = new List<GBPAUD_OCO4_UP_S2>();
        public static List<GBPAUD_OCO4_UP_S2> GBPAUD_UP_S2_OCO4Sets3 = new List<GBPAUD_OCO4_UP_S2>();
        public static List<GBPAUD_OCO4_UP_S2> GBPAUD_UP_S2_OCO4Sets4 = new List<GBPAUD_OCO4_UP_S2>();
        public static List<GBPAUD_OCO4_UP_S2> GBPAUD_UP_S2_OCO4Sets5 = new List<GBPAUD_OCO4_UP_S2>();
        public static List<GBPAUD_OCO4_UP_S2> GBPAUD_UP_S2_OCO4Sets6 = new List<GBPAUD_OCO4_UP_S2>();
        
        public static bool GBPAUD_OCO4_UP_S2_IsReady = true;
		public static bool GBPAUD_OCO4_UP_S2_Monthly_IsReady = true;
        
        //oco4 down
        public static OrderTicket GBPAUD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket GBPAUD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int GBPAUD_OCO4_EO1_DOWN_S2_ID ;
        public static int GBPAUD_OCO4_EO2_DOWN_S2_ID ;
        public static int GBPAUD_OCO4_EO3_DOWN_S2_ID ;
        public static int GBPAUD_OCO4_EO4_DOWN_S2_ID ;
        public static int GBPAUD_OCO4_EO5_DOWN_S2_ID ;
        public static int GBPAUD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool GBPAUD_OCO4_EO1_DOWN_S2 ;
        public static bool GBPAUD_OCO4_EO2_DOWN_S2 ;
        public static bool GBPAUD_OCO4_EO3_DOWN_S2 ;
        public static bool GBPAUD_OCO4_EO4_DOWN_S2 ;
        public static bool GBPAUD_OCO4_EO5_DOWN_S2 ;
        public static bool GBPAUD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_DOWN_S2> GBPAUD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_DOWN_S2> GBPAUD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_DOWN_S2> GBPAUD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_DOWN_S2> GBPAUD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_DOWN_S2> GBPAUD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, GBPAUD_OCO4_DOWN_S2> GBPAUD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static GBPAUD_OCO4_DOWN_S2 GBPAUD_PFO_OCO4_DOWN_S2_1 ;
        public static GBPAUD_OCO4_DOWN_S2 GBPAUD_PFO_OCO4_DOWN_S2_2 ;
        public static GBPAUD_OCO4_DOWN_S2 GBPAUD_PFO_OCO4_DOWN_S2_3 ;
        public static GBPAUD_OCO4_DOWN_S2 GBPAUD_PFO_OCO4_DOWN_S2_4 ;
        public static GBPAUD_OCO4_DOWN_S2 GBPAUD_PFO_OCO4_DOWN_S2_5 ;
        public static GBPAUD_OCO4_DOWN_S2 GBPAUD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<GBPAUD_OCO4_DOWN_S2> GBPAUD_DOWN_S2_OCO4Sets1 = new List<GBPAUD_OCO4_DOWN_S2>();
        public static List<GBPAUD_OCO4_DOWN_S2> GBPAUD_DOWN_S2_OCO4Sets2 = new List<GBPAUD_OCO4_DOWN_S2>();
        public static List<GBPAUD_OCO4_DOWN_S2> GBPAUD_DOWN_S2_OCO4Sets3 = new List<GBPAUD_OCO4_DOWN_S2>();
        public static List<GBPAUD_OCO4_DOWN_S2> GBPAUD_DOWN_S2_OCO4Sets4 = new List<GBPAUD_OCO4_DOWN_S2>();
        public static List<GBPAUD_OCO4_DOWN_S2> GBPAUD_DOWN_S2_OCO4Sets5 = new List<GBPAUD_OCO4_DOWN_S2>();
        public static List<GBPAUD_OCO4_DOWN_S2> GBPAUD_DOWN_S2_OCO4Sets6 = new List<GBPAUD_OCO4_DOWN_S2>();
        
        public static bool GBPAUD_OCO4_DOWN_S2_IsReady = true;
		public static bool GBPAUD_OCO4_DOWN_S2_Monthly_IsReady = true;
        
        
////////////////////////////
		public static decimal GBPAUD_UP_S2_SL {get; set;}
		public static decimal GBPAUD_UP_S2_TP1 {get; set;}
		public static decimal GBPAUD_UP_S2_TP2 {get; set;}
		public static decimal GBPAUD_UP_S2_TP3 {get; set;}
		public static decimal GBPAUD_UP_S2_TP4 {get; set;}
		public static decimal GBPAUD_UP_S2_TP5 {get; set;}
		public static decimal GBPAUD_UP_S2_TP6 {get; set;}
		
		public static decimal GBPAUD_DOWN_S2_SL {get; set;}
		public static decimal GBPAUD_DOWN_S2_TP1 {get; set;}
		public static decimal GBPAUD_DOWN_S2_TP2 {get; set;}
		public static decimal GBPAUD_DOWN_S2_TP3 {get; set;}
		public static decimal GBPAUD_DOWN_S2_TP4 {get; set;}
		public static decimal GBPAUD_DOWN_S2_TP5 {get; set;}
		public static decimal GBPAUD_DOWN_S2_TP6 {get; set;}

        public static bool GBPAUD_Signal_Condition_UP_1 ;
        public static bool GBPAUD_Signal_Condition_UP_2 ;
        public static bool GBPAUD_Signal_Condition_UP_3 ;
        public static bool GBPAUD_Signal_Condition_DOWN_S2 ;
        
        public static int GBPAUD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int GBPAUD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPAUD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPAUD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPAUD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int GBPAUD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int GBPAUD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int GBPAUD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int GBPAUD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int GBPAUD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_GBPAUD_UP_S2 ;
        public static bool DOWM_GBPAUD_UP_S2 ;
        public static bool DOWT_GBPAUD_UP_S2 ;
        public static bool DOWW_GBPAUD_UP_S2 ;
        public static bool DOWTH_GBPAUD_UP_S2 ;
        
		public static bool DOWR_GBPAUD_DOWN_S2 ;
        public static bool DOWM_GBPAUD_DOWN_S2 ;
        public static bool DOWT_GBPAUD_DOWN_S2 ;
        public static bool DOWW_GBPAUD_DOWN_S2 ;
        public static bool DOWTH_GBPAUD_DOWN_S2 ;
        
        
		public static int GBPAUD_quantity_UP_S2 ;
		public static int GBPAUD_quantity_SL_UP_S2 ;
		public static int GBPAUD_quantity_TP1_UP_S2 ;
		public static int GBPAUD_quantity_TP2_UP_S2 ;
		public static int GBPAUD_quantity_TP3_UP_S2 ;
		public static int GBPAUD_quantity_TP4_UP_S2 ;
		public static int GBPAUD_quantity_TP5_UP_S2;
		public static int GBPAUD_quantity_TP6_UP_S2 ;
		
		public static int GBPAUD_quantity_DOWN_S2 ;
		public static int GBPAUD_quantity_SL_DOWN_S2 ;
		public static int GBPAUD_quantity_TP1_DOWN_S2 ;
		public static int GBPAUD_quantity_TP2_DOWN_S2 ;
		public static int GBPAUD_quantity_TP3_DOWN_S2 ;
		public static int GBPAUD_quantity_TP4_DOWN_S2 ;
		public static int GBPAUD_quantity_TP5_DOWN_S2;
		public static int GBPAUD_quantity_TP6_DOWN_S2 ;
    }
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct EURJPY_OCO1_DOWN_S2
    {
        public EURJPY_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 =="TP1_EURJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY 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 =="TP1_EURJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY 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 EURJPY_OCO1_UP_S2
    {
        public EURJPY_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 =="TP1_EURJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY 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 =="TP1_EURJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURJPY 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 EURJPY_OCO2_DOWN_S2
    {
        public EURJPY_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 =="TP1_EURJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY 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 =="TP1_EURJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY 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 EURJPY_OCO2_UP_S2
    {
        public EURJPY_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 =="TP1_EURJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY 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 =="TP1_EURJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURJPY 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 EURJPY_OCO3_DOWN_S2
    {
        public EURJPY_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 =="TP1_EURJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY 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 =="TP1_EURJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY 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 EURJPY_OCO3_UP_S2
    {
        public EURJPY_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 =="TP1_EURJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY 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 =="TP1_EURJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURJPY 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 EURJPY_OCO4_DOWN_S2
    {
        public EURJPY_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 =="TP1_EURJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY 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 =="TP1_EURJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY 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 EURJPY_OCO4_UP_S2
    {
        public EURJPY_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 =="TP1_EURJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY 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 =="TP1_EURJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURJPY 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.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 _NZDJPY;
		
    	///oco1 up
    	public static OrderTicket NZDJPY_OCO1_MO1_UP_S2;
    	public static OrderTicket NZDJPY_OCO1_MO2_UP_S2;
    	public static OrderTicket NZDJPY_OCO1_MO3_UP_S2;
    	public static OrderTicket NZDJPY_OCO1_MO4_UP_S2;
    	public static OrderTicket NZDJPY_OCO1_MO5_UP_S2;
    	public static OrderTicket NZDJPY_OCO1_MO6_UP_S2;
    	
    	public static int NZDJPY_OCO1_EO1_UP_S2_ID ;
        public static int NZDJPY_OCO1_EO2_UP_S2_ID ;
        public static int NZDJPY_OCO1_EO3_UP_S2_ID ;
        public static int NZDJPY_OCO1_EO4_UP_S2_ID ;
        public static int NZDJPY_OCO1_EO5_UP_S2_ID ;
        public static int NZDJPY_OCO1_EO6_UP_S2_ID ;
        
        public static bool NZDJPY_OCO1_EO1_UP_S2 ;
        public static bool NZDJPY_OCO1_EO2_UP_S2 ;
        public static bool NZDJPY_OCO1_EO3_UP_S2 ;
        public static bool NZDJPY_OCO1_EO4_UP_S2 ;
        public static bool NZDJPY_OCO1_EO5_UP_S2 ;
        public static bool NZDJPY_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_UP_S2> NZDJPY_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_UP_S2> NZDJPY_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_UP_S2> NZDJPY_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_UP_S2> NZDJPY_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_UP_S2> NZDJPY_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_UP_S2> NZDJPY_OOFE_OCO1_UP_S2_6 ;
        
        public static NZDJPY_OCO1_UP_S2 NZDJPY_PFO_OCO1_UP_S2_1 ;
        public static NZDJPY_OCO1_UP_S2 NZDJPY_PFO_OCO1_UP_S2_2 ;
        public static NZDJPY_OCO1_UP_S2 NZDJPY_PFO_OCO1_UP_S2_3 ;
        public static NZDJPY_OCO1_UP_S2 NZDJPY_PFO_OCO1_UP_S2_4 ;
        public static NZDJPY_OCO1_UP_S2 NZDJPY_PFO_OCO1_UP_S2_5 ;
        public static NZDJPY_OCO1_UP_S2 NZDJPY_PFO_OCO1_UP_S2_6 ;
        
        public static List<NZDJPY_OCO1_UP_S2> NZDJPY_UP_S2_OCO1Sets1 = new List<NZDJPY_OCO1_UP_S2>();
        public static List<NZDJPY_OCO1_UP_S2> NZDJPY_UP_S2_OCO1Sets2 = new List<NZDJPY_OCO1_UP_S2>();
        public static List<NZDJPY_OCO1_UP_S2> NZDJPY_UP_S2_OCO1Sets3 = new List<NZDJPY_OCO1_UP_S2>();
        public static List<NZDJPY_OCO1_UP_S2> NZDJPY_UP_S2_OCO1Sets4 = new List<NZDJPY_OCO1_UP_S2>();
        public static List<NZDJPY_OCO1_UP_S2> NZDJPY_UP_S2_OCO1Sets5 = new List<NZDJPY_OCO1_UP_S2>();
        public static List<NZDJPY_OCO1_UP_S2> NZDJPY_UP_S2_OCO1Sets6 = new List<NZDJPY_OCO1_UP_S2>();
        
        public static bool NZDJPY_OCO1_UP_S2_IsReady = true;
        public static bool NZDJPY_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket NZDJPY_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO1_MO6_DOWN_S2 ;
    	
    	public static int NZDJPY_OCO1_EO1_DOWN_S2_ID ;
        public static int NZDJPY_OCO1_EO2_DOWN_S2_ID ;
        public static int NZDJPY_OCO1_EO3_DOWN_S2_ID ;
        public static int NZDJPY_OCO1_EO4_DOWN_S2_ID ;
        public static int NZDJPY_OCO1_EO5_DOWN_S2_ID ;
        public static int NZDJPY_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool NZDJPY_OCO1_EO1_DOWN_S2 ;
        public static bool NZDJPY_OCO1_EO2_DOWN_S2 ;
        public static bool NZDJPY_OCO1_EO3_DOWN_S2 ;
        public static bool NZDJPY_OCO1_EO4_DOWN_S2 ;
        public static bool NZDJPY_OCO1_EO5_DOWN_S2 ;
        public static bool NZDJPY_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_DOWN_S2> NZDJPY_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_DOWN_S2> NZDJPY_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_DOWN_S2> NZDJPY_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_DOWN_S2> NZDJPY_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_DOWN_S2> NZDJPY_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO1_DOWN_S2> NZDJPY_OOFE_OCO1_DOWN_S2_6 ;
        
        public static NZDJPY_OCO1_DOWN_S2 NZDJPY_PFO_OCO1_DOWN_S2_1 ;
        public static NZDJPY_OCO1_DOWN_S2 NZDJPY_PFO_OCO1_DOWN_S2_2 ;
        public static NZDJPY_OCO1_DOWN_S2 NZDJPY_PFO_OCO1_DOWN_S2_3 ;
        public static NZDJPY_OCO1_DOWN_S2 NZDJPY_PFO_OCO1_DOWN_S2_4 ;
        public static NZDJPY_OCO1_DOWN_S2 NZDJPY_PFO_OCO1_DOWN_S2_5 ;
        public static NZDJPY_OCO1_DOWN_S2 NZDJPY_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<NZDJPY_OCO1_DOWN_S2> NZDJPY_DOWN_S2_OCO1Sets1 = new List<NZDJPY_OCO1_DOWN_S2>();
        public static List<NZDJPY_OCO1_DOWN_S2> NZDJPY_DOWN_S2_OCO1Sets2 = new List<NZDJPY_OCO1_DOWN_S2>();
        public static List<NZDJPY_OCO1_DOWN_S2> NZDJPY_DOWN_S2_OCO1Sets3 = new List<NZDJPY_OCO1_DOWN_S2>();
        public static List<NZDJPY_OCO1_DOWN_S2> NZDJPY_DOWN_S2_OCO1Sets4 = new List<NZDJPY_OCO1_DOWN_S2>();
        public static List<NZDJPY_OCO1_DOWN_S2> NZDJPY_DOWN_S2_OCO1Sets5 = new List<NZDJPY_OCO1_DOWN_S2>();
        public static List<NZDJPY_OCO1_DOWN_S2> NZDJPY_DOWN_S2_OCO1Sets6 = new List<NZDJPY_OCO1_DOWN_S2>();
        
        public static bool NZDJPY_OCO1_DOWN_S2_IsReady = true;
        public static bool NZDJPY_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket NZDJPY_OCO2_MO1_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO2_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO3_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO4_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO5_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO6_UP_S2 ;
    	
    	public static int NZDJPY_OCO2_EO1_UP_S2_ID ;
        public static int NZDJPY_OCO2_EO2_UP_S2_ID ;
        public static int NZDJPY_OCO2_EO3_UP_S2_ID ;
        public static int NZDJPY_OCO2_EO4_UP_S2_ID ;
        public static int NZDJPY_OCO2_EO5_UP_S2_ID ;
        public static int NZDJPY_OCO2_EO6_UP_S2_ID ;
        
        public static bool NZDJPY_OCO2_EO1_UP_S2 ;
        public static bool NZDJPY_OCO2_EO2_UP_S2 ;
        public static bool NZDJPY_OCO2_EO3_UP_S2 ;
        public static bool NZDJPY_OCO2_EO4_UP_S2 ;
        public static bool NZDJPY_OCO2_EO5_UP_S2 ;
        public static bool NZDJPY_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_UP_S2> NZDJPY_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_UP_S2> NZDJPY_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_UP_S2> NZDJPY_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_UP_S2> NZDJPY_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_UP_S2> NZDJPY_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_UP_S2> NZDJPY_OOFE_OCO2_UP_S2_6 ;
        
        public static NZDJPY_OCO2_UP_S2 NZDJPY_PFO_OCO2_UP_S2_1 ;
        public static NZDJPY_OCO2_UP_S2 NZDJPY_PFO_OCO2_UP_S2_2 ;
        public static NZDJPY_OCO2_UP_S2 NZDJPY_PFO_OCO2_UP_S2_3 ;
        public static NZDJPY_OCO2_UP_S2 NZDJPY_PFO_OCO2_UP_S2_4 ;
        public static NZDJPY_OCO2_UP_S2 NZDJPY_PFO_OCO2_UP_S2_5 ;
        public static NZDJPY_OCO2_UP_S2 NZDJPY_PFO_OCO2_UP_S2_6 ;
        
        public static List<NZDJPY_OCO2_UP_S2> NZDJPY_UP_S2_OCO2Sets1 = new List<NZDJPY_OCO2_UP_S2>();
        public static List<NZDJPY_OCO2_UP_S2> NZDJPY_UP_S2_OCO2Sets2 = new List<NZDJPY_OCO2_UP_S2>();
        public static List<NZDJPY_OCO2_UP_S2> NZDJPY_UP_S2_OCO2Sets3 = new List<NZDJPY_OCO2_UP_S2>();
        public static List<NZDJPY_OCO2_UP_S2> NZDJPY_UP_S2_OCO2Sets4 = new List<NZDJPY_OCO2_UP_S2>();
        public static List<NZDJPY_OCO2_UP_S2> NZDJPY_UP_S2_OCO2Sets5 = new List<NZDJPY_OCO2_UP_S2>();
        public static List<NZDJPY_OCO2_UP_S2> NZDJPY_UP_S2_OCO2Sets6 = new List<NZDJPY_OCO2_UP_S2>();
        
        public static bool NZDJPY_OCO2_UP_S2_IsReady = true;
        public static bool NZDJPY_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket NZDJPY_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO2_MO6_DOWN_S2 ;
    	
    	public static int NZDJPY_OCO2_EO1_DOWN_S2_ID ;
        public static int NZDJPY_OCO2_EO2_DOWN_S2_ID ;
        public static int NZDJPY_OCO2_EO3_DOWN_S2_ID ;
        public static int NZDJPY_OCO2_EO4_DOWN_S2_ID ;
        public static int NZDJPY_OCO2_EO5_DOWN_S2_ID ;
        public static int NZDJPY_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool NZDJPY_OCO2_EO1_DOWN_S2 ;
        public static bool NZDJPY_OCO2_EO2_DOWN_S2 ;
        public static bool NZDJPY_OCO2_EO3_DOWN_S2 ;
        public static bool NZDJPY_OCO2_EO4_DOWN_S2 ;
        public static bool NZDJPY_OCO2_EO5_DOWN_S2 ;
        public static bool NZDJPY_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_DOWN_S2> NZDJPY_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_DOWN_S2> NZDJPY_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_DOWN_S2> NZDJPY_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_DOWN_S2> NZDJPY_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_DOWN_S2> NZDJPY_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO2_DOWN_S2> NZDJPY_OOFE_OCO2_DOWN_S2_6 ;
        
        public static NZDJPY_OCO2_DOWN_S2 NZDJPY_PFO_OCO2_DOWN_S2_1 ;
        public static NZDJPY_OCO2_DOWN_S2 NZDJPY_PFO_OCO2_DOWN_S2_2 ;
        public static NZDJPY_OCO2_DOWN_S2 NZDJPY_PFO_OCO2_DOWN_S2_3 ;
        public static NZDJPY_OCO2_DOWN_S2 NZDJPY_PFO_OCO2_DOWN_S2_4 ;
        public static NZDJPY_OCO2_DOWN_S2 NZDJPY_PFO_OCO2_DOWN_S2_5 ;
        public static NZDJPY_OCO2_DOWN_S2 NZDJPY_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<NZDJPY_OCO2_DOWN_S2> NZDJPY_DOWN_S2_OCO2Sets1 = new List<NZDJPY_OCO2_DOWN_S2>();
        public static List<NZDJPY_OCO2_DOWN_S2> NZDJPY_DOWN_S2_OCO2Sets2 = new List<NZDJPY_OCO2_DOWN_S2>();
        public static List<NZDJPY_OCO2_DOWN_S2> NZDJPY_DOWN_S2_OCO2Sets3 = new List<NZDJPY_OCO2_DOWN_S2>();
        public static List<NZDJPY_OCO2_DOWN_S2> NZDJPY_DOWN_S2_OCO2Sets4 = new List<NZDJPY_OCO2_DOWN_S2>();
        public static List<NZDJPY_OCO2_DOWN_S2> NZDJPY_DOWN_S2_OCO2Sets5 = new List<NZDJPY_OCO2_DOWN_S2>();
        public static List<NZDJPY_OCO2_DOWN_S2> NZDJPY_DOWN_S2_OCO2Sets6 = new List<NZDJPY_OCO2_DOWN_S2>();
        
        public static bool NZDJPY_OCO2_DOWN_S2_IsReady = true;
        public static bool NZDJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket NZDJPY_OCO3_MO1_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO2_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO3_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO4_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO5_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO6_UP_S2 ;
    	
    	public static int NZDJPY_OCO3_EO1_UP_S2_ID ;
        public static int NZDJPY_OCO3_EO2_UP_S2_ID ;
        public static int NZDJPY_OCO3_EO3_UP_S2_ID ;
        public static int NZDJPY_OCO3_EO4_UP_S2_ID ;
        public static int NZDJPY_OCO3_EO5_UP_S2_ID ;
        public static int NZDJPY_OCO3_EO6_UP_S2_ID ;
        
        public static bool NZDJPY_OCO3_EO1_UP_S2 ;
        public static bool NZDJPY_OCO3_EO2_UP_S2 ;
        public static bool NZDJPY_OCO3_EO3_UP_S2 ;
        public static bool NZDJPY_OCO3_EO4_UP_S2 ;
        public static bool NZDJPY_OCO3_EO5_UP_S2 ;
        public static bool NZDJPY_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_UP_S2> NZDJPY_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_UP_S2> NZDJPY_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_UP_S2> NZDJPY_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_UP_S2> NZDJPY_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_UP_S2> NZDJPY_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_UP_S2> NZDJPY_OOFE_OCO3_UP_S2_6 ;
        
        public static NZDJPY_OCO3_UP_S2 NZDJPY_PFO_OCO3_UP_S2_1 ;
        public static NZDJPY_OCO3_UP_S2 NZDJPY_PFO_OCO3_UP_S2_2 ;
        public static NZDJPY_OCO3_UP_S2 NZDJPY_PFO_OCO3_UP_S2_3 ;
        public static NZDJPY_OCO3_UP_S2 NZDJPY_PFO_OCO3_UP_S2_4 ;
        public static NZDJPY_OCO3_UP_S2 NZDJPY_PFO_OCO3_UP_S2_5 ;
        public static NZDJPY_OCO3_UP_S2 NZDJPY_PFO_OCO3_UP_S2_6 ;
        
        public static List<NZDJPY_OCO3_UP_S2> NZDJPY_UP_S2_OCO3Sets1 = new List<NZDJPY_OCO3_UP_S2>();
        public static List<NZDJPY_OCO3_UP_S2> NZDJPY_UP_S2_OCO3Sets2 = new List<NZDJPY_OCO3_UP_S2>();
        public static List<NZDJPY_OCO3_UP_S2> NZDJPY_UP_S2_OCO3Sets3 = new List<NZDJPY_OCO3_UP_S2>();
        public static List<NZDJPY_OCO3_UP_S2> NZDJPY_UP_S2_OCO3Sets4 = new List<NZDJPY_OCO3_UP_S2>();
        public static List<NZDJPY_OCO3_UP_S2> NZDJPY_UP_S2_OCO3Sets5 = new List<NZDJPY_OCO3_UP_S2>();
        public static List<NZDJPY_OCO3_UP_S2> NZDJPY_UP_S2_OCO3Sets6 = new List<NZDJPY_OCO3_UP_S2>();
        
        public static bool NZDJPY_OCO3_UP_S2_IsReady = true;
        public static bool NZDJPY_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket NZDJPY_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO3_MO6_DOWN_S2 ;
    	
    	public static int NZDJPY_OCO3_EO1_DOWN_S2_ID ;
        public static int NZDJPY_OCO3_EO2_DOWN_S2_ID ;
        public static int NZDJPY_OCO3_EO3_DOWN_S2_ID ;
        public static int NZDJPY_OCO3_EO4_DOWN_S2_ID ;
        public static int NZDJPY_OCO3_EO5_DOWN_S2_ID ;
        public static int NZDJPY_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool NZDJPY_OCO3_EO1_DOWN_S2 ;
        public static bool NZDJPY_OCO3_EO2_DOWN_S2 ;
        public static bool NZDJPY_OCO3_EO3_DOWN_S2 ;
        public static bool NZDJPY_OCO3_EO4_DOWN_S2 ;
        public static bool NZDJPY_OCO3_EO5_DOWN_S2 ;
        public static bool NZDJPY_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_DOWN_S2> NZDJPY_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_DOWN_S2> NZDJPY_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_DOWN_S2> NZDJPY_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_DOWN_S2> NZDJPY_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_DOWN_S2> NZDJPY_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO3_DOWN_S2> NZDJPY_OOFE_OCO3_DOWN_S2_6 ;
        
        public static NZDJPY_OCO3_DOWN_S2 NZDJPY_PFO_OCO3_DOWN_S2_1 ;
        public static NZDJPY_OCO3_DOWN_S2 NZDJPY_PFO_OCO3_DOWN_S2_2 ;
        public static NZDJPY_OCO3_DOWN_S2 NZDJPY_PFO_OCO3_DOWN_S2_3 ;
        public static NZDJPY_OCO3_DOWN_S2 NZDJPY_PFO_OCO3_DOWN_S2_4 ;
        public static NZDJPY_OCO3_DOWN_S2 NZDJPY_PFO_OCO3_DOWN_S2_5 ;
        public static NZDJPY_OCO3_DOWN_S2 NZDJPY_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<NZDJPY_OCO3_DOWN_S2> NZDJPY_DOWN_S2_OCO3Sets1 = new List<NZDJPY_OCO3_DOWN_S2>();
        public static List<NZDJPY_OCO3_DOWN_S2> NZDJPY_DOWN_S2_OCO3Sets2 = new List<NZDJPY_OCO3_DOWN_S2>();
        public static List<NZDJPY_OCO3_DOWN_S2> NZDJPY_DOWN_S2_OCO3Sets3 = new List<NZDJPY_OCO3_DOWN_S2>();
        public static List<NZDJPY_OCO3_DOWN_S2> NZDJPY_DOWN_S2_OCO3Sets4 = new List<NZDJPY_OCO3_DOWN_S2>();
        public static List<NZDJPY_OCO3_DOWN_S2> NZDJPY_DOWN_S2_OCO3Sets5 = new List<NZDJPY_OCO3_DOWN_S2>();
        public static List<NZDJPY_OCO3_DOWN_S2> NZDJPY_DOWN_S2_OCO3Sets6 = new List<NZDJPY_OCO3_DOWN_S2>();
        
        public static bool NZDJPY_OCO3_DOWN_S2_IsReady = true;
        public static bool NZDJPY_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket NZDJPY_OCO4_MO1_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO2_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO3_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO4_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO5_UP_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO6_UP_S2 ;
    	
    	public static int NZDJPY_OCO4_EO1_UP_S2_ID ;
        public static int NZDJPY_OCO4_EO2_UP_S2_ID ;
        public static int NZDJPY_OCO4_EO3_UP_S2_ID ;
        public static int NZDJPY_OCO4_EO4_UP_S2_ID ;
        public static int NZDJPY_OCO4_EO5_UP_S2_ID ;
        public static int NZDJPY_OCO4_EO6_UP_S2_ID ;
        
        public static bool NZDJPY_OCO4_EO1_UP_S2 ;
        public static bool NZDJPY_OCO4_EO2_UP_S2 ;
        public static bool NZDJPY_OCO4_EO3_UP_S2 ;
        public static bool NZDJPY_OCO4_EO4_UP_S2 ;
        public static bool NZDJPY_OCO4_EO5_UP_S2 ;
        public static bool NZDJPY_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_UP_S2> NZDJPY_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_UP_S2> NZDJPY_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_UP_S2> NZDJPY_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_UP_S2> NZDJPY_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_UP_S2> NZDJPY_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_UP_S2> NZDJPY_OOFE_OCO4_UP_S2_6 ;
        
        public static NZDJPY_OCO4_UP_S2 NZDJPY_PFO_OCO4_UP_S2_1 ;
        public static NZDJPY_OCO4_UP_S2 NZDJPY_PFO_OCO4_UP_S2_2 ;
        public static NZDJPY_OCO4_UP_S2 NZDJPY_PFO_OCO4_UP_S2_3 ;
        public static NZDJPY_OCO4_UP_S2 NZDJPY_PFO_OCO4_UP_S2_4 ;
        public static NZDJPY_OCO4_UP_S2 NZDJPY_PFO_OCO4_UP_S2_5 ;
        public static NZDJPY_OCO4_UP_S2 NZDJPY_PFO_OCO4_UP_S2_6 ;
        
        public static List<NZDJPY_OCO4_UP_S2> NZDJPY_UP_S2_OCO4Sets1 = new List<NZDJPY_OCO4_UP_S2>();
        public static List<NZDJPY_OCO4_UP_S2> NZDJPY_UP_S2_OCO4Sets2 = new List<NZDJPY_OCO4_UP_S2>();
        public static List<NZDJPY_OCO4_UP_S2> NZDJPY_UP_S2_OCO4Sets3 = new List<NZDJPY_OCO4_UP_S2>();
        public static List<NZDJPY_OCO4_UP_S2> NZDJPY_UP_S2_OCO4Sets4 = new List<NZDJPY_OCO4_UP_S2>();
        public static List<NZDJPY_OCO4_UP_S2> NZDJPY_UP_S2_OCO4Sets5 = new List<NZDJPY_OCO4_UP_S2>();
        public static List<NZDJPY_OCO4_UP_S2> NZDJPY_UP_S2_OCO4Sets6 = new List<NZDJPY_OCO4_UP_S2>();
        
        public static bool NZDJPY_OCO4_UP_S2_IsReady = true;
        public static bool NZDJPY_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket NZDJPY_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket NZDJPY_OCO4_MO6_DOWN_S2 ;
    	
    	public static int NZDJPY_OCO4_EO1_DOWN_S2_ID ;
        public static int NZDJPY_OCO4_EO2_DOWN_S2_ID ;
        public static int NZDJPY_OCO4_EO3_DOWN_S2_ID ;
        public static int NZDJPY_OCO4_EO4_DOWN_S2_ID ;
        public static int NZDJPY_OCO4_EO5_DOWN_S2_ID ;
        public static int NZDJPY_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool NZDJPY_OCO4_EO1_DOWN_S2 ;
        public static bool NZDJPY_OCO4_EO2_DOWN_S2 ;
        public static bool NZDJPY_OCO4_EO3_DOWN_S2 ;
        public static bool NZDJPY_OCO4_EO4_DOWN_S2 ;
        public static bool NZDJPY_OCO4_EO5_DOWN_S2 ;
        public static bool NZDJPY_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_DOWN_S2> NZDJPY_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_DOWN_S2> NZDJPY_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_DOWN_S2> NZDJPY_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_DOWN_S2> NZDJPY_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_DOWN_S2> NZDJPY_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDJPY_OCO4_DOWN_S2> NZDJPY_OOFE_OCO4_DOWN_S2_6 ;
        
        public static NZDJPY_OCO4_DOWN_S2 NZDJPY_PFO_OCO4_DOWN_S2_1 ;
        public static NZDJPY_OCO4_DOWN_S2 NZDJPY_PFO_OCO4_DOWN_S2_2 ;
        public static NZDJPY_OCO4_DOWN_S2 NZDJPY_PFO_OCO4_DOWN_S2_3 ;
        public static NZDJPY_OCO4_DOWN_S2 NZDJPY_PFO_OCO4_DOWN_S2_4 ;
        public static NZDJPY_OCO4_DOWN_S2 NZDJPY_PFO_OCO4_DOWN_S2_5 ;
        public static NZDJPY_OCO4_DOWN_S2 NZDJPY_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<NZDJPY_OCO4_DOWN_S2> NZDJPY_DOWN_S2_OCO4Sets1 = new List<NZDJPY_OCO4_DOWN_S2>();
        public static List<NZDJPY_OCO4_DOWN_S2> NZDJPY_DOWN_S2_OCO4Sets2 = new List<NZDJPY_OCO4_DOWN_S2>();
        public static List<NZDJPY_OCO4_DOWN_S2> NZDJPY_DOWN_S2_OCO4Sets3 = new List<NZDJPY_OCO4_DOWN_S2>();
        public static List<NZDJPY_OCO4_DOWN_S2> NZDJPY_DOWN_S2_OCO4Sets4 = new List<NZDJPY_OCO4_DOWN_S2>();
        public static List<NZDJPY_OCO4_DOWN_S2> NZDJPY_DOWN_S2_OCO4Sets5 = new List<NZDJPY_OCO4_DOWN_S2>();
        public static List<NZDJPY_OCO4_DOWN_S2> NZDJPY_DOWN_S2_OCO4Sets6 = new List<NZDJPY_OCO4_DOWN_S2>();
        
        public static bool NZDJPY_OCO4_DOWN_S2_IsReady = true;
        public static bool NZDJPY_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal NZDJPY_UP_S2_SL {get; set;}
		public static decimal NZDJPY_UP_S2_TP1 {get; set;}
		public static decimal NZDJPY_UP_S2_TP2 {get; set;}
		public static decimal NZDJPY_UP_S2_TP3 {get; set;}
		public static decimal NZDJPY_UP_S2_TP4 {get; set;}
		public static decimal NZDJPY_UP_S2_TP5 {get; set;}
		public static decimal NZDJPY_UP_S2_TP6 {get; set;}
		
		public static decimal NZDJPY_DOWN_S2_SL {get; set;}
		public static decimal NZDJPY_DOWN_S2_TP1 {get; set;}
		public static decimal NZDJPY_DOWN_S2_TP2 {get; set;}
		public static decimal NZDJPY_DOWN_S2_TP3 {get; set;}
		public static decimal NZDJPY_DOWN_S2_TP4 {get; set;}
		public static decimal NZDJPY_DOWN_S2_TP5 {get; set;}
		public static decimal NZDJPY_DOWN_S2_TP6 {get; set;}

        public static bool NZDJPY_Signal_Condition_UP_1 ;
        public static bool NZDJPY_Signal_Condition_UP_2 ;
        public static bool NZDJPY_Signal_Condition_UP_3 ;
        public static bool NZDJPY_Signal_Condition_DOWN_S2 ;
        
        public static int NZDJPY_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int NZDJPY_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int NZDJPY_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int NZDJPY_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int NZDJPY_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int NZDJPY_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int NZDJPY_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int NZDJPY_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int NZDJPY_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int NZDJPY_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_NZDJPY_UP_S2 ;
        public static bool DOWM_NZDJPY_UP_S2 ;
        public static bool DOWT_NZDJPY_UP_S2 ;
        public static bool DOWW_NZDJPY_UP_S2 ;
        public static bool DOWTH_NZDJPY_UP_S2 ;
        
		public static bool DOWR_NZDJPY_DOWN_S2 ;
        public static bool DOWM_NZDJPY_DOWN_S2 ;
        public static bool DOWT_NZDJPY_DOWN_S2 ;
        public static bool DOWW_NZDJPY_DOWN_S2 ;
        public static bool DOWTH_NZDJPY_DOWN_S2 ;
        
        
		public static int NZDJPY_quantity_UP_S2 ;
		public static int NZDJPY_quantity_SL_UP_S2 ;
		public static int NZDJPY_quantity_TP1_UP_S2 ;
		public static int NZDJPY_quantity_TP2_UP_S2 ;
		public static int NZDJPY_quantity_TP3_UP_S2 ;
		public static int NZDJPY_quantity_TP4_UP_S2 ;
		public static int NZDJPY_quantity_TP5_UP_S2;
		public static int NZDJPY_quantity_TP6_UP_S2 ;
		
		public static int NZDJPY_quantity_DOWN_S2 ;
		public static int NZDJPY_quantity_SL_DOWN_S2 ;
		public static int NZDJPY_quantity_TP1_DOWN_S2 ;
		public static int NZDJPY_quantity_TP2_DOWN_S2 ;
		public static int NZDJPY_quantity_TP3_DOWN_S2 ;
		public static int NZDJPY_quantity_TP4_DOWN_S2 ;
		public static int NZDJPY_quantity_TP5_DOWN_S2;
		public static int NZDJPY_quantity_TP6_DOWN_S2 ;
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_USDCAD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_USDCAD_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(x=>x.Tag.Contains("USDCAD_UP_S2_OCO1")))
			{
				Base.USDCAD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCAD_UP_S2_OCO2")))
			{
				Base.USDCAD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCAD_UP_S2_OCO3")))
			{
				Base.USDCAD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCAD_UP_S2_OCO4")))
			{
				Base.USDCAD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("USDCAD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.USDCAD_OCO1_EO1_UP_S2)
	                Base.USDCAD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.USDCAD_OCO1_EO2_UP_S2)
	                Base.USDCAD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO1_EO3_UP_S2)
	                Base.USDCAD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO1_EO4_UP_S2)
	                Base.USDCAD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO1_EO5_UP_S2)
	                Base.USDCAD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO1_EO6_UP_S2)
	                Base.USDCAD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCAD_OCO1S1_UP_S2 = 0;
		                for (; USDCAD_OCO1S1_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets1.Count; USDCAD_OCO1S1_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO1Sets1[USDCAD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO1Sets1[USDCAD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.USDCAD_UP_S2_OCO1Sets1.Clear();
		                        USDCAD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDCAD_OCO1S2_UP_S2 = 0;
		                for (; USDCAD_OCO1S2_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets2.Count; USDCAD_OCO1S2_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO1Sets2[USDCAD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO1Sets2[USDCAD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.USDCAD_UP_S2_OCO1Sets2.Clear();
		                        USDCAD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO1S3_UP_S2 = 0;
		                for (; USDCAD_OCO1S3_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets3.Count; USDCAD_OCO1S3_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO1Sets3[USDCAD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO1Sets3[USDCAD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.USDCAD_UP_S2_OCO1Sets3.Clear();
		                        USDCAD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO1S4_UP_S2 = 0;
		                for (; USDCAD_OCO1S4_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets4.Count; USDCAD_OCO1S4_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO1Sets4[USDCAD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO1Sets4[USDCAD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.USDCAD_UP_S2_OCO1Sets4.Clear();
		                        USDCAD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO1S5_UP_S2 = 0;
		                for (; USDCAD_OCO1S5_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets5.Count; USDCAD_OCO1S5_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO1Sets5[USDCAD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO1Sets5[USDCAD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.USDCAD_UP_S2_OCO1Sets5.Clear();
		                        USDCAD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO1S6_UP_S2 = 0;
		                for (; USDCAD_OCO1S6_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets6.Count; USDCAD_OCO1S6_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO1Sets6[USDCAD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO1Sets6[USDCAD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.USDCAD_UP_S2_OCO1Sets6.Clear();
		                        USDCAD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.USDCAD_OCO2_EO1_UP_S2)
                	Base.USDCAD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.USDCAD_OCO2_EO2_UP_S2)
	                Base.USDCAD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO2_EO3_UP_S2)
	                Base.USDCAD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO2_EO4_UP_S2)
	                Base.USDCAD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO2_EO5_UP_S2)
	                Base.USDCAD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO2_EO6_UP_S2)
	                Base.USDCAD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCAD_OCO2S1_UP_S2 = 0;
		                for (; USDCAD_OCO2S1_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets1.Count; USDCAD_OCO2S1_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO2Sets1[USDCAD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO2Sets1[USDCAD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.USDCAD_UP_S2_OCO2Sets1.Clear();
		                        USDCAD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDCAD_OCO2S2_UP_S2 = 0;
		                for (; USDCAD_OCO2S2_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets2.Count; USDCAD_OCO2S2_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO2Sets2[USDCAD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO2Sets2[USDCAD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.USDCAD_UP_S2_OCO2Sets2.Clear();
		                        USDCAD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO2S3_UP_S2 = 0;
		                for (; USDCAD_OCO2S3_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets3.Count; USDCAD_OCO2S3_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO2Sets3[USDCAD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO2Sets3[USDCAD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.USDCAD_UP_S2_OCO2Sets3.Clear();
		                        USDCAD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO2S4_UP_S2 = 0;
		                for (; USDCAD_OCO2S4_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets4.Count; USDCAD_OCO2S4_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO2Sets4[USDCAD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO2Sets4[USDCAD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.USDCAD_UP_S2_OCO2Sets4.Clear();
		                        USDCAD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO2S5_UP_S2 = 0;
		                for (; USDCAD_OCO2S5_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets5.Count; USDCAD_OCO2S5_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO2Sets5[USDCAD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO2Sets5[USDCAD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.USDCAD_UP_S2_OCO2Sets5.Clear();
		                        USDCAD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO2S6_UP_S2 = 0;
		                for (; USDCAD_OCO2S6_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets6.Count; USDCAD_OCO2S6_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO2Sets6[USDCAD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO2Sets6[USDCAD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.USDCAD_UP_S2_OCO2Sets6.Clear();
		                        USDCAD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.USDCAD_OCO3_EO1_UP_S2)
            		Base.USDCAD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.USDCAD_OCO3_EO2_UP_S2)
	                Base.USDCAD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO3_EO3_UP_S2)
	                Base.USDCAD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO3_EO4_UP_S2)
	                Base.USDCAD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO3_EO5_UP_S2)
	                Base.USDCAD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO3_EO6_UP_S2)
	                Base.USDCAD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCAD_OCO3S1_UP_S2 = 0;
		                for (; USDCAD_OCO3S1_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets1.Count; USDCAD_OCO3S1_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO3Sets1[USDCAD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO3Sets1[USDCAD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.USDCAD_UP_S2_OCO3Sets1.Clear();
		                        USDCAD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDCAD_OCO3S2_UP_S2 = 0;
		                for (; USDCAD_OCO3S2_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets2.Count; USDCAD_OCO3S2_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO3Sets2[USDCAD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO3Sets2[USDCAD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.USDCAD_UP_S2_OCO3Sets2.Clear();
		                        USDCAD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO3S3_UP_S2 = 0;
		                for (; USDCAD_OCO3S3_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets3.Count; USDCAD_OCO3S3_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO3Sets3[USDCAD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO3Sets3[USDCAD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.USDCAD_UP_S2_OCO3Sets3.Clear();
		                        USDCAD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO3S4_UP_S2 = 0;
		                for (; USDCAD_OCO3S4_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets4.Count; USDCAD_OCO3S4_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO3Sets4[USDCAD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO3Sets4[USDCAD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.USDCAD_UP_S2_OCO3Sets4.Clear();
		                        USDCAD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO3S5_UP_S2 = 0;
		                for (; USDCAD_OCO3S5_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets5.Count; USDCAD_OCO3S5_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO3Sets5[USDCAD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO3Sets5[USDCAD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.USDCAD_UP_S2_OCO3Sets5.Clear();
		                        USDCAD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO3S6_UP_S2 = 0;
		                for (; USDCAD_OCO3S6_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets6.Count; USDCAD_OCO3S6_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO3Sets6[USDCAD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO3Sets6[USDCAD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.USDCAD_UP_S2_OCO3Sets6.Clear();
		                        USDCAD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDCAD_OCO4_EO1_UP_S2)
            		Base.USDCAD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.USDCAD_OCO4_EO2_UP_S2)
	                Base.USDCAD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO4_EO3_UP_S2)
	                Base.USDCAD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO4_EO4_UP_S2)
	                Base.USDCAD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO4_EO5_UP_S2)
	                Base.USDCAD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO4_EO6_UP_S2)
	                Base.USDCAD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCAD_OCO4S1_UP_S2 = 0;
		                for (; USDCAD_OCO4S1_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets1.Count; USDCAD_OCO4S1_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO4Sets1[USDCAD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO4Sets1[USDCAD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.USDCAD_UP_S2_OCO4Sets1.Clear();
		                        USDCAD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDCAD_OCO4S2_UP_S2 = 0;
		                for (; USDCAD_OCO4S2_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets2.Count; USDCAD_OCO4S2_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO4Sets2[USDCAD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO4Sets2[USDCAD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.USDCAD_UP_S2_OCO4Sets2.Clear();
		                        USDCAD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO4S3_UP_S2 = 0;
		                for (; USDCAD_OCO4S3_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets3.Count; USDCAD_OCO4S3_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO4Sets3[USDCAD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO4Sets3[USDCAD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.USDCAD_UP_S2_OCO4Sets3.Clear();
		                        USDCAD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO4S4_UP_S2 = 0;
		                for (; USDCAD_OCO4S4_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets4.Count; USDCAD_OCO4S4_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO4Sets4[USDCAD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO4Sets4[USDCAD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.USDCAD_UP_S2_OCO4Sets4.Clear();
		                        USDCAD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO4S5_UP_S2 = 0;
		                for (; USDCAD_OCO4S5_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets5.Count; USDCAD_OCO4S5_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO4Sets5[USDCAD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO4Sets5[USDCAD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.USDCAD_UP_S2_OCO4Sets5.Clear();
		                        USDCAD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO4S6_UP_S2 = 0;
		                for (; USDCAD_OCO4S6_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets6.Count; USDCAD_OCO4S6_UP_S2++)
		                    if (Base.USDCAD_UP_S2_OCO4Sets6[USDCAD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_UP_S2_OCO4Sets6[USDCAD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.USDCAD_UP_S2_OCO4Sets6.Clear();
		                        USDCAD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_USDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_USDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_USDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_USDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_USDCAD_UP_S2 = DOWM_USDCAD_UP_S2 || DOWT_USDCAD_UP_S2 || DOWW_USDCAD_UP_S2 || DOWTH_USDCAD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("USDCAD"))
	            	{
	            		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.USDCAD_OCO1_UP_S2_IsReady == false ||
	                    	Base.USDCAD_OCO2_UP_S2_IsReady == false ||
	                    	Base.USDCAD_OCO3_UP_S2_IsReady == false ||
	                    	Base.USDCAD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.USDCAD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.USDCAD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.USDCAD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.USDCAD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.USDCAD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.USDCAD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.USDCAD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.USDCAD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	USDCAD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											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.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*2
				                										
				                										)
			                							
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	USDCAD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*2
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	USDCAD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
		
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*2
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (USDCAD_Signal_Condition_UP_1)
	                	{
	                    	USDCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (USDCAD_Signal_Condition_UP_2)
	                	{
	                    	USDCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (USDCAD_Signal_Condition_UP_3)
	                	{
	                    	USDCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (USDCAD_Signal_Condition_UP_1)
	                	{
	                    	USDCAD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (USDCAD_Signal_Condition_UP_2)
	                	{
	                    	USDCAD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (USDCAD_Signal_Condition_UP_3)
	                	{
	                    	USDCAD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    USDCAD_UP_S2_TP2 =  USDCAD_UP_S2_SL * 0;
	                    USDCAD_UP_S2_TP3 =  USDCAD_UP_S2_SL * 0;
	                    USDCAD_UP_S2_TP4 =  USDCAD_UP_S2_SL * 0;
	                    USDCAD_UP_S2_TP5 =  USDCAD_UP_S2_SL * 0;
	                    USDCAD_UP_S2_TP6 =  USDCAD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    USDCAD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    USDCAD_quantity_SL_UP_S2 = USDCAD_quantity_UP_S2;
	                    USDCAD_quantity_TP1_UP_S2 = (int)Math.Floor(USDCAD_quantity_UP_S2 * 1m);
	                    USDCAD_quantity_TP2_UP_S2 = (int)Math.Floor(USDCAD_quantity_TP1_UP_S2 * 0m);
	                    USDCAD_quantity_TP3_UP_S2 = (int)Math.Floor(USDCAD_quantity_TP2_UP_S2 * 0m);
	                    USDCAD_quantity_TP4_UP_S2 = (int)Math.Floor(USDCAD_quantity_TP3_UP_S2 * 0m);
	                    USDCAD_quantity_TP5_UP_S2 = (int)Math.Floor(USDCAD_quantity_TP4_UP_S2 * 0m);
	                    USDCAD_quantity_TP6_UP_S2 = (int)Math.Floor(USDCAD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((USDCAD_Signal_Condition_UP_1 || USDCAD_Signal_Condition_UP_2 || USDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_USDCAD_UP_S2 && 
	                    Base.USDCAD_OCO1_UP_S2_IsReady == true &&
	                    Base.USDCAD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCAD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP1_UP_S2, false,"USDCAD_UP_S2_Entry_TP1_OCO1");
	                         Base.USDCAD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.USDCAD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP2_UP_S2, false,"USDCAD_UP_S2_Entry_TP2_OCO1");
	                         Base.USDCAD_OCO1_EO2_UP_S2 = false;
	
	                         Base.USDCAD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP3_UP_S2, false,"USDCAD_UP_S2_Entry_TP3_OCO1");
	                         Base.USDCAD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.USDCAD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP4_UP_S2, false,"USDCAD_UP_S2_Entry_TP4_OCO1");
	                         Base.USDCAD_OCO1_EO4_UP_S2 = false;

							Base.USDCAD_OCO1_UP_S2_IsReady = false;
							
							if (Base.USDCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((USDCAD_Signal_Condition_UP_1 || USDCAD_Signal_Condition_UP_2 || USDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_USDCAD_UP_S2 && 
	                    Base.USDCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.USDCAD_OCO2_UP_S2_IsReady == true &&
	                    Base.USDCAD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCAD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP1_UP_S2, false,"USDCAD_UP_S2_Entry_TP1_OCO2");
	                         Base.USDCAD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.USDCAD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP2_UP_S2, false,"USDCAD_UP_S2_Entry_TP2_OCO2");
	                         Base.USDCAD_OCO2_EO2_UP_S2 = false;
	
	                         Base.USDCAD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP3_UP_S2, false,"USDCAD_UP_S2_Entry_TP3_OCO2");
	                         Base.USDCAD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.USDCAD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP4_UP_S2, false,"USDCAD_UP_S2_Entry_TP4_OCO2");
	                         Base.USDCAD_OCO2_EO4_UP_S2 = false;

							Base.USDCAD_OCO2_UP_S2_IsReady = false;
							
							if (Base.USDCAD_OCO2_UP_S2_IsReady == false && Base.USDCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((USDCAD_Signal_Condition_UP_1 || USDCAD_Signal_Condition_UP_2 || USDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_USDCAD_UP_S2 &&
	                    Base.USDCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.USDCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.USDCAD_OCO3_UP_S2_IsReady == true &&
	                    Base.USDCAD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCAD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP1_UP_S2, false,"USDCAD_UP_S2_Entry_TP1_OCO3");
	                         Base.USDCAD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.USDCAD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP2_UP_S2, false,"USDCAD_UP_S2_Entry_TP2_OCO3");
	                         Base.USDCAD_OCO3_EO2_UP_S2 = false;
	
	                         Base.USDCAD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP3_UP_S2, false,"USDCAD_UP_S2_Entry_TP3_OCO3");
	                         Base.USDCAD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.USDCAD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP4_UP_S2, false,"USDCAD_UP_S2_Entry_TP4_OCO3");
	                         Base.USDCAD_OCO3_EO4_UP_S2 = false;

							Base.USDCAD_OCO3_UP_S2_IsReady = false;
							
							if (Base.USDCAD_OCO3_UP_S2_IsReady == false && Base.USDCAD_OCO2_UP_S2_IsReady == false && Base.USDCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((USDCAD_Signal_Condition_UP_1 || USDCAD_Signal_Condition_UP_2 || USDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_USDCAD_UP_S2 && 
	                    Base.USDCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.USDCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.USDCAD_OCO3_UP_S2_IsReady == false &&
	                    Base.USDCAD_OCO4_UP_S2_IsReady == true &&
	                    Base.USDCAD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCAD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP1_UP_S2, false,"USDCAD_UP_S2_Entry_TP1_OCO4");
	                         Base.USDCAD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.USDCAD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP2_UP_S2, false,"USDCAD_UP_S2_Entry_TP2_OCO4");
	                         Base.USDCAD_OCO4_EO2_UP_S2 = false;
	
	                         Base.USDCAD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP3_UP_S2, false,"USDCAD_UP_S2_Entry_TP3_OCO4");
	                         Base.USDCAD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.USDCAD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCAD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP4_UP_S2, false,"USDCAD_UP_S2_Entry_TP4_OCO4");
	                         Base.USDCAD_OCO4_EO4_UP_S2 = false;

							Base.USDCAD_OCO4_UP_S2_IsReady = false;
							
							if (Base.USDCAD_OCO4_UP_S2_IsReady == false && Base.USDCAD_OCO3_UP_S2_IsReady == false && Base.USDCAD_OCO2_UP_S2_IsReady == false && Base.USDCAD_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDJPY_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDJPY_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("AUDJPY_DOWN_S2_OCO1")))
			{
				Base.AUDJPY_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDJPY_DOWN_S2_OCO2")))
			{
				Base.AUDJPY_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDJPY_DOWN_S2_OCO3")))
			{
				Base.AUDJPY_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDJPY_DOWN_S2_OCO4")))
			{
				Base.AUDJPY_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDJPY_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.AUDJPY_OCO1_EO1_DOWN_S2)
	                Base.AUDJPY_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDJPY_OCO1_EO2_DOWN_S2)
	                Base.AUDJPY_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO1_EO3_DOWN_S2)
	                Base.AUDJPY_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO1_EO4_DOWN_S2)
	                Base.AUDJPY_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO1_EO5_DOWN_S2)
	                Base.AUDJPY_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO1_EO6_DOWN_S2)
	                Base.AUDJPY_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDJPY_OCO1S1_DOWN_S2 = 0;
		                for (; AUDJPY_OCO1S1_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets1.Count; AUDJPY_OCO1S1_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO1Sets1[AUDJPY_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO1Sets1[AUDJPY_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.AUDJPY_DOWN_S2_OCO1Sets1.Clear();
		                        AUDJPY_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDJPY_OCO1S2_DOWN_S2 = 0;
		                for (; AUDJPY_OCO1S2_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets2.Count; AUDJPY_OCO1S2_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO1Sets2[AUDJPY_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO1Sets2[AUDJPY_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.AUDJPY_DOWN_S2_OCO1Sets2.Clear();
		                        AUDJPY_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO1S3_DOWN_S2 = 0;
		                for (; AUDJPY_OCO1S3_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets3.Count; AUDJPY_OCO1S3_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO1Sets3[AUDJPY_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO1Sets3[AUDJPY_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.AUDJPY_DOWN_S2_OCO1Sets3.Clear();
		                        AUDJPY_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO1S4_DOWN_S2 = 0;
		                for (; AUDJPY_OCO1S4_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets4.Count; AUDJPY_OCO1S4_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO1Sets4[AUDJPY_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO1Sets4[AUDJPY_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.AUDJPY_DOWN_S2_OCO1Sets4.Clear();
		                        AUDJPY_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO1S5_DOWN_S2 = 0;
		                for (; AUDJPY_OCO1S5_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets5.Count; AUDJPY_OCO1S5_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO1Sets5[AUDJPY_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO1Sets5[AUDJPY_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.AUDJPY_DOWN_S2_OCO1Sets5.Clear();
		                        AUDJPY_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO1S6_DOWN_S2 = 0;
		                for (; AUDJPY_OCO1S6_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets6.Count; AUDJPY_OCO1S6_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO1Sets6[AUDJPY_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO1Sets6[AUDJPY_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.AUDJPY_DOWN_S2_OCO1Sets6.Clear();
		                        AUDJPY_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDJPY_OCO2_EO1_DOWN_S2)
	                Base.AUDJPY_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDJPY_OCO2_EO2_DOWN_S2)
	                Base.AUDJPY_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO2_EO3_DOWN_S2)
	                Base.AUDJPY_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO2_EO4_DOWN_S2)
	                Base.AUDJPY_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO2_EO5_DOWN_S2)
	                Base.AUDJPY_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO2_EO6_DOWN_S2)
	                Base.AUDJPY_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDJPY_OCO2S1_DOWN_S2 = 0;
		                for (; AUDJPY_OCO2S1_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets1.Count; AUDJPY_OCO2S1_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO2Sets1[AUDJPY_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO2Sets1[AUDJPY_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.AUDJPY_DOWN_S2_OCO2Sets1.Clear();
		                        AUDJPY_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDJPY_OCO2S2_DOWN_S2 = 0;
		                for (; AUDJPY_OCO2S2_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets2.Count; AUDJPY_OCO2S2_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO2Sets2[AUDJPY_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO2Sets2[AUDJPY_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.AUDJPY_DOWN_S2_OCO2Sets2.Clear();
		                        AUDJPY_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO2S3_DOWN_S2 = 0;
		                for (; AUDJPY_OCO2S3_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets3.Count; AUDJPY_OCO2S3_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO2Sets3[AUDJPY_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO2Sets3[AUDJPY_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.AUDJPY_DOWN_S2_OCO2Sets3.Clear();
		                        AUDJPY_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO2S4_DOWN_S2 = 0;
		                for (; AUDJPY_OCO2S4_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets4.Count; AUDJPY_OCO2S4_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO2Sets4[AUDJPY_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO2Sets4[AUDJPY_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.AUDJPY_DOWN_S2_OCO2Sets4.Clear();
		                        AUDJPY_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO2S5_DOWN_S2 = 0;
		                for (; AUDJPY_OCO2S5_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets5.Count; AUDJPY_OCO2S5_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO2Sets5[AUDJPY_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO2Sets5[AUDJPY_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.AUDJPY_DOWN_S2_OCO2Sets5.Clear();
		                        AUDJPY_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO2S6_DOWN_S2 = 0;
		                for (; AUDJPY_OCO2S6_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets6.Count; AUDJPY_OCO2S6_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO2Sets6[AUDJPY_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO2Sets6[AUDJPY_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.AUDJPY_DOWN_S2_OCO2Sets6.Clear();
		                        AUDJPY_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDJPY_OCO3_EO1_DOWN_S2)
	                Base.AUDJPY_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDJPY_OCO3_EO2_DOWN_S2)
	                Base.AUDJPY_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO3_EO3_DOWN_S2)
	                Base.AUDJPY_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO3_EO4_DOWN_S2)
	                Base.AUDJPY_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO3_EO5_DOWN_S2)
	                Base.AUDJPY_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO3_EO6_DOWN_S2)
	                Base.AUDJPY_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDJPY_OCO3S1_DOWN_S2 = 0;
		                for (; AUDJPY_OCO3S1_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets1.Count; AUDJPY_OCO3S1_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO3Sets1[AUDJPY_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO3Sets1[AUDJPY_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.AUDJPY_DOWN_S2_OCO3Sets1.Clear();
		                        AUDJPY_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDJPY_OCO3S2_DOWN_S2 = 0;
		                for (; AUDJPY_OCO3S2_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets2.Count; AUDJPY_OCO3S2_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO3Sets2[AUDJPY_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO3Sets2[AUDJPY_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.AUDJPY_DOWN_S2_OCO3Sets2.Clear();
		                        AUDJPY_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO3S3_DOWN_S2 = 0;
		                for (; AUDJPY_OCO3S3_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets3.Count; AUDJPY_OCO3S3_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO3Sets3[AUDJPY_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO3Sets3[AUDJPY_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.AUDJPY_DOWN_S2_OCO3Sets3.Clear();
		                        AUDJPY_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO3S4_DOWN_S2 = 0;
		                for (; AUDJPY_OCO3S4_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets4.Count; AUDJPY_OCO3S4_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO3Sets4[AUDJPY_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO3Sets4[AUDJPY_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.AUDJPY_DOWN_S2_OCO3Sets4.Clear();
		                        AUDJPY_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO3S5_DOWN_S2 = 0;
		                for (; AUDJPY_OCO3S5_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets5.Count; AUDJPY_OCO3S5_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO3Sets5[AUDJPY_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO3Sets5[AUDJPY_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.AUDJPY_DOWN_S2_OCO3Sets5.Clear();
		                        AUDJPY_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO3S6_DOWN_S2 = 0;
		                for (; AUDJPY_OCO3S6_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets6.Count; AUDJPY_OCO3S6_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO3Sets6[AUDJPY_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO3Sets6[AUDJPY_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.AUDJPY_DOWN_S2_OCO3Sets6.Clear();
		                        AUDJPY_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDJPY_OCO4_EO1_DOWN_S2)
	                Base.AUDJPY_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDJPY_OCO4_EO2_DOWN_S2)
	                Base.AUDJPY_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO4_EO3_DOWN_S2)
	                Base.AUDJPY_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO4_EO4_DOWN_S2)
	                Base.AUDJPY_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO4_EO5_DOWN_S2)
	                Base.AUDJPY_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO4_EO6_DOWN_S2)
	                Base.AUDJPY_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDJPY_OCO4S1_DOWN_S2 = 0;
		                for (; AUDJPY_OCO4S1_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets1.Count; AUDJPY_OCO4S1_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO4Sets1[AUDJPY_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO4Sets1[AUDJPY_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.AUDJPY_DOWN_S2_OCO4Sets1.Clear();
		                        AUDJPY_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDJPY_OCO4S2_DOWN_S2 = 0;
		                for (; AUDJPY_OCO4S2_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets2.Count; AUDJPY_OCO4S2_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO4Sets2[AUDJPY_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO4Sets2[AUDJPY_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.AUDJPY_DOWN_S2_OCO4Sets2.Clear();
		                        AUDJPY_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO4S3_DOWN_S2 = 0;
		                for (; AUDJPY_OCO4S3_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets3.Count; AUDJPY_OCO4S3_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO4Sets3[AUDJPY_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO4Sets3[AUDJPY_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.AUDJPY_DOWN_S2_OCO4Sets3.Clear();
		                        AUDJPY_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO4S4_DOWN_S2 = 0;
		                for (; AUDJPY_OCO4S4_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets4.Count; AUDJPY_OCO4S4_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO4Sets4[AUDJPY_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO4Sets4[AUDJPY_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.AUDJPY_DOWN_S2_OCO4Sets4.Clear();
		                        AUDJPY_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO4S5_DOWN_S2 = 0;
		                for (; AUDJPY_OCO4S5_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets5.Count; AUDJPY_OCO4S5_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO4Sets5[AUDJPY_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO4Sets5[AUDJPY_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.AUDJPY_DOWN_S2_OCO4Sets5.Clear();
		                        AUDJPY_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO4S6_DOWN_S2 = 0;
		                for (; AUDJPY_OCO4S6_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets6.Count; AUDJPY_OCO4S6_DOWN_S2++)
		                    if (Base.AUDJPY_DOWN_S2_OCO4Sets6[AUDJPY_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_DOWN_S2_OCO4Sets6[AUDJPY_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.AUDJPY_DOWN_S2_OCO4Sets6.Clear();
		                        AUDJPY_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();
	            	}
	            	
					DOWM_AUDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDJPY_DOWN_S2 = DOWM_AUDJPY_DOWN_S2 || DOWT_AUDJPY_DOWN_S2 || DOWW_AUDJPY_DOWN_S2 || DOWTH_AUDJPY_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDJPY"))
	            	{
	            		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.AUDJPY_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.AUDJPY_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.AUDJPY_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.AUDJPY_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.AUDJPY_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDJPY_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDJPY_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDJPY_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDJPY_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDJPY_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDJPY_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	AUDJPY_Signal_Condition_DOWN_S2 =  
	                									(
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.04m &&
	                										
	                										//prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//prices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[1] > prices_ASK_Close[0] * 0.02m &&

	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 && //yuhukj
	                										
	                										//prices_BID_Open[0] - prices_ASK_Close[0] > 0 &&
 	                										
	                										//prices_BID_Close[0] > pricesM_ASK_High[0] && 
	                										//prices_ASK_High[0] > pricesM_ASK_High[0] && 
	                										
	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										pricesM_BID_Open[1] - pricesM_ASK_Close[1] > 0 &&

															pricesM_BID_High[1] - pricesM_ASK_Close[1] > prices_BID_Close[0] * 0.03m &&
	                										
	                										prices_ASK_High[0] > pricesM_ASK_High[0] &&
	                										//prices_BID_Close[0] < pricesM_BID_High[0] &&
	                										
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.05m
	                									);

	                    AUDJPY_DOWN_S2_SL  =  1.5m;
	                    AUDJPY_DOWN_S2_TP1 =  0.125m;
	                    AUDJPY_DOWN_S2_TP2 =  AUDJPY_DOWN_S2_SL * 0;
	                    AUDJPY_DOWN_S2_TP3 =  AUDJPY_DOWN_S2_SL * 0;
	                    AUDJPY_DOWN_S2_TP4 =  AUDJPY_DOWN_S2_SL * 0;
	                    AUDJPY_DOWN_S2_TP5 =  AUDJPY_DOWN_S2_SL * 0;
	                    AUDJPY_DOWN_S2_TP6 =  AUDJPY_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    AUDJPY_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    AUDJPY_quantity_SL_DOWN_S2 = AUDJPY_quantity_DOWN_S2;
	                    AUDJPY_quantity_TP1_DOWN_S2 = (int)Math.Floor(AUDJPY_quantity_DOWN_S2 * 1m);
	                    AUDJPY_quantity_TP2_DOWN_S2 = (int)Math.Floor(AUDJPY_quantity_TP1_DOWN_S2 * 0m);
	                    AUDJPY_quantity_TP3_DOWN_S2 = (int)Math.Floor(AUDJPY_quantity_TP2_DOWN_S2 * 0m);
	                    AUDJPY_quantity_TP4_DOWN_S2 = (int)Math.Floor(AUDJPY_quantity_TP3_DOWN_S2 * 0m);
	                    AUDJPY_quantity_TP5_DOWN_S2 = (int)Math.Floor(AUDJPY_quantity_TP4_DOWN_S2 * 0m);
	                    AUDJPY_quantity_TP6_DOWN_S2 = (int)Math.Floor(AUDJPY_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (AUDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDJPY_DOWN_S2 && 
	                    Base.AUDJPY_OCO1_DOWN_S2_IsReady == true &&
	                    Base.AUDJPY_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDJPY_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP1_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP1_OCO1");
	                         Base.AUDJPY_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDJPY_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP2_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP2_OCO1");
	                         Base.AUDJPY_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.AUDJPY_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP3_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP3_OCO1");
	                         Base.AUDJPY_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDJPY_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP4_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP4_OCO1");
	                         Base.AUDJPY_OCO1_EO4_DOWN_S2 = false;

							Base.AUDJPY_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.AUDJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (AUDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDJPY_DOWN_S2 && 
	                    Base.AUDJPY_OCO2_DOWN_S2_IsReady == true &&
	                    Base.AUDJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDJPY_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDJPY_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP1_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP1_OCO2");
	                         Base.AUDJPY_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDJPY_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP2_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP2_OCO2");
	                         Base.AUDJPY_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.AUDJPY_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP3_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP3_OCO2");
	                         Base.AUDJPY_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDJPY_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP4_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP4_OCO2");
	                         Base.AUDJPY_OCO2_EO4_DOWN_S2 = false;

							Base.AUDJPY_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.AUDJPY_OCO2_DOWN_S2_IsReady == false && Base.AUDJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (AUDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDJPY_DOWN_S2 &&
	                    Base.AUDJPY_OCO3_DOWN_S2_IsReady == true &&
	                    Base.AUDJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDJPY_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDJPY_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP1_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP1_OCO3");
	                         Base.AUDJPY_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDJPY_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP2_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP2_OCO3");
	                         Base.AUDJPY_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.AUDJPY_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP3_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP3_OCO3");
	                         Base.AUDJPY_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDJPY_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP4_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP4_OCO3");
	                         Base.AUDJPY_OCO3_EO4_DOWN_S2 = false;

							Base.AUDJPY_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.AUDJPY_OCO3_DOWN_S2_IsReady == false && Base.AUDJPY_OCO2_DOWN_S2_IsReady == false && Base.AUDJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (AUDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDJPY_DOWN_S2 && 
	                    Base.AUDJPY_OCO4_DOWN_S2_IsReady == true &&
	                    Base.AUDJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDJPY_OCO3_DOWN_S2_IsReady == false &&
	                    Base.AUDJPY_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDJPY_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP1_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP1_OCO4");
	                         Base.AUDJPY_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDJPY_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP2_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP2_OCO4");
	                         Base.AUDJPY_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.AUDJPY_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP3_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP3_OCO4");
	                         Base.AUDJPY_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDJPY_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDJPY_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP4_DOWN_S2, false,"AUDJPY_DOWN_S2_Entry_TP4_OCO4");
	                         Base.AUDJPY_OCO4_EO4_DOWN_S2 = false;

							Base.AUDJPY_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.AUDJPY_OCO4_DOWN_S2_IsReady == false && Base.AUDJPY_OCO3_DOWN_S2_IsReady == false && Base.AUDJPY_OCO2_DOWN_S2_IsReady == false && Base.AUDJPY_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.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 AUDCHF_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDCHF_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("AUDCHF OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCHF OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCHF OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCHF OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        }
		        
				if (Base.AUDCHF_OCO1_EO1_DOWN_S2)
	                Base.AUDCHF_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCHF_OCO1_EO2_DOWN_S2)
	                Base.AUDCHF_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO1_EO3_DOWN_S2)
	                Base.AUDCHF_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO1_EO4_DOWN_S2)
	                Base.AUDCHF_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDCHF_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP1_AUDCHF_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP1,"TP1_AUDCHF_DOWN_S2_OCO1"));
		                 };
		                Base.AUDCHF_DOWN_S2_OCO1Sets1.Add( Base.AUDCHF_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP2_AUDCHF_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP2,"TP2_AUDCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO1Sets2.Add( Base.AUDCHF_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP3_AUDCHF_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP3,"TP3_AUDCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO1Sets3.Add( Base.AUDCHF_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP4_AUDCHF_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP4,"TP4_AUDCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO1Sets4.Add( Base.AUDCHF_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDCHF_OCO1S1_DOWN_S2 = 0;
	                for (; AUDCHF_OCO1S1_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets1.Count; AUDCHF_OCO1S1_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO1Sets1[AUDCHF_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO1Sets1[AUDCHF_OCO1S1_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO1Sets1.RemoveAt(AUDCHF_OCO1S1_DOWN_S2);
	                        AUDCHF_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCHF_OCO1S2_DOWN_S2 = 0;
	                for (; AUDCHF_OCO1S2_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets2.Count; AUDCHF_OCO1S2_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO1Sets2[AUDCHF_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO1Sets2[AUDCHF_OCO1S2_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO1Sets2.RemoveAt(AUDCHF_OCO1S2_DOWN_S2);
	                        AUDCHF_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO1S3_DOWN_S2 = 0;
	                for (; AUDCHF_OCO1S3_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets3.Count; AUDCHF_OCO1S3_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO1Sets3[AUDCHF_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO1Sets3[AUDCHF_OCO1S3_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO1Sets3.RemoveAt(AUDCHF_OCO1S3_DOWN_S2);
	                        AUDCHF_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO1S4_DOWN_S2 = 0;
	                for (; AUDCHF_OCO1S4_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets4.Count; AUDCHF_OCO1S4_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO1Sets4[AUDCHF_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO1Sets4[AUDCHF_OCO1S4_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO1Sets4.RemoveAt(AUDCHF_OCO1S4_DOWN_S2);
	                        AUDCHF_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCHF_OCO2_EO1_DOWN_S2)
	                Base.AUDCHF_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCHF_OCO2_EO2_DOWN_S2)
	                Base.AUDCHF_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO2_EO3_DOWN_S2)
	                Base.AUDCHF_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO2_EO4_DOWN_S2)
	                Base.AUDCHF_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDCHF_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP1_AUDCHF_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP1,"TP1_AUDCHF_DOWN_S2_OCO2"));
		                 };
		                Base.AUDCHF_DOWN_S2_OCO2Sets1.Add( Base.AUDCHF_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP2_AUDCHF_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP2,"TP2_AUDCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO2Sets2.Add( Base.AUDCHF_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP3_AUDCHF_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP3,"TP3_AUDCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO2Sets3.Add( Base.AUDCHF_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP4_AUDCHF_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP4,"TP4_AUDCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO2Sets4.Add( Base.AUDCHF_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDCHF_OCO2S1_DOWN_S2 = 0;
	                for (; AUDCHF_OCO2S1_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets1.Count; AUDCHF_OCO2S1_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO2Sets1[AUDCHF_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO2Sets1[AUDCHF_OCO2S1_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO2Sets1.RemoveAt(AUDCHF_OCO2S1_DOWN_S2);
	                        AUDCHF_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCHF_OCO2S2_DOWN_S2 = 0;
	                for (; AUDCHF_OCO2S2_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets2.Count; AUDCHF_OCO2S2_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO2Sets2[AUDCHF_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO2Sets2[AUDCHF_OCO2S2_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO2Sets2.RemoveAt(AUDCHF_OCO2S2_DOWN_S2);
	                        AUDCHF_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO2S3_DOWN_S2 = 0;
	                for (; AUDCHF_OCO2S3_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets3.Count; AUDCHF_OCO2S3_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO2Sets3[AUDCHF_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO2Sets3[AUDCHF_OCO2S3_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO2Sets3.RemoveAt(AUDCHF_OCO2S3_DOWN_S2);
	                        AUDCHF_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO2S4_DOWN_S2 = 0;
	                for (; AUDCHF_OCO2S4_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets4.Count; AUDCHF_OCO2S4_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO2Sets4[AUDCHF_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO2Sets4[AUDCHF_OCO2S4_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO2Sets4.RemoveAt(AUDCHF_OCO2S4_DOWN_S2);
	                        AUDCHF_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCHF_OCO3_EO1_DOWN_S2)
	                Base.AUDCHF_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCHF_OCO3_EO2_DOWN_S2)
	                Base.AUDCHF_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO3_EO3_DOWN_S2)
	                Base.AUDCHF_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO3_EO4_DOWN_S2)
	                Base.AUDCHF_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDCHF_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP1_AUDCHF_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP1,"TP1_AUDCHF_DOWN_S2_OCO3"));
		                 };
		                Base.AUDCHF_DOWN_S2_OCO3Sets1.Add( Base.AUDCHF_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP2_AUDCHF_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP2,"TP2_AUDCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO3Sets2.Add( Base.AUDCHF_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP3_AUDCHF_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP3,"TP3_AUDCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO3Sets3.Add( Base.AUDCHF_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP4_AUDCHF_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP4,"TP4_AUDCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO3Sets4.Add( Base.AUDCHF_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDCHF_OCO3S1_DOWN_S2 = 0;
	                for (; AUDCHF_OCO3S1_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets1.Count; AUDCHF_OCO3S1_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO3Sets1[AUDCHF_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO3Sets1[AUDCHF_OCO3S1_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO3Sets1.RemoveAt(AUDCHF_OCO3S1_DOWN_S2);
	                        AUDCHF_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCHF_OCO3S2_DOWN_S2 = 0;
	                for (; AUDCHF_OCO3S2_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets2.Count; AUDCHF_OCO3S2_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO3Sets2[AUDCHF_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO3Sets2[AUDCHF_OCO3S2_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO3Sets2.RemoveAt(AUDCHF_OCO3S2_DOWN_S2);
	                        AUDCHF_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO3S3_DOWN_S2 = 0;
	                for (; AUDCHF_OCO3S3_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets3.Count; AUDCHF_OCO3S3_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO3Sets3[AUDCHF_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO3Sets3[AUDCHF_OCO3S3_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO3Sets3.RemoveAt(AUDCHF_OCO3S3_DOWN_S2);
	                        AUDCHF_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO3S4_DOWN_S2 = 0;
	                for (; AUDCHF_OCO3S4_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets4.Count; AUDCHF_OCO3S4_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO3Sets4[AUDCHF_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO3Sets4[AUDCHF_OCO3S4_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO3Sets4.RemoveAt(AUDCHF_OCO3S4_DOWN_S2);
	                        AUDCHF_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCHF_OCO4_EO1_DOWN_S2)
	                Base.AUDCHF_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCHF_OCO4_EO2_DOWN_S2)
	                Base.AUDCHF_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO4_EO3_DOWN_S2)
	                Base.AUDCHF_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO4_EO4_DOWN_S2)
	                Base.AUDCHF_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDCHF_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP1_AUDCHF_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP1,"TP1_AUDCHF_DOWN_S2_OCO4"));
		                 };
		                Base.AUDCHF_DOWN_S2_OCO4Sets1.Add( Base.AUDCHF_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP2_AUDCHF_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP2,"TP2_AUDCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO4Sets2.Add( Base.AUDCHF_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP3_AUDCHF_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP3,"TP3_AUDCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO4Sets3.Add( Base.AUDCHF_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_DOWN_S2_SL,"SL_TP4_AUDCHF_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_DOWN_S2_TP4,"TP4_AUDCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDCHF_DOWN_S2_OCO4Sets4.Add( Base.AUDCHF_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDCHF_OCO4S1_DOWN_S2 = 0;
	                for (; AUDCHF_OCO4S1_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets1.Count; AUDCHF_OCO4S1_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO4Sets1[AUDCHF_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO4Sets1[AUDCHF_OCO4S1_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO4Sets1.RemoveAt(AUDCHF_OCO4S1_DOWN_S2);
	                        AUDCHF_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCHF_OCO4S2_DOWN_S2 = 0;
	                for (; AUDCHF_OCO4S2_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets2.Count; AUDCHF_OCO4S2_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO4Sets2[AUDCHF_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO4Sets2[AUDCHF_OCO4S2_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO4Sets2.RemoveAt(AUDCHF_OCO4S2_DOWN_S2);
	                        AUDCHF_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO4S3_DOWN_S2 = 0;
	                for (; AUDCHF_OCO4S3_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets3.Count; AUDCHF_OCO4S3_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO4Sets3[AUDCHF_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO4Sets3[AUDCHF_OCO4S3_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO4Sets3.RemoveAt(AUDCHF_OCO4S3_DOWN_S2);
	                        AUDCHF_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO4S4_DOWN_S2 = 0;
	                for (; AUDCHF_OCO4S4_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets4.Count; AUDCHF_OCO4S4_DOWN_S2++)
	                    if (Base.AUDCHF_DOWN_S2_OCO4Sets4[AUDCHF_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_DOWN_S2_OCO4Sets4[AUDCHF_OCO4S4_DOWN_S2].Filled();
	                        Base.AUDCHF_DOWN_S2_OCO4Sets4.RemoveAt(AUDCHF_OCO4S4_DOWN_S2);
	                        AUDCHF_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDJPY_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDJPY_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(x=>x.Tag.Contains("AUDJPY_UP_S2_OCO1")))
			{
				Base.AUDJPY_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDJPY_UP_S2_OCO2")))
			{
				Base.AUDJPY_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDJPY_UP_S2_OCO3")))
			{
				Base.AUDJPY_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDJPY_UP_S2_OCO4")))
			{
				Base.AUDJPY_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDJPY_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.AUDJPY_OCO1_EO1_UP_S2)
	                Base.AUDJPY_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDJPY_OCO1_EO2_UP_S2)
	                Base.AUDJPY_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO1_EO3_UP_S2)
	                Base.AUDJPY_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO1_EO4_UP_S2)
	                Base.AUDJPY_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO1_EO5_UP_S2)
	                Base.AUDJPY_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO1_EO6_UP_S2)
	                Base.AUDJPY_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDJPY_OCO1S1_UP_S2 = 0;
		                for (; AUDJPY_OCO1S1_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets1.Count; AUDJPY_OCO1S1_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO1Sets1[AUDJPY_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO1Sets1[AUDJPY_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_1__Time out_OCO1");
		                        Base.AUDJPY_UP_S2_OCO1Sets1.Clear();
		                        AUDJPY_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDJPY_OCO1S2_UP_S2 = 0;
		                for (; AUDJPY_OCO1S2_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets2.Count; AUDJPY_OCO1S2_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO1Sets2[AUDJPY_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO1Sets2[AUDJPY_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_2__Time out_OCO1");
		                        Base.AUDJPY_UP_S2_OCO1Sets2.Clear();
		                        AUDJPY_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO1S3_UP_S2 = 0;
		                for (; AUDJPY_OCO1S3_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets3.Count; AUDJPY_OCO1S3_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO1Sets3[AUDJPY_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO1Sets3[AUDJPY_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_3__Time out_OCO1");
		                        Base.AUDJPY_UP_S2_OCO1Sets3.Clear();
		                        AUDJPY_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO1S4_UP_S2 = 0;
		                for (; AUDJPY_OCO1S4_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets4.Count; AUDJPY_OCO1S4_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO1Sets4[AUDJPY_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO1Sets4[AUDJPY_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_4__Time out_OCO1");
		                        Base.AUDJPY_UP_S2_OCO1Sets4.Clear();
		                        AUDJPY_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO1S5_UP_S2 = 0;
		                for (; AUDJPY_OCO1S5_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets5.Count; AUDJPY_OCO1S5_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO1Sets5[AUDJPY_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO1Sets5[AUDJPY_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_5__Time out_OCO1");
		                        Base.AUDJPY_UP_S2_OCO1Sets5.Clear();
		                        AUDJPY_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO1S6_UP_S2 = 0;
		                for (; AUDJPY_OCO1S6_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets6.Count; AUDJPY_OCO1S6_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO1Sets6[AUDJPY_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO1Sets6[AUDJPY_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_6__Time out_OCO1");
		                        Base.AUDJPY_UP_S2_OCO1Sets6.Clear();
		                        AUDJPY_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDJPY_OCO2_EO1_UP_S2)
                	Base.AUDJPY_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDJPY_OCO2_EO2_UP_S2)
	                Base.AUDJPY_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO2_EO3_UP_S2)
	                Base.AUDJPY_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO2_EO4_UP_S2)
	                Base.AUDJPY_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO2_EO5_UP_S2)
	                Base.AUDJPY_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO2_EO6_UP_S2)
	                Base.AUDJPY_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDJPY_OCO2S1_UP_S2 = 0;
		                for (; AUDJPY_OCO2S1_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets1.Count; AUDJPY_OCO2S1_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO2Sets1[AUDJPY_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO2Sets1[AUDJPY_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_1__Time out_OCO2");
		                        Base.AUDJPY_UP_S2_OCO2Sets1.Clear();
		                        AUDJPY_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDJPY_OCO2S2_UP_S2 = 0;
		                for (; AUDJPY_OCO2S2_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets2.Count; AUDJPY_OCO2S2_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO2Sets2[AUDJPY_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO2Sets2[AUDJPY_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_2__Time out_OCO2");
		                        Base.AUDJPY_UP_S2_OCO2Sets2.Clear();
		                        AUDJPY_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO2S3_UP_S2 = 0;
		                for (; AUDJPY_OCO2S3_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets3.Count; AUDJPY_OCO2S3_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO2Sets3[AUDJPY_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO2Sets3[AUDJPY_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_3__Time out_OCO2");
		                        Base.AUDJPY_UP_S2_OCO2Sets3.Clear();
		                        AUDJPY_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO2S4_UP_S2 = 0;
		                for (; AUDJPY_OCO2S4_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets4.Count; AUDJPY_OCO2S4_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO2Sets4[AUDJPY_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO2Sets4[AUDJPY_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_4__Time out_OCO2");
		                        Base.AUDJPY_UP_S2_OCO2Sets4.Clear();
		                        AUDJPY_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO2S5_UP_S2 = 0;
		                for (; AUDJPY_OCO2S5_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets5.Count; AUDJPY_OCO2S5_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO2Sets5[AUDJPY_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO2Sets5[AUDJPY_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_5__Time out_OCO2");
		                        Base.AUDJPY_UP_S2_OCO2Sets5.Clear();
		                        AUDJPY_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO2S6_UP_S2 = 0;
		                for (; AUDJPY_OCO2S6_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets6.Count; AUDJPY_OCO2S6_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO2Sets6[AUDJPY_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO2Sets6[AUDJPY_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_6__Time out_OCO2");
		                        Base.AUDJPY_UP_S2_OCO2Sets6.Clear();
		                        AUDJPY_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDJPY_OCO3_EO1_UP_S2)
            		Base.AUDJPY_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDJPY_OCO3_EO2_UP_S2)
	                Base.AUDJPY_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO3_EO3_UP_S2)
	                Base.AUDJPY_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO3_EO4_UP_S2)
	                Base.AUDJPY_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO3_EO5_UP_S2)
	                Base.AUDJPY_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO3_EO6_UP_S2)
	                Base.AUDJPY_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDJPY_OCO3S1_UP_S2 = 0;
		                for (; AUDJPY_OCO3S1_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets1.Count; AUDJPY_OCO3S1_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO3Sets1[AUDJPY_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO3Sets1[AUDJPY_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_1__Time out_OCO3");
		                        Base.AUDJPY_UP_S2_OCO3Sets1.Clear();
		                        AUDJPY_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDJPY_OCO3S2_UP_S2 = 0;
		                for (; AUDJPY_OCO3S2_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets2.Count; AUDJPY_OCO3S2_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO3Sets2[AUDJPY_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO3Sets2[AUDJPY_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_2__Time out_OCO3");
		                        Base.AUDJPY_UP_S2_OCO3Sets2.Clear();
		                        AUDJPY_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO3S3_UP_S2 = 0;
		                for (; AUDJPY_OCO3S3_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets3.Count; AUDJPY_OCO3S3_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO3Sets3[AUDJPY_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO3Sets3[AUDJPY_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_3__Time out_OCO3");
		                        Base.AUDJPY_UP_S2_OCO3Sets3.Clear();
		                        AUDJPY_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO3S4_UP_S2 = 0;
		                for (; AUDJPY_OCO3S4_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets4.Count; AUDJPY_OCO3S4_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO3Sets4[AUDJPY_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO3Sets4[AUDJPY_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_4__Time out_OCO3");
		                        Base.AUDJPY_UP_S2_OCO3Sets4.Clear();
		                        AUDJPY_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO3S5_UP_S2 = 0;
		                for (; AUDJPY_OCO3S5_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets5.Count; AUDJPY_OCO3S5_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO3Sets5[AUDJPY_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO3Sets5[AUDJPY_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_5__Time out_OCO3");
		                        Base.AUDJPY_UP_S2_OCO3Sets5.Clear();
		                        AUDJPY_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO3S6_UP_S2 = 0;
		                for (; AUDJPY_OCO3S6_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets6.Count; AUDJPY_OCO3S6_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO3Sets6[AUDJPY_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO3Sets6[AUDJPY_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_6__Time out_OCO3");
		                        Base.AUDJPY_UP_S2_OCO3Sets6.Clear();
		                        AUDJPY_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDJPY_OCO4_EO1_UP_S2)
            		Base.AUDJPY_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDJPY_OCO4_EO2_UP_S2)
	                Base.AUDJPY_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO4_EO3_UP_S2)
	                Base.AUDJPY_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO4_EO4_UP_S2)
	                Base.AUDJPY_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO4_EO5_UP_S2)
	                Base.AUDJPY_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDJPY_OCO4_EO6_UP_S2)
	                Base.AUDJPY_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDJPY_OCO4S1_UP_S2 = 0;
		                for (; AUDJPY_OCO4S1_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets1.Count; AUDJPY_OCO4S1_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO4Sets1[AUDJPY_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO4Sets1[AUDJPY_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_1__Time out_OCO4");
		                        Base.AUDJPY_UP_S2_OCO4Sets1.Clear();
		                        AUDJPY_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDJPY_OCO4S2_UP_S2 = 0;
		                for (; AUDJPY_OCO4S2_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets2.Count; AUDJPY_OCO4S2_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO4Sets2[AUDJPY_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO4Sets2[AUDJPY_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_2__Time out_OCO4");
		                        Base.AUDJPY_UP_S2_OCO4Sets2.Clear();
		                        AUDJPY_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO4S3_UP_S2 = 0;
		                for (; AUDJPY_OCO4S3_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets3.Count; AUDJPY_OCO4S3_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO4Sets3[AUDJPY_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO4Sets3[AUDJPY_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_3__Time out_OCO4");
		                        Base.AUDJPY_UP_S2_OCO4Sets3.Clear();
		                        AUDJPY_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDJPY_OCO4S4_UP_S2 = 0;
		                for (; AUDJPY_OCO4S4_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets4.Count; AUDJPY_OCO4S4_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO4Sets4[AUDJPY_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO4Sets4[AUDJPY_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_4__Time out_OCO4");
		                        Base.AUDJPY_UP_S2_OCO4Sets4.Clear();
		                        AUDJPY_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO4S5_UP_S2 = 0;
		                for (; AUDJPY_OCO4S5_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets5.Count; AUDJPY_OCO4S5_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO4Sets5[AUDJPY_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO4Sets5[AUDJPY_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_5__Time out_OCO4");
		                        Base.AUDJPY_UP_S2_OCO4Sets5.Clear();
		                        AUDJPY_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDJPY_OCO4S6_UP_S2 = 0;
		                for (; AUDJPY_OCO4S6_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets6.Count; AUDJPY_OCO4S6_UP_S2++)
		                    if (Base.AUDJPY_UP_S2_OCO4Sets6[AUDJPY_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDJPY_UP_S2_OCO4Sets6[AUDJPY_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("AUDJPY", order.Quantity, false, "AUDJPY_UP_S2_Entry_6__Time out_OCO4");
		                        Base.AUDJPY_UP_S2_OCO4Sets6.Clear();
		                        AUDJPY_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_AUDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDJPY_UP_S2 = DOWM_AUDJPY_UP_S2 || DOWT_AUDJPY_UP_S2 || DOWW_AUDJPY_UP_S2 || DOWTH_AUDJPY_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDJPY") && SY1D.Symbol.ID.Market == Market.FXCM)
	            	{
	            		if(SY1D.BQ[0].Open != 0)
	            		{
	            			algorithm.Debug("ID : " + SY1D.Symbol.ID.Market);
	            		}
	            		
	            		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.AUDJPY_OCO1_UP_S2_IsReady == false ||
	                    	Base.AUDJPY_OCO2_UP_S2_IsReady == false ||
	                    	Base.AUDJPY_OCO3_UP_S2_IsReady == false ||
	                    	Base.AUDJPY_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.AUDJPY_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDJPY_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDJPY_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDJPY_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDJPY_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.AUDJPY_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.AUDJPY_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.AUDJPY_OCO4_UP_S2_Monthly_IsReady = true;
                    	}

	                	AUDJPY_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										
		                										)
		                							
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                	AUDJPY_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                									
	                	AUDJPY_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										&&
		                										
		                										(

		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.681m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.681m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                	if (AUDJPY_Signal_Condition_UP_1)
	                	{
	                    	AUDJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDJPY_Signal_Condition_UP_2)
	                	{
	                    	AUDJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDJPY_Signal_Condition_UP_3)
	                	{
	                    	AUDJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (AUDJPY_Signal_Condition_UP_1)
	                	{
	                    	AUDJPY_UP_S2_TP1  =  Base.Yen_TP_1 ;
	                	}
	                	
	                	if (AUDJPY_Signal_Condition_UP_2)
	                	{
	                    	AUDJPY_UP_S2_TP1  =  Base.Yen_TP_2 ;
	                	}
	                	
	                	if (AUDJPY_Signal_Condition_UP_3)
	                	{
	                    	AUDJPY_UP_S2_TP1  =  Base.Yen_TP_3 ;
	                	}

	                    AUDJPY_UP_S2_TP2 =  AUDJPY_UP_S2_SL * 0;
	                    AUDJPY_UP_S2_TP3 =  AUDJPY_UP_S2_SL * 0;
	                    AUDJPY_UP_S2_TP4 =  AUDJPY_UP_S2_SL * 0;
	                    AUDJPY_UP_S2_TP5 =  AUDJPY_UP_S2_SL * 0;
	                    AUDJPY_UP_S2_TP6 =  AUDJPY_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    AUDJPY_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    AUDJPY_quantity_SL_UP_S2 = AUDJPY_quantity_UP_S2;
	                    AUDJPY_quantity_TP1_UP_S2 = (int)Math.Floor(AUDJPY_quantity_UP_S2 * 1m);
	                    AUDJPY_quantity_TP2_UP_S2 = (int)Math.Floor(AUDJPY_quantity_TP1_UP_S2 * 0m);
	                    AUDJPY_quantity_TP3_UP_S2 = (int)Math.Floor(AUDJPY_quantity_TP2_UP_S2 * 0m);
	                    AUDJPY_quantity_TP4_UP_S2 = (int)Math.Floor(AUDJPY_quantity_TP3_UP_S2 * 0m);
	                    AUDJPY_quantity_TP5_UP_S2 = (int)Math.Floor(AUDJPY_quantity_TP4_UP_S2 * 0m);
	                    AUDJPY_quantity_TP6_UP_S2 = (int)Math.Floor(AUDJPY_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((AUDJPY_Signal_Condition_UP_1 || AUDJPY_Signal_Condition_UP_2 || AUDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_AUDJPY_UP_S2 && 
	                    Base.AUDJPY_OCO1_UP_S2_IsReady == true &&
	                    Base.AUDJPY_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDJPY_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP1_UP_S2, false,"AUDJPY_UP_S2_Entry_TP1_OCO1");
	                         Base.AUDJPY_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.AUDJPY_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP2_UP_S2, false,"AUDJPY_UP_S2_Entry_TP2_OCO1");
	                         Base.AUDJPY_OCO1_EO2_UP_S2 = false;
	
	                         Base.AUDJPY_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP3_UP_S2, false,"AUDJPY_UP_S2_Entry_TP3_OCO1");
	                         Base.AUDJPY_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.AUDJPY_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP4_UP_S2, false,"AUDJPY_UP_S2_Entry_TP4_OCO1");
	                         Base.AUDJPY_OCO1_EO4_UP_S2 = false;

							Base.AUDJPY_OCO1_UP_S2_IsReady = false;
							
							if (Base.AUDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco2:
	                    if ((AUDJPY_Signal_Condition_UP_1 || AUDJPY_Signal_Condition_UP_2 || AUDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_AUDJPY_UP_S2 && 
	                    Base.AUDJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDJPY_OCO2_UP_S2_IsReady == true &&
	                    Base.AUDJPY_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDJPY_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP1_UP_S2, false,"AUDJPY_UP_S2_Entry_TP1_OCO2");
	                         Base.AUDJPY_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.AUDJPY_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP2_UP_S2, false,"AUDJPY_UP_S2_Entry_TP2_OCO2");
	                         Base.AUDJPY_OCO2_EO2_UP_S2 = false;
	
	                         Base.AUDJPY_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP3_UP_S2, false,"AUDJPY_UP_S2_Entry_TP3_OCO2");
	                         Base.AUDJPY_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.AUDJPY_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP4_UP_S2, false,"AUDJPY_UP_S2_Entry_TP4_OCO2");
	                         Base.AUDJPY_OCO2_EO4_UP_S2 = false;

							Base.AUDJPY_OCO2_UP_S2_IsReady = false;
							
							if (Base.AUDJPY_OCO2_UP_S2_IsReady == false && Base.AUDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco3:
	                    if ((AUDJPY_Signal_Condition_UP_1 || AUDJPY_Signal_Condition_UP_2 || AUDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_AUDJPY_UP_S2 &&
	                    Base.AUDJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDJPY_OCO3_UP_S2_IsReady == true &&
	                    Base.AUDJPY_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDJPY_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP1_UP_S2, false,"AUDJPY_UP_S2_Entry_TP1_OCO3");
	                         Base.AUDJPY_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.AUDJPY_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP2_UP_S2, false,"AUDJPY_UP_S2_Entry_TP2_OCO3");
	                         Base.AUDJPY_OCO3_EO2_UP_S2 = false;
	
	                         Base.AUDJPY_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP3_UP_S2, false,"AUDJPY_UP_S2_Entry_TP3_OCO3");
	                         Base.AUDJPY_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.AUDJPY_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP4_UP_S2, false,"AUDJPY_UP_S2_Entry_TP4_OCO3");
	                         Base.AUDJPY_OCO3_EO4_UP_S2 = false;

							Base.AUDJPY_OCO3_UP_S2_IsReady = false;
							
							if (Base.AUDJPY_OCO3_UP_S2_IsReady == false && Base.AUDJPY_OCO2_UP_S2_IsReady == false && Base.AUDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco4:
	                    if ((AUDJPY_Signal_Condition_UP_1 || AUDJPY_Signal_Condition_UP_2 || AUDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_AUDJPY_UP_S2 && 
	                    Base.AUDJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDJPY_OCO3_UP_S2_IsReady == false &&
	                    Base.AUDJPY_OCO4_UP_S2_IsReady == true &&
	                    Base.AUDJPY_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDJPY_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP1_UP_S2, false,"AUDJPY_UP_S2_Entry_TP1_OCO4");
	                         Base.AUDJPY_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.AUDJPY_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP2_UP_S2, false,"AUDJPY_UP_S2_Entry_TP2_OCO4");
	                         Base.AUDJPY_OCO4_EO2_UP_S2 = false;
	
	                         Base.AUDJPY_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP3_UP_S2, false,"AUDJPY_UP_S2_Entry_TP3_OCO4");
	                         Base.AUDJPY_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.AUDJPY_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDJPY_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDJPY_quantity_TP4_UP_S2, false,"AUDJPY_UP_S2_Entry_TP4_OCO4");
	                         Base.AUDJPY_OCO4_EO4_UP_S2 = false;

							Base.AUDJPY_OCO4_UP_S2_IsReady = false;
							
							if (Base.AUDJPY_OCO4_UP_S2_IsReady == false && Base.AUDJPY_OCO3_UP_S2_IsReady == false && Base.AUDJPY_OCO2_UP_S2_IsReady == false && Base.AUDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct AUDJPY_OCO1_DOWN_S2
    {
        public AUDJPY_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 =="TP1_AUDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY 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 =="TP1_AUDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY 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 AUDJPY_OCO1_UP_S2
    {
        public AUDJPY_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 =="TP1_AUDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY 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 =="TP1_AUDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDJPY 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 AUDJPY_OCO2_DOWN_S2
    {
        public AUDJPY_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 =="TP1_AUDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY 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 =="TP1_AUDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY 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 AUDJPY_OCO2_UP_S2
    {
        public AUDJPY_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 =="TP1_AUDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY 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 =="TP1_AUDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDJPY 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 AUDJPY_OCO3_DOWN_S2
    {
        public AUDJPY_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 =="TP1_AUDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY 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 =="TP1_AUDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY 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 AUDJPY_OCO3_UP_S2
    {
        public AUDJPY_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 =="TP1_AUDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY 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 =="TP1_AUDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDJPY 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 AUDJPY_OCO4_DOWN_S2
    {
        public AUDJPY_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 =="TP1_AUDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY 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 =="TP1_AUDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY 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 AUDJPY_OCO4_UP_S2
    {
        public AUDJPY_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 =="TP1_AUDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY 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 =="TP1_AUDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDJPY 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 AUDNZD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDNZD_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("AUDNZD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDNZD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDNZD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDNZD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDNZD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDNZD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDNZD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        }
		        
				if (Base.AUDNZD_OCO1_EO1_UP_S2)
	                Base.AUDNZD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDNZD_OCO1_EO2_UP_S2)
	                Base.AUDNZD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO1_EO3_UP_S2)
	                Base.AUDNZD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO1_EO4_UP_S2)
	                Base.AUDNZD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO1_EO5_UP_S2)
	                Base.AUDNZD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO1_EO6_UP_S2)
	                Base.AUDNZD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.AUDNZD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP1,"TP1_AUDNZD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP1_AUDNZD_UP_S2_OCO1"));
		                 };
		                Base.AUDNZD_UP_S2_OCO1Sets1.Add( Base.AUDNZD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP2,"TP2_AUDNZD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP2_AUDNZD_UP_S2_OCO1"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO1Sets2.Add( Base.AUDNZD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP3,"TP3_AUDNZD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP3_AUDNZD_UP_S2_OCO1"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO1Sets3.Add( Base.AUDNZD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP4,"TP4_AUDNZD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP4_AUDNZD_UP_S2_OCO1"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO1Sets4.Add( Base.AUDNZD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP5,"TP5_AUDNZD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP5_AUDNZD_UP_S2_OCO1"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO1Sets5.Add( Base.AUDNZD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP6,"TP6_AUDNZD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP6_AUDNZD_UP_S2_OCO1"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO1Sets6.Add( Base.AUDNZD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDNZD_OCO1S1_UP_S2 = 0;
	                for (; AUDNZD_OCO1S1_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets1.Count; AUDNZD_OCO1S1_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO1Sets1[AUDNZD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO1Sets1[AUDNZD_OCO1S1_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO1Sets1.RemoveAt(AUDNZD_OCO1S1_UP_S2);
	                        AUDNZD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDNZD_OCO1S2_UP_S2 = 0;
	                for (; AUDNZD_OCO1S2_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets2.Count; AUDNZD_OCO1S2_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO1Sets2[AUDNZD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO1Sets2[AUDNZD_OCO1S2_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO1Sets2.RemoveAt(AUDNZD_OCO1S2_UP_S2);
	                        AUDNZD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO1S3_UP_S2 = 0;
	                for (; AUDNZD_OCO1S3_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets3.Count; AUDNZD_OCO1S3_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO1Sets3[AUDNZD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO1Sets3[AUDNZD_OCO1S3_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO1Sets3.RemoveAt(AUDNZD_OCO1S3_UP_S2);
	                        AUDNZD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO1S4_UP_S2 = 0;
	                for (; AUDNZD_OCO1S4_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets4.Count; AUDNZD_OCO1S4_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO1Sets4[AUDNZD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO1Sets4[AUDNZD_OCO1S4_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO1Sets4.RemoveAt(AUDNZD_OCO1S4_UP_S2);
	                        AUDNZD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDNZD_OCO1S5_UP_S2 = 0;
	                for (; AUDNZD_OCO1S5_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets5.Count; AUDNZD_OCO1S5_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO1Sets5[AUDNZD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO1Sets5[AUDNZD_OCO1S5_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO1Sets5.RemoveAt(AUDNZD_OCO1S5_UP_S2);
	                        AUDNZD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDNZD_OCO1S6_UP_S2 = 0;
	                for (; AUDNZD_OCO1S6_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets6.Count; AUDNZD_OCO1S6_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO1Sets6[AUDNZD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO1Sets6[AUDNZD_OCO1S6_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO1Sets6.RemoveAt(AUDNZD_OCO1S6_UP_S2);
	                        AUDNZD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.AUDNZD_OCO2_EO1_UP_S2)
	                Base.AUDNZD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDNZD_OCO2_EO2_UP_S2)
	                Base.AUDNZD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO2_EO3_UP_S2)
	                Base.AUDNZD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO2_EO4_UP_S2)
	                Base.AUDNZD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO2_EO5_UP_S2)
	                Base.AUDNZD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO2_EO6_UP_S2)
	                Base.AUDNZD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.AUDNZD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP1,"TP1_AUDNZD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP1_AUDNZD_UP_S2_OCO2"));
		                 };
		                Base.AUDNZD_UP_S2_OCO2Sets1.Add( Base.AUDNZD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP2,"TP2_AUDNZD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP2_AUDNZD_UP_S2_OCO2"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO2Sets2.Add( Base.AUDNZD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP3,"TP3_AUDNZD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP3_AUDNZD_UP_S2_OCO2"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO2Sets3.Add( Base.AUDNZD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP4,"TP4_AUDNZD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP4_AUDNZD_UP_S2_OCO2"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO2Sets4.Add( Base.AUDNZD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP5,"TP5_AUDNZD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP5_AUDNZD_UP_S2_OCO2"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO2Sets5.Add( Base.AUDNZD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP6,"TP6_AUDNZD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP6_AUDNZD_UP_S2_OCO2"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO2Sets6.Add( Base.AUDNZD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDNZD_OCO2S1_UP_S2 = 0;
	                for (; AUDNZD_OCO2S1_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets1.Count; AUDNZD_OCO2S1_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO2Sets1[AUDNZD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO2Sets1[AUDNZD_OCO2S1_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO2Sets1.RemoveAt(AUDNZD_OCO2S1_UP_S2);
	                        AUDNZD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDNZD_OCO2S2_UP_S2 = 0;
	                for (; AUDNZD_OCO2S2_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets2.Count; AUDNZD_OCO2S2_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO2Sets2[AUDNZD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO2Sets2[AUDNZD_OCO2S2_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO2Sets2.RemoveAt(AUDNZD_OCO2S2_UP_S2);
	                        AUDNZD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO2S3_UP_S2 = 0;
	                for (; AUDNZD_OCO2S3_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets3.Count; AUDNZD_OCO2S3_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO2Sets3[AUDNZD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO2Sets3[AUDNZD_OCO2S3_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO2Sets3.RemoveAt(AUDNZD_OCO2S3_UP_S2);
	                        AUDNZD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO2S4_UP_S2 = 0;
	                for (; AUDNZD_OCO2S4_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets4.Count; AUDNZD_OCO2S4_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO2Sets4[AUDNZD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO2Sets4[AUDNZD_OCO2S4_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO2Sets4.RemoveAt(AUDNZD_OCO2S4_UP_S2);
	                        AUDNZD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDNZD_OCO2S5_UP_S2 = 0;
	                for (; AUDNZD_OCO2S5_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets5.Count; AUDNZD_OCO2S5_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO2Sets5[AUDNZD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO2Sets5[AUDNZD_OCO2S5_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO2Sets5.RemoveAt(AUDNZD_OCO2S5_UP_S2);
	                        AUDNZD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDNZD_OCO2S6_UP_S2 = 0;
	                for (; AUDNZD_OCO2S6_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets6.Count; AUDNZD_OCO2S6_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO2Sets6[AUDNZD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO2Sets6[AUDNZD_OCO2S6_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO2Sets6.RemoveAt(AUDNZD_OCO2S6_UP_S2);
	                        AUDNZD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDNZD_OCO3_EO1_UP_S2)
	                Base.AUDNZD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDNZD_OCO3_EO2_UP_S2)
	                Base.AUDNZD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO3_EO3_UP_S2)
	                Base.AUDNZD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO3_EO4_UP_S2)
	                Base.AUDNZD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO3_EO5_UP_S2)
	                Base.AUDNZD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO3_EO6_UP_S2)
	                Base.AUDNZD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.AUDNZD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP1,"TP1_AUDNZD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP1_AUDNZD_UP_S2_OCO3"));
		                 };
		                Base.AUDNZD_UP_S2_OCO3Sets1.Add( Base.AUDNZD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP2,"TP2_AUDNZD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP2_AUDNZD_UP_S2_OCO3"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO3Sets2.Add( Base.AUDNZD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP3,"TP3_AUDNZD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP3_AUDNZD_UP_S2_OCO3"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO3Sets3.Add( Base.AUDNZD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP4,"TP4_AUDNZD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP4_AUDNZD_UP_S2_OCO3"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO3Sets4.Add( Base.AUDNZD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP5,"TP5_AUDNZD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP5_AUDNZD_UP_S2_OCO3"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO3Sets5.Add( Base.AUDNZD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP6,"TP6_AUDNZD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP6_AUDNZD_UP_S2_OCO3"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO3Sets6.Add( Base.AUDNZD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDNZD_OCO3S1_UP_S2 = 0;
	                for (; AUDNZD_OCO3S1_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets1.Count; AUDNZD_OCO3S1_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO3Sets1[AUDNZD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO3Sets1[AUDNZD_OCO3S1_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO3Sets1.RemoveAt(AUDNZD_OCO3S1_UP_S2);
	                        AUDNZD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDNZD_OCO3S2_UP_S2 = 0;
	                for (; AUDNZD_OCO3S2_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets2.Count; AUDNZD_OCO3S2_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO3Sets2[AUDNZD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO3Sets2[AUDNZD_OCO3S2_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO3Sets2.RemoveAt(AUDNZD_OCO3S2_UP_S2);
	                        AUDNZD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO3S3_UP_S2 = 0;
	                for (; AUDNZD_OCO3S3_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets3.Count; AUDNZD_OCO3S3_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO3Sets3[AUDNZD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO3Sets3[AUDNZD_OCO3S3_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO3Sets3.RemoveAt(AUDNZD_OCO3S3_UP_S2);
	                        AUDNZD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO3S4_UP_S2 = 0;
	                for (; AUDNZD_OCO3S4_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets4.Count; AUDNZD_OCO3S4_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO3Sets4[AUDNZD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO3Sets4[AUDNZD_OCO3S4_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO3Sets4.RemoveAt(AUDNZD_OCO3S4_UP_S2);
	                        AUDNZD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDNZD_OCO3S5_UP_S2 = 0;
	                for (; AUDNZD_OCO3S5_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets5.Count; AUDNZD_OCO3S5_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO3Sets5[AUDNZD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO3Sets5[AUDNZD_OCO3S5_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO3Sets5.RemoveAt(AUDNZD_OCO3S5_UP_S2);
	                        AUDNZD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDNZD_OCO3S6_UP_S2 = 0;
	                for (; AUDNZD_OCO3S6_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets6.Count; AUDNZD_OCO3S6_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO3Sets6[AUDNZD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO3Sets6[AUDNZD_OCO3S6_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO3Sets6.RemoveAt(AUDNZD_OCO3S6_UP_S2);
	                        AUDNZD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDNZD_OCO4_EO1_UP_S2)
	                Base.AUDNZD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDNZD_OCO4_EO2_UP_S2)
	                Base.AUDNZD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO4_EO3_UP_S2)
	                Base.AUDNZD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO4_EO4_UP_S2)
	                Base.AUDNZD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO4_EO5_UP_S2)
	                Base.AUDNZD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO4_EO6_UP_S2)
	                Base.AUDNZD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.AUDNZD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP1,"TP1_AUDNZD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP1_AUDNZD_UP_S2_OCO4"));
		                 };
		                Base.AUDNZD_UP_S2_OCO4Sets1.Add( Base.AUDNZD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP2,"TP2_AUDNZD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP2_AUDNZD_UP_S2_OCO4"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO4Sets2.Add( Base.AUDNZD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP3,"TP3_AUDNZD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP3_AUDNZD_UP_S2_OCO4"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO4Sets3.Add( Base.AUDNZD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP4,"TP4_AUDNZD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP4_AUDNZD_UP_S2_OCO4"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO4Sets4.Add( Base.AUDNZD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP5,"TP5_AUDNZD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP5_AUDNZD_UP_S2_OCO4"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO4Sets5.Add( Base.AUDNZD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_UP_S2_TP6,"TP6_AUDNZD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_UP_S2_SL,"SL_TP6_AUDNZD_UP_S2_OCO4"));
		                 };
	                    Base.AUDNZD_UP_S2_OCO4Sets6.Add( Base.AUDNZD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDNZD_OCO4S1_UP_S2 = 0;
	                for (; AUDNZD_OCO4S1_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets1.Count; AUDNZD_OCO4S1_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO4Sets1[AUDNZD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO4Sets1[AUDNZD_OCO4S1_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO4Sets1.RemoveAt(AUDNZD_OCO4S1_UP_S2);
	                        AUDNZD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDNZD_OCO4S2_UP_S2 = 0;
	                for (; AUDNZD_OCO4S2_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets2.Count; AUDNZD_OCO4S2_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO4Sets2[AUDNZD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO4Sets2[AUDNZD_OCO4S2_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO4Sets2.RemoveAt(AUDNZD_OCO4S2_UP_S2);
	                        AUDNZD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO4S3_UP_S2 = 0;
	                for (; AUDNZD_OCO4S3_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets3.Count; AUDNZD_OCO4S3_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO4Sets3[AUDNZD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO4Sets3[AUDNZD_OCO4S3_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO4Sets3.RemoveAt(AUDNZD_OCO4S3_UP_S2);
	                        AUDNZD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO4S4_UP_S2 = 0;
	                for (; AUDNZD_OCO4S4_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets4.Count; AUDNZD_OCO4S4_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO4Sets4[AUDNZD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO4Sets4[AUDNZD_OCO4S4_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO4Sets4.RemoveAt(AUDNZD_OCO4S4_UP_S2);
	                        AUDNZD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDNZD_OCO4S5_UP_S2 = 0;
	                for (; AUDNZD_OCO4S5_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets5.Count; AUDNZD_OCO4S5_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO4Sets5[AUDNZD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO4Sets5[AUDNZD_OCO4S5_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO4Sets5.RemoveAt(AUDNZD_OCO4S5_UP_S2);
	                        AUDNZD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDNZD_OCO4S6_UP_S2 = 0;
	                for (; AUDNZD_OCO4S6_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets6.Count; AUDNZD_OCO4S6_UP_S2++)
	                    if (Base.AUDNZD_UP_S2_OCO4Sets6[AUDNZD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_UP_S2_OCO4Sets6[AUDNZD_OCO4S6_UP_S2].Filled();
	                        Base.AUDNZD_UP_S2_OCO4Sets6.RemoveAt(AUDNZD_OCO4S6_UP_S2);
	                        AUDNZD_OCO4S6_UP_S2 = 0;
	                        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.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 AUDNZD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDNZD_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("AUDNZD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDNZD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDNZD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDNZD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDNZD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDNZD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDNZD S2");
		        	}
		        }
		        
				if (Base.AUDNZD_OCO1_EO1_DOWN_S2)
	                Base.AUDNZD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDNZD_OCO1_EO2_DOWN_S2)
	                Base.AUDNZD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO1_EO3_DOWN_S2)
	                Base.AUDNZD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO1_EO4_DOWN_S2)
	                Base.AUDNZD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDNZD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP1_AUDNZD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP1,"TP1_AUDNZD_DOWN_S2_OCO1"));
		                 };
		                Base.AUDNZD_DOWN_S2_OCO1Sets1.Add( Base.AUDNZD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP2_AUDNZD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP2,"TP2_AUDNZD_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO1Sets2.Add( Base.AUDNZD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP3_AUDNZD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP3,"TP3_AUDNZD_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO1Sets3.Add( Base.AUDNZD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP4_AUDNZD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP4,"TP4_AUDNZD_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO1Sets4.Add( Base.AUDNZD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDNZD_OCO1S1_DOWN_S2 = 0;
	                for (; AUDNZD_OCO1S1_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets1.Count; AUDNZD_OCO1S1_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO1Sets1[AUDNZD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO1Sets1[AUDNZD_OCO1S1_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO1Sets1.RemoveAt(AUDNZD_OCO1S1_DOWN_S2);
	                        AUDNZD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDNZD_OCO1S2_DOWN_S2 = 0;
	                for (; AUDNZD_OCO1S2_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets2.Count; AUDNZD_OCO1S2_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO1Sets2[AUDNZD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO1Sets2[AUDNZD_OCO1S2_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO1Sets2.RemoveAt(AUDNZD_OCO1S2_DOWN_S2);
	                        AUDNZD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO1S3_DOWN_S2 = 0;
	                for (; AUDNZD_OCO1S3_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets3.Count; AUDNZD_OCO1S3_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO1Sets3[AUDNZD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO1Sets3[AUDNZD_OCO1S3_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO1Sets3.RemoveAt(AUDNZD_OCO1S3_DOWN_S2);
	                        AUDNZD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO1S4_DOWN_S2 = 0;
	                for (; AUDNZD_OCO1S4_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets4.Count; AUDNZD_OCO1S4_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO1Sets4[AUDNZD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO1Sets4[AUDNZD_OCO1S4_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO1Sets4.RemoveAt(AUDNZD_OCO1S4_DOWN_S2);
	                        AUDNZD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDNZD_OCO2_EO1_DOWN_S2)
	                Base.AUDNZD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDNZD_OCO2_EO2_DOWN_S2)
	                Base.AUDNZD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO2_EO3_DOWN_S2)
	                Base.AUDNZD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO2_EO4_DOWN_S2)
	                Base.AUDNZD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDNZD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP1_AUDNZD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP1,"TP1_AUDNZD_DOWN_S2_OCO2"));
		                 };
		                Base.AUDNZD_DOWN_S2_OCO2Sets1.Add( Base.AUDNZD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP2_AUDNZD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP2,"TP2_AUDNZD_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO2Sets2.Add( Base.AUDNZD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP3_AUDNZD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP3,"TP3_AUDNZD_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO2Sets3.Add( Base.AUDNZD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP4_AUDNZD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP4,"TP4_AUDNZD_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO2Sets4.Add( Base.AUDNZD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDNZD_OCO2S1_DOWN_S2 = 0;
	                for (; AUDNZD_OCO2S1_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets1.Count; AUDNZD_OCO2S1_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO2Sets1[AUDNZD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO2Sets1[AUDNZD_OCO2S1_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO2Sets1.RemoveAt(AUDNZD_OCO2S1_DOWN_S2);
	                        AUDNZD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDNZD_OCO2S2_DOWN_S2 = 0;
	                for (; AUDNZD_OCO2S2_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets2.Count; AUDNZD_OCO2S2_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO2Sets2[AUDNZD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO2Sets2[AUDNZD_OCO2S2_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO2Sets2.RemoveAt(AUDNZD_OCO2S2_DOWN_S2);
	                        AUDNZD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO2S3_DOWN_S2 = 0;
	                for (; AUDNZD_OCO2S3_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets3.Count; AUDNZD_OCO2S3_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO2Sets3[AUDNZD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO2Sets3[AUDNZD_OCO2S3_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO2Sets3.RemoveAt(AUDNZD_OCO2S3_DOWN_S2);
	                        AUDNZD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO2S4_DOWN_S2 = 0;
	                for (; AUDNZD_OCO2S4_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets4.Count; AUDNZD_OCO2S4_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO2Sets4[AUDNZD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO2Sets4[AUDNZD_OCO2S4_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO2Sets4.RemoveAt(AUDNZD_OCO2S4_DOWN_S2);
	                        AUDNZD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDNZD_OCO3_EO1_DOWN_S2)
	                Base.AUDNZD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDNZD_OCO3_EO2_DOWN_S2)
	                Base.AUDNZD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO3_EO3_DOWN_S2)
	                Base.AUDNZD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO3_EO4_DOWN_S2)
	                Base.AUDNZD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDNZD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP1_AUDNZD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP1,"TP1_AUDNZD_DOWN_S2_OCO3"));
		                 };
		                Base.AUDNZD_DOWN_S2_OCO3Sets1.Add( Base.AUDNZD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP2_AUDNZD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP2,"TP2_AUDNZD_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO3Sets2.Add( Base.AUDNZD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP3_AUDNZD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP3,"TP3_AUDNZD_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO3Sets3.Add( Base.AUDNZD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP4_AUDNZD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP4,"TP4_AUDNZD_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO3Sets4.Add( Base.AUDNZD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDNZD_OCO3S1_DOWN_S2 = 0;
	                for (; AUDNZD_OCO3S1_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets1.Count; AUDNZD_OCO3S1_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO3Sets1[AUDNZD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO3Sets1[AUDNZD_OCO3S1_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO3Sets1.RemoveAt(AUDNZD_OCO3S1_DOWN_S2);
	                        AUDNZD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDNZD_OCO3S2_DOWN_S2 = 0;
	                for (; AUDNZD_OCO3S2_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets2.Count; AUDNZD_OCO3S2_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO3Sets2[AUDNZD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO3Sets2[AUDNZD_OCO3S2_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO3Sets2.RemoveAt(AUDNZD_OCO3S2_DOWN_S2);
	                        AUDNZD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO3S3_DOWN_S2 = 0;
	                for (; AUDNZD_OCO3S3_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets3.Count; AUDNZD_OCO3S3_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO3Sets3[AUDNZD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO3Sets3[AUDNZD_OCO3S3_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO3Sets3.RemoveAt(AUDNZD_OCO3S3_DOWN_S2);
	                        AUDNZD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO3S4_DOWN_S2 = 0;
	                for (; AUDNZD_OCO3S4_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets4.Count; AUDNZD_OCO3S4_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO3Sets4[AUDNZD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO3Sets4[AUDNZD_OCO3S4_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO3Sets4.RemoveAt(AUDNZD_OCO3S4_DOWN_S2);
	                        AUDNZD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDNZD_OCO4_EO1_DOWN_S2)
	                Base.AUDNZD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDNZD_OCO4_EO2_DOWN_S2)
	                Base.AUDNZD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO4_EO3_DOWN_S2)
	                Base.AUDNZD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDNZD_OCO4_EO4_DOWN_S2)
	                Base.AUDNZD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDNZD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP1_AUDNZD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP1,"TP1_AUDNZD_DOWN_S2_OCO4"));
		                 };
		                Base.AUDNZD_DOWN_S2_OCO4Sets1.Add( Base.AUDNZD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP2_AUDNZD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP2,"TP2_AUDNZD_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO4Sets2.Add( Base.AUDNZD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP3_AUDNZD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP3,"TP3_AUDNZD_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO4Sets3.Add( Base.AUDNZD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDNZD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDNZD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDNZD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDNZD_DOWN_S2_SL,"SL_TP4_AUDNZD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDNZD_DOWN_S2_TP4,"TP4_AUDNZD_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDNZD_DOWN_S2_OCO4Sets4.Add( Base.AUDNZD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDNZD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDNZD_OCO4S1_DOWN_S2 = 0;
	                for (; AUDNZD_OCO4S1_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets1.Count; AUDNZD_OCO4S1_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO4Sets1[AUDNZD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO4Sets1[AUDNZD_OCO4S1_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO4Sets1.RemoveAt(AUDNZD_OCO4S1_DOWN_S2);
	                        AUDNZD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDNZD_OCO4S2_DOWN_S2 = 0;
	                for (; AUDNZD_OCO4S2_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets2.Count; AUDNZD_OCO4S2_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO4Sets2[AUDNZD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO4Sets2[AUDNZD_OCO4S2_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO4Sets2.RemoveAt(AUDNZD_OCO4S2_DOWN_S2);
	                        AUDNZD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO4S3_DOWN_S2 = 0;
	                for (; AUDNZD_OCO4S3_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets3.Count; AUDNZD_OCO4S3_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO4Sets3[AUDNZD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO4Sets3[AUDNZD_OCO4S3_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO4Sets3.RemoveAt(AUDNZD_OCO4S3_DOWN_S2);
	                        AUDNZD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDNZD_OCO4S4_DOWN_S2 = 0;
	                for (; AUDNZD_OCO4S4_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets4.Count; AUDNZD_OCO4S4_DOWN_S2++)
	                    if (Base.AUDNZD_DOWN_S2_OCO4Sets4[AUDNZD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDNZD_DOWN_S2_OCO4Sets4[AUDNZD_OCO4S4_DOWN_S2].Filled();
	                        Base.AUDNZD_DOWN_S2_OCO4Sets4.RemoveAt(AUDNZD_OCO4S4_DOWN_S2);
	                        AUDNZD_OCO4S4_DOWN_S2 = 0;
	                        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 _AUDUSD;
		
    	///oco1 up
    	public static OrderTicket AUDUSD_OCO1_MO1_UP_S2;
    	public static OrderTicket AUDUSD_OCO1_MO2_UP_S2;
    	public static OrderTicket AUDUSD_OCO1_MO3_UP_S2;
    	public static OrderTicket AUDUSD_OCO1_MO4_UP_S2;
    	public static OrderTicket AUDUSD_OCO1_MO5_UP_S2;
    	public static OrderTicket AUDUSD_OCO1_MO6_UP_S2;
    	
    	public static int AUDUSD_OCO1_EO1_UP_S2_ID ;
        public static int AUDUSD_OCO1_EO2_UP_S2_ID ;
        public static int AUDUSD_OCO1_EO3_UP_S2_ID ;
        public static int AUDUSD_OCO1_EO4_UP_S2_ID ;
        public static int AUDUSD_OCO1_EO5_UP_S2_ID ;
        public static int AUDUSD_OCO1_EO6_UP_S2_ID ;
        
        public static bool AUDUSD_OCO1_EO1_UP_S2 ;
        public static bool AUDUSD_OCO1_EO2_UP_S2 ;
        public static bool AUDUSD_OCO1_EO3_UP_S2 ;
        public static bool AUDUSD_OCO1_EO4_UP_S2 ;
        public static bool AUDUSD_OCO1_EO5_UP_S2 ;
        public static bool AUDUSD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_UP_S2> AUDUSD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_UP_S2> AUDUSD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_UP_S2> AUDUSD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_UP_S2> AUDUSD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_UP_S2> AUDUSD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_UP_S2> AUDUSD_OOFE_OCO1_UP_S2_6 ;
        
        public static AUDUSD_OCO1_UP_S2 AUDUSD_PFO_OCO1_UP_S2_1 ;
        public static AUDUSD_OCO1_UP_S2 AUDUSD_PFO_OCO1_UP_S2_2 ;
        public static AUDUSD_OCO1_UP_S2 AUDUSD_PFO_OCO1_UP_S2_3 ;
        public static AUDUSD_OCO1_UP_S2 AUDUSD_PFO_OCO1_UP_S2_4 ;
        public static AUDUSD_OCO1_UP_S2 AUDUSD_PFO_OCO1_UP_S2_5 ;
        public static AUDUSD_OCO1_UP_S2 AUDUSD_PFO_OCO1_UP_S2_6 ;
        
        public static List<AUDUSD_OCO1_UP_S2> AUDUSD_UP_S2_OCO1Sets1 = new List<AUDUSD_OCO1_UP_S2>();
        public static List<AUDUSD_OCO1_UP_S2> AUDUSD_UP_S2_OCO1Sets2 = new List<AUDUSD_OCO1_UP_S2>();
        public static List<AUDUSD_OCO1_UP_S2> AUDUSD_UP_S2_OCO1Sets3 = new List<AUDUSD_OCO1_UP_S2>();
        public static List<AUDUSD_OCO1_UP_S2> AUDUSD_UP_S2_OCO1Sets4 = new List<AUDUSD_OCO1_UP_S2>();
        public static List<AUDUSD_OCO1_UP_S2> AUDUSD_UP_S2_OCO1Sets5 = new List<AUDUSD_OCO1_UP_S2>();
        public static List<AUDUSD_OCO1_UP_S2> AUDUSD_UP_S2_OCO1Sets6 = new List<AUDUSD_OCO1_UP_S2>();
        
        public static bool AUDUSD_OCO1_UP_S2_IsReady = true;
		public static bool AUDUSD_OCO1_UP_S2_Monthly_IsReady = true;
        
        //oco1 down
		public static OrderTicket AUDUSD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int AUDUSD_OCO1_EO1_DOWN_S2_ID ;
        public static int AUDUSD_OCO1_EO2_DOWN_S2_ID ;
        public static int AUDUSD_OCO1_EO3_DOWN_S2_ID ;
        public static int AUDUSD_OCO1_EO4_DOWN_S2_ID ;
        public static int AUDUSD_OCO1_EO5_DOWN_S2_ID ;
        public static int AUDUSD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool AUDUSD_OCO1_EO1_DOWN_S2 ;
        public static bool AUDUSD_OCO1_EO2_DOWN_S2 ;
        public static bool AUDUSD_OCO1_EO3_DOWN_S2 ;
        public static bool AUDUSD_OCO1_EO4_DOWN_S2 ;
        public static bool AUDUSD_OCO1_EO5_DOWN_S2 ;
        public static bool AUDUSD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_DOWN_S2> AUDUSD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_DOWN_S2> AUDUSD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_DOWN_S2> AUDUSD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_DOWN_S2> AUDUSD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_DOWN_S2> AUDUSD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO1_DOWN_S2> AUDUSD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static AUDUSD_OCO1_DOWN_S2 AUDUSD_PFO_OCO1_DOWN_S2_1 ;
        public static AUDUSD_OCO1_DOWN_S2 AUDUSD_PFO_OCO1_DOWN_S2_2 ;
        public static AUDUSD_OCO1_DOWN_S2 AUDUSD_PFO_OCO1_DOWN_S2_3 ;
        public static AUDUSD_OCO1_DOWN_S2 AUDUSD_PFO_OCO1_DOWN_S2_4 ;
        public static AUDUSD_OCO1_DOWN_S2 AUDUSD_PFO_OCO1_DOWN_S2_5 ;
        public static AUDUSD_OCO1_DOWN_S2 AUDUSD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<AUDUSD_OCO1_DOWN_S2> AUDUSD_DOWN_S2_OCO1Sets1 = new List<AUDUSD_OCO1_DOWN_S2>();
        public static List<AUDUSD_OCO1_DOWN_S2> AUDUSD_DOWN_S2_OCO1Sets2 = new List<AUDUSD_OCO1_DOWN_S2>();
        public static List<AUDUSD_OCO1_DOWN_S2> AUDUSD_DOWN_S2_OCO1Sets3 = new List<AUDUSD_OCO1_DOWN_S2>();
        public static List<AUDUSD_OCO1_DOWN_S2> AUDUSD_DOWN_S2_OCO1Sets4 = new List<AUDUSD_OCO1_DOWN_S2>();
        public static List<AUDUSD_OCO1_DOWN_S2> AUDUSD_DOWN_S2_OCO1Sets5 = new List<AUDUSD_OCO1_DOWN_S2>();
        public static List<AUDUSD_OCO1_DOWN_S2> AUDUSD_DOWN_S2_OCO1Sets6 = new List<AUDUSD_OCO1_DOWN_S2>();
        
        public static bool AUDUSD_OCO1_DOWN_S2_IsReady = true;
		public static bool AUDUSD_OCO1_DOWN_S2_Monthly_IsReady = true;
        
        //oco2 up
        public static OrderTicket AUDUSD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO6_UP_S2 ;
    	
    	public static int AUDUSD_OCO2_EO1_UP_S2_ID ;
        public static int AUDUSD_OCO2_EO2_UP_S2_ID ;
        public static int AUDUSD_OCO2_EO3_UP_S2_ID ;
        public static int AUDUSD_OCO2_EO4_UP_S2_ID ;
        public static int AUDUSD_OCO2_EO5_UP_S2_ID ;
        public static int AUDUSD_OCO2_EO6_UP_S2_ID ;
        
        public static bool AUDUSD_OCO2_EO1_UP_S2 ;
        public static bool AUDUSD_OCO2_EO2_UP_S2 ;
        public static bool AUDUSD_OCO2_EO3_UP_S2 ;
        public static bool AUDUSD_OCO2_EO4_UP_S2 ;
        public static bool AUDUSD_OCO2_EO5_UP_S2 ;
        public static bool AUDUSD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_UP_S2> AUDUSD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_UP_S2> AUDUSD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_UP_S2> AUDUSD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_UP_S2> AUDUSD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_UP_S2> AUDUSD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_UP_S2> AUDUSD_OOFE_OCO2_UP_S2_6 ;
        
        public static AUDUSD_OCO2_UP_S2 AUDUSD_PFO_OCO2_UP_S2_1 ;
        public static AUDUSD_OCO2_UP_S2 AUDUSD_PFO_OCO2_UP_S2_2 ;
        public static AUDUSD_OCO2_UP_S2 AUDUSD_PFO_OCO2_UP_S2_3 ;
        public static AUDUSD_OCO2_UP_S2 AUDUSD_PFO_OCO2_UP_S2_4 ;
        public static AUDUSD_OCO2_UP_S2 AUDUSD_PFO_OCO2_UP_S2_5 ;
        public static AUDUSD_OCO2_UP_S2 AUDUSD_PFO_OCO2_UP_S2_6 ;
        
        public static List<AUDUSD_OCO2_UP_S2> AUDUSD_UP_S2_OCO2Sets1 = new List<AUDUSD_OCO2_UP_S2>();
        public static List<AUDUSD_OCO2_UP_S2> AUDUSD_UP_S2_OCO2Sets2 = new List<AUDUSD_OCO2_UP_S2>();
        public static List<AUDUSD_OCO2_UP_S2> AUDUSD_UP_S2_OCO2Sets3 = new List<AUDUSD_OCO2_UP_S2>();
        public static List<AUDUSD_OCO2_UP_S2> AUDUSD_UP_S2_OCO2Sets4 = new List<AUDUSD_OCO2_UP_S2>();
        public static List<AUDUSD_OCO2_UP_S2> AUDUSD_UP_S2_OCO2Sets5 = new List<AUDUSD_OCO2_UP_S2>();
        public static List<AUDUSD_OCO2_UP_S2> AUDUSD_UP_S2_OCO2Sets6 = new List<AUDUSD_OCO2_UP_S2>();
        
        public static bool AUDUSD_OCO2_UP_S2_IsReady = true;
		public static bool AUDUSD_OCO2_UP_S2_Monthly_IsReady = true;
        
        //oco2 down
        public static OrderTicket AUDUSD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int AUDUSD_OCO2_EO1_DOWN_S2_ID ;
        public static int AUDUSD_OCO2_EO2_DOWN_S2_ID ;
        public static int AUDUSD_OCO2_EO3_DOWN_S2_ID ;
        public static int AUDUSD_OCO2_EO4_DOWN_S2_ID ;
        public static int AUDUSD_OCO2_EO5_DOWN_S2_ID ;
        public static int AUDUSD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool AUDUSD_OCO2_EO1_DOWN_S2 ;
        public static bool AUDUSD_OCO2_EO2_DOWN_S2 ;
        public static bool AUDUSD_OCO2_EO3_DOWN_S2 ;
        public static bool AUDUSD_OCO2_EO4_DOWN_S2 ;
        public static bool AUDUSD_OCO2_EO5_DOWN_S2 ;
        public static bool AUDUSD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_DOWN_S2> AUDUSD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_DOWN_S2> AUDUSD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_DOWN_S2> AUDUSD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_DOWN_S2> AUDUSD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_DOWN_S2> AUDUSD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO2_DOWN_S2> AUDUSD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static AUDUSD_OCO2_DOWN_S2 AUDUSD_PFO_OCO2_DOWN_S2_1 ;
        public static AUDUSD_OCO2_DOWN_S2 AUDUSD_PFO_OCO2_DOWN_S2_2 ;
        public static AUDUSD_OCO2_DOWN_S2 AUDUSD_PFO_OCO2_DOWN_S2_3 ;
        public static AUDUSD_OCO2_DOWN_S2 AUDUSD_PFO_OCO2_DOWN_S2_4 ;
        public static AUDUSD_OCO2_DOWN_S2 AUDUSD_PFO_OCO2_DOWN_S2_5 ;
        public static AUDUSD_OCO2_DOWN_S2 AUDUSD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<AUDUSD_OCO2_DOWN_S2> AUDUSD_DOWN_S2_OCO2Sets1 = new List<AUDUSD_OCO2_DOWN_S2>();
        public static List<AUDUSD_OCO2_DOWN_S2> AUDUSD_DOWN_S2_OCO2Sets2 = new List<AUDUSD_OCO2_DOWN_S2>();
        public static List<AUDUSD_OCO2_DOWN_S2> AUDUSD_DOWN_S2_OCO2Sets3 = new List<AUDUSD_OCO2_DOWN_S2>();
        public static List<AUDUSD_OCO2_DOWN_S2> AUDUSD_DOWN_S2_OCO2Sets4 = new List<AUDUSD_OCO2_DOWN_S2>();
        public static List<AUDUSD_OCO2_DOWN_S2> AUDUSD_DOWN_S2_OCO2Sets5 = new List<AUDUSD_OCO2_DOWN_S2>();
        public static List<AUDUSD_OCO2_DOWN_S2> AUDUSD_DOWN_S2_OCO2Sets6 = new List<AUDUSD_OCO2_DOWN_S2>();
        
        public static bool AUDUSD_OCO2_DOWN_S2_IsReady = true;
		public static bool AUDUSD_OCO2_DOWN_S2_Monthly_IsReady = true;
        
        //oco3 up
        public static OrderTicket AUDUSD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO6_UP_S2 ;
    	
    	public static int AUDUSD_OCO3_EO1_UP_S2_ID ;
        public static int AUDUSD_OCO3_EO2_UP_S2_ID ;
        public static int AUDUSD_OCO3_EO3_UP_S2_ID ;
        public static int AUDUSD_OCO3_EO4_UP_S2_ID ;
        public static int AUDUSD_OCO3_EO5_UP_S2_ID ;
        public static int AUDUSD_OCO3_EO6_UP_S2_ID ;
        
        public static bool AUDUSD_OCO3_EO1_UP_S2 ;
        public static bool AUDUSD_OCO3_EO2_UP_S2 ;
        public static bool AUDUSD_OCO3_EO3_UP_S2 ;
        public static bool AUDUSD_OCO3_EO4_UP_S2 ;
        public static bool AUDUSD_OCO3_EO5_UP_S2 ;
        public static bool AUDUSD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_UP_S2> AUDUSD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_UP_S2> AUDUSD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_UP_S2> AUDUSD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_UP_S2> AUDUSD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_UP_S2> AUDUSD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_UP_S2> AUDUSD_OOFE_OCO3_UP_S2_6 ;
        
        public static AUDUSD_OCO3_UP_S2 AUDUSD_PFO_OCO3_UP_S2_1 ;
        public static AUDUSD_OCO3_UP_S2 AUDUSD_PFO_OCO3_UP_S2_2 ;
        public static AUDUSD_OCO3_UP_S2 AUDUSD_PFO_OCO3_UP_S2_3 ;
        public static AUDUSD_OCO3_UP_S2 AUDUSD_PFO_OCO3_UP_S2_4 ;
        public static AUDUSD_OCO3_UP_S2 AUDUSD_PFO_OCO3_UP_S2_5 ;
        public static AUDUSD_OCO3_UP_S2 AUDUSD_PFO_OCO3_UP_S2_6 ;
        
        public static List<AUDUSD_OCO3_UP_S2> AUDUSD_UP_S2_OCO3Sets1 = new List<AUDUSD_OCO3_UP_S2>();
        public static List<AUDUSD_OCO3_UP_S2> AUDUSD_UP_S2_OCO3Sets2 = new List<AUDUSD_OCO3_UP_S2>();
        public static List<AUDUSD_OCO3_UP_S2> AUDUSD_UP_S2_OCO3Sets3 = new List<AUDUSD_OCO3_UP_S2>();
        public static List<AUDUSD_OCO3_UP_S2> AUDUSD_UP_S2_OCO3Sets4 = new List<AUDUSD_OCO3_UP_S2>();
        public static List<AUDUSD_OCO3_UP_S2> AUDUSD_UP_S2_OCO3Sets5 = new List<AUDUSD_OCO3_UP_S2>();
        public static List<AUDUSD_OCO3_UP_S2> AUDUSD_UP_S2_OCO3Sets6 = new List<AUDUSD_OCO3_UP_S2>();
        
        public static bool AUDUSD_OCO3_UP_S2_IsReady = true;
		public static bool AUDUSD_OCO3_UP_S2_Monthly_IsReady = true;
        
        //oco3 down
        public static OrderTicket AUDUSD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int AUDUSD_OCO3_EO1_DOWN_S2_ID ;
        public static int AUDUSD_OCO3_EO2_DOWN_S2_ID ;
        public static int AUDUSD_OCO3_EO3_DOWN_S2_ID ;
        public static int AUDUSD_OCO3_EO4_DOWN_S2_ID ;
        public static int AUDUSD_OCO3_EO5_DOWN_S2_ID ;
        public static int AUDUSD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool AUDUSD_OCO3_EO1_DOWN_S2 ;
        public static bool AUDUSD_OCO3_EO2_DOWN_S2 ;
        public static bool AUDUSD_OCO3_EO3_DOWN_S2 ;
        public static bool AUDUSD_OCO3_EO4_DOWN_S2 ;
        public static bool AUDUSD_OCO3_EO5_DOWN_S2 ;
        public static bool AUDUSD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_DOWN_S2> AUDUSD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_DOWN_S2> AUDUSD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_DOWN_S2> AUDUSD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_DOWN_S2> AUDUSD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_DOWN_S2> AUDUSD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO3_DOWN_S2> AUDUSD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static AUDUSD_OCO3_DOWN_S2 AUDUSD_PFO_OCO3_DOWN_S2_1 ;
        public static AUDUSD_OCO3_DOWN_S2 AUDUSD_PFO_OCO3_DOWN_S2_2 ;
        public static AUDUSD_OCO3_DOWN_S2 AUDUSD_PFO_OCO3_DOWN_S2_3 ;
        public static AUDUSD_OCO3_DOWN_S2 AUDUSD_PFO_OCO3_DOWN_S2_4 ;
        public static AUDUSD_OCO3_DOWN_S2 AUDUSD_PFO_OCO3_DOWN_S2_5 ;
        public static AUDUSD_OCO3_DOWN_S2 AUDUSD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<AUDUSD_OCO3_DOWN_S2> AUDUSD_DOWN_S2_OCO3Sets1 = new List<AUDUSD_OCO3_DOWN_S2>();
        public static List<AUDUSD_OCO3_DOWN_S2> AUDUSD_DOWN_S2_OCO3Sets2 = new List<AUDUSD_OCO3_DOWN_S2>();
        public static List<AUDUSD_OCO3_DOWN_S2> AUDUSD_DOWN_S2_OCO3Sets3 = new List<AUDUSD_OCO3_DOWN_S2>();
        public static List<AUDUSD_OCO3_DOWN_S2> AUDUSD_DOWN_S2_OCO3Sets4 = new List<AUDUSD_OCO3_DOWN_S2>();
        public static List<AUDUSD_OCO3_DOWN_S2> AUDUSD_DOWN_S2_OCO3Sets5 = new List<AUDUSD_OCO3_DOWN_S2>();
        public static List<AUDUSD_OCO3_DOWN_S2> AUDUSD_DOWN_S2_OCO3Sets6 = new List<AUDUSD_OCO3_DOWN_S2>();
        
        public static bool AUDUSD_OCO3_DOWN_S2_IsReady = true;
		public static bool AUDUSD_OCO3_DOWN_S2_Monthly_IsReady = true;
        
        //oco4 up
        public static OrderTicket AUDUSD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO6_UP_S2 ;
    	
    	public static int AUDUSD_OCO4_EO1_UP_S2_ID ;
        public static int AUDUSD_OCO4_EO2_UP_S2_ID ;
        public static int AUDUSD_OCO4_EO3_UP_S2_ID ;
        public static int AUDUSD_OCO4_EO4_UP_S2_ID ;
        public static int AUDUSD_OCO4_EO5_UP_S2_ID ;
        public static int AUDUSD_OCO4_EO6_UP_S2_ID ;
        
        public static bool AUDUSD_OCO4_EO1_UP_S2 ;
        public static bool AUDUSD_OCO4_EO2_UP_S2 ;
        public static bool AUDUSD_OCO4_EO3_UP_S2 ;
        public static bool AUDUSD_OCO4_EO4_UP_S2 ;
        public static bool AUDUSD_OCO4_EO5_UP_S2 ;
        public static bool AUDUSD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_UP_S2> AUDUSD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_UP_S2> AUDUSD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_UP_S2> AUDUSD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_UP_S2> AUDUSD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_UP_S2> AUDUSD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_UP_S2> AUDUSD_OOFE_OCO4_UP_S2_6 ;
        
        public static AUDUSD_OCO4_UP_S2 AUDUSD_PFO_OCO4_UP_S2_1 ;
        public static AUDUSD_OCO4_UP_S2 AUDUSD_PFO_OCO4_UP_S2_2 ;
        public static AUDUSD_OCO4_UP_S2 AUDUSD_PFO_OCO4_UP_S2_3 ;
        public static AUDUSD_OCO4_UP_S2 AUDUSD_PFO_OCO4_UP_S2_4 ;
        public static AUDUSD_OCO4_UP_S2 AUDUSD_PFO_OCO4_UP_S2_5 ;
        public static AUDUSD_OCO4_UP_S2 AUDUSD_PFO_OCO4_UP_S2_6 ;
        
        public static List<AUDUSD_OCO4_UP_S2> AUDUSD_UP_S2_OCO4Sets1 = new List<AUDUSD_OCO4_UP_S2>();
        public static List<AUDUSD_OCO4_UP_S2> AUDUSD_UP_S2_OCO4Sets2 = new List<AUDUSD_OCO4_UP_S2>();
        public static List<AUDUSD_OCO4_UP_S2> AUDUSD_UP_S2_OCO4Sets3 = new List<AUDUSD_OCO4_UP_S2>();
        public static List<AUDUSD_OCO4_UP_S2> AUDUSD_UP_S2_OCO4Sets4 = new List<AUDUSD_OCO4_UP_S2>();
        public static List<AUDUSD_OCO4_UP_S2> AUDUSD_UP_S2_OCO4Sets5 = new List<AUDUSD_OCO4_UP_S2>();
        public static List<AUDUSD_OCO4_UP_S2> AUDUSD_UP_S2_OCO4Sets6 = new List<AUDUSD_OCO4_UP_S2>();
        
        public static bool AUDUSD_OCO4_UP_S2_IsReady = true;
		public static bool AUDUSD_OCO4_UP_S2_Monthly_IsReady = true;
        
        //oco4 down
        public static OrderTicket AUDUSD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket AUDUSD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int AUDUSD_OCO4_EO1_DOWN_S2_ID ;
        public static int AUDUSD_OCO4_EO2_DOWN_S2_ID ;
        public static int AUDUSD_OCO4_EO3_DOWN_S2_ID ;
        public static int AUDUSD_OCO4_EO4_DOWN_S2_ID ;
        public static int AUDUSD_OCO4_EO5_DOWN_S2_ID ;
        public static int AUDUSD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool AUDUSD_OCO4_EO1_DOWN_S2 ;
        public static bool AUDUSD_OCO4_EO2_DOWN_S2 ;
        public static bool AUDUSD_OCO4_EO3_DOWN_S2 ;
        public static bool AUDUSD_OCO4_EO4_DOWN_S2 ;
        public static bool AUDUSD_OCO4_EO5_DOWN_S2 ;
        public static bool AUDUSD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_DOWN_S2> AUDUSD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_DOWN_S2> AUDUSD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_DOWN_S2> AUDUSD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_DOWN_S2> AUDUSD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_DOWN_S2> AUDUSD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDUSD_OCO4_DOWN_S2> AUDUSD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static AUDUSD_OCO4_DOWN_S2 AUDUSD_PFO_OCO4_DOWN_S2_1 ;
        public static AUDUSD_OCO4_DOWN_S2 AUDUSD_PFO_OCO4_DOWN_S2_2 ;
        public static AUDUSD_OCO4_DOWN_S2 AUDUSD_PFO_OCO4_DOWN_S2_3 ;
        public static AUDUSD_OCO4_DOWN_S2 AUDUSD_PFO_OCO4_DOWN_S2_4 ;
        public static AUDUSD_OCO4_DOWN_S2 AUDUSD_PFO_OCO4_DOWN_S2_5 ;
        public static AUDUSD_OCO4_DOWN_S2 AUDUSD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<AUDUSD_OCO4_DOWN_S2> AUDUSD_DOWN_S2_OCO4Sets1 = new List<AUDUSD_OCO4_DOWN_S2>();
        public static List<AUDUSD_OCO4_DOWN_S2> AUDUSD_DOWN_S2_OCO4Sets2 = new List<AUDUSD_OCO4_DOWN_S2>();
        public static List<AUDUSD_OCO4_DOWN_S2> AUDUSD_DOWN_S2_OCO4Sets3 = new List<AUDUSD_OCO4_DOWN_S2>();
        public static List<AUDUSD_OCO4_DOWN_S2> AUDUSD_DOWN_S2_OCO4Sets4 = new List<AUDUSD_OCO4_DOWN_S2>();
        public static List<AUDUSD_OCO4_DOWN_S2> AUDUSD_DOWN_S2_OCO4Sets5 = new List<AUDUSD_OCO4_DOWN_S2>();
        public static List<AUDUSD_OCO4_DOWN_S2> AUDUSD_DOWN_S2_OCO4Sets6 = new List<AUDUSD_OCO4_DOWN_S2>();
        
        public static bool AUDUSD_OCO4_DOWN_S2_IsReady = true;
		public static bool AUDUSD_OCO4_DOWN_S2_Monthly_IsReady = true;
        
        
////////////////////////////
		public static decimal AUDUSD_UP_S2_SL {get; set;}
		public static decimal AUDUSD_UP_S2_TP1 {get; set;}
		public static decimal AUDUSD_UP_S2_TP2 {get; set;}
		public static decimal AUDUSD_UP_S2_TP3 {get; set;}
		public static decimal AUDUSD_UP_S2_TP4 {get; set;}
		public static decimal AUDUSD_UP_S2_TP5 {get; set;}
		public static decimal AUDUSD_UP_S2_TP6 {get; set;}
		
		public static decimal AUDUSD_DOWN_S2_SL {get; set;}
		public static decimal AUDUSD_DOWN_S2_TP1 {get; set;}
		public static decimal AUDUSD_DOWN_S2_TP2 {get; set;}
		public static decimal AUDUSD_DOWN_S2_TP3 {get; set;}
		public static decimal AUDUSD_DOWN_S2_TP4 {get; set;}
		public static decimal AUDUSD_DOWN_S2_TP5 {get; set;}
		public static decimal AUDUSD_DOWN_S2_TP6 {get; set;}

        public static bool AUDUSD_Signal_Condition_UP_1 ;
        public static bool AUDUSD_Signal_Condition_UP_2 ;
        public static bool AUDUSD_Signal_Condition_UP_3 ;
        public static bool AUDUSD_Signal_Condition_DOWN_S2 ;
        
        public static int AUDUSD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int AUDUSD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDUSD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDUSD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDUSD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int AUDUSD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int AUDUSD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDUSD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDUSD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDUSD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_AUDUSD_UP_S2 ;
        public static bool DOWM_AUDUSD_UP_S2 ;
        public static bool DOWT_AUDUSD_UP_S2 ;
        public static bool DOWW_AUDUSD_UP_S2 ;
        public static bool DOWTH_AUDUSD_UP_S2 ;
        
		public static bool DOWR_AUDUSD_DOWN_S2 ;
        public static bool DOWM_AUDUSD_DOWN_S2 ;
        public static bool DOWT_AUDUSD_DOWN_S2 ;
        public static bool DOWW_AUDUSD_DOWN_S2 ;
        public static bool DOWTH_AUDUSD_DOWN_S2 ;
        
        
		public static int AUDUSD_quantity_UP_S2 ;
		public static int AUDUSD_quantity_SL_UP_S2 ;
		public static int AUDUSD_quantity_TP1_UP_S2 ;
		public static int AUDUSD_quantity_TP2_UP_S2 ;
		public static int AUDUSD_quantity_TP3_UP_S2 ;
		public static int AUDUSD_quantity_TP4_UP_S2 ;
		public static int AUDUSD_quantity_TP5_UP_S2;
		public static int AUDUSD_quantity_TP6_UP_S2 ;
		
		public static int AUDUSD_quantity_DOWN_S2 ;
		public static int AUDUSD_quantity_SL_DOWN_S2 ;
		public static int AUDUSD_quantity_TP1_DOWN_S2 ;
		public static int AUDUSD_quantity_TP2_DOWN_S2 ;
		public static int AUDUSD_quantity_TP3_DOWN_S2 ;
		public static int AUDUSD_quantity_TP4_DOWN_S2 ;
		public static int AUDUSD_quantity_TP5_DOWN_S2;
		public static int AUDUSD_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.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 _NZDUSD;
		
    	///oco1 up
    	public static OrderTicket NZDUSD_OCO1_MO1_UP_S2;
    	public static OrderTicket NZDUSD_OCO1_MO2_UP_S2;
    	public static OrderTicket NZDUSD_OCO1_MO3_UP_S2;
    	public static OrderTicket NZDUSD_OCO1_MO4_UP_S2;
    	public static OrderTicket NZDUSD_OCO1_MO5_UP_S2;
    	public static OrderTicket NZDUSD_OCO1_MO6_UP_S2;
    	
    	public static int NZDUSD_OCO1_EO1_UP_S2_ID ;
        public static int NZDUSD_OCO1_EO2_UP_S2_ID ;
        public static int NZDUSD_OCO1_EO3_UP_S2_ID ;
        public static int NZDUSD_OCO1_EO4_UP_S2_ID ;
        public static int NZDUSD_OCO1_EO5_UP_S2_ID ;
        public static int NZDUSD_OCO1_EO6_UP_S2_ID ;
        
        public static bool NZDUSD_OCO1_EO1_UP_S2 ;
        public static bool NZDUSD_OCO1_EO2_UP_S2 ;
        public static bool NZDUSD_OCO1_EO3_UP_S2 ;
        public static bool NZDUSD_OCO1_EO4_UP_S2 ;
        public static bool NZDUSD_OCO1_EO5_UP_S2 ;
        public static bool NZDUSD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_UP_S2> NZDUSD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_UP_S2> NZDUSD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_UP_S2> NZDUSD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_UP_S2> NZDUSD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_UP_S2> NZDUSD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_UP_S2> NZDUSD_OOFE_OCO1_UP_S2_6 ;
        
        public static NZDUSD_OCO1_UP_S2 NZDUSD_PFO_OCO1_UP_S2_1 ;
        public static NZDUSD_OCO1_UP_S2 NZDUSD_PFO_OCO1_UP_S2_2 ;
        public static NZDUSD_OCO1_UP_S2 NZDUSD_PFO_OCO1_UP_S2_3 ;
        public static NZDUSD_OCO1_UP_S2 NZDUSD_PFO_OCO1_UP_S2_4 ;
        public static NZDUSD_OCO1_UP_S2 NZDUSD_PFO_OCO1_UP_S2_5 ;
        public static NZDUSD_OCO1_UP_S2 NZDUSD_PFO_OCO1_UP_S2_6 ;
        
        public static List<NZDUSD_OCO1_UP_S2> NZDUSD_UP_S2_OCO1Sets1 = new List<NZDUSD_OCO1_UP_S2>();
        public static List<NZDUSD_OCO1_UP_S2> NZDUSD_UP_S2_OCO1Sets2 = new List<NZDUSD_OCO1_UP_S2>();
        public static List<NZDUSD_OCO1_UP_S2> NZDUSD_UP_S2_OCO1Sets3 = new List<NZDUSD_OCO1_UP_S2>();
        public static List<NZDUSD_OCO1_UP_S2> NZDUSD_UP_S2_OCO1Sets4 = new List<NZDUSD_OCO1_UP_S2>();
        public static List<NZDUSD_OCO1_UP_S2> NZDUSD_UP_S2_OCO1Sets5 = new List<NZDUSD_OCO1_UP_S2>();
        public static List<NZDUSD_OCO1_UP_S2> NZDUSD_UP_S2_OCO1Sets6 = new List<NZDUSD_OCO1_UP_S2>();
        
        public static bool NZDUSD_OCO1_UP_S2_IsReady = true;
        public static bool NZDUSD_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket NZDUSD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int NZDUSD_OCO1_EO1_DOWN_S2_ID ;
        public static int NZDUSD_OCO1_EO2_DOWN_S2_ID ;
        public static int NZDUSD_OCO1_EO3_DOWN_S2_ID ;
        public static int NZDUSD_OCO1_EO4_DOWN_S2_ID ;
        public static int NZDUSD_OCO1_EO5_DOWN_S2_ID ;
        public static int NZDUSD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool NZDUSD_OCO1_EO1_DOWN_S2 ;
        public static bool NZDUSD_OCO1_EO2_DOWN_S2 ;
        public static bool NZDUSD_OCO1_EO3_DOWN_S2 ;
        public static bool NZDUSD_OCO1_EO4_DOWN_S2 ;
        public static bool NZDUSD_OCO1_EO5_DOWN_S2 ;
        public static bool NZDUSD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_DOWN_S2> NZDUSD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_DOWN_S2> NZDUSD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_DOWN_S2> NZDUSD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_DOWN_S2> NZDUSD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_DOWN_S2> NZDUSD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO1_DOWN_S2> NZDUSD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static NZDUSD_OCO1_DOWN_S2 NZDUSD_PFO_OCO1_DOWN_S2_1 ;
        public static NZDUSD_OCO1_DOWN_S2 NZDUSD_PFO_OCO1_DOWN_S2_2 ;
        public static NZDUSD_OCO1_DOWN_S2 NZDUSD_PFO_OCO1_DOWN_S2_3 ;
        public static NZDUSD_OCO1_DOWN_S2 NZDUSD_PFO_OCO1_DOWN_S2_4 ;
        public static NZDUSD_OCO1_DOWN_S2 NZDUSD_PFO_OCO1_DOWN_S2_5 ;
        public static NZDUSD_OCO1_DOWN_S2 NZDUSD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<NZDUSD_OCO1_DOWN_S2> NZDUSD_DOWN_S2_OCO1Sets1 = new List<NZDUSD_OCO1_DOWN_S2>();
        public static List<NZDUSD_OCO1_DOWN_S2> NZDUSD_DOWN_S2_OCO1Sets2 = new List<NZDUSD_OCO1_DOWN_S2>();
        public static List<NZDUSD_OCO1_DOWN_S2> NZDUSD_DOWN_S2_OCO1Sets3 = new List<NZDUSD_OCO1_DOWN_S2>();
        public static List<NZDUSD_OCO1_DOWN_S2> NZDUSD_DOWN_S2_OCO1Sets4 = new List<NZDUSD_OCO1_DOWN_S2>();
        public static List<NZDUSD_OCO1_DOWN_S2> NZDUSD_DOWN_S2_OCO1Sets5 = new List<NZDUSD_OCO1_DOWN_S2>();
        public static List<NZDUSD_OCO1_DOWN_S2> NZDUSD_DOWN_S2_OCO1Sets6 = new List<NZDUSD_OCO1_DOWN_S2>();
        
        public static bool NZDUSD_OCO1_DOWN_S2_IsReady = true;
        public static bool NZDUSD_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket NZDUSD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO6_UP_S2 ;
    	
    	public static int NZDUSD_OCO2_EO1_UP_S2_ID ;
        public static int NZDUSD_OCO2_EO2_UP_S2_ID ;
        public static int NZDUSD_OCO2_EO3_UP_S2_ID ;
        public static int NZDUSD_OCO2_EO4_UP_S2_ID ;
        public static int NZDUSD_OCO2_EO5_UP_S2_ID ;
        public static int NZDUSD_OCO2_EO6_UP_S2_ID ;
        
        public static bool NZDUSD_OCO2_EO1_UP_S2 ;
        public static bool NZDUSD_OCO2_EO2_UP_S2 ;
        public static bool NZDUSD_OCO2_EO3_UP_S2 ;
        public static bool NZDUSD_OCO2_EO4_UP_S2 ;
        public static bool NZDUSD_OCO2_EO5_UP_S2 ;
        public static bool NZDUSD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_UP_S2> NZDUSD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_UP_S2> NZDUSD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_UP_S2> NZDUSD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_UP_S2> NZDUSD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_UP_S2> NZDUSD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_UP_S2> NZDUSD_OOFE_OCO2_UP_S2_6 ;
        
        public static NZDUSD_OCO2_UP_S2 NZDUSD_PFO_OCO2_UP_S2_1 ;
        public static NZDUSD_OCO2_UP_S2 NZDUSD_PFO_OCO2_UP_S2_2 ;
        public static NZDUSD_OCO2_UP_S2 NZDUSD_PFO_OCO2_UP_S2_3 ;
        public static NZDUSD_OCO2_UP_S2 NZDUSD_PFO_OCO2_UP_S2_4 ;
        public static NZDUSD_OCO2_UP_S2 NZDUSD_PFO_OCO2_UP_S2_5 ;
        public static NZDUSD_OCO2_UP_S2 NZDUSD_PFO_OCO2_UP_S2_6 ;
        
        public static List<NZDUSD_OCO2_UP_S2> NZDUSD_UP_S2_OCO2Sets1 = new List<NZDUSD_OCO2_UP_S2>();
        public static List<NZDUSD_OCO2_UP_S2> NZDUSD_UP_S2_OCO2Sets2 = new List<NZDUSD_OCO2_UP_S2>();
        public static List<NZDUSD_OCO2_UP_S2> NZDUSD_UP_S2_OCO2Sets3 = new List<NZDUSD_OCO2_UP_S2>();
        public static List<NZDUSD_OCO2_UP_S2> NZDUSD_UP_S2_OCO2Sets4 = new List<NZDUSD_OCO2_UP_S2>();
        public static List<NZDUSD_OCO2_UP_S2> NZDUSD_UP_S2_OCO2Sets5 = new List<NZDUSD_OCO2_UP_S2>();
        public static List<NZDUSD_OCO2_UP_S2> NZDUSD_UP_S2_OCO2Sets6 = new List<NZDUSD_OCO2_UP_S2>();
        
        public static bool NZDUSD_OCO2_UP_S2_IsReady = true;
        public static bool NZDUSD_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket NZDUSD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int NZDUSD_OCO2_EO1_DOWN_S2_ID ;
        public static int NZDUSD_OCO2_EO2_DOWN_S2_ID ;
        public static int NZDUSD_OCO2_EO3_DOWN_S2_ID ;
        public static int NZDUSD_OCO2_EO4_DOWN_S2_ID ;
        public static int NZDUSD_OCO2_EO5_DOWN_S2_ID ;
        public static int NZDUSD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool NZDUSD_OCO2_EO1_DOWN_S2 ;
        public static bool NZDUSD_OCO2_EO2_DOWN_S2 ;
        public static bool NZDUSD_OCO2_EO3_DOWN_S2 ;
        public static bool NZDUSD_OCO2_EO4_DOWN_S2 ;
        public static bool NZDUSD_OCO2_EO5_DOWN_S2 ;
        public static bool NZDUSD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_DOWN_S2> NZDUSD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_DOWN_S2> NZDUSD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_DOWN_S2> NZDUSD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_DOWN_S2> NZDUSD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_DOWN_S2> NZDUSD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO2_DOWN_S2> NZDUSD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static NZDUSD_OCO2_DOWN_S2 NZDUSD_PFO_OCO2_DOWN_S2_1 ;
        public static NZDUSD_OCO2_DOWN_S2 NZDUSD_PFO_OCO2_DOWN_S2_2 ;
        public static NZDUSD_OCO2_DOWN_S2 NZDUSD_PFO_OCO2_DOWN_S2_3 ;
        public static NZDUSD_OCO2_DOWN_S2 NZDUSD_PFO_OCO2_DOWN_S2_4 ;
        public static NZDUSD_OCO2_DOWN_S2 NZDUSD_PFO_OCO2_DOWN_S2_5 ;
        public static NZDUSD_OCO2_DOWN_S2 NZDUSD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<NZDUSD_OCO2_DOWN_S2> NZDUSD_DOWN_S2_OCO2Sets1 = new List<NZDUSD_OCO2_DOWN_S2>();
        public static List<NZDUSD_OCO2_DOWN_S2> NZDUSD_DOWN_S2_OCO2Sets2 = new List<NZDUSD_OCO2_DOWN_S2>();
        public static List<NZDUSD_OCO2_DOWN_S2> NZDUSD_DOWN_S2_OCO2Sets3 = new List<NZDUSD_OCO2_DOWN_S2>();
        public static List<NZDUSD_OCO2_DOWN_S2> NZDUSD_DOWN_S2_OCO2Sets4 = new List<NZDUSD_OCO2_DOWN_S2>();
        public static List<NZDUSD_OCO2_DOWN_S2> NZDUSD_DOWN_S2_OCO2Sets5 = new List<NZDUSD_OCO2_DOWN_S2>();
        public static List<NZDUSD_OCO2_DOWN_S2> NZDUSD_DOWN_S2_OCO2Sets6 = new List<NZDUSD_OCO2_DOWN_S2>();
        
        public static bool NZDUSD_OCO2_DOWN_S2_IsReady = true;
        public static bool NZDUSD_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket NZDUSD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO6_UP_S2 ;
    	
    	public static int NZDUSD_OCO3_EO1_UP_S2_ID ;
        public static int NZDUSD_OCO3_EO2_UP_S2_ID ;
        public static int NZDUSD_OCO3_EO3_UP_S2_ID ;
        public static int NZDUSD_OCO3_EO4_UP_S2_ID ;
        public static int NZDUSD_OCO3_EO5_UP_S2_ID ;
        public static int NZDUSD_OCO3_EO6_UP_S2_ID ;
        
        public static bool NZDUSD_OCO3_EO1_UP_S2 ;
        public static bool NZDUSD_OCO3_EO2_UP_S2 ;
        public static bool NZDUSD_OCO3_EO3_UP_S2 ;
        public static bool NZDUSD_OCO3_EO4_UP_S2 ;
        public static bool NZDUSD_OCO3_EO5_UP_S2 ;
        public static bool NZDUSD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_UP_S2> NZDUSD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_UP_S2> NZDUSD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_UP_S2> NZDUSD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_UP_S2> NZDUSD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_UP_S2> NZDUSD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_UP_S2> NZDUSD_OOFE_OCO3_UP_S2_6 ;
        
        public static NZDUSD_OCO3_UP_S2 NZDUSD_PFO_OCO3_UP_S2_1 ;
        public static NZDUSD_OCO3_UP_S2 NZDUSD_PFO_OCO3_UP_S2_2 ;
        public static NZDUSD_OCO3_UP_S2 NZDUSD_PFO_OCO3_UP_S2_3 ;
        public static NZDUSD_OCO3_UP_S2 NZDUSD_PFO_OCO3_UP_S2_4 ;
        public static NZDUSD_OCO3_UP_S2 NZDUSD_PFO_OCO3_UP_S2_5 ;
        public static NZDUSD_OCO3_UP_S2 NZDUSD_PFO_OCO3_UP_S2_6 ;
        
        public static List<NZDUSD_OCO3_UP_S2> NZDUSD_UP_S2_OCO3Sets1 = new List<NZDUSD_OCO3_UP_S2>();
        public static List<NZDUSD_OCO3_UP_S2> NZDUSD_UP_S2_OCO3Sets2 = new List<NZDUSD_OCO3_UP_S2>();
        public static List<NZDUSD_OCO3_UP_S2> NZDUSD_UP_S2_OCO3Sets3 = new List<NZDUSD_OCO3_UP_S2>();
        public static List<NZDUSD_OCO3_UP_S2> NZDUSD_UP_S2_OCO3Sets4 = new List<NZDUSD_OCO3_UP_S2>();
        public static List<NZDUSD_OCO3_UP_S2> NZDUSD_UP_S2_OCO3Sets5 = new List<NZDUSD_OCO3_UP_S2>();
        public static List<NZDUSD_OCO3_UP_S2> NZDUSD_UP_S2_OCO3Sets6 = new List<NZDUSD_OCO3_UP_S2>();
        
        public static bool NZDUSD_OCO3_UP_S2_IsReady = true;
        public static bool NZDUSD_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket NZDUSD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int NZDUSD_OCO3_EO1_DOWN_S2_ID ;
        public static int NZDUSD_OCO3_EO2_DOWN_S2_ID ;
        public static int NZDUSD_OCO3_EO3_DOWN_S2_ID ;
        public static int NZDUSD_OCO3_EO4_DOWN_S2_ID ;
        public static int NZDUSD_OCO3_EO5_DOWN_S2_ID ;
        public static int NZDUSD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool NZDUSD_OCO3_EO1_DOWN_S2 ;
        public static bool NZDUSD_OCO3_EO2_DOWN_S2 ;
        public static bool NZDUSD_OCO3_EO3_DOWN_S2 ;
        public static bool NZDUSD_OCO3_EO4_DOWN_S2 ;
        public static bool NZDUSD_OCO3_EO5_DOWN_S2 ;
        public static bool NZDUSD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_DOWN_S2> NZDUSD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_DOWN_S2> NZDUSD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_DOWN_S2> NZDUSD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_DOWN_S2> NZDUSD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_DOWN_S2> NZDUSD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO3_DOWN_S2> NZDUSD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static NZDUSD_OCO3_DOWN_S2 NZDUSD_PFO_OCO3_DOWN_S2_1 ;
        public static NZDUSD_OCO3_DOWN_S2 NZDUSD_PFO_OCO3_DOWN_S2_2 ;
        public static NZDUSD_OCO3_DOWN_S2 NZDUSD_PFO_OCO3_DOWN_S2_3 ;
        public static NZDUSD_OCO3_DOWN_S2 NZDUSD_PFO_OCO3_DOWN_S2_4 ;
        public static NZDUSD_OCO3_DOWN_S2 NZDUSD_PFO_OCO3_DOWN_S2_5 ;
        public static NZDUSD_OCO3_DOWN_S2 NZDUSD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<NZDUSD_OCO3_DOWN_S2> NZDUSD_DOWN_S2_OCO3Sets1 = new List<NZDUSD_OCO3_DOWN_S2>();
        public static List<NZDUSD_OCO3_DOWN_S2> NZDUSD_DOWN_S2_OCO3Sets2 = new List<NZDUSD_OCO3_DOWN_S2>();
        public static List<NZDUSD_OCO3_DOWN_S2> NZDUSD_DOWN_S2_OCO3Sets3 = new List<NZDUSD_OCO3_DOWN_S2>();
        public static List<NZDUSD_OCO3_DOWN_S2> NZDUSD_DOWN_S2_OCO3Sets4 = new List<NZDUSD_OCO3_DOWN_S2>();
        public static List<NZDUSD_OCO3_DOWN_S2> NZDUSD_DOWN_S2_OCO3Sets5 = new List<NZDUSD_OCO3_DOWN_S2>();
        public static List<NZDUSD_OCO3_DOWN_S2> NZDUSD_DOWN_S2_OCO3Sets6 = new List<NZDUSD_OCO3_DOWN_S2>();
        
        public static bool NZDUSD_OCO3_DOWN_S2_IsReady = true;
        public static bool NZDUSD_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket NZDUSD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO6_UP_S2 ;
    	
    	public static int NZDUSD_OCO4_EO1_UP_S2_ID ;
        public static int NZDUSD_OCO4_EO2_UP_S2_ID ;
        public static int NZDUSD_OCO4_EO3_UP_S2_ID ;
        public static int NZDUSD_OCO4_EO4_UP_S2_ID ;
        public static int NZDUSD_OCO4_EO5_UP_S2_ID ;
        public static int NZDUSD_OCO4_EO6_UP_S2_ID ;
        
        public static bool NZDUSD_OCO4_EO1_UP_S2 ;
        public static bool NZDUSD_OCO4_EO2_UP_S2 ;
        public static bool NZDUSD_OCO4_EO3_UP_S2 ;
        public static bool NZDUSD_OCO4_EO4_UP_S2 ;
        public static bool NZDUSD_OCO4_EO5_UP_S2 ;
        public static bool NZDUSD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_UP_S2> NZDUSD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_UP_S2> NZDUSD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_UP_S2> NZDUSD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_UP_S2> NZDUSD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_UP_S2> NZDUSD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_UP_S2> NZDUSD_OOFE_OCO4_UP_S2_6 ;
        
        public static NZDUSD_OCO4_UP_S2 NZDUSD_PFO_OCO4_UP_S2_1 ;
        public static NZDUSD_OCO4_UP_S2 NZDUSD_PFO_OCO4_UP_S2_2 ;
        public static NZDUSD_OCO4_UP_S2 NZDUSD_PFO_OCO4_UP_S2_3 ;
        public static NZDUSD_OCO4_UP_S2 NZDUSD_PFO_OCO4_UP_S2_4 ;
        public static NZDUSD_OCO4_UP_S2 NZDUSD_PFO_OCO4_UP_S2_5 ;
        public static NZDUSD_OCO4_UP_S2 NZDUSD_PFO_OCO4_UP_S2_6 ;
        
        public static List<NZDUSD_OCO4_UP_S2> NZDUSD_UP_S2_OCO4Sets1 = new List<NZDUSD_OCO4_UP_S2>();
        public static List<NZDUSD_OCO4_UP_S2> NZDUSD_UP_S2_OCO4Sets2 = new List<NZDUSD_OCO4_UP_S2>();
        public static List<NZDUSD_OCO4_UP_S2> NZDUSD_UP_S2_OCO4Sets3 = new List<NZDUSD_OCO4_UP_S2>();
        public static List<NZDUSD_OCO4_UP_S2> NZDUSD_UP_S2_OCO4Sets4 = new List<NZDUSD_OCO4_UP_S2>();
        public static List<NZDUSD_OCO4_UP_S2> NZDUSD_UP_S2_OCO4Sets5 = new List<NZDUSD_OCO4_UP_S2>();
        public static List<NZDUSD_OCO4_UP_S2> NZDUSD_UP_S2_OCO4Sets6 = new List<NZDUSD_OCO4_UP_S2>();
        
        public static bool NZDUSD_OCO4_UP_S2_IsReady = true;
        public static bool NZDUSD_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket NZDUSD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket NZDUSD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int NZDUSD_OCO4_EO1_DOWN_S2_ID ;
        public static int NZDUSD_OCO4_EO2_DOWN_S2_ID ;
        public static int NZDUSD_OCO4_EO3_DOWN_S2_ID ;
        public static int NZDUSD_OCO4_EO4_DOWN_S2_ID ;
        public static int NZDUSD_OCO4_EO5_DOWN_S2_ID ;
        public static int NZDUSD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool NZDUSD_OCO4_EO1_DOWN_S2 ;
        public static bool NZDUSD_OCO4_EO2_DOWN_S2 ;
        public static bool NZDUSD_OCO4_EO3_DOWN_S2 ;
        public static bool NZDUSD_OCO4_EO4_DOWN_S2 ;
        public static bool NZDUSD_OCO4_EO5_DOWN_S2 ;
        public static bool NZDUSD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_DOWN_S2> NZDUSD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_DOWN_S2> NZDUSD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_DOWN_S2> NZDUSD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_DOWN_S2> NZDUSD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_DOWN_S2> NZDUSD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDUSD_OCO4_DOWN_S2> NZDUSD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static NZDUSD_OCO4_DOWN_S2 NZDUSD_PFO_OCO4_DOWN_S2_1 ;
        public static NZDUSD_OCO4_DOWN_S2 NZDUSD_PFO_OCO4_DOWN_S2_2 ;
        public static NZDUSD_OCO4_DOWN_S2 NZDUSD_PFO_OCO4_DOWN_S2_3 ;
        public static NZDUSD_OCO4_DOWN_S2 NZDUSD_PFO_OCO4_DOWN_S2_4 ;
        public static NZDUSD_OCO4_DOWN_S2 NZDUSD_PFO_OCO4_DOWN_S2_5 ;
        public static NZDUSD_OCO4_DOWN_S2 NZDUSD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<NZDUSD_OCO4_DOWN_S2> NZDUSD_DOWN_S2_OCO4Sets1 = new List<NZDUSD_OCO4_DOWN_S2>();
        public static List<NZDUSD_OCO4_DOWN_S2> NZDUSD_DOWN_S2_OCO4Sets2 = new List<NZDUSD_OCO4_DOWN_S2>();
        public static List<NZDUSD_OCO4_DOWN_S2> NZDUSD_DOWN_S2_OCO4Sets3 = new List<NZDUSD_OCO4_DOWN_S2>();
        public static List<NZDUSD_OCO4_DOWN_S2> NZDUSD_DOWN_S2_OCO4Sets4 = new List<NZDUSD_OCO4_DOWN_S2>();
        public static List<NZDUSD_OCO4_DOWN_S2> NZDUSD_DOWN_S2_OCO4Sets5 = new List<NZDUSD_OCO4_DOWN_S2>();
        public static List<NZDUSD_OCO4_DOWN_S2> NZDUSD_DOWN_S2_OCO4Sets6 = new List<NZDUSD_OCO4_DOWN_S2>();
        
        public static bool NZDUSD_OCO4_DOWN_S2_IsReady = true;
        public static bool NZDUSD_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal NZDUSD_UP_S2_SL {get; set;}
		public static decimal NZDUSD_UP_S2_TP1 {get; set;}
		public static decimal NZDUSD_UP_S2_TP2 {get; set;}
		public static decimal NZDUSD_UP_S2_TP3 {get; set;}
		public static decimal NZDUSD_UP_S2_TP4 {get; set;}
		public static decimal NZDUSD_UP_S2_TP5 {get; set;}
		public static decimal NZDUSD_UP_S2_TP6 {get; set;}
		
		public static decimal NZDUSD_DOWN_S2_SL {get; set;}
		public static decimal NZDUSD_DOWN_S2_TP1 {get; set;}
		public static decimal NZDUSD_DOWN_S2_TP2 {get; set;}
		public static decimal NZDUSD_DOWN_S2_TP3 {get; set;}
		public static decimal NZDUSD_DOWN_S2_TP4 {get; set;}
		public static decimal NZDUSD_DOWN_S2_TP5 {get; set;}
		public static decimal NZDUSD_DOWN_S2_TP6 {get; set;}

        public static bool NZDUSD_Signal_Condition_UP_1 ;
        public static bool NZDUSD_Signal_Condition_UP_2 ;
        public static bool NZDUSD_Signal_Condition_UP_3 ;
        public static bool NZDUSD_Signal_Condition_DOWN_S2 ;
        
        public static int NZDUSD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int NZDUSD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int NZDUSD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int NZDUSD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int NZDUSD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int NZDUSD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int NZDUSD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int NZDUSD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int NZDUSD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int NZDUSD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_NZDUSD_UP_S2 ;
        public static bool DOWM_NZDUSD_UP_S2 ;
        public static bool DOWT_NZDUSD_UP_S2 ;
        public static bool DOWW_NZDUSD_UP_S2 ;
        public static bool DOWTH_NZDUSD_UP_S2 ;
        
		public static bool DOWR_NZDUSD_DOWN_S2 ;
        public static bool DOWM_NZDUSD_DOWN_S2 ;
        public static bool DOWT_NZDUSD_DOWN_S2 ;
        public static bool DOWW_NZDUSD_DOWN_S2 ;
        public static bool DOWTH_NZDUSD_DOWN_S2 ;
        
        
		public static int NZDUSD_quantity_UP_S2 ;
		public static int NZDUSD_quantity_SL_UP_S2 ;
		public static int NZDUSD_quantity_TP1_UP_S2 ;
		public static int NZDUSD_quantity_TP2_UP_S2 ;
		public static int NZDUSD_quantity_TP3_UP_S2 ;
		public static int NZDUSD_quantity_TP4_UP_S2 ;
		public static int NZDUSD_quantity_TP5_UP_S2;
		public static int NZDUSD_quantity_TP6_UP_S2 ;
		
		public static int NZDUSD_quantity_DOWN_S2 ;
		public static int NZDUSD_quantity_SL_DOWN_S2 ;
		public static int NZDUSD_quantity_TP1_DOWN_S2 ;
		public static int NZDUSD_quantity_TP2_DOWN_S2 ;
		public static int NZDUSD_quantity_TP3_DOWN_S2 ;
		public static int NZDUSD_quantity_TP4_DOWN_S2 ;
		public static int NZDUSD_quantity_TP5_DOWN_S2;
		public static int NZDUSD_quantity_TP6_DOWN_S2 ;
    }
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct NZDJPY_OCO1_DOWN_S2
    {
        public NZDJPY_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 =="TP1_NZDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY 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 =="TP1_NZDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY 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 NZDJPY_OCO1_UP_S2
    {
        public NZDJPY_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 =="TP1_NZDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY 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 =="TP1_NZDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDJPY 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 NZDJPY_OCO2_DOWN_S2
    {
        public NZDJPY_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 =="TP1_NZDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY 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 =="TP1_NZDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY 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 NZDJPY_OCO2_UP_S2
    {
        public NZDJPY_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 =="TP1_NZDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY 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 =="TP1_NZDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDJPY 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 NZDJPY_OCO3_DOWN_S2
    {
        public NZDJPY_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 =="TP1_NZDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY 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 =="TP1_NZDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY 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 NZDJPY_OCO3_UP_S2
    {
        public NZDJPY_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 =="TP1_NZDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY 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 =="TP1_NZDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDJPY 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 NZDJPY_OCO4_DOWN_S2
    {
        public NZDJPY_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 =="TP1_NZDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY 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 =="TP1_NZDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY 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 NZDJPY_OCO4_UP_S2
    {
        public NZDJPY_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 =="TP1_NZDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY 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 =="TP1_NZDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDJPY 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.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 _NZDCHF;
		
    	///oco1 up
    	public static OrderTicket NZDCHF_OCO1_MO1_UP_S2;
    	public static OrderTicket NZDCHF_OCO1_MO2_UP_S2;
    	public static OrderTicket NZDCHF_OCO1_MO3_UP_S2;
    	public static OrderTicket NZDCHF_OCO1_MO4_UP_S2;
    	public static OrderTicket NZDCHF_OCO1_MO5_UP_S2;
    	public static OrderTicket NZDCHF_OCO1_MO6_UP_S2;
    	
    	public static int NZDCHF_OCO1_EO1_UP_S2_ID ;
        public static int NZDCHF_OCO1_EO2_UP_S2_ID ;
        public static int NZDCHF_OCO1_EO3_UP_S2_ID ;
        public static int NZDCHF_OCO1_EO4_UP_S2_ID ;
        public static int NZDCHF_OCO1_EO5_UP_S2_ID ;
        public static int NZDCHF_OCO1_EO6_UP_S2_ID ;
        
        public static bool NZDCHF_OCO1_EO1_UP_S2 ;
        public static bool NZDCHF_OCO1_EO2_UP_S2 ;
        public static bool NZDCHF_OCO1_EO3_UP_S2 ;
        public static bool NZDCHF_OCO1_EO4_UP_S2 ;
        public static bool NZDCHF_OCO1_EO5_UP_S2 ;
        public static bool NZDCHF_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_UP_S2> NZDCHF_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_UP_S2> NZDCHF_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_UP_S2> NZDCHF_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_UP_S2> NZDCHF_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_UP_S2> NZDCHF_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_UP_S2> NZDCHF_OOFE_OCO1_UP_S2_6 ;
        
        public static NZDCHF_OCO1_UP_S2 NZDCHF_PFO_OCO1_UP_S2_1 ;
        public static NZDCHF_OCO1_UP_S2 NZDCHF_PFO_OCO1_UP_S2_2 ;
        public static NZDCHF_OCO1_UP_S2 NZDCHF_PFO_OCO1_UP_S2_3 ;
        public static NZDCHF_OCO1_UP_S2 NZDCHF_PFO_OCO1_UP_S2_4 ;
        public static NZDCHF_OCO1_UP_S2 NZDCHF_PFO_OCO1_UP_S2_5 ;
        public static NZDCHF_OCO1_UP_S2 NZDCHF_PFO_OCO1_UP_S2_6 ;
        
        public static List<NZDCHF_OCO1_UP_S2> NZDCHF_UP_S2_OCO1Sets1 = new List<NZDCHF_OCO1_UP_S2>();
        public static List<NZDCHF_OCO1_UP_S2> NZDCHF_UP_S2_OCO1Sets2 = new List<NZDCHF_OCO1_UP_S2>();
        public static List<NZDCHF_OCO1_UP_S2> NZDCHF_UP_S2_OCO1Sets3 = new List<NZDCHF_OCO1_UP_S2>();
        public static List<NZDCHF_OCO1_UP_S2> NZDCHF_UP_S2_OCO1Sets4 = new List<NZDCHF_OCO1_UP_S2>();
        public static List<NZDCHF_OCO1_UP_S2> NZDCHF_UP_S2_OCO1Sets5 = new List<NZDCHF_OCO1_UP_S2>();
        public static List<NZDCHF_OCO1_UP_S2> NZDCHF_UP_S2_OCO1Sets6 = new List<NZDCHF_OCO1_UP_S2>();
        
        public static bool NZDCHF_OCO1_UP_S2_IsReady = true;
        public static bool NZDCHF_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket NZDCHF_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO1_MO6_DOWN_S2 ;
    	
    	public static int NZDCHF_OCO1_EO1_DOWN_S2_ID ;
        public static int NZDCHF_OCO1_EO2_DOWN_S2_ID ;
        public static int NZDCHF_OCO1_EO3_DOWN_S2_ID ;
        public static int NZDCHF_OCO1_EO4_DOWN_S2_ID ;
        public static int NZDCHF_OCO1_EO5_DOWN_S2_ID ;
        public static int NZDCHF_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool NZDCHF_OCO1_EO1_DOWN_S2 ;
        public static bool NZDCHF_OCO1_EO2_DOWN_S2 ;
        public static bool NZDCHF_OCO1_EO3_DOWN_S2 ;
        public static bool NZDCHF_OCO1_EO4_DOWN_S2 ;
        public static bool NZDCHF_OCO1_EO5_DOWN_S2 ;
        public static bool NZDCHF_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_DOWN_S2> NZDCHF_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_DOWN_S2> NZDCHF_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_DOWN_S2> NZDCHF_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_DOWN_S2> NZDCHF_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_DOWN_S2> NZDCHF_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO1_DOWN_S2> NZDCHF_OOFE_OCO1_DOWN_S2_6 ;
        
        public static NZDCHF_OCO1_DOWN_S2 NZDCHF_PFO_OCO1_DOWN_S2_1 ;
        public static NZDCHF_OCO1_DOWN_S2 NZDCHF_PFO_OCO1_DOWN_S2_2 ;
        public static NZDCHF_OCO1_DOWN_S2 NZDCHF_PFO_OCO1_DOWN_S2_3 ;
        public static NZDCHF_OCO1_DOWN_S2 NZDCHF_PFO_OCO1_DOWN_S2_4 ;
        public static NZDCHF_OCO1_DOWN_S2 NZDCHF_PFO_OCO1_DOWN_S2_5 ;
        public static NZDCHF_OCO1_DOWN_S2 NZDCHF_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<NZDCHF_OCO1_DOWN_S2> NZDCHF_DOWN_S2_OCO1Sets1 = new List<NZDCHF_OCO1_DOWN_S2>();
        public static List<NZDCHF_OCO1_DOWN_S2> NZDCHF_DOWN_S2_OCO1Sets2 = new List<NZDCHF_OCO1_DOWN_S2>();
        public static List<NZDCHF_OCO1_DOWN_S2> NZDCHF_DOWN_S2_OCO1Sets3 = new List<NZDCHF_OCO1_DOWN_S2>();
        public static List<NZDCHF_OCO1_DOWN_S2> NZDCHF_DOWN_S2_OCO1Sets4 = new List<NZDCHF_OCO1_DOWN_S2>();
        public static List<NZDCHF_OCO1_DOWN_S2> NZDCHF_DOWN_S2_OCO1Sets5 = new List<NZDCHF_OCO1_DOWN_S2>();
        public static List<NZDCHF_OCO1_DOWN_S2> NZDCHF_DOWN_S2_OCO1Sets6 = new List<NZDCHF_OCO1_DOWN_S2>();
        
        public static bool NZDCHF_OCO1_DOWN_S2_IsReady = true;
        public static bool NZDCHF_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket NZDCHF_OCO2_MO1_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO2_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO3_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO4_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO5_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO6_UP_S2 ;
    	
    	public static int NZDCHF_OCO2_EO1_UP_S2_ID ;
        public static int NZDCHF_OCO2_EO2_UP_S2_ID ;
        public static int NZDCHF_OCO2_EO3_UP_S2_ID ;
        public static int NZDCHF_OCO2_EO4_UP_S2_ID ;
        public static int NZDCHF_OCO2_EO5_UP_S2_ID ;
        public static int NZDCHF_OCO2_EO6_UP_S2_ID ;
        
        public static bool NZDCHF_OCO2_EO1_UP_S2 ;
        public static bool NZDCHF_OCO2_EO2_UP_S2 ;
        public static bool NZDCHF_OCO2_EO3_UP_S2 ;
        public static bool NZDCHF_OCO2_EO4_UP_S2 ;
        public static bool NZDCHF_OCO2_EO5_UP_S2 ;
        public static bool NZDCHF_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_UP_S2> NZDCHF_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_UP_S2> NZDCHF_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_UP_S2> NZDCHF_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_UP_S2> NZDCHF_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_UP_S2> NZDCHF_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_UP_S2> NZDCHF_OOFE_OCO2_UP_S2_6 ;
        
        public static NZDCHF_OCO2_UP_S2 NZDCHF_PFO_OCO2_UP_S2_1 ;
        public static NZDCHF_OCO2_UP_S2 NZDCHF_PFO_OCO2_UP_S2_2 ;
        public static NZDCHF_OCO2_UP_S2 NZDCHF_PFO_OCO2_UP_S2_3 ;
        public static NZDCHF_OCO2_UP_S2 NZDCHF_PFO_OCO2_UP_S2_4 ;
        public static NZDCHF_OCO2_UP_S2 NZDCHF_PFO_OCO2_UP_S2_5 ;
        public static NZDCHF_OCO2_UP_S2 NZDCHF_PFO_OCO2_UP_S2_6 ;
        
        public static List<NZDCHF_OCO2_UP_S2> NZDCHF_UP_S2_OCO2Sets1 = new List<NZDCHF_OCO2_UP_S2>();
        public static List<NZDCHF_OCO2_UP_S2> NZDCHF_UP_S2_OCO2Sets2 = new List<NZDCHF_OCO2_UP_S2>();
        public static List<NZDCHF_OCO2_UP_S2> NZDCHF_UP_S2_OCO2Sets3 = new List<NZDCHF_OCO2_UP_S2>();
        public static List<NZDCHF_OCO2_UP_S2> NZDCHF_UP_S2_OCO2Sets4 = new List<NZDCHF_OCO2_UP_S2>();
        public static List<NZDCHF_OCO2_UP_S2> NZDCHF_UP_S2_OCO2Sets5 = new List<NZDCHF_OCO2_UP_S2>();
        public static List<NZDCHF_OCO2_UP_S2> NZDCHF_UP_S2_OCO2Sets6 = new List<NZDCHF_OCO2_UP_S2>();
        
        public static bool NZDCHF_OCO2_UP_S2_IsReady = true;
        public static bool NZDCHF_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket NZDCHF_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO2_MO6_DOWN_S2 ;
    	
    	public static int NZDCHF_OCO2_EO1_DOWN_S2_ID ;
        public static int NZDCHF_OCO2_EO2_DOWN_S2_ID ;
        public static int NZDCHF_OCO2_EO3_DOWN_S2_ID ;
        public static int NZDCHF_OCO2_EO4_DOWN_S2_ID ;
        public static int NZDCHF_OCO2_EO5_DOWN_S2_ID ;
        public static int NZDCHF_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool NZDCHF_OCO2_EO1_DOWN_S2 ;
        public static bool NZDCHF_OCO2_EO2_DOWN_S2 ;
        public static bool NZDCHF_OCO2_EO3_DOWN_S2 ;
        public static bool NZDCHF_OCO2_EO4_DOWN_S2 ;
        public static bool NZDCHF_OCO2_EO5_DOWN_S2 ;
        public static bool NZDCHF_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_DOWN_S2> NZDCHF_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_DOWN_S2> NZDCHF_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_DOWN_S2> NZDCHF_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_DOWN_S2> NZDCHF_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_DOWN_S2> NZDCHF_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO2_DOWN_S2> NZDCHF_OOFE_OCO2_DOWN_S2_6 ;
        
        public static NZDCHF_OCO2_DOWN_S2 NZDCHF_PFO_OCO2_DOWN_S2_1 ;
        public static NZDCHF_OCO2_DOWN_S2 NZDCHF_PFO_OCO2_DOWN_S2_2 ;
        public static NZDCHF_OCO2_DOWN_S2 NZDCHF_PFO_OCO2_DOWN_S2_3 ;
        public static NZDCHF_OCO2_DOWN_S2 NZDCHF_PFO_OCO2_DOWN_S2_4 ;
        public static NZDCHF_OCO2_DOWN_S2 NZDCHF_PFO_OCO2_DOWN_S2_5 ;
        public static NZDCHF_OCO2_DOWN_S2 NZDCHF_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<NZDCHF_OCO2_DOWN_S2> NZDCHF_DOWN_S2_OCO2Sets1 = new List<NZDCHF_OCO2_DOWN_S2>();
        public static List<NZDCHF_OCO2_DOWN_S2> NZDCHF_DOWN_S2_OCO2Sets2 = new List<NZDCHF_OCO2_DOWN_S2>();
        public static List<NZDCHF_OCO2_DOWN_S2> NZDCHF_DOWN_S2_OCO2Sets3 = new List<NZDCHF_OCO2_DOWN_S2>();
        public static List<NZDCHF_OCO2_DOWN_S2> NZDCHF_DOWN_S2_OCO2Sets4 = new List<NZDCHF_OCO2_DOWN_S2>();
        public static List<NZDCHF_OCO2_DOWN_S2> NZDCHF_DOWN_S2_OCO2Sets5 = new List<NZDCHF_OCO2_DOWN_S2>();
        public static List<NZDCHF_OCO2_DOWN_S2> NZDCHF_DOWN_S2_OCO2Sets6 = new List<NZDCHF_OCO2_DOWN_S2>();
        
        public static bool NZDCHF_OCO2_DOWN_S2_IsReady = true;
        public static bool NZDCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket NZDCHF_OCO3_MO1_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO2_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO3_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO4_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO5_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO6_UP_S2 ;
    	
    	public static int NZDCHF_OCO3_EO1_UP_S2_ID ;
        public static int NZDCHF_OCO3_EO2_UP_S2_ID ;
        public static int NZDCHF_OCO3_EO3_UP_S2_ID ;
        public static int NZDCHF_OCO3_EO4_UP_S2_ID ;
        public static int NZDCHF_OCO3_EO5_UP_S2_ID ;
        public static int NZDCHF_OCO3_EO6_UP_S2_ID ;
        
        public static bool NZDCHF_OCO3_EO1_UP_S2 ;
        public static bool NZDCHF_OCO3_EO2_UP_S2 ;
        public static bool NZDCHF_OCO3_EO3_UP_S2 ;
        public static bool NZDCHF_OCO3_EO4_UP_S2 ;
        public static bool NZDCHF_OCO3_EO5_UP_S2 ;
        public static bool NZDCHF_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_UP_S2> NZDCHF_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_UP_S2> NZDCHF_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_UP_S2> NZDCHF_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_UP_S2> NZDCHF_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_UP_S2> NZDCHF_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_UP_S2> NZDCHF_OOFE_OCO3_UP_S2_6 ;
        
        public static NZDCHF_OCO3_UP_S2 NZDCHF_PFO_OCO3_UP_S2_1 ;
        public static NZDCHF_OCO3_UP_S2 NZDCHF_PFO_OCO3_UP_S2_2 ;
        public static NZDCHF_OCO3_UP_S2 NZDCHF_PFO_OCO3_UP_S2_3 ;
        public static NZDCHF_OCO3_UP_S2 NZDCHF_PFO_OCO3_UP_S2_4 ;
        public static NZDCHF_OCO3_UP_S2 NZDCHF_PFO_OCO3_UP_S2_5 ;
        public static NZDCHF_OCO3_UP_S2 NZDCHF_PFO_OCO3_UP_S2_6 ;
        
        public static List<NZDCHF_OCO3_UP_S2> NZDCHF_UP_S2_OCO3Sets1 = new List<NZDCHF_OCO3_UP_S2>();
        public static List<NZDCHF_OCO3_UP_S2> NZDCHF_UP_S2_OCO3Sets2 = new List<NZDCHF_OCO3_UP_S2>();
        public static List<NZDCHF_OCO3_UP_S2> NZDCHF_UP_S2_OCO3Sets3 = new List<NZDCHF_OCO3_UP_S2>();
        public static List<NZDCHF_OCO3_UP_S2> NZDCHF_UP_S2_OCO3Sets4 = new List<NZDCHF_OCO3_UP_S2>();
        public static List<NZDCHF_OCO3_UP_S2> NZDCHF_UP_S2_OCO3Sets5 = new List<NZDCHF_OCO3_UP_S2>();
        public static List<NZDCHF_OCO3_UP_S2> NZDCHF_UP_S2_OCO3Sets6 = new List<NZDCHF_OCO3_UP_S2>();
        
        public static bool NZDCHF_OCO3_UP_S2_IsReady = true;
        public static bool NZDCHF_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket NZDCHF_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO3_MO6_DOWN_S2 ;
    	
    	public static int NZDCHF_OCO3_EO1_DOWN_S2_ID ;
        public static int NZDCHF_OCO3_EO2_DOWN_S2_ID ;
        public static int NZDCHF_OCO3_EO3_DOWN_S2_ID ;
        public static int NZDCHF_OCO3_EO4_DOWN_S2_ID ;
        public static int NZDCHF_OCO3_EO5_DOWN_S2_ID ;
        public static int NZDCHF_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool NZDCHF_OCO3_EO1_DOWN_S2 ;
        public static bool NZDCHF_OCO3_EO2_DOWN_S2 ;
        public static bool NZDCHF_OCO3_EO3_DOWN_S2 ;
        public static bool NZDCHF_OCO3_EO4_DOWN_S2 ;
        public static bool NZDCHF_OCO3_EO5_DOWN_S2 ;
        public static bool NZDCHF_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_DOWN_S2> NZDCHF_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_DOWN_S2> NZDCHF_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_DOWN_S2> NZDCHF_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_DOWN_S2> NZDCHF_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_DOWN_S2> NZDCHF_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO3_DOWN_S2> NZDCHF_OOFE_OCO3_DOWN_S2_6 ;
        
        public static NZDCHF_OCO3_DOWN_S2 NZDCHF_PFO_OCO3_DOWN_S2_1 ;
        public static NZDCHF_OCO3_DOWN_S2 NZDCHF_PFO_OCO3_DOWN_S2_2 ;
        public static NZDCHF_OCO3_DOWN_S2 NZDCHF_PFO_OCO3_DOWN_S2_3 ;
        public static NZDCHF_OCO3_DOWN_S2 NZDCHF_PFO_OCO3_DOWN_S2_4 ;
        public static NZDCHF_OCO3_DOWN_S2 NZDCHF_PFO_OCO3_DOWN_S2_5 ;
        public static NZDCHF_OCO3_DOWN_S2 NZDCHF_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<NZDCHF_OCO3_DOWN_S2> NZDCHF_DOWN_S2_OCO3Sets1 = new List<NZDCHF_OCO3_DOWN_S2>();
        public static List<NZDCHF_OCO3_DOWN_S2> NZDCHF_DOWN_S2_OCO3Sets2 = new List<NZDCHF_OCO3_DOWN_S2>();
        public static List<NZDCHF_OCO3_DOWN_S2> NZDCHF_DOWN_S2_OCO3Sets3 = new List<NZDCHF_OCO3_DOWN_S2>();
        public static List<NZDCHF_OCO3_DOWN_S2> NZDCHF_DOWN_S2_OCO3Sets4 = new List<NZDCHF_OCO3_DOWN_S2>();
        public static List<NZDCHF_OCO3_DOWN_S2> NZDCHF_DOWN_S2_OCO3Sets5 = new List<NZDCHF_OCO3_DOWN_S2>();
        public static List<NZDCHF_OCO3_DOWN_S2> NZDCHF_DOWN_S2_OCO3Sets6 = new List<NZDCHF_OCO3_DOWN_S2>();
        
        public static bool NZDCHF_OCO3_DOWN_S2_IsReady = true;
        public static bool NZDCHF_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket NZDCHF_OCO4_MO1_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO2_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO3_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO4_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO5_UP_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO6_UP_S2 ;
    	
    	public static int NZDCHF_OCO4_EO1_UP_S2_ID ;
        public static int NZDCHF_OCO4_EO2_UP_S2_ID ;
        public static int NZDCHF_OCO4_EO3_UP_S2_ID ;
        public static int NZDCHF_OCO4_EO4_UP_S2_ID ;
        public static int NZDCHF_OCO4_EO5_UP_S2_ID ;
        public static int NZDCHF_OCO4_EO6_UP_S2_ID ;
        
        public static bool NZDCHF_OCO4_EO1_UP_S2 ;
        public static bool NZDCHF_OCO4_EO2_UP_S2 ;
        public static bool NZDCHF_OCO4_EO3_UP_S2 ;
        public static bool NZDCHF_OCO4_EO4_UP_S2 ;
        public static bool NZDCHF_OCO4_EO5_UP_S2 ;
        public static bool NZDCHF_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_UP_S2> NZDCHF_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_UP_S2> NZDCHF_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_UP_S2> NZDCHF_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_UP_S2> NZDCHF_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_UP_S2> NZDCHF_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_UP_S2> NZDCHF_OOFE_OCO4_UP_S2_6 ;
        
        public static NZDCHF_OCO4_UP_S2 NZDCHF_PFO_OCO4_UP_S2_1 ;
        public static NZDCHF_OCO4_UP_S2 NZDCHF_PFO_OCO4_UP_S2_2 ;
        public static NZDCHF_OCO4_UP_S2 NZDCHF_PFO_OCO4_UP_S2_3 ;
        public static NZDCHF_OCO4_UP_S2 NZDCHF_PFO_OCO4_UP_S2_4 ;
        public static NZDCHF_OCO4_UP_S2 NZDCHF_PFO_OCO4_UP_S2_5 ;
        public static NZDCHF_OCO4_UP_S2 NZDCHF_PFO_OCO4_UP_S2_6 ;
        
        public static List<NZDCHF_OCO4_UP_S2> NZDCHF_UP_S2_OCO4Sets1 = new List<NZDCHF_OCO4_UP_S2>();
        public static List<NZDCHF_OCO4_UP_S2> NZDCHF_UP_S2_OCO4Sets2 = new List<NZDCHF_OCO4_UP_S2>();
        public static List<NZDCHF_OCO4_UP_S2> NZDCHF_UP_S2_OCO4Sets3 = new List<NZDCHF_OCO4_UP_S2>();
        public static List<NZDCHF_OCO4_UP_S2> NZDCHF_UP_S2_OCO4Sets4 = new List<NZDCHF_OCO4_UP_S2>();
        public static List<NZDCHF_OCO4_UP_S2> NZDCHF_UP_S2_OCO4Sets5 = new List<NZDCHF_OCO4_UP_S2>();
        public static List<NZDCHF_OCO4_UP_S2> NZDCHF_UP_S2_OCO4Sets6 = new List<NZDCHF_OCO4_UP_S2>();
        
        public static bool NZDCHF_OCO4_UP_S2_IsReady = true;
        public static bool NZDCHF_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket NZDCHF_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket NZDCHF_OCO4_MO6_DOWN_S2 ;
    	
    	public static int NZDCHF_OCO4_EO1_DOWN_S2_ID ;
        public static int NZDCHF_OCO4_EO2_DOWN_S2_ID ;
        public static int NZDCHF_OCO4_EO3_DOWN_S2_ID ;
        public static int NZDCHF_OCO4_EO4_DOWN_S2_ID ;
        public static int NZDCHF_OCO4_EO5_DOWN_S2_ID ;
        public static int NZDCHF_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool NZDCHF_OCO4_EO1_DOWN_S2 ;
        public static bool NZDCHF_OCO4_EO2_DOWN_S2 ;
        public static bool NZDCHF_OCO4_EO3_DOWN_S2 ;
        public static bool NZDCHF_OCO4_EO4_DOWN_S2 ;
        public static bool NZDCHF_OCO4_EO5_DOWN_S2 ;
        public static bool NZDCHF_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_DOWN_S2> NZDCHF_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_DOWN_S2> NZDCHF_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_DOWN_S2> NZDCHF_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_DOWN_S2> NZDCHF_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_DOWN_S2> NZDCHF_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCHF_OCO4_DOWN_S2> NZDCHF_OOFE_OCO4_DOWN_S2_6 ;
        
        public static NZDCHF_OCO4_DOWN_S2 NZDCHF_PFO_OCO4_DOWN_S2_1 ;
        public static NZDCHF_OCO4_DOWN_S2 NZDCHF_PFO_OCO4_DOWN_S2_2 ;
        public static NZDCHF_OCO4_DOWN_S2 NZDCHF_PFO_OCO4_DOWN_S2_3 ;
        public static NZDCHF_OCO4_DOWN_S2 NZDCHF_PFO_OCO4_DOWN_S2_4 ;
        public static NZDCHF_OCO4_DOWN_S2 NZDCHF_PFO_OCO4_DOWN_S2_5 ;
        public static NZDCHF_OCO4_DOWN_S2 NZDCHF_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<NZDCHF_OCO4_DOWN_S2> NZDCHF_DOWN_S2_OCO4Sets1 = new List<NZDCHF_OCO4_DOWN_S2>();
        public static List<NZDCHF_OCO4_DOWN_S2> NZDCHF_DOWN_S2_OCO4Sets2 = new List<NZDCHF_OCO4_DOWN_S2>();
        public static List<NZDCHF_OCO4_DOWN_S2> NZDCHF_DOWN_S2_OCO4Sets3 = new List<NZDCHF_OCO4_DOWN_S2>();
        public static List<NZDCHF_OCO4_DOWN_S2> NZDCHF_DOWN_S2_OCO4Sets4 = new List<NZDCHF_OCO4_DOWN_S2>();
        public static List<NZDCHF_OCO4_DOWN_S2> NZDCHF_DOWN_S2_OCO4Sets5 = new List<NZDCHF_OCO4_DOWN_S2>();
        public static List<NZDCHF_OCO4_DOWN_S2> NZDCHF_DOWN_S2_OCO4Sets6 = new List<NZDCHF_OCO4_DOWN_S2>();
        
        public static bool NZDCHF_OCO4_DOWN_S2_IsReady = true;
        public static bool NZDCHF_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal NZDCHF_UP_S2_SL {get; set;}
		public static decimal NZDCHF_UP_S2_TP1 {get; set;}
		public static decimal NZDCHF_UP_S2_TP2 {get; set;}
		public static decimal NZDCHF_UP_S2_TP3 {get; set;}
		public static decimal NZDCHF_UP_S2_TP4 {get; set;}
		public static decimal NZDCHF_UP_S2_TP5 {get; set;}
		public static decimal NZDCHF_UP_S2_TP6 {get; set;}
		
		public static decimal NZDCHF_DOWN_S2_SL {get; set;}
		public static decimal NZDCHF_DOWN_S2_TP1 {get; set;}
		public static decimal NZDCHF_DOWN_S2_TP2 {get; set;}
		public static decimal NZDCHF_DOWN_S2_TP3 {get; set;}
		public static decimal NZDCHF_DOWN_S2_TP4 {get; set;}
		public static decimal NZDCHF_DOWN_S2_TP5 {get; set;}
		public static decimal NZDCHF_DOWN_S2_TP6 {get; set;}

        public static bool NZDCHF_Signal_Condition_UP_1 ;
        public static bool NZDCHF_Signal_Condition_UP_2 ;
        public static bool NZDCHF_Signal_Condition_UP_3 ;
        public static bool NZDCHF_Signal_Condition_DOWN_S2 ;
        
        public static int NZDCHF_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int NZDCHF_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int NZDCHF_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int NZDCHF_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int NZDCHF_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int NZDCHF_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int NZDCHF_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int NZDCHF_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int NZDCHF_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int NZDCHF_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_NZDCHF_UP_S2 ;
        public static bool DOWM_NZDCHF_UP_S2 ;
        public static bool DOWT_NZDCHF_UP_S2 ;
        public static bool DOWW_NZDCHF_UP_S2 ;
        public static bool DOWTH_NZDCHF_UP_S2 ;
        
		public static bool DOWR_NZDCHF_DOWN_S2 ;
        public static bool DOWM_NZDCHF_DOWN_S2 ;
        public static bool DOWT_NZDCHF_DOWN_S2 ;
        public static bool DOWW_NZDCHF_DOWN_S2 ;
        public static bool DOWTH_NZDCHF_DOWN_S2 ;
        
        
		public static int NZDCHF_quantity_UP_S2 ;
		public static int NZDCHF_quantity_SL_UP_S2 ;
		public static int NZDCHF_quantity_TP1_UP_S2 ;
		public static int NZDCHF_quantity_TP2_UP_S2 ;
		public static int NZDCHF_quantity_TP3_UP_S2 ;
		public static int NZDCHF_quantity_TP4_UP_S2 ;
		public static int NZDCHF_quantity_TP5_UP_S2;
		public static int NZDCHF_quantity_TP6_UP_S2 ;
		
		public static int NZDCHF_quantity_DOWN_S2 ;
		public static int NZDCHF_quantity_SL_DOWN_S2 ;
		public static int NZDCHF_quantity_TP1_DOWN_S2 ;
		public static int NZDCHF_quantity_TP2_DOWN_S2 ;
		public static int NZDCHF_quantity_TP3_DOWN_S2 ;
		public static int NZDCHF_quantity_TP4_DOWN_S2 ;
		public static int NZDCHF_quantity_TP5_DOWN_S2;
		public static int NZDCHF_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 AUDUSD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDUSD_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("AUDUSD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDUSD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDUSD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDUSD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDUSD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDUSD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDUSD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        }
		        
				if (Base.AUDUSD_OCO1_EO1_UP_S2)
	                Base.AUDUSD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDUSD_OCO1_EO2_UP_S2)
	                Base.AUDUSD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO1_EO3_UP_S2)
	                Base.AUDUSD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO1_EO4_UP_S2)
	                Base.AUDUSD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO1_EO5_UP_S2)
	                Base.AUDUSD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO1_EO6_UP_S2)
	                Base.AUDUSD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.AUDUSD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP1,"TP1_AUDUSD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP1_AUDUSD_UP_S2_OCO1"));
		                 };
		                Base.AUDUSD_UP_S2_OCO1Sets1.Add( Base.AUDUSD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP2,"TP2_AUDUSD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP2_AUDUSD_UP_S2_OCO1"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO1Sets2.Add( Base.AUDUSD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP3,"TP3_AUDUSD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP3_AUDUSD_UP_S2_OCO1"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO1Sets3.Add( Base.AUDUSD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP4,"TP4_AUDUSD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP4_AUDUSD_UP_S2_OCO1"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO1Sets4.Add( Base.AUDUSD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP5,"TP5_AUDUSD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP5_AUDUSD_UP_S2_OCO1"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO1Sets5.Add( Base.AUDUSD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP6,"TP6_AUDUSD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP6_AUDUSD_UP_S2_OCO1"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO1Sets6.Add( Base.AUDUSD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDUSD_OCO1S1_UP_S2 = 0;
	                for (; AUDUSD_OCO1S1_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets1.Count; AUDUSD_OCO1S1_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO1Sets1[AUDUSD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO1Sets1[AUDUSD_OCO1S1_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO1Sets1.RemoveAt(AUDUSD_OCO1S1_UP_S2);
	                        AUDUSD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDUSD_OCO1S2_UP_S2 = 0;
	                for (; AUDUSD_OCO1S2_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets2.Count; AUDUSD_OCO1S2_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO1Sets2[AUDUSD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO1Sets2[AUDUSD_OCO1S2_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO1Sets2.RemoveAt(AUDUSD_OCO1S2_UP_S2);
	                        AUDUSD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO1S3_UP_S2 = 0;
	                for (; AUDUSD_OCO1S3_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets3.Count; AUDUSD_OCO1S3_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO1Sets3[AUDUSD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO1Sets3[AUDUSD_OCO1S3_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO1Sets3.RemoveAt(AUDUSD_OCO1S3_UP_S2);
	                        AUDUSD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO1S4_UP_S2 = 0;
	                for (; AUDUSD_OCO1S4_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets4.Count; AUDUSD_OCO1S4_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO1Sets4[AUDUSD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO1Sets4[AUDUSD_OCO1S4_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO1Sets4.RemoveAt(AUDUSD_OCO1S4_UP_S2);
	                        AUDUSD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDUSD_OCO1S5_UP_S2 = 0;
	                for (; AUDUSD_OCO1S5_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets5.Count; AUDUSD_OCO1S5_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO1Sets5[AUDUSD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO1Sets5[AUDUSD_OCO1S5_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO1Sets5.RemoveAt(AUDUSD_OCO1S5_UP_S2);
	                        AUDUSD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDUSD_OCO1S6_UP_S2 = 0;
	                for (; AUDUSD_OCO1S6_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets6.Count; AUDUSD_OCO1S6_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO1Sets6[AUDUSD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO1Sets6[AUDUSD_OCO1S6_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO1Sets6.RemoveAt(AUDUSD_OCO1S6_UP_S2);
	                        AUDUSD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.AUDUSD_OCO2_EO1_UP_S2)
	                Base.AUDUSD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDUSD_OCO2_EO2_UP_S2)
	                Base.AUDUSD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO2_EO3_UP_S2)
	                Base.AUDUSD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO2_EO4_UP_S2)
	                Base.AUDUSD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO2_EO5_UP_S2)
	                Base.AUDUSD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO2_EO6_UP_S2)
	                Base.AUDUSD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.AUDUSD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP1,"TP1_AUDUSD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP1_AUDUSD_UP_S2_OCO2"));
		                 };
		                Base.AUDUSD_UP_S2_OCO2Sets1.Add( Base.AUDUSD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP2,"TP2_AUDUSD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP2_AUDUSD_UP_S2_OCO2"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO2Sets2.Add( Base.AUDUSD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP3,"TP3_AUDUSD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP3_AUDUSD_UP_S2_OCO2"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO2Sets3.Add( Base.AUDUSD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP4,"TP4_AUDUSD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP4_AUDUSD_UP_S2_OCO2"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO2Sets4.Add( Base.AUDUSD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP5,"TP5_AUDUSD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP5_AUDUSD_UP_S2_OCO2"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO2Sets5.Add( Base.AUDUSD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP6,"TP6_AUDUSD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP6_AUDUSD_UP_S2_OCO2"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO2Sets6.Add( Base.AUDUSD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDUSD_OCO2S1_UP_S2 = 0;
	                for (; AUDUSD_OCO2S1_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets1.Count; AUDUSD_OCO2S1_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO2Sets1[AUDUSD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO2Sets1[AUDUSD_OCO2S1_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO2Sets1.RemoveAt(AUDUSD_OCO2S1_UP_S2);
	                        AUDUSD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDUSD_OCO2S2_UP_S2 = 0;
	                for (; AUDUSD_OCO2S2_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets2.Count; AUDUSD_OCO2S2_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO2Sets2[AUDUSD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO2Sets2[AUDUSD_OCO2S2_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO2Sets2.RemoveAt(AUDUSD_OCO2S2_UP_S2);
	                        AUDUSD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO2S3_UP_S2 = 0;
	                for (; AUDUSD_OCO2S3_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets3.Count; AUDUSD_OCO2S3_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO2Sets3[AUDUSD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO2Sets3[AUDUSD_OCO2S3_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO2Sets3.RemoveAt(AUDUSD_OCO2S3_UP_S2);
	                        AUDUSD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO2S4_UP_S2 = 0;
	                for (; AUDUSD_OCO2S4_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets4.Count; AUDUSD_OCO2S4_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO2Sets4[AUDUSD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO2Sets4[AUDUSD_OCO2S4_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO2Sets4.RemoveAt(AUDUSD_OCO2S4_UP_S2);
	                        AUDUSD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDUSD_OCO2S5_UP_S2 = 0;
	                for (; AUDUSD_OCO2S5_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets5.Count; AUDUSD_OCO2S5_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO2Sets5[AUDUSD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO2Sets5[AUDUSD_OCO2S5_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO2Sets5.RemoveAt(AUDUSD_OCO2S5_UP_S2);
	                        AUDUSD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDUSD_OCO2S6_UP_S2 = 0;
	                for (; AUDUSD_OCO2S6_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets6.Count; AUDUSD_OCO2S6_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO2Sets6[AUDUSD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO2Sets6[AUDUSD_OCO2S6_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO2Sets6.RemoveAt(AUDUSD_OCO2S6_UP_S2);
	                        AUDUSD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDUSD_OCO3_EO1_UP_S2)
	                Base.AUDUSD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDUSD_OCO3_EO2_UP_S2)
	                Base.AUDUSD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO3_EO3_UP_S2)
	                Base.AUDUSD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO3_EO4_UP_S2)
	                Base.AUDUSD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO3_EO5_UP_S2)
	                Base.AUDUSD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO3_EO6_UP_S2)
	                Base.AUDUSD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.AUDUSD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP1,"TP1_AUDUSD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP1_AUDUSD_UP_S2_OCO3"));
		                 };
		                Base.AUDUSD_UP_S2_OCO3Sets1.Add( Base.AUDUSD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP2,"TP2_AUDUSD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP2_AUDUSD_UP_S2_OCO3"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO3Sets2.Add( Base.AUDUSD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP3,"TP3_AUDUSD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP3_AUDUSD_UP_S2_OCO3"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO3Sets3.Add( Base.AUDUSD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP4,"TP4_AUDUSD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP4_AUDUSD_UP_S2_OCO3"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO3Sets4.Add( Base.AUDUSD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP5,"TP5_AUDUSD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP5_AUDUSD_UP_S2_OCO3"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO3Sets5.Add( Base.AUDUSD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP6,"TP6_AUDUSD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP6_AUDUSD_UP_S2_OCO3"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO3Sets6.Add( Base.AUDUSD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDUSD_OCO3S1_UP_S2 = 0;
	                for (; AUDUSD_OCO3S1_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets1.Count; AUDUSD_OCO3S1_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO3Sets1[AUDUSD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO3Sets1[AUDUSD_OCO3S1_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO3Sets1.RemoveAt(AUDUSD_OCO3S1_UP_S2);
	                        AUDUSD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDUSD_OCO3S2_UP_S2 = 0;
	                for (; AUDUSD_OCO3S2_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets2.Count; AUDUSD_OCO3S2_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO3Sets2[AUDUSD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO3Sets2[AUDUSD_OCO3S2_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO3Sets2.RemoveAt(AUDUSD_OCO3S2_UP_S2);
	                        AUDUSD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO3S3_UP_S2 = 0;
	                for (; AUDUSD_OCO3S3_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets3.Count; AUDUSD_OCO3S3_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO3Sets3[AUDUSD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO3Sets3[AUDUSD_OCO3S3_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO3Sets3.RemoveAt(AUDUSD_OCO3S3_UP_S2);
	                        AUDUSD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO3S4_UP_S2 = 0;
	                for (; AUDUSD_OCO3S4_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets4.Count; AUDUSD_OCO3S4_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO3Sets4[AUDUSD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO3Sets4[AUDUSD_OCO3S4_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO3Sets4.RemoveAt(AUDUSD_OCO3S4_UP_S2);
	                        AUDUSD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDUSD_OCO3S5_UP_S2 = 0;
	                for (; AUDUSD_OCO3S5_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets5.Count; AUDUSD_OCO3S5_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO3Sets5[AUDUSD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO3Sets5[AUDUSD_OCO3S5_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO3Sets5.RemoveAt(AUDUSD_OCO3S5_UP_S2);
	                        AUDUSD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDUSD_OCO3S6_UP_S2 = 0;
	                for (; AUDUSD_OCO3S6_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets6.Count; AUDUSD_OCO3S6_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO3Sets6[AUDUSD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO3Sets6[AUDUSD_OCO3S6_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO3Sets6.RemoveAt(AUDUSD_OCO3S6_UP_S2);
	                        AUDUSD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDUSD_OCO4_EO1_UP_S2)
	                Base.AUDUSD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDUSD_OCO4_EO2_UP_S2)
	                Base.AUDUSD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO4_EO3_UP_S2)
	                Base.AUDUSD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO4_EO4_UP_S2)
	                Base.AUDUSD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO4_EO5_UP_S2)
	                Base.AUDUSD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO4_EO6_UP_S2)
	                Base.AUDUSD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.AUDUSD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP1,"TP1_AUDUSD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP1_AUDUSD_UP_S2_OCO4"));
		                 };
		                Base.AUDUSD_UP_S2_OCO4Sets1.Add( Base.AUDUSD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP2,"TP2_AUDUSD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP2_AUDUSD_UP_S2_OCO4"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO4Sets2.Add( Base.AUDUSD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP3,"TP3_AUDUSD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP3_AUDUSD_UP_S2_OCO4"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO4Sets3.Add( Base.AUDUSD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP4,"TP4_AUDUSD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP4_AUDUSD_UP_S2_OCO4"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO4Sets4.Add( Base.AUDUSD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP5,"TP5_AUDUSD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP5_AUDUSD_UP_S2_OCO4"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO4Sets5.Add( Base.AUDUSD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_UP_S2_TP6,"TP6_AUDUSD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_UP_S2_SL,"SL_TP6_AUDUSD_UP_S2_OCO4"));
		                 };
	                    Base.AUDUSD_UP_S2_OCO4Sets6.Add( Base.AUDUSD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDUSD_OCO4S1_UP_S2 = 0;
	                for (; AUDUSD_OCO4S1_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets1.Count; AUDUSD_OCO4S1_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO4Sets1[AUDUSD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO4Sets1[AUDUSD_OCO4S1_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO4Sets1.RemoveAt(AUDUSD_OCO4S1_UP_S2);
	                        AUDUSD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDUSD_OCO4S2_UP_S2 = 0;
	                for (; AUDUSD_OCO4S2_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets2.Count; AUDUSD_OCO4S2_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO4Sets2[AUDUSD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO4Sets2[AUDUSD_OCO4S2_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO4Sets2.RemoveAt(AUDUSD_OCO4S2_UP_S2);
	                        AUDUSD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO4S3_UP_S2 = 0;
	                for (; AUDUSD_OCO4S3_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets3.Count; AUDUSD_OCO4S3_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO4Sets3[AUDUSD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO4Sets3[AUDUSD_OCO4S3_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO4Sets3.RemoveAt(AUDUSD_OCO4S3_UP_S2);
	                        AUDUSD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO4S4_UP_S2 = 0;
	                for (; AUDUSD_OCO4S4_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets4.Count; AUDUSD_OCO4S4_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO4Sets4[AUDUSD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO4Sets4[AUDUSD_OCO4S4_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO4Sets4.RemoveAt(AUDUSD_OCO4S4_UP_S2);
	                        AUDUSD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDUSD_OCO4S5_UP_S2 = 0;
	                for (; AUDUSD_OCO4S5_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets5.Count; AUDUSD_OCO4S5_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO4Sets5[AUDUSD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO4Sets5[AUDUSD_OCO4S5_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO4Sets5.RemoveAt(AUDUSD_OCO4S5_UP_S2);
	                        AUDUSD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDUSD_OCO4S6_UP_S2 = 0;
	                for (; AUDUSD_OCO4S6_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets6.Count; AUDUSD_OCO4S6_UP_S2++)
	                    if (Base.AUDUSD_UP_S2_OCO4Sets6[AUDUSD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_UP_S2_OCO4Sets6[AUDUSD_OCO4S6_UP_S2].Filled();
	                        Base.AUDUSD_UP_S2_OCO4Sets6.RemoveAt(AUDUSD_OCO4S6_UP_S2);
	                        AUDUSD_OCO4S6_UP_S2 = 0;
	                        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.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 AUDUSD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDUSD_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("AUDUSD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDUSD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDUSD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDUSD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDUSD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDUSD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDUSD S2");
		        	}
		        }
		        
				if (Base.AUDUSD_OCO1_EO1_DOWN_S2)
	                Base.AUDUSD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDUSD_OCO1_EO2_DOWN_S2)
	                Base.AUDUSD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO1_EO3_DOWN_S2)
	                Base.AUDUSD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO1_EO4_DOWN_S2)
	                Base.AUDUSD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDUSD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP1_AUDUSD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP1,"TP1_AUDUSD_DOWN_S2_OCO1"));
		                 };
		                Base.AUDUSD_DOWN_S2_OCO1Sets1.Add( Base.AUDUSD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP2_AUDUSD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP2,"TP2_AUDUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO1Sets2.Add( Base.AUDUSD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP3_AUDUSD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP3,"TP3_AUDUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO1Sets3.Add( Base.AUDUSD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP4_AUDUSD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP4,"TP4_AUDUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO1Sets4.Add( Base.AUDUSD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDUSD_OCO1S1_DOWN_S2 = 0;
	                for (; AUDUSD_OCO1S1_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets1.Count; AUDUSD_OCO1S1_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO1Sets1[AUDUSD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO1Sets1[AUDUSD_OCO1S1_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO1Sets1.RemoveAt(AUDUSD_OCO1S1_DOWN_S2);
	                        AUDUSD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDUSD_OCO1S2_DOWN_S2 = 0;
	                for (; AUDUSD_OCO1S2_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets2.Count; AUDUSD_OCO1S2_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO1Sets2[AUDUSD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO1Sets2[AUDUSD_OCO1S2_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO1Sets2.RemoveAt(AUDUSD_OCO1S2_DOWN_S2);
	                        AUDUSD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO1S3_DOWN_S2 = 0;
	                for (; AUDUSD_OCO1S3_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets3.Count; AUDUSD_OCO1S3_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO1Sets3[AUDUSD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO1Sets3[AUDUSD_OCO1S3_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO1Sets3.RemoveAt(AUDUSD_OCO1S3_DOWN_S2);
	                        AUDUSD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO1S4_DOWN_S2 = 0;
	                for (; AUDUSD_OCO1S4_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets4.Count; AUDUSD_OCO1S4_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO1Sets4[AUDUSD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO1Sets4[AUDUSD_OCO1S4_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO1Sets4.RemoveAt(AUDUSD_OCO1S4_DOWN_S2);
	                        AUDUSD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDUSD_OCO2_EO1_DOWN_S2)
	                Base.AUDUSD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDUSD_OCO2_EO2_DOWN_S2)
	                Base.AUDUSD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO2_EO3_DOWN_S2)
	                Base.AUDUSD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO2_EO4_DOWN_S2)
	                Base.AUDUSD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDUSD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP1_AUDUSD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP1,"TP1_AUDUSD_DOWN_S2_OCO2"));
		                 };
		                Base.AUDUSD_DOWN_S2_OCO2Sets1.Add( Base.AUDUSD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP2_AUDUSD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP2,"TP2_AUDUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO2Sets2.Add( Base.AUDUSD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP3_AUDUSD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP3,"TP3_AUDUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO2Sets3.Add( Base.AUDUSD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP4_AUDUSD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP4,"TP4_AUDUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO2Sets4.Add( Base.AUDUSD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDUSD_OCO2S1_DOWN_S2 = 0;
	                for (; AUDUSD_OCO2S1_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets1.Count; AUDUSD_OCO2S1_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO2Sets1[AUDUSD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO2Sets1[AUDUSD_OCO2S1_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO2Sets1.RemoveAt(AUDUSD_OCO2S1_DOWN_S2);
	                        AUDUSD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDUSD_OCO2S2_DOWN_S2 = 0;
	                for (; AUDUSD_OCO2S2_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets2.Count; AUDUSD_OCO2S2_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO2Sets2[AUDUSD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO2Sets2[AUDUSD_OCO2S2_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO2Sets2.RemoveAt(AUDUSD_OCO2S2_DOWN_S2);
	                        AUDUSD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO2S3_DOWN_S2 = 0;
	                for (; AUDUSD_OCO2S3_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets3.Count; AUDUSD_OCO2S3_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO2Sets3[AUDUSD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO2Sets3[AUDUSD_OCO2S3_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO2Sets3.RemoveAt(AUDUSD_OCO2S3_DOWN_S2);
	                        AUDUSD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO2S4_DOWN_S2 = 0;
	                for (; AUDUSD_OCO2S4_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets4.Count; AUDUSD_OCO2S4_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO2Sets4[AUDUSD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO2Sets4[AUDUSD_OCO2S4_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO2Sets4.RemoveAt(AUDUSD_OCO2S4_DOWN_S2);
	                        AUDUSD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDUSD_OCO3_EO1_DOWN_S2)
	                Base.AUDUSD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDUSD_OCO3_EO2_DOWN_S2)
	                Base.AUDUSD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO3_EO3_DOWN_S2)
	                Base.AUDUSD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO3_EO4_DOWN_S2)
	                Base.AUDUSD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDUSD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP1_AUDUSD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP1,"TP1_AUDUSD_DOWN_S2_OCO3"));
		                 };
		                Base.AUDUSD_DOWN_S2_OCO3Sets1.Add( Base.AUDUSD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP2_AUDUSD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP2,"TP2_AUDUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO3Sets2.Add( Base.AUDUSD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP3_AUDUSD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP3,"TP3_AUDUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO3Sets3.Add( Base.AUDUSD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP4_AUDUSD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP4,"TP4_AUDUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO3Sets4.Add( Base.AUDUSD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDUSD_OCO3S1_DOWN_S2 = 0;
	                for (; AUDUSD_OCO3S1_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets1.Count; AUDUSD_OCO3S1_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO3Sets1[AUDUSD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO3Sets1[AUDUSD_OCO3S1_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO3Sets1.RemoveAt(AUDUSD_OCO3S1_DOWN_S2);
	                        AUDUSD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDUSD_OCO3S2_DOWN_S2 = 0;
	                for (; AUDUSD_OCO3S2_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets2.Count; AUDUSD_OCO3S2_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO3Sets2[AUDUSD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO3Sets2[AUDUSD_OCO3S2_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO3Sets2.RemoveAt(AUDUSD_OCO3S2_DOWN_S2);
	                        AUDUSD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO3S3_DOWN_S2 = 0;
	                for (; AUDUSD_OCO3S3_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets3.Count; AUDUSD_OCO3S3_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO3Sets3[AUDUSD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO3Sets3[AUDUSD_OCO3S3_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO3Sets3.RemoveAt(AUDUSD_OCO3S3_DOWN_S2);
	                        AUDUSD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO3S4_DOWN_S2 = 0;
	                for (; AUDUSD_OCO3S4_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets4.Count; AUDUSD_OCO3S4_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO3Sets4[AUDUSD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO3Sets4[AUDUSD_OCO3S4_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO3Sets4.RemoveAt(AUDUSD_OCO3S4_DOWN_S2);
	                        AUDUSD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDUSD_OCO4_EO1_DOWN_S2)
	                Base.AUDUSD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDUSD_OCO4_EO2_DOWN_S2)
	                Base.AUDUSD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO4_EO3_DOWN_S2)
	                Base.AUDUSD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDUSD_OCO4_EO4_DOWN_S2)
	                Base.AUDUSD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDUSD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP1_AUDUSD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP1,"TP1_AUDUSD_DOWN_S2_OCO4"));
		                 };
		                Base.AUDUSD_DOWN_S2_OCO4Sets1.Add( Base.AUDUSD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP2_AUDUSD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP2,"TP2_AUDUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO4Sets2.Add( Base.AUDUSD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP3_AUDUSD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP3,"TP3_AUDUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO4Sets3.Add( Base.AUDUSD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDUSD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDUSD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDUSD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDUSD_DOWN_S2_SL,"SL_TP4_AUDUSD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDUSD_DOWN_S2_TP4,"TP4_AUDUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDUSD_DOWN_S2_OCO4Sets4.Add( Base.AUDUSD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDUSD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDUSD_OCO4S1_DOWN_S2 = 0;
	                for (; AUDUSD_OCO4S1_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets1.Count; AUDUSD_OCO4S1_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO4Sets1[AUDUSD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO4Sets1[AUDUSD_OCO4S1_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO4Sets1.RemoveAt(AUDUSD_OCO4S1_DOWN_S2);
	                        AUDUSD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDUSD_OCO4S2_DOWN_S2 = 0;
	                for (; AUDUSD_OCO4S2_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets2.Count; AUDUSD_OCO4S2_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO4Sets2[AUDUSD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO4Sets2[AUDUSD_OCO4S2_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO4Sets2.RemoveAt(AUDUSD_OCO4S2_DOWN_S2);
	                        AUDUSD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO4S3_DOWN_S2 = 0;
	                for (; AUDUSD_OCO4S3_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets3.Count; AUDUSD_OCO4S3_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO4Sets3[AUDUSD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO4Sets3[AUDUSD_OCO4S3_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO4Sets3.RemoveAt(AUDUSD_OCO4S3_DOWN_S2);
	                        AUDUSD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDUSD_OCO4S4_DOWN_S2 = 0;
	                for (; AUDUSD_OCO4S4_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets4.Count; AUDUSD_OCO4S4_DOWN_S2++)
	                    if (Base.AUDUSD_DOWN_S2_OCO4Sets4[AUDUSD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDUSD_DOWN_S2_OCO4Sets4[AUDUSD_OCO4S4_DOWN_S2].Filled();
	                        Base.AUDUSD_DOWN_S2_OCO4Sets4.RemoveAt(AUDUSD_OCO4S4_DOWN_S2);
	                        AUDUSD_OCO4S4_DOWN_S2 = 0;
	                        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 _NZDCAD;
		
    	///oco1 up
    	public static OrderTicket NZDCAD_OCO1_MO1_UP_S2;
    	public static OrderTicket NZDCAD_OCO1_MO2_UP_S2;
    	public static OrderTicket NZDCAD_OCO1_MO3_UP_S2;
    	public static OrderTicket NZDCAD_OCO1_MO4_UP_S2;
    	public static OrderTicket NZDCAD_OCO1_MO5_UP_S2;
    	public static OrderTicket NZDCAD_OCO1_MO6_UP_S2;
    	
    	public static int NZDCAD_OCO1_EO1_UP_S2_ID ;
        public static int NZDCAD_OCO1_EO2_UP_S2_ID ;
        public static int NZDCAD_OCO1_EO3_UP_S2_ID ;
        public static int NZDCAD_OCO1_EO4_UP_S2_ID ;
        public static int NZDCAD_OCO1_EO5_UP_S2_ID ;
        public static int NZDCAD_OCO1_EO6_UP_S2_ID ;
        
        public static bool NZDCAD_OCO1_EO1_UP_S2 ;
        public static bool NZDCAD_OCO1_EO2_UP_S2 ;
        public static bool NZDCAD_OCO1_EO3_UP_S2 ;
        public static bool NZDCAD_OCO1_EO4_UP_S2 ;
        public static bool NZDCAD_OCO1_EO5_UP_S2 ;
        public static bool NZDCAD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_UP_S2> NZDCAD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_UP_S2> NZDCAD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_UP_S2> NZDCAD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_UP_S2> NZDCAD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_UP_S2> NZDCAD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_UP_S2> NZDCAD_OOFE_OCO1_UP_S2_6 ;
        
        public static NZDCAD_OCO1_UP_S2 NZDCAD_PFO_OCO1_UP_S2_1 ;
        public static NZDCAD_OCO1_UP_S2 NZDCAD_PFO_OCO1_UP_S2_2 ;
        public static NZDCAD_OCO1_UP_S2 NZDCAD_PFO_OCO1_UP_S2_3 ;
        public static NZDCAD_OCO1_UP_S2 NZDCAD_PFO_OCO1_UP_S2_4 ;
        public static NZDCAD_OCO1_UP_S2 NZDCAD_PFO_OCO1_UP_S2_5 ;
        public static NZDCAD_OCO1_UP_S2 NZDCAD_PFO_OCO1_UP_S2_6 ;
        
        public static List<NZDCAD_OCO1_UP_S2> NZDCAD_UP_S2_OCO1Sets1 = new List<NZDCAD_OCO1_UP_S2>();
        public static List<NZDCAD_OCO1_UP_S2> NZDCAD_UP_S2_OCO1Sets2 = new List<NZDCAD_OCO1_UP_S2>();
        public static List<NZDCAD_OCO1_UP_S2> NZDCAD_UP_S2_OCO1Sets3 = new List<NZDCAD_OCO1_UP_S2>();
        public static List<NZDCAD_OCO1_UP_S2> NZDCAD_UP_S2_OCO1Sets4 = new List<NZDCAD_OCO1_UP_S2>();
        public static List<NZDCAD_OCO1_UP_S2> NZDCAD_UP_S2_OCO1Sets5 = new List<NZDCAD_OCO1_UP_S2>();
        public static List<NZDCAD_OCO1_UP_S2> NZDCAD_UP_S2_OCO1Sets6 = new List<NZDCAD_OCO1_UP_S2>();
        
        public static bool NZDCAD_OCO1_UP_S2_IsReady = true;
        public static bool NZDCAD_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket NZDCAD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int NZDCAD_OCO1_EO1_DOWN_S2_ID ;
        public static int NZDCAD_OCO1_EO2_DOWN_S2_ID ;
        public static int NZDCAD_OCO1_EO3_DOWN_S2_ID ;
        public static int NZDCAD_OCO1_EO4_DOWN_S2_ID ;
        public static int NZDCAD_OCO1_EO5_DOWN_S2_ID ;
        public static int NZDCAD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool NZDCAD_OCO1_EO1_DOWN_S2 ;
        public static bool NZDCAD_OCO1_EO2_DOWN_S2 ;
        public static bool NZDCAD_OCO1_EO3_DOWN_S2 ;
        public static bool NZDCAD_OCO1_EO4_DOWN_S2 ;
        public static bool NZDCAD_OCO1_EO5_DOWN_S2 ;
        public static bool NZDCAD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_DOWN_S2> NZDCAD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_DOWN_S2> NZDCAD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_DOWN_S2> NZDCAD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_DOWN_S2> NZDCAD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_DOWN_S2> NZDCAD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO1_DOWN_S2> NZDCAD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static NZDCAD_OCO1_DOWN_S2 NZDCAD_PFO_OCO1_DOWN_S2_1 ;
        public static NZDCAD_OCO1_DOWN_S2 NZDCAD_PFO_OCO1_DOWN_S2_2 ;
        public static NZDCAD_OCO1_DOWN_S2 NZDCAD_PFO_OCO1_DOWN_S2_3 ;
        public static NZDCAD_OCO1_DOWN_S2 NZDCAD_PFO_OCO1_DOWN_S2_4 ;
        public static NZDCAD_OCO1_DOWN_S2 NZDCAD_PFO_OCO1_DOWN_S2_5 ;
        public static NZDCAD_OCO1_DOWN_S2 NZDCAD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<NZDCAD_OCO1_DOWN_S2> NZDCAD_DOWN_S2_OCO1Sets1 = new List<NZDCAD_OCO1_DOWN_S2>();
        public static List<NZDCAD_OCO1_DOWN_S2> NZDCAD_DOWN_S2_OCO1Sets2 = new List<NZDCAD_OCO1_DOWN_S2>();
        public static List<NZDCAD_OCO1_DOWN_S2> NZDCAD_DOWN_S2_OCO1Sets3 = new List<NZDCAD_OCO1_DOWN_S2>();
        public static List<NZDCAD_OCO1_DOWN_S2> NZDCAD_DOWN_S2_OCO1Sets4 = new List<NZDCAD_OCO1_DOWN_S2>();
        public static List<NZDCAD_OCO1_DOWN_S2> NZDCAD_DOWN_S2_OCO1Sets5 = new List<NZDCAD_OCO1_DOWN_S2>();
        public static List<NZDCAD_OCO1_DOWN_S2> NZDCAD_DOWN_S2_OCO1Sets6 = new List<NZDCAD_OCO1_DOWN_S2>();
        
        public static bool NZDCAD_OCO1_DOWN_S2_IsReady = true;
        public static bool NZDCAD_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket NZDCAD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO6_UP_S2 ;
    	
    	public static int NZDCAD_OCO2_EO1_UP_S2_ID ;
        public static int NZDCAD_OCO2_EO2_UP_S2_ID ;
        public static int NZDCAD_OCO2_EO3_UP_S2_ID ;
        public static int NZDCAD_OCO2_EO4_UP_S2_ID ;
        public static int NZDCAD_OCO2_EO5_UP_S2_ID ;
        public static int NZDCAD_OCO2_EO6_UP_S2_ID ;
        
        public static bool NZDCAD_OCO2_EO1_UP_S2 ;
        public static bool NZDCAD_OCO2_EO2_UP_S2 ;
        public static bool NZDCAD_OCO2_EO3_UP_S2 ;
        public static bool NZDCAD_OCO2_EO4_UP_S2 ;
        public static bool NZDCAD_OCO2_EO5_UP_S2 ;
        public static bool NZDCAD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_UP_S2> NZDCAD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_UP_S2> NZDCAD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_UP_S2> NZDCAD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_UP_S2> NZDCAD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_UP_S2> NZDCAD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_UP_S2> NZDCAD_OOFE_OCO2_UP_S2_6 ;
        
        public static NZDCAD_OCO2_UP_S2 NZDCAD_PFO_OCO2_UP_S2_1 ;
        public static NZDCAD_OCO2_UP_S2 NZDCAD_PFO_OCO2_UP_S2_2 ;
        public static NZDCAD_OCO2_UP_S2 NZDCAD_PFO_OCO2_UP_S2_3 ;
        public static NZDCAD_OCO2_UP_S2 NZDCAD_PFO_OCO2_UP_S2_4 ;
        public static NZDCAD_OCO2_UP_S2 NZDCAD_PFO_OCO2_UP_S2_5 ;
        public static NZDCAD_OCO2_UP_S2 NZDCAD_PFO_OCO2_UP_S2_6 ;
        
        public static List<NZDCAD_OCO2_UP_S2> NZDCAD_UP_S2_OCO2Sets1 = new List<NZDCAD_OCO2_UP_S2>();
        public static List<NZDCAD_OCO2_UP_S2> NZDCAD_UP_S2_OCO2Sets2 = new List<NZDCAD_OCO2_UP_S2>();
        public static List<NZDCAD_OCO2_UP_S2> NZDCAD_UP_S2_OCO2Sets3 = new List<NZDCAD_OCO2_UP_S2>();
        public static List<NZDCAD_OCO2_UP_S2> NZDCAD_UP_S2_OCO2Sets4 = new List<NZDCAD_OCO2_UP_S2>();
        public static List<NZDCAD_OCO2_UP_S2> NZDCAD_UP_S2_OCO2Sets5 = new List<NZDCAD_OCO2_UP_S2>();
        public static List<NZDCAD_OCO2_UP_S2> NZDCAD_UP_S2_OCO2Sets6 = new List<NZDCAD_OCO2_UP_S2>();
        
        public static bool NZDCAD_OCO2_UP_S2_IsReady = true;
        public static bool NZDCAD_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket NZDCAD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int NZDCAD_OCO2_EO1_DOWN_S2_ID ;
        public static int NZDCAD_OCO2_EO2_DOWN_S2_ID ;
        public static int NZDCAD_OCO2_EO3_DOWN_S2_ID ;
        public static int NZDCAD_OCO2_EO4_DOWN_S2_ID ;
        public static int NZDCAD_OCO2_EO5_DOWN_S2_ID ;
        public static int NZDCAD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool NZDCAD_OCO2_EO1_DOWN_S2 ;
        public static bool NZDCAD_OCO2_EO2_DOWN_S2 ;
        public static bool NZDCAD_OCO2_EO3_DOWN_S2 ;
        public static bool NZDCAD_OCO2_EO4_DOWN_S2 ;
        public static bool NZDCAD_OCO2_EO5_DOWN_S2 ;
        public static bool NZDCAD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_DOWN_S2> NZDCAD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_DOWN_S2> NZDCAD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_DOWN_S2> NZDCAD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_DOWN_S2> NZDCAD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_DOWN_S2> NZDCAD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO2_DOWN_S2> NZDCAD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static NZDCAD_OCO2_DOWN_S2 NZDCAD_PFO_OCO2_DOWN_S2_1 ;
        public static NZDCAD_OCO2_DOWN_S2 NZDCAD_PFO_OCO2_DOWN_S2_2 ;
        public static NZDCAD_OCO2_DOWN_S2 NZDCAD_PFO_OCO2_DOWN_S2_3 ;
        public static NZDCAD_OCO2_DOWN_S2 NZDCAD_PFO_OCO2_DOWN_S2_4 ;
        public static NZDCAD_OCO2_DOWN_S2 NZDCAD_PFO_OCO2_DOWN_S2_5 ;
        public static NZDCAD_OCO2_DOWN_S2 NZDCAD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<NZDCAD_OCO2_DOWN_S2> NZDCAD_DOWN_S2_OCO2Sets1 = new List<NZDCAD_OCO2_DOWN_S2>();
        public static List<NZDCAD_OCO2_DOWN_S2> NZDCAD_DOWN_S2_OCO2Sets2 = new List<NZDCAD_OCO2_DOWN_S2>();
        public static List<NZDCAD_OCO2_DOWN_S2> NZDCAD_DOWN_S2_OCO2Sets3 = new List<NZDCAD_OCO2_DOWN_S2>();
        public static List<NZDCAD_OCO2_DOWN_S2> NZDCAD_DOWN_S2_OCO2Sets4 = new List<NZDCAD_OCO2_DOWN_S2>();
        public static List<NZDCAD_OCO2_DOWN_S2> NZDCAD_DOWN_S2_OCO2Sets5 = new List<NZDCAD_OCO2_DOWN_S2>();
        public static List<NZDCAD_OCO2_DOWN_S2> NZDCAD_DOWN_S2_OCO2Sets6 = new List<NZDCAD_OCO2_DOWN_S2>();
        
        public static bool NZDCAD_OCO2_DOWN_S2_IsReady = true;
        public static bool NZDCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket NZDCAD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO6_UP_S2 ;
    	
    	public static int NZDCAD_OCO3_EO1_UP_S2_ID ;
        public static int NZDCAD_OCO3_EO2_UP_S2_ID ;
        public static int NZDCAD_OCO3_EO3_UP_S2_ID ;
        public static int NZDCAD_OCO3_EO4_UP_S2_ID ;
        public static int NZDCAD_OCO3_EO5_UP_S2_ID ;
        public static int NZDCAD_OCO3_EO6_UP_S2_ID ;
        
        public static bool NZDCAD_OCO3_EO1_UP_S2 ;
        public static bool NZDCAD_OCO3_EO2_UP_S2 ;
        public static bool NZDCAD_OCO3_EO3_UP_S2 ;
        public static bool NZDCAD_OCO3_EO4_UP_S2 ;
        public static bool NZDCAD_OCO3_EO5_UP_S2 ;
        public static bool NZDCAD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_UP_S2> NZDCAD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_UP_S2> NZDCAD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_UP_S2> NZDCAD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_UP_S2> NZDCAD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_UP_S2> NZDCAD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_UP_S2> NZDCAD_OOFE_OCO3_UP_S2_6 ;
        
        public static NZDCAD_OCO3_UP_S2 NZDCAD_PFO_OCO3_UP_S2_1 ;
        public static NZDCAD_OCO3_UP_S2 NZDCAD_PFO_OCO3_UP_S2_2 ;
        public static NZDCAD_OCO3_UP_S2 NZDCAD_PFO_OCO3_UP_S2_3 ;
        public static NZDCAD_OCO3_UP_S2 NZDCAD_PFO_OCO3_UP_S2_4 ;
        public static NZDCAD_OCO3_UP_S2 NZDCAD_PFO_OCO3_UP_S2_5 ;
        public static NZDCAD_OCO3_UP_S2 NZDCAD_PFO_OCO3_UP_S2_6 ;
        
        public static List<NZDCAD_OCO3_UP_S2> NZDCAD_UP_S2_OCO3Sets1 = new List<NZDCAD_OCO3_UP_S2>();
        public static List<NZDCAD_OCO3_UP_S2> NZDCAD_UP_S2_OCO3Sets2 = new List<NZDCAD_OCO3_UP_S2>();
        public static List<NZDCAD_OCO3_UP_S2> NZDCAD_UP_S2_OCO3Sets3 = new List<NZDCAD_OCO3_UP_S2>();
        public static List<NZDCAD_OCO3_UP_S2> NZDCAD_UP_S2_OCO3Sets4 = new List<NZDCAD_OCO3_UP_S2>();
        public static List<NZDCAD_OCO3_UP_S2> NZDCAD_UP_S2_OCO3Sets5 = new List<NZDCAD_OCO3_UP_S2>();
        public static List<NZDCAD_OCO3_UP_S2> NZDCAD_UP_S2_OCO3Sets6 = new List<NZDCAD_OCO3_UP_S2>();
        
        public static bool NZDCAD_OCO3_UP_S2_IsReady = true;
        public static bool NZDCAD_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket NZDCAD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int NZDCAD_OCO3_EO1_DOWN_S2_ID ;
        public static int NZDCAD_OCO3_EO2_DOWN_S2_ID ;
        public static int NZDCAD_OCO3_EO3_DOWN_S2_ID ;
        public static int NZDCAD_OCO3_EO4_DOWN_S2_ID ;
        public static int NZDCAD_OCO3_EO5_DOWN_S2_ID ;
        public static int NZDCAD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool NZDCAD_OCO3_EO1_DOWN_S2 ;
        public static bool NZDCAD_OCO3_EO2_DOWN_S2 ;
        public static bool NZDCAD_OCO3_EO3_DOWN_S2 ;
        public static bool NZDCAD_OCO3_EO4_DOWN_S2 ;
        public static bool NZDCAD_OCO3_EO5_DOWN_S2 ;
        public static bool NZDCAD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_DOWN_S2> NZDCAD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_DOWN_S2> NZDCAD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_DOWN_S2> NZDCAD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_DOWN_S2> NZDCAD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_DOWN_S2> NZDCAD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO3_DOWN_S2> NZDCAD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static NZDCAD_OCO3_DOWN_S2 NZDCAD_PFO_OCO3_DOWN_S2_1 ;
        public static NZDCAD_OCO3_DOWN_S2 NZDCAD_PFO_OCO3_DOWN_S2_2 ;
        public static NZDCAD_OCO3_DOWN_S2 NZDCAD_PFO_OCO3_DOWN_S2_3 ;
        public static NZDCAD_OCO3_DOWN_S2 NZDCAD_PFO_OCO3_DOWN_S2_4 ;
        public static NZDCAD_OCO3_DOWN_S2 NZDCAD_PFO_OCO3_DOWN_S2_5 ;
        public static NZDCAD_OCO3_DOWN_S2 NZDCAD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<NZDCAD_OCO3_DOWN_S2> NZDCAD_DOWN_S2_OCO3Sets1 = new List<NZDCAD_OCO3_DOWN_S2>();
        public static List<NZDCAD_OCO3_DOWN_S2> NZDCAD_DOWN_S2_OCO3Sets2 = new List<NZDCAD_OCO3_DOWN_S2>();
        public static List<NZDCAD_OCO3_DOWN_S2> NZDCAD_DOWN_S2_OCO3Sets3 = new List<NZDCAD_OCO3_DOWN_S2>();
        public static List<NZDCAD_OCO3_DOWN_S2> NZDCAD_DOWN_S2_OCO3Sets4 = new List<NZDCAD_OCO3_DOWN_S2>();
        public static List<NZDCAD_OCO3_DOWN_S2> NZDCAD_DOWN_S2_OCO3Sets5 = new List<NZDCAD_OCO3_DOWN_S2>();
        public static List<NZDCAD_OCO3_DOWN_S2> NZDCAD_DOWN_S2_OCO3Sets6 = new List<NZDCAD_OCO3_DOWN_S2>();
        
        public static bool NZDCAD_OCO3_DOWN_S2_IsReady = true;
        public static bool NZDCAD_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket NZDCAD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO6_UP_S2 ;
    	
    	public static int NZDCAD_OCO4_EO1_UP_S2_ID ;
        public static int NZDCAD_OCO4_EO2_UP_S2_ID ;
        public static int NZDCAD_OCO4_EO3_UP_S2_ID ;
        public static int NZDCAD_OCO4_EO4_UP_S2_ID ;
        public static int NZDCAD_OCO4_EO5_UP_S2_ID ;
        public static int NZDCAD_OCO4_EO6_UP_S2_ID ;
        
        public static bool NZDCAD_OCO4_EO1_UP_S2 ;
        public static bool NZDCAD_OCO4_EO2_UP_S2 ;
        public static bool NZDCAD_OCO4_EO3_UP_S2 ;
        public static bool NZDCAD_OCO4_EO4_UP_S2 ;
        public static bool NZDCAD_OCO4_EO5_UP_S2 ;
        public static bool NZDCAD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_UP_S2> NZDCAD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_UP_S2> NZDCAD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_UP_S2> NZDCAD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_UP_S2> NZDCAD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_UP_S2> NZDCAD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_UP_S2> NZDCAD_OOFE_OCO4_UP_S2_6 ;
        
        public static NZDCAD_OCO4_UP_S2 NZDCAD_PFO_OCO4_UP_S2_1 ;
        public static NZDCAD_OCO4_UP_S2 NZDCAD_PFO_OCO4_UP_S2_2 ;
        public static NZDCAD_OCO4_UP_S2 NZDCAD_PFO_OCO4_UP_S2_3 ;
        public static NZDCAD_OCO4_UP_S2 NZDCAD_PFO_OCO4_UP_S2_4 ;
        public static NZDCAD_OCO4_UP_S2 NZDCAD_PFO_OCO4_UP_S2_5 ;
        public static NZDCAD_OCO4_UP_S2 NZDCAD_PFO_OCO4_UP_S2_6 ;
        
        public static List<NZDCAD_OCO4_UP_S2> NZDCAD_UP_S2_OCO4Sets1 = new List<NZDCAD_OCO4_UP_S2>();
        public static List<NZDCAD_OCO4_UP_S2> NZDCAD_UP_S2_OCO4Sets2 = new List<NZDCAD_OCO4_UP_S2>();
        public static List<NZDCAD_OCO4_UP_S2> NZDCAD_UP_S2_OCO4Sets3 = new List<NZDCAD_OCO4_UP_S2>();
        public static List<NZDCAD_OCO4_UP_S2> NZDCAD_UP_S2_OCO4Sets4 = new List<NZDCAD_OCO4_UP_S2>();
        public static List<NZDCAD_OCO4_UP_S2> NZDCAD_UP_S2_OCO4Sets5 = new List<NZDCAD_OCO4_UP_S2>();
        public static List<NZDCAD_OCO4_UP_S2> NZDCAD_UP_S2_OCO4Sets6 = new List<NZDCAD_OCO4_UP_S2>();
        
        public static bool NZDCAD_OCO4_UP_S2_IsReady = true;
        public static bool NZDCAD_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket NZDCAD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket NZDCAD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int NZDCAD_OCO4_EO1_DOWN_S2_ID ;
        public static int NZDCAD_OCO4_EO2_DOWN_S2_ID ;
        public static int NZDCAD_OCO4_EO3_DOWN_S2_ID ;
        public static int NZDCAD_OCO4_EO4_DOWN_S2_ID ;
        public static int NZDCAD_OCO4_EO5_DOWN_S2_ID ;
        public static int NZDCAD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool NZDCAD_OCO4_EO1_DOWN_S2 ;
        public static bool NZDCAD_OCO4_EO2_DOWN_S2 ;
        public static bool NZDCAD_OCO4_EO3_DOWN_S2 ;
        public static bool NZDCAD_OCO4_EO4_DOWN_S2 ;
        public static bool NZDCAD_OCO4_EO5_DOWN_S2 ;
        public static bool NZDCAD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_DOWN_S2> NZDCAD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_DOWN_S2> NZDCAD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_DOWN_S2> NZDCAD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_DOWN_S2> NZDCAD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_DOWN_S2> NZDCAD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, NZDCAD_OCO4_DOWN_S2> NZDCAD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static NZDCAD_OCO4_DOWN_S2 NZDCAD_PFO_OCO4_DOWN_S2_1 ;
        public static NZDCAD_OCO4_DOWN_S2 NZDCAD_PFO_OCO4_DOWN_S2_2 ;
        public static NZDCAD_OCO4_DOWN_S2 NZDCAD_PFO_OCO4_DOWN_S2_3 ;
        public static NZDCAD_OCO4_DOWN_S2 NZDCAD_PFO_OCO4_DOWN_S2_4 ;
        public static NZDCAD_OCO4_DOWN_S2 NZDCAD_PFO_OCO4_DOWN_S2_5 ;
        public static NZDCAD_OCO4_DOWN_S2 NZDCAD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<NZDCAD_OCO4_DOWN_S2> NZDCAD_DOWN_S2_OCO4Sets1 = new List<NZDCAD_OCO4_DOWN_S2>();
        public static List<NZDCAD_OCO4_DOWN_S2> NZDCAD_DOWN_S2_OCO4Sets2 = new List<NZDCAD_OCO4_DOWN_S2>();
        public static List<NZDCAD_OCO4_DOWN_S2> NZDCAD_DOWN_S2_OCO4Sets3 = new List<NZDCAD_OCO4_DOWN_S2>();
        public static List<NZDCAD_OCO4_DOWN_S2> NZDCAD_DOWN_S2_OCO4Sets4 = new List<NZDCAD_OCO4_DOWN_S2>();
        public static List<NZDCAD_OCO4_DOWN_S2> NZDCAD_DOWN_S2_OCO4Sets5 = new List<NZDCAD_OCO4_DOWN_S2>();
        public static List<NZDCAD_OCO4_DOWN_S2> NZDCAD_DOWN_S2_OCO4Sets6 = new List<NZDCAD_OCO4_DOWN_S2>();
        
        public static bool NZDCAD_OCO4_DOWN_S2_IsReady = true;
        public static bool NZDCAD_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal NZDCAD_UP_S2_SL {get; set;}
		public static decimal NZDCAD_UP_S2_TP1 {get; set;}
		public static decimal NZDCAD_UP_S2_TP2 {get; set;}
		public static decimal NZDCAD_UP_S2_TP3 {get; set;}
		public static decimal NZDCAD_UP_S2_TP4 {get; set;}
		public static decimal NZDCAD_UP_S2_TP5 {get; set;}
		public static decimal NZDCAD_UP_S2_TP6 {get; set;}
		
		public static decimal NZDCAD_DOWN_S2_SL {get; set;}
		public static decimal NZDCAD_DOWN_S2_TP1 {get; set;}
		public static decimal NZDCAD_DOWN_S2_TP2 {get; set;}
		public static decimal NZDCAD_DOWN_S2_TP3 {get; set;}
		public static decimal NZDCAD_DOWN_S2_TP4 {get; set;}
		public static decimal NZDCAD_DOWN_S2_TP5 {get; set;}
		public static decimal NZDCAD_DOWN_S2_TP6 {get; set;}

        public static bool NZDCAD_Signal_Condition_UP_1 ;
        public static bool NZDCAD_Signal_Condition_UP_2 ;
        public static bool NZDCAD_Signal_Condition_UP_3 ;
        public static bool NZDCAD_Signal_Condition_DOWN_S2 ;
        
        public static int NZDCAD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int NZDCAD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int NZDCAD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int NZDCAD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int NZDCAD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int NZDCAD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int NZDCAD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int NZDCAD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int NZDCAD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int NZDCAD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_NZDCAD_UP_S2 ;
        public static bool DOWM_NZDCAD_UP_S2 ;
        public static bool DOWT_NZDCAD_UP_S2 ;
        public static bool DOWW_NZDCAD_UP_S2 ;
        public static bool DOWTH_NZDCAD_UP_S2 ;
        
		public static bool DOWR_NZDCAD_DOWN_S2 ;
        public static bool DOWM_NZDCAD_DOWN_S2 ;
        public static bool DOWT_NZDCAD_DOWN_S2 ;
        public static bool DOWW_NZDCAD_DOWN_S2 ;
        public static bool DOWTH_NZDCAD_DOWN_S2 ;
        
        
		public static int NZDCAD_quantity_UP_S2 ;
		public static int NZDCAD_quantity_SL_UP_S2 ;
		public static int NZDCAD_quantity_TP1_UP_S2 ;
		public static int NZDCAD_quantity_TP2_UP_S2 ;
		public static int NZDCAD_quantity_TP3_UP_S2 ;
		public static int NZDCAD_quantity_TP4_UP_S2 ;
		public static int NZDCAD_quantity_TP5_UP_S2;
		public static int NZDCAD_quantity_TP6_UP_S2 ;
		
		public static int NZDCAD_quantity_DOWN_S2 ;
		public static int NZDCAD_quantity_SL_DOWN_S2 ;
		public static int NZDCAD_quantity_TP1_DOWN_S2 ;
		public static int NZDCAD_quantity_TP2_DOWN_S2 ;
		public static int NZDCAD_quantity_TP3_DOWN_S2 ;
		public static int NZDCAD_quantity_TP4_DOWN_S2 ;
		public static int NZDCAD_quantity_TP5_DOWN_S2;
		public static int NZDCAD_quantity_TP6_DOWN_S2 ;
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_NZDUSD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_NZDUSD_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("NZDUSD_DOWN_S2_OCO1")))
			{
				Base.NZDUSD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDUSD_DOWN_S2_OCO2")))
			{
				Base.NZDUSD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDUSD_DOWN_S2_OCO3")))
			{
				Base.NZDUSD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDUSD_DOWN_S2_OCO4")))
			{
				Base.NZDUSD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("NZDUSD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.NZDUSD_OCO1_EO1_DOWN_S2)
	                Base.NZDUSD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDUSD_OCO1_EO2_DOWN_S2)
	                Base.NZDUSD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO1_EO3_DOWN_S2)
	                Base.NZDUSD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO1_EO4_DOWN_S2)
	                Base.NZDUSD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO1_EO5_DOWN_S2)
	                Base.NZDUSD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO1_EO6_DOWN_S2)
	                Base.NZDUSD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDUSD_OCO1S1_DOWN_S2 = 0;
		                for (; NZDUSD_OCO1S1_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets1.Count; NZDUSD_OCO1S1_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO1Sets1[NZDUSD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO1Sets1[NZDUSD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.NZDUSD_DOWN_S2_OCO1Sets1.Clear();
		                        NZDUSD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDUSD_OCO1S2_DOWN_S2 = 0;
		                for (; NZDUSD_OCO1S2_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets2.Count; NZDUSD_OCO1S2_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO1Sets2[NZDUSD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO1Sets2[NZDUSD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.NZDUSD_DOWN_S2_OCO1Sets2.Clear();
		                        NZDUSD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO1S3_DOWN_S2 = 0;
		                for (; NZDUSD_OCO1S3_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets3.Count; NZDUSD_OCO1S3_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO1Sets3[NZDUSD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO1Sets3[NZDUSD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.NZDUSD_DOWN_S2_OCO1Sets3.Clear();
		                        NZDUSD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO1S4_DOWN_S2 = 0;
		                for (; NZDUSD_OCO1S4_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets4.Count; NZDUSD_OCO1S4_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO1Sets4[NZDUSD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO1Sets4[NZDUSD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.NZDUSD_DOWN_S2_OCO1Sets4.Clear();
		                        NZDUSD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO1S5_DOWN_S2 = 0;
		                for (; NZDUSD_OCO1S5_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets5.Count; NZDUSD_OCO1S5_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO1Sets5[NZDUSD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO1Sets5[NZDUSD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.NZDUSD_DOWN_S2_OCO1Sets5.Clear();
		                        NZDUSD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO1S6_DOWN_S2 = 0;
		                for (; NZDUSD_OCO1S6_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets6.Count; NZDUSD_OCO1S6_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO1Sets6[NZDUSD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO1Sets6[NZDUSD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.NZDUSD_DOWN_S2_OCO1Sets6.Clear();
		                        NZDUSD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDUSD_OCO2_EO1_DOWN_S2)
	                Base.NZDUSD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDUSD_OCO2_EO2_DOWN_S2)
	                Base.NZDUSD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO2_EO3_DOWN_S2)
	                Base.NZDUSD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO2_EO4_DOWN_S2)
	                Base.NZDUSD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO2_EO5_DOWN_S2)
	                Base.NZDUSD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO2_EO6_DOWN_S2)
	                Base.NZDUSD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDUSD_OCO2S1_DOWN_S2 = 0;
		                for (; NZDUSD_OCO2S1_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets1.Count; NZDUSD_OCO2S1_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO2Sets1[NZDUSD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO2Sets1[NZDUSD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.NZDUSD_DOWN_S2_OCO2Sets1.Clear();
		                        NZDUSD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDUSD_OCO2S2_DOWN_S2 = 0;
		                for (; NZDUSD_OCO2S2_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets2.Count; NZDUSD_OCO2S2_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO2Sets2[NZDUSD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO2Sets2[NZDUSD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.NZDUSD_DOWN_S2_OCO2Sets2.Clear();
		                        NZDUSD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO2S3_DOWN_S2 = 0;
		                for (; NZDUSD_OCO2S3_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets3.Count; NZDUSD_OCO2S3_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO2Sets3[NZDUSD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO2Sets3[NZDUSD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.NZDUSD_DOWN_S2_OCO2Sets3.Clear();
		                        NZDUSD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO2S4_DOWN_S2 = 0;
		                for (; NZDUSD_OCO2S4_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets4.Count; NZDUSD_OCO2S4_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO2Sets4[NZDUSD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO2Sets4[NZDUSD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.NZDUSD_DOWN_S2_OCO2Sets4.Clear();
		                        NZDUSD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO2S5_DOWN_S2 = 0;
		                for (; NZDUSD_OCO2S5_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets5.Count; NZDUSD_OCO2S5_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO2Sets5[NZDUSD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO2Sets5[NZDUSD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.NZDUSD_DOWN_S2_OCO2Sets5.Clear();
		                        NZDUSD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO2S6_DOWN_S2 = 0;
		                for (; NZDUSD_OCO2S6_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets6.Count; NZDUSD_OCO2S6_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO2Sets6[NZDUSD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO2Sets6[NZDUSD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.NZDUSD_DOWN_S2_OCO2Sets6.Clear();
		                        NZDUSD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDUSD_OCO3_EO1_DOWN_S2)
	                Base.NZDUSD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDUSD_OCO3_EO2_DOWN_S2)
	                Base.NZDUSD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO3_EO3_DOWN_S2)
	                Base.NZDUSD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO3_EO4_DOWN_S2)
	                Base.NZDUSD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO3_EO5_DOWN_S2)
	                Base.NZDUSD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO3_EO6_DOWN_S2)
	                Base.NZDUSD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDUSD_OCO3S1_DOWN_S2 = 0;
		                for (; NZDUSD_OCO3S1_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets1.Count; NZDUSD_OCO3S1_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO3Sets1[NZDUSD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO3Sets1[NZDUSD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.NZDUSD_DOWN_S2_OCO3Sets1.Clear();
		                        NZDUSD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDUSD_OCO3S2_DOWN_S2 = 0;
		                for (; NZDUSD_OCO3S2_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets2.Count; NZDUSD_OCO3S2_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO3Sets2[NZDUSD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO3Sets2[NZDUSD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.NZDUSD_DOWN_S2_OCO3Sets2.Clear();
		                        NZDUSD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO3S3_DOWN_S2 = 0;
		                for (; NZDUSD_OCO3S3_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets3.Count; NZDUSD_OCO3S3_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO3Sets3[NZDUSD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO3Sets3[NZDUSD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.NZDUSD_DOWN_S2_OCO3Sets3.Clear();
		                        NZDUSD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO3S4_DOWN_S2 = 0;
		                for (; NZDUSD_OCO3S4_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets4.Count; NZDUSD_OCO3S4_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO3Sets4[NZDUSD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO3Sets4[NZDUSD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.NZDUSD_DOWN_S2_OCO3Sets4.Clear();
		                        NZDUSD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO3S5_DOWN_S2 = 0;
		                for (; NZDUSD_OCO3S5_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets5.Count; NZDUSD_OCO3S5_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO3Sets5[NZDUSD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO3Sets5[NZDUSD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.NZDUSD_DOWN_S2_OCO3Sets5.Clear();
		                        NZDUSD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO3S6_DOWN_S2 = 0;
		                for (; NZDUSD_OCO3S6_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets6.Count; NZDUSD_OCO3S6_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO3Sets6[NZDUSD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO3Sets6[NZDUSD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.NZDUSD_DOWN_S2_OCO3Sets6.Clear();
		                        NZDUSD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDUSD_OCO4_EO1_DOWN_S2)
	                Base.NZDUSD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDUSD_OCO4_EO2_DOWN_S2)
	                Base.NZDUSD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO4_EO3_DOWN_S2)
	                Base.NZDUSD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO4_EO4_DOWN_S2)
	                Base.NZDUSD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO4_EO5_DOWN_S2)
	                Base.NZDUSD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO4_EO6_DOWN_S2)
	                Base.NZDUSD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDUSD_OCO4S1_DOWN_S2 = 0;
		                for (; NZDUSD_OCO4S1_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets1.Count; NZDUSD_OCO4S1_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO4Sets1[NZDUSD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO4Sets1[NZDUSD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.NZDUSD_DOWN_S2_OCO4Sets1.Clear();
		                        NZDUSD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDUSD_OCO4S2_DOWN_S2 = 0;
		                for (; NZDUSD_OCO4S2_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets2.Count; NZDUSD_OCO4S2_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO4Sets2[NZDUSD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO4Sets2[NZDUSD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.NZDUSD_DOWN_S2_OCO4Sets2.Clear();
		                        NZDUSD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO4S3_DOWN_S2 = 0;
		                for (; NZDUSD_OCO4S3_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets3.Count; NZDUSD_OCO4S3_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO4Sets3[NZDUSD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO4Sets3[NZDUSD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.NZDUSD_DOWN_S2_OCO4Sets3.Clear();
		                        NZDUSD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO4S4_DOWN_S2 = 0;
		                for (; NZDUSD_OCO4S4_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets4.Count; NZDUSD_OCO4S4_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO4Sets4[NZDUSD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO4Sets4[NZDUSD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.NZDUSD_DOWN_S2_OCO4Sets4.Clear();
		                        NZDUSD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO4S5_DOWN_S2 = 0;
		                for (; NZDUSD_OCO4S5_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets5.Count; NZDUSD_OCO4S5_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO4Sets5[NZDUSD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO4Sets5[NZDUSD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.NZDUSD_DOWN_S2_OCO4Sets5.Clear();
		                        NZDUSD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO4S6_DOWN_S2 = 0;
		                for (; NZDUSD_OCO4S6_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets6.Count; NZDUSD_OCO4S6_DOWN_S2++)
		                    if (Base.NZDUSD_DOWN_S2_OCO4Sets6[NZDUSD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_DOWN_S2_OCO4Sets6[NZDUSD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.NZDUSD_DOWN_S2_OCO4Sets6.Clear();
		                        NZDUSD_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();
	            	}
	            	
					DOWM_NZDUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_NZDUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_NZDUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_NZDUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_NZDUSD_DOWN_S2 = DOWM_NZDUSD_DOWN_S2 || DOWT_NZDUSD_DOWN_S2 || DOWW_NZDUSD_DOWN_S2 || DOWTH_NZDUSD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("NZDUSD"))
	            	{
	            		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.NZDUSD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.NZDUSD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.NZDUSD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.NZDUSD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.NZDUSD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDUSD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDUSD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDUSD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.NZDUSD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.NZDUSD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.NZDUSD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.NZDUSD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	NZDUSD_Signal_Condition_DOWN_S2 =  
	                									(
															//pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.02m &&
	                										
	                										//prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//prices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[0] > prices_ASK_Close[0] * 0.0165m &&
	                										
	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										
	                										prices_ASK_High[0] > pricesM_ASK_High[0] &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.0005m
	                									);
	                									
	                    NZDUSD_DOWN_S2_SL  =  0.01m;
	                    NZDUSD_DOWN_S2_TP1 =  0.1m;
	                    NZDUSD_DOWN_S2_TP2 =  NZDUSD_DOWN_S2_SL * 0;
	                    NZDUSD_DOWN_S2_TP3 =  NZDUSD_DOWN_S2_SL * 0;
	                    NZDUSD_DOWN_S2_TP4 =  NZDUSD_DOWN_S2_SL * 0;
	                    NZDUSD_DOWN_S2_TP5 =  NZDUSD_DOWN_S2_SL * 0;
	                    NZDUSD_DOWN_S2_TP6 =  NZDUSD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    NZDUSD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    NZDUSD_quantity_SL_DOWN_S2 = NZDUSD_quantity_DOWN_S2;
	                    NZDUSD_quantity_TP1_DOWN_S2 = (int)Math.Floor(NZDUSD_quantity_DOWN_S2 * 1m);
	                    NZDUSD_quantity_TP2_DOWN_S2 = (int)Math.Floor(NZDUSD_quantity_TP1_DOWN_S2 * 0m);
	                    NZDUSD_quantity_TP3_DOWN_S2 = (int)Math.Floor(NZDUSD_quantity_TP2_DOWN_S2 * 0m);
	                    NZDUSD_quantity_TP4_DOWN_S2 = (int)Math.Floor(NZDUSD_quantity_TP3_DOWN_S2 * 0m);
	                    NZDUSD_quantity_TP5_DOWN_S2 = (int)Math.Floor(NZDUSD_quantity_TP4_DOWN_S2 * 0m);
	                    NZDUSD_quantity_TP6_DOWN_S2 = (int)Math.Floor(NZDUSD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (NZDUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDUSD_DOWN_S2 && 
	                    Base.NZDUSD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.NZDUSD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDUSD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP1_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.NZDUSD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDUSD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP2_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.NZDUSD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.NZDUSD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP3_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.NZDUSD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDUSD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP4_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.NZDUSD_OCO1_EO4_DOWN_S2 = false;

							Base.NZDUSD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.NZDUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (NZDUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDUSD_DOWN_S2 && 
	                    Base.NZDUSD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.NZDUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDUSD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDUSD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP1_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.NZDUSD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDUSD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP2_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.NZDUSD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.NZDUSD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP3_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.NZDUSD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDUSD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP4_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.NZDUSD_OCO2_EO4_DOWN_S2 = false;

							Base.NZDUSD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.NZDUSD_OCO2_DOWN_S2_IsReady == false && Base.NZDUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (NZDUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDUSD_DOWN_S2 &&
	                    Base.NZDUSD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.NZDUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDUSD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.NZDUSD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDUSD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP1_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.NZDUSD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDUSD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP2_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.NZDUSD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.NZDUSD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP3_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.NZDUSD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDUSD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP4_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.NZDUSD_OCO3_EO4_DOWN_S2 = false;

							Base.NZDUSD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.NZDUSD_OCO3_DOWN_S2_IsReady == false && Base.NZDUSD_OCO2_DOWN_S2_IsReady == false && Base.NZDUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (NZDUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDUSD_DOWN_S2 && 
	                    Base.NZDUSD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.NZDUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDUSD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.NZDUSD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.NZDUSD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDUSD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP1_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.NZDUSD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDUSD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP2_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.NZDUSD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.NZDUSD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP3_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.NZDUSD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDUSD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDUSD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP4_DOWN_S2, false,"NZDUSD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.NZDUSD_OCO4_EO4_DOWN_S2 = false;

							Base.NZDUSD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.NZDUSD_OCO4_DOWN_S2_IsReady == false && Base.NZDUSD_OCO3_DOWN_S2_IsReady == false && Base.NZDUSD_OCO2_DOWN_S2_IsReady == false && Base.NZDUSD_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_NZDUSD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_NZDUSD_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(x=>x.Tag.Contains("NZDUSD_UP_S2_OCO1")))
			{
				Base.NZDUSD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDUSD_UP_S2_OCO2")))
			{
				Base.NZDUSD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDUSD_UP_S2_OCO3")))
			{
				Base.NZDUSD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDUSD_UP_S2_OCO4")))
			{
				Base.NZDUSD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("NZDUSD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.NZDUSD_OCO1_EO1_UP_S2)
	                Base.NZDUSD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDUSD_OCO1_EO2_UP_S2)
	                Base.NZDUSD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO1_EO3_UP_S2)
	                Base.NZDUSD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO1_EO4_UP_S2)
	                Base.NZDUSD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO1_EO5_UP_S2)
	                Base.NZDUSD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO1_EO6_UP_S2)
	                Base.NZDUSD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDUSD_OCO1S1_UP_S2 = 0;
		                for (; NZDUSD_OCO1S1_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets1.Count; NZDUSD_OCO1S1_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO1Sets1[NZDUSD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO1Sets1[NZDUSD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.NZDUSD_UP_S2_OCO1Sets1.Clear();
		                        NZDUSD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDUSD_OCO1S2_UP_S2 = 0;
		                for (; NZDUSD_OCO1S2_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets2.Count; NZDUSD_OCO1S2_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO1Sets2[NZDUSD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO1Sets2[NZDUSD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.NZDUSD_UP_S2_OCO1Sets2.Clear();
		                        NZDUSD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO1S3_UP_S2 = 0;
		                for (; NZDUSD_OCO1S3_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets3.Count; NZDUSD_OCO1S3_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO1Sets3[NZDUSD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO1Sets3[NZDUSD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.NZDUSD_UP_S2_OCO1Sets3.Clear();
		                        NZDUSD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO1S4_UP_S2 = 0;
		                for (; NZDUSD_OCO1S4_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets4.Count; NZDUSD_OCO1S4_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO1Sets4[NZDUSD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO1Sets4[NZDUSD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.NZDUSD_UP_S2_OCO1Sets4.Clear();
		                        NZDUSD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO1S5_UP_S2 = 0;
		                for (; NZDUSD_OCO1S5_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets5.Count; NZDUSD_OCO1S5_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO1Sets5[NZDUSD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO1Sets5[NZDUSD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.NZDUSD_UP_S2_OCO1Sets5.Clear();
		                        NZDUSD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO1S6_UP_S2 = 0;
		                for (; NZDUSD_OCO1S6_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets6.Count; NZDUSD_OCO1S6_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO1Sets6[NZDUSD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO1Sets6[NZDUSD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.NZDUSD_UP_S2_OCO1Sets6.Clear();
		                        NZDUSD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.NZDUSD_OCO2_EO1_UP_S2)
                	Base.NZDUSD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDUSD_OCO2_EO2_UP_S2)
	                Base.NZDUSD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO2_EO3_UP_S2)
	                Base.NZDUSD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO2_EO4_UP_S2)
	                Base.NZDUSD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO2_EO5_UP_S2)
	                Base.NZDUSD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO2_EO6_UP_S2)
	                Base.NZDUSD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDUSD_OCO2S1_UP_S2 = 0;
		                for (; NZDUSD_OCO2S1_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets1.Count; NZDUSD_OCO2S1_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO2Sets1[NZDUSD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO2Sets1[NZDUSD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.NZDUSD_UP_S2_OCO2Sets1.Clear();
		                        NZDUSD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDUSD_OCO2S2_UP_S2 = 0;
		                for (; NZDUSD_OCO2S2_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets2.Count; NZDUSD_OCO2S2_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO2Sets2[NZDUSD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO2Sets2[NZDUSD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.NZDUSD_UP_S2_OCO2Sets2.Clear();
		                        NZDUSD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO2S3_UP_S2 = 0;
		                for (; NZDUSD_OCO2S3_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets3.Count; NZDUSD_OCO2S3_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO2Sets3[NZDUSD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO2Sets3[NZDUSD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.NZDUSD_UP_S2_OCO2Sets3.Clear();
		                        NZDUSD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO2S4_UP_S2 = 0;
		                for (; NZDUSD_OCO2S4_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets4.Count; NZDUSD_OCO2S4_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO2Sets4[NZDUSD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO2Sets4[NZDUSD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.NZDUSD_UP_S2_OCO2Sets4.Clear();
		                        NZDUSD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO2S5_UP_S2 = 0;
		                for (; NZDUSD_OCO2S5_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets5.Count; NZDUSD_OCO2S5_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO2Sets5[NZDUSD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO2Sets5[NZDUSD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.NZDUSD_UP_S2_OCO2Sets5.Clear();
		                        NZDUSD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO2S6_UP_S2 = 0;
		                for (; NZDUSD_OCO2S6_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets6.Count; NZDUSD_OCO2S6_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO2Sets6[NZDUSD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO2Sets6[NZDUSD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.NZDUSD_UP_S2_OCO2Sets6.Clear();
		                        NZDUSD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.NZDUSD_OCO3_EO1_UP_S2)
            		Base.NZDUSD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDUSD_OCO3_EO2_UP_S2)
	                Base.NZDUSD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO3_EO3_UP_S2)
	                Base.NZDUSD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO3_EO4_UP_S2)
	                Base.NZDUSD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO3_EO5_UP_S2)
	                Base.NZDUSD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO3_EO6_UP_S2)
	                Base.NZDUSD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDUSD_OCO3S1_UP_S2 = 0;
		                for (; NZDUSD_OCO3S1_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets1.Count; NZDUSD_OCO3S1_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO3Sets1[NZDUSD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO3Sets1[NZDUSD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.NZDUSD_UP_S2_OCO3Sets1.Clear();
		                        NZDUSD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDUSD_OCO3S2_UP_S2 = 0;
		                for (; NZDUSD_OCO3S2_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets2.Count; NZDUSD_OCO3S2_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO3Sets2[NZDUSD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO3Sets2[NZDUSD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.NZDUSD_UP_S2_OCO3Sets2.Clear();
		                        NZDUSD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO3S3_UP_S2 = 0;
		                for (; NZDUSD_OCO3S3_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets3.Count; NZDUSD_OCO3S3_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO3Sets3[NZDUSD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO3Sets3[NZDUSD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.NZDUSD_UP_S2_OCO3Sets3.Clear();
		                        NZDUSD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO3S4_UP_S2 = 0;
		                for (; NZDUSD_OCO3S4_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets4.Count; NZDUSD_OCO3S4_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO3Sets4[NZDUSD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO3Sets4[NZDUSD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.NZDUSD_UP_S2_OCO3Sets4.Clear();
		                        NZDUSD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO3S5_UP_S2 = 0;
		                for (; NZDUSD_OCO3S5_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets5.Count; NZDUSD_OCO3S5_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO3Sets5[NZDUSD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO3Sets5[NZDUSD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.NZDUSD_UP_S2_OCO3Sets5.Clear();
		                        NZDUSD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO3S6_UP_S2 = 0;
		                for (; NZDUSD_OCO3S6_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets6.Count; NZDUSD_OCO3S6_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO3Sets6[NZDUSD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO3Sets6[NZDUSD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.NZDUSD_UP_S2_OCO3Sets6.Clear();
		                        NZDUSD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDUSD_OCO4_EO1_UP_S2)
            		Base.NZDUSD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDUSD_OCO4_EO2_UP_S2)
	                Base.NZDUSD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO4_EO3_UP_S2)
	                Base.NZDUSD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO4_EO4_UP_S2)
	                Base.NZDUSD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO4_EO5_UP_S2)
	                Base.NZDUSD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDUSD_OCO4_EO6_UP_S2)
	                Base.NZDUSD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDUSD_OCO4S1_UP_S2 = 0;
		                for (; NZDUSD_OCO4S1_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets1.Count; NZDUSD_OCO4S1_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO4Sets1[NZDUSD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO4Sets1[NZDUSD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.NZDUSD_UP_S2_OCO4Sets1.Clear();
		                        NZDUSD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDUSD_OCO4S2_UP_S2 = 0;
		                for (; NZDUSD_OCO4S2_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets2.Count; NZDUSD_OCO4S2_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO4Sets2[NZDUSD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO4Sets2[NZDUSD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.NZDUSD_UP_S2_OCO4Sets2.Clear();
		                        NZDUSD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO4S3_UP_S2 = 0;
		                for (; NZDUSD_OCO4S3_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets3.Count; NZDUSD_OCO4S3_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO4Sets3[NZDUSD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO4Sets3[NZDUSD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.NZDUSD_UP_S2_OCO4Sets3.Clear();
		                        NZDUSD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDUSD_OCO4S4_UP_S2 = 0;
		                for (; NZDUSD_OCO4S4_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets4.Count; NZDUSD_OCO4S4_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO4Sets4[NZDUSD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO4Sets4[NZDUSD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.NZDUSD_UP_S2_OCO4Sets4.Clear();
		                        NZDUSD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO4S5_UP_S2 = 0;
		                for (; NZDUSD_OCO4S5_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets5.Count; NZDUSD_OCO4S5_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO4Sets5[NZDUSD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO4Sets5[NZDUSD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.NZDUSD_UP_S2_OCO4Sets5.Clear();
		                        NZDUSD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDUSD_OCO4S6_UP_S2 = 0;
		                for (; NZDUSD_OCO4S6_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets6.Count; NZDUSD_OCO4S6_UP_S2++)
		                    if (Base.NZDUSD_UP_S2_OCO4Sets6[NZDUSD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDUSD_UP_S2_OCO4Sets6[NZDUSD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDUSD", order.Quantity, false, "NZDUSD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.NZDUSD_UP_S2_OCO4Sets6.Clear();
		                        NZDUSD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_NZDUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_NZDUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_NZDUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_NZDUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_NZDUSD_UP_S2 = DOWM_NZDUSD_UP_S2 || DOWT_NZDUSD_UP_S2 || DOWW_NZDUSD_UP_S2 || DOWTH_NZDUSD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("NZDUSD"))
	            	{
	            		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.NZDUSD_OCO1_UP_S2_IsReady == false ||
	                    	Base.NZDUSD_OCO2_UP_S2_IsReady == false ||
	                    	Base.NZDUSD_OCO3_UP_S2_IsReady == false ||
	                    	Base.NZDUSD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.NZDUSD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDUSD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDUSD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDUSD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.NZDUSD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.NZDUSD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.NZDUSD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.NZDUSD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	NZDUSD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
		                										
		                										)
		                							
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	NZDUSD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	NZDUSD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (NZDUSD_Signal_Condition_UP_1)
	                	{
	                    	NZDUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (NZDUSD_Signal_Condition_UP_2)
	                	{
	                    	NZDUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (NZDUSD_Signal_Condition_UP_3)
	                	{
	                    	NZDUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (NZDUSD_Signal_Condition_UP_1)
	                	{
	                    	NZDUSD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (NZDUSD_Signal_Condition_UP_2)
	                	{
	                    	NZDUSD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (NZDUSD_Signal_Condition_UP_3)
	                	{
	                    	NZDUSD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    NZDUSD_UP_S2_TP2 =  NZDUSD_UP_S2_SL * 0;
	                    NZDUSD_UP_S2_TP3 =  NZDUSD_UP_S2_SL * 0;
	                    NZDUSD_UP_S2_TP4 =  NZDUSD_UP_S2_SL * 0;
	                    NZDUSD_UP_S2_TP5 =  NZDUSD_UP_S2_SL * 0;
	                    NZDUSD_UP_S2_TP6 =  NZDUSD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    NZDUSD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    NZDUSD_quantity_SL_UP_S2 = NZDUSD_quantity_UP_S2;
	                    NZDUSD_quantity_TP1_UP_S2 = (int)Math.Floor(NZDUSD_quantity_UP_S2 * 1m);
	                    NZDUSD_quantity_TP2_UP_S2 = (int)Math.Floor(NZDUSD_quantity_TP1_UP_S2 * 0m);
	                    NZDUSD_quantity_TP3_UP_S2 = (int)Math.Floor(NZDUSD_quantity_TP2_UP_S2 * 0m);
	                    NZDUSD_quantity_TP4_UP_S2 = (int)Math.Floor(NZDUSD_quantity_TP3_UP_S2 * 0m);
	                    NZDUSD_quantity_TP5_UP_S2 = (int)Math.Floor(NZDUSD_quantity_TP4_UP_S2 * 0m);
	                    NZDUSD_quantity_TP6_UP_S2 = (int)Math.Floor(NZDUSD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((NZDUSD_Signal_Condition_UP_1 || NZDUSD_Signal_Condition_UP_2 || NZDUSD_Signal_Condition_UP_3)  && 
	                    DOWR_NZDUSD_UP_S2 && 
	                    Base.NZDUSD_OCO1_UP_S2_IsReady == true &&
	                    Base.NZDUSD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDUSD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP1_UP_S2, false,"NZDUSD_UP_S2_Entry_TP1_OCO1");
	                         Base.NZDUSD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.NZDUSD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP2_UP_S2, false,"NZDUSD_UP_S2_Entry_TP2_OCO1");
	                         Base.NZDUSD_OCO1_EO2_UP_S2 = false;
	
	                         Base.NZDUSD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP3_UP_S2, false,"NZDUSD_UP_S2_Entry_TP3_OCO1");
	                         Base.NZDUSD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.NZDUSD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP4_UP_S2, false,"NZDUSD_UP_S2_Entry_TP4_OCO1");
	                         Base.NZDUSD_OCO1_EO4_UP_S2 = false;

							Base.NZDUSD_OCO1_UP_S2_IsReady = false;
							
							if (Base.NZDUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((NZDUSD_Signal_Condition_UP_1 || NZDUSD_Signal_Condition_UP_2 || NZDUSD_Signal_Condition_UP_3)  && 
	                    DOWR_NZDUSD_UP_S2 && 
	                    Base.NZDUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDUSD_OCO2_UP_S2_IsReady == true &&
	                    Base.NZDUSD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDUSD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP1_UP_S2, false,"NZDUSD_UP_S2_Entry_TP1_OCO2");
	                         Base.NZDUSD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.NZDUSD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP2_UP_S2, false,"NZDUSD_UP_S2_Entry_TP2_OCO2");
	                         Base.NZDUSD_OCO2_EO2_UP_S2 = false;
	
	                         Base.NZDUSD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP3_UP_S2, false,"NZDUSD_UP_S2_Entry_TP3_OCO2");
	                         Base.NZDUSD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.NZDUSD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP4_UP_S2, false,"NZDUSD_UP_S2_Entry_TP4_OCO2");
	                         Base.NZDUSD_OCO2_EO4_UP_S2 = false;

							Base.NZDUSD_OCO2_UP_S2_IsReady = false;
							
							if (Base.NZDUSD_OCO2_UP_S2_IsReady == false && Base.NZDUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((NZDUSD_Signal_Condition_UP_1 || NZDUSD_Signal_Condition_UP_2 || NZDUSD_Signal_Condition_UP_3)  && 
	                    DOWR_NZDUSD_UP_S2 &&
	                    Base.NZDUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDUSD_OCO2_UP_S2_IsReady == false &&
	                    Base.NZDUSD_OCO3_UP_S2_IsReady == true &&
	                    Base.NZDUSD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDUSD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP1_UP_S2, false,"NZDUSD_UP_S2_Entry_TP1_OCO3");
	                         Base.NZDUSD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.NZDUSD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP2_UP_S2, false,"NZDUSD_UP_S2_Entry_TP2_OCO3");
	                         Base.NZDUSD_OCO3_EO2_UP_S2 = false;
	
	                         Base.NZDUSD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP3_UP_S2, false,"NZDUSD_UP_S2_Entry_TP3_OCO3");
	                         Base.NZDUSD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.NZDUSD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP4_UP_S2, false,"NZDUSD_UP_S2_Entry_TP4_OCO3");
	                         Base.NZDUSD_OCO3_EO4_UP_S2 = false;

							Base.NZDUSD_OCO3_UP_S2_IsReady = false;
							
							if (Base.NZDUSD_OCO3_UP_S2_IsReady == false && Base.NZDUSD_OCO2_UP_S2_IsReady == false && Base.NZDUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((NZDUSD_Signal_Condition_UP_1 || NZDUSD_Signal_Condition_UP_2 || NZDUSD_Signal_Condition_UP_3)  && 
	                    DOWR_NZDUSD_UP_S2 && 
	                    Base.NZDUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDUSD_OCO2_UP_S2_IsReady == false &&
	                    Base.NZDUSD_OCO3_UP_S2_IsReady == false &&
	                    Base.NZDUSD_OCO4_UP_S2_IsReady == true &&
	                    Base.NZDUSD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDUSD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP1_UP_S2, false,"NZDUSD_UP_S2_Entry_TP1_OCO4");
	                         Base.NZDUSD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.NZDUSD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP2_UP_S2, false,"NZDUSD_UP_S2_Entry_TP2_OCO4");
	                         Base.NZDUSD_OCO4_EO2_UP_S2 = false;
	
	                         Base.NZDUSD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP3_UP_S2, false,"NZDUSD_UP_S2_Entry_TP3_OCO4");
	                         Base.NZDUSD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.NZDUSD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDUSD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDUSD_quantity_TP4_UP_S2, false,"NZDUSD_UP_S2_Entry_TP4_OCO4");
	                         Base.NZDUSD_OCO4_EO4_UP_S2 = false;

							Base.NZDUSD_OCO4_UP_S2_IsReady = false;
							
							if (Base.NZDUSD_OCO4_UP_S2_IsReady == false && Base.NZDUSD_OCO3_UP_S2_IsReady == false && Base.NZDUSD_OCO2_UP_S2_IsReady == false && Base.NZDUSD_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.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 EURUSD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURUSD_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("EURUSD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURUSD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURUSD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURUSD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURUSD S2");
		        	}
		        }
		        
				if (Base.EURUSD_OCO1_EO1_DOWN_S2)
	                Base.EURUSD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURUSD_OCO1_EO2_DOWN_S2)
	                Base.EURUSD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO1_EO3_DOWN_S2)
	                Base.EURUSD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO1_EO4_DOWN_S2)
	                Base.EURUSD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURUSD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.EURUSD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP1_EURUSD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP1,"TP1_EURUSD_DOWN_S2_OCO1"));
		                 };
		                Base.EURUSD_DOWN_S2_OCO1Sets1.Add( Base.EURUSD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURUSD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP2_EURUSD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP2,"TP2_EURUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO1Sets2.Add( Base.EURUSD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP3_EURUSD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP3,"TP3_EURUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO1Sets3.Add( Base.EURUSD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP4_EURUSD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP4,"TP4_EURUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO1Sets4.Add( Base.EURUSD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURUSD_OCO1S1_DOWN_S2 = 0;
	                for (; EURUSD_OCO1S1_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets1.Count; EURUSD_OCO1S1_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO1Sets1[EURUSD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO1Sets1[EURUSD_OCO1S1_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO1Sets1.RemoveAt(EURUSD_OCO1S1_DOWN_S2);
	                        EURUSD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURUSD_OCO1S2_DOWN_S2 = 0;
	                for (; EURUSD_OCO1S2_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets2.Count; EURUSD_OCO1S2_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO1Sets2[EURUSD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO1Sets2[EURUSD_OCO1S2_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO1Sets2.RemoveAt(EURUSD_OCO1S2_DOWN_S2);
	                        EURUSD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO1S3_DOWN_S2 = 0;
	                for (; EURUSD_OCO1S3_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets3.Count; EURUSD_OCO1S3_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO1Sets3[EURUSD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO1Sets3[EURUSD_OCO1S3_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO1Sets3.RemoveAt(EURUSD_OCO1S3_DOWN_S2);
	                        EURUSD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO1S4_DOWN_S2 = 0;
	                for (; EURUSD_OCO1S4_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets4.Count; EURUSD_OCO1S4_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO1Sets4[EURUSD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO1Sets4[EURUSD_OCO1S4_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO1Sets4.RemoveAt(EURUSD_OCO1S4_DOWN_S2);
	                        EURUSD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURUSD_OCO2_EO1_DOWN_S2)
	                Base.EURUSD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURUSD_OCO2_EO2_DOWN_S2)
	                Base.EURUSD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO2_EO3_DOWN_S2)
	                Base.EURUSD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO2_EO4_DOWN_S2)
	                Base.EURUSD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURUSD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.EURUSD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP1_EURUSD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP1,"TP1_EURUSD_DOWN_S2_OCO2"));
		                 };
		                Base.EURUSD_DOWN_S2_OCO2Sets1.Add( Base.EURUSD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURUSD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP2_EURUSD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP2,"TP2_EURUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO2Sets2.Add( Base.EURUSD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP3_EURUSD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP3,"TP3_EURUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO2Sets3.Add( Base.EURUSD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP4_EURUSD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP4,"TP4_EURUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO2Sets4.Add( Base.EURUSD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURUSD_OCO2S1_DOWN_S2 = 0;
	                for (; EURUSD_OCO2S1_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets1.Count; EURUSD_OCO2S1_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO2Sets1[EURUSD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO2Sets1[EURUSD_OCO2S1_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO2Sets1.RemoveAt(EURUSD_OCO2S1_DOWN_S2);
	                        EURUSD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURUSD_OCO2S2_DOWN_S2 = 0;
	                for (; EURUSD_OCO2S2_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets2.Count; EURUSD_OCO2S2_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO2Sets2[EURUSD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO2Sets2[EURUSD_OCO2S2_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO2Sets2.RemoveAt(EURUSD_OCO2S2_DOWN_S2);
	                        EURUSD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO2S3_DOWN_S2 = 0;
	                for (; EURUSD_OCO2S3_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets3.Count; EURUSD_OCO2S3_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO2Sets3[EURUSD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO2Sets3[EURUSD_OCO2S3_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO2Sets3.RemoveAt(EURUSD_OCO2S3_DOWN_S2);
	                        EURUSD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO2S4_DOWN_S2 = 0;
	                for (; EURUSD_OCO2S4_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets4.Count; EURUSD_OCO2S4_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO2Sets4[EURUSD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO2Sets4[EURUSD_OCO2S4_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO2Sets4.RemoveAt(EURUSD_OCO2S4_DOWN_S2);
	                        EURUSD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURUSD_OCO3_EO1_DOWN_S2)
	                Base.EURUSD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURUSD_OCO3_EO2_DOWN_S2)
	                Base.EURUSD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO3_EO3_DOWN_S2)
	                Base.EURUSD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO3_EO4_DOWN_S2)
	                Base.EURUSD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURUSD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.EURUSD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP1_EURUSD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP1,"TP1_EURUSD_DOWN_S2_OCO3"));
		                 };
		                Base.EURUSD_DOWN_S2_OCO3Sets1.Add( Base.EURUSD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURUSD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP2_EURUSD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP2,"TP2_EURUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO3Sets2.Add( Base.EURUSD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP3_EURUSD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP3,"TP3_EURUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO3Sets3.Add( Base.EURUSD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP4_EURUSD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP4,"TP4_EURUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO3Sets4.Add( Base.EURUSD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURUSD_OCO3S1_DOWN_S2 = 0;
	                for (; EURUSD_OCO3S1_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets1.Count; EURUSD_OCO3S1_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO3Sets1[EURUSD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO3Sets1[EURUSD_OCO3S1_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO3Sets1.RemoveAt(EURUSD_OCO3S1_DOWN_S2);
	                        EURUSD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURUSD_OCO3S2_DOWN_S2 = 0;
	                for (; EURUSD_OCO3S2_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets2.Count; EURUSD_OCO3S2_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO3Sets2[EURUSD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO3Sets2[EURUSD_OCO3S2_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO3Sets2.RemoveAt(EURUSD_OCO3S2_DOWN_S2);
	                        EURUSD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO3S3_DOWN_S2 = 0;
	                for (; EURUSD_OCO3S3_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets3.Count; EURUSD_OCO3S3_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO3Sets3[EURUSD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO3Sets3[EURUSD_OCO3S3_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO3Sets3.RemoveAt(EURUSD_OCO3S3_DOWN_S2);
	                        EURUSD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO3S4_DOWN_S2 = 0;
	                for (; EURUSD_OCO3S4_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets4.Count; EURUSD_OCO3S4_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO3Sets4[EURUSD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO3Sets4[EURUSD_OCO3S4_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO3Sets4.RemoveAt(EURUSD_OCO3S4_DOWN_S2);
	                        EURUSD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURUSD_OCO4_EO1_DOWN_S2)
	                Base.EURUSD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURUSD_OCO4_EO2_DOWN_S2)
	                Base.EURUSD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO4_EO3_DOWN_S2)
	                Base.EURUSD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO4_EO4_DOWN_S2)
	                Base.EURUSD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURUSD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.EURUSD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP1_EURUSD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP1,"TP1_EURUSD_DOWN_S2_OCO4"));
		                 };
		                Base.EURUSD_DOWN_S2_OCO4Sets1.Add( Base.EURUSD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURUSD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP2_EURUSD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP2,"TP2_EURUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO4Sets2.Add( Base.EURUSD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP3_EURUSD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP3,"TP3_EURUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO4Sets3.Add( Base.EURUSD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_DOWN_S2_SL,"SL_TP4_EURUSD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_DOWN_S2_TP4,"TP4_EURUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURUSD_DOWN_S2_OCO4Sets4.Add( Base.EURUSD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURUSD_OCO4S1_DOWN_S2 = 0;
	                for (; EURUSD_OCO4S1_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets1.Count; EURUSD_OCO4S1_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO4Sets1[EURUSD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO4Sets1[EURUSD_OCO4S1_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO4Sets1.RemoveAt(EURUSD_OCO4S1_DOWN_S2);
	                        EURUSD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURUSD_OCO4S2_DOWN_S2 = 0;
	                for (; EURUSD_OCO4S2_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets2.Count; EURUSD_OCO4S2_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO4Sets2[EURUSD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO4Sets2[EURUSD_OCO4S2_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO4Sets2.RemoveAt(EURUSD_OCO4S2_DOWN_S2);
	                        EURUSD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO4S3_DOWN_S2 = 0;
	                for (; EURUSD_OCO4S3_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets3.Count; EURUSD_OCO4S3_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO4Sets3[EURUSD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO4Sets3[EURUSD_OCO4S3_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO4Sets3.RemoveAt(EURUSD_OCO4S3_DOWN_S2);
	                        EURUSD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO4S4_DOWN_S2 = 0;
	                for (; EURUSD_OCO4S4_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets4.Count; EURUSD_OCO4S4_DOWN_S2++)
	                    if (Base.EURUSD_DOWN_S2_OCO4Sets4[EURUSD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_DOWN_S2_OCO4Sets4[EURUSD_OCO4S4_DOWN_S2].Filled();
	                        Base.EURUSD_DOWN_S2_OCO4Sets4.RemoveAt(EURUSD_OCO4S4_DOWN_S2);
	                        EURUSD_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_NZDCHF_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_NZDCHF_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(x=>x.Tag.Contains("NZDCHF_UP_S2_OCO1")))
			{
				Base.NZDCHF_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCHF_UP_S2_OCO2")))
			{
				Base.NZDCHF_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCHF_UP_S2_OCO3")))
			{
				Base.NZDCHF_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCHF_UP_S2_OCO4")))
			{
				Base.NZDCHF_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("NZDCHF_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.NZDCHF_OCO1_EO1_UP_S2)
	                Base.NZDCHF_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDCHF_OCO1_EO2_UP_S2)
	                Base.NZDCHF_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO1_EO3_UP_S2)
	                Base.NZDCHF_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO1_EO4_UP_S2)
	                Base.NZDCHF_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO1_EO5_UP_S2)
	                Base.NZDCHF_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO1_EO6_UP_S2)
	                Base.NZDCHF_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCHF_OCO1S1_UP_S2 = 0;
		                for (; NZDCHF_OCO1S1_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets1.Count; NZDCHF_OCO1S1_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO1Sets1[NZDCHF_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO1Sets1[NZDCHF_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_1__Time out_OCO1");
		                        Base.NZDCHF_UP_S2_OCO1Sets1.Clear();
		                        NZDCHF_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCHF_OCO1S2_UP_S2 = 0;
		                for (; NZDCHF_OCO1S2_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets2.Count; NZDCHF_OCO1S2_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO1Sets2[NZDCHF_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO1Sets2[NZDCHF_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_2__Time out_OCO1");
		                        Base.NZDCHF_UP_S2_OCO1Sets2.Clear();
		                        NZDCHF_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO1S3_UP_S2 = 0;
		                for (; NZDCHF_OCO1S3_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets3.Count; NZDCHF_OCO1S3_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO1Sets3[NZDCHF_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO1Sets3[NZDCHF_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_3__Time out_OCO1");
		                        Base.NZDCHF_UP_S2_OCO1Sets3.Clear();
		                        NZDCHF_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO1S4_UP_S2 = 0;
		                for (; NZDCHF_OCO1S4_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets4.Count; NZDCHF_OCO1S4_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO1Sets4[NZDCHF_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO1Sets4[NZDCHF_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_4__Time out_OCO1");
		                        Base.NZDCHF_UP_S2_OCO1Sets4.Clear();
		                        NZDCHF_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO1S5_UP_S2 = 0;
		                for (; NZDCHF_OCO1S5_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets5.Count; NZDCHF_OCO1S5_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO1Sets5[NZDCHF_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO1Sets5[NZDCHF_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_5__Time out_OCO1");
		                        Base.NZDCHF_UP_S2_OCO1Sets5.Clear();
		                        NZDCHF_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO1S6_UP_S2 = 0;
		                for (; NZDCHF_OCO1S6_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets6.Count; NZDCHF_OCO1S6_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO1Sets6[NZDCHF_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO1Sets6[NZDCHF_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_6__Time out_OCO1");
		                        Base.NZDCHF_UP_S2_OCO1Sets6.Clear();
		                        NZDCHF_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.NZDCHF_OCO2_EO1_UP_S2)
                	Base.NZDCHF_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDCHF_OCO2_EO2_UP_S2)
	                Base.NZDCHF_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO2_EO3_UP_S2)
	                Base.NZDCHF_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO2_EO4_UP_S2)
	                Base.NZDCHF_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO2_EO5_UP_S2)
	                Base.NZDCHF_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO2_EO6_UP_S2)
	                Base.NZDCHF_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCHF_OCO2S1_UP_S2 = 0;
		                for (; NZDCHF_OCO2S1_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets1.Count; NZDCHF_OCO2S1_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO2Sets1[NZDCHF_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO2Sets1[NZDCHF_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_1__Time out_OCO2");
		                        Base.NZDCHF_UP_S2_OCO2Sets1.Clear();
		                        NZDCHF_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCHF_OCO2S2_UP_S2 = 0;
		                for (; NZDCHF_OCO2S2_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets2.Count; NZDCHF_OCO2S2_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO2Sets2[NZDCHF_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO2Sets2[NZDCHF_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_2__Time out_OCO2");
		                        Base.NZDCHF_UP_S2_OCO2Sets2.Clear();
		                        NZDCHF_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO2S3_UP_S2 = 0;
		                for (; NZDCHF_OCO2S3_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets3.Count; NZDCHF_OCO2S3_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO2Sets3[NZDCHF_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO2Sets3[NZDCHF_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_3__Time out_OCO2");
		                        Base.NZDCHF_UP_S2_OCO2Sets3.Clear();
		                        NZDCHF_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO2S4_UP_S2 = 0;
		                for (; NZDCHF_OCO2S4_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets4.Count; NZDCHF_OCO2S4_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO2Sets4[NZDCHF_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO2Sets4[NZDCHF_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_4__Time out_OCO2");
		                        Base.NZDCHF_UP_S2_OCO2Sets4.Clear();
		                        NZDCHF_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO2S5_UP_S2 = 0;
		                for (; NZDCHF_OCO2S5_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets5.Count; NZDCHF_OCO2S5_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO2Sets5[NZDCHF_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO2Sets5[NZDCHF_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_5__Time out_OCO2");
		                        Base.NZDCHF_UP_S2_OCO2Sets5.Clear();
		                        NZDCHF_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO2S6_UP_S2 = 0;
		                for (; NZDCHF_OCO2S6_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets6.Count; NZDCHF_OCO2S6_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO2Sets6[NZDCHF_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO2Sets6[NZDCHF_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_6__Time out_OCO2");
		                        Base.NZDCHF_UP_S2_OCO2Sets6.Clear();
		                        NZDCHF_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.NZDCHF_OCO3_EO1_UP_S2)
            		Base.NZDCHF_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDCHF_OCO3_EO2_UP_S2)
	                Base.NZDCHF_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO3_EO3_UP_S2)
	                Base.NZDCHF_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO3_EO4_UP_S2)
	                Base.NZDCHF_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO3_EO5_UP_S2)
	                Base.NZDCHF_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO3_EO6_UP_S2)
	                Base.NZDCHF_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCHF_OCO3S1_UP_S2 = 0;
		                for (; NZDCHF_OCO3S1_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets1.Count; NZDCHF_OCO3S1_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO3Sets1[NZDCHF_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO3Sets1[NZDCHF_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_1__Time out_OCO3");
		                        Base.NZDCHF_UP_S2_OCO3Sets1.Clear();
		                        NZDCHF_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCHF_OCO3S2_UP_S2 = 0;
		                for (; NZDCHF_OCO3S2_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets2.Count; NZDCHF_OCO3S2_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO3Sets2[NZDCHF_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO3Sets2[NZDCHF_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_2__Time out_OCO3");
		                        Base.NZDCHF_UP_S2_OCO3Sets2.Clear();
		                        NZDCHF_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO3S3_UP_S2 = 0;
		                for (; NZDCHF_OCO3S3_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets3.Count; NZDCHF_OCO3S3_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO3Sets3[NZDCHF_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO3Sets3[NZDCHF_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_3__Time out_OCO3");
		                        Base.NZDCHF_UP_S2_OCO3Sets3.Clear();
		                        NZDCHF_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO3S4_UP_S2 = 0;
		                for (; NZDCHF_OCO3S4_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets4.Count; NZDCHF_OCO3S4_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO3Sets4[NZDCHF_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO3Sets4[NZDCHF_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_4__Time out_OCO3");
		                        Base.NZDCHF_UP_S2_OCO3Sets4.Clear();
		                        NZDCHF_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO3S5_UP_S2 = 0;
		                for (; NZDCHF_OCO3S5_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets5.Count; NZDCHF_OCO3S5_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO3Sets5[NZDCHF_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO3Sets5[NZDCHF_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_5__Time out_OCO3");
		                        Base.NZDCHF_UP_S2_OCO3Sets5.Clear();
		                        NZDCHF_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO3S6_UP_S2 = 0;
		                for (; NZDCHF_OCO3S6_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets6.Count; NZDCHF_OCO3S6_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO3Sets6[NZDCHF_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO3Sets6[NZDCHF_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_6__Time out_OCO3");
		                        Base.NZDCHF_UP_S2_OCO3Sets6.Clear();
		                        NZDCHF_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDCHF_OCO4_EO1_UP_S2)
            		Base.NZDCHF_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDCHF_OCO4_EO2_UP_S2)
	                Base.NZDCHF_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO4_EO3_UP_S2)
	                Base.NZDCHF_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO4_EO4_UP_S2)
	                Base.NZDCHF_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO4_EO5_UP_S2)
	                Base.NZDCHF_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO4_EO6_UP_S2)
	                Base.NZDCHF_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCHF_OCO4S1_UP_S2 = 0;
		                for (; NZDCHF_OCO4S1_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets1.Count; NZDCHF_OCO4S1_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO4Sets1[NZDCHF_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO4Sets1[NZDCHF_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_1__Time out_OCO4");
		                        Base.NZDCHF_UP_S2_OCO4Sets1.Clear();
		                        NZDCHF_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCHF_OCO4S2_UP_S2 = 0;
		                for (; NZDCHF_OCO4S2_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets2.Count; NZDCHF_OCO4S2_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO4Sets2[NZDCHF_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO4Sets2[NZDCHF_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_2__Time out_OCO4");
		                        Base.NZDCHF_UP_S2_OCO4Sets2.Clear();
		                        NZDCHF_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO4S3_UP_S2 = 0;
		                for (; NZDCHF_OCO4S3_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets3.Count; NZDCHF_OCO4S3_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO4Sets3[NZDCHF_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO4Sets3[NZDCHF_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_3__Time out_OCO4");
		                        Base.NZDCHF_UP_S2_OCO4Sets3.Clear();
		                        NZDCHF_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO4S4_UP_S2 = 0;
		                for (; NZDCHF_OCO4S4_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets4.Count; NZDCHF_OCO4S4_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO4Sets4[NZDCHF_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO4Sets4[NZDCHF_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_4__Time out_OCO4");
		                        Base.NZDCHF_UP_S2_OCO4Sets4.Clear();
		                        NZDCHF_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO4S5_UP_S2 = 0;
		                for (; NZDCHF_OCO4S5_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets5.Count; NZDCHF_OCO4S5_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO4Sets5[NZDCHF_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO4Sets5[NZDCHF_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_5__Time out_OCO4");
		                        Base.NZDCHF_UP_S2_OCO4Sets5.Clear();
		                        NZDCHF_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO4S6_UP_S2 = 0;
		                for (; NZDCHF_OCO4S6_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets6.Count; NZDCHF_OCO4S6_UP_S2++)
		                    if (Base.NZDCHF_UP_S2_OCO4Sets6[NZDCHF_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_UP_S2_OCO4Sets6[NZDCHF_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_UP_S2_Entry_6__Time out_OCO4");
		                        Base.NZDCHF_UP_S2_OCO4Sets6.Clear();
		                        NZDCHF_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_NZDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_NZDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_NZDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_NZDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_NZDCHF_UP_S2 = DOWM_NZDCHF_UP_S2 || DOWT_NZDCHF_UP_S2 || DOWW_NZDCHF_UP_S2 || DOWTH_NZDCHF_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("NZDCHF"))
	            	{
	            		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.NZDCHF_OCO1_UP_S2_IsReady == false ||
	                    	Base.NZDCHF_OCO2_UP_S2_IsReady == false ||
	                    	Base.NZDCHF_OCO3_UP_S2_IsReady == false ||
	                    	Base.NZDCHF_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.NZDCHF_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDCHF_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDCHF_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDCHF_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.NZDCHF_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.NZDCHF_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.NZDCHF_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.NZDCHF_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	NZDCHF_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                							
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	NZDCHF_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	NZDCHF_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
		
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (NZDCHF_Signal_Condition_UP_1)
	                	{
	                    	NZDCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (NZDCHF_Signal_Condition_UP_2)
	                	{
	                    	NZDCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (NZDCHF_Signal_Condition_UP_3)
	                	{
	                    	NZDCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (NZDCHF_Signal_Condition_UP_1)
	                	{
	                    	NZDCHF_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (NZDCHF_Signal_Condition_UP_2)
	                	{
	                    	NZDCHF_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (NZDCHF_Signal_Condition_UP_3)
	                	{
	                    	NZDCHF_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    NZDCHF_UP_S2_TP2 =  NZDCHF_UP_S2_SL * 0;
	                    NZDCHF_UP_S2_TP3 =  NZDCHF_UP_S2_SL * 0;
	                    NZDCHF_UP_S2_TP4 =  NZDCHF_UP_S2_SL * 0;
	                    NZDCHF_UP_S2_TP5 =  NZDCHF_UP_S2_SL * 0;
	                    NZDCHF_UP_S2_TP6 =  NZDCHF_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    NZDCHF_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    NZDCHF_quantity_SL_UP_S2 = NZDCHF_quantity_UP_S2;
	                    NZDCHF_quantity_TP1_UP_S2 = (int)Math.Floor(NZDCHF_quantity_UP_S2 * 1m);
	                    NZDCHF_quantity_TP2_UP_S2 = (int)Math.Floor(NZDCHF_quantity_TP1_UP_S2 * 0m);
	                    NZDCHF_quantity_TP3_UP_S2 = (int)Math.Floor(NZDCHF_quantity_TP2_UP_S2 * 0m);
	                    NZDCHF_quantity_TP4_UP_S2 = (int)Math.Floor(NZDCHF_quantity_TP3_UP_S2 * 0m);
	                    NZDCHF_quantity_TP5_UP_S2 = (int)Math.Floor(NZDCHF_quantity_TP4_UP_S2 * 0m);
	                    NZDCHF_quantity_TP6_UP_S2 = (int)Math.Floor(NZDCHF_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((NZDCHF_Signal_Condition_UP_1 || NZDCHF_Signal_Condition_UP_2 || NZDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_NZDCHF_UP_S2 && 
	                    Base.NZDCHF_OCO1_UP_S2_IsReady == true &&
	                    Base.NZDCHF_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCHF_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP1_UP_S2, false,"NZDCHF_UP_S2_Entry_TP1_OCO1");
	                         Base.NZDCHF_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.NZDCHF_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP2_UP_S2, false,"NZDCHF_UP_S2_Entry_TP2_OCO1");
	                         Base.NZDCHF_OCO1_EO2_UP_S2 = false;
	
	                         Base.NZDCHF_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP3_UP_S2, false,"NZDCHF_UP_S2_Entry_TP3_OCO1");
	                         Base.NZDCHF_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.NZDCHF_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP4_UP_S2, false,"NZDCHF_UP_S2_Entry_TP4_OCO1");
	                         Base.NZDCHF_OCO1_EO4_UP_S2 = false;

							Base.NZDCHF_OCO1_UP_S2_IsReady = false;
							
							if (Base.NZDCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((NZDCHF_Signal_Condition_UP_1 || NZDCHF_Signal_Condition_UP_2 || NZDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_NZDCHF_UP_S2 && 
	                    Base.NZDCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDCHF_OCO2_UP_S2_IsReady == true &&
	                    Base.NZDCHF_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCHF_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP1_UP_S2, false,"NZDCHF_UP_S2_Entry_TP1_OCO2");
	                         Base.NZDCHF_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.NZDCHF_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP2_UP_S2, false,"NZDCHF_UP_S2_Entry_TP2_OCO2");
	                         Base.NZDCHF_OCO2_EO2_UP_S2 = false;
	
	                         Base.NZDCHF_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP3_UP_S2, false,"NZDCHF_UP_S2_Entry_TP3_OCO2");
	                         Base.NZDCHF_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.NZDCHF_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP4_UP_S2, false,"NZDCHF_UP_S2_Entry_TP4_OCO2");
	                         Base.NZDCHF_OCO2_EO4_UP_S2 = false;

							Base.NZDCHF_OCO2_UP_S2_IsReady = false;
							
							if (Base.NZDCHF_OCO2_UP_S2_IsReady == false && Base.NZDCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((NZDCHF_Signal_Condition_UP_1 || NZDCHF_Signal_Condition_UP_2 || NZDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_NZDCHF_UP_S2 &&
	                    Base.NZDCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.NZDCHF_OCO3_UP_S2_IsReady == true &&
	                    Base.NZDCHF_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCHF_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP1_UP_S2, false,"NZDCHF_UP_S2_Entry_TP1_OCO3");
	                         Base.NZDCHF_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.NZDCHF_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP2_UP_S2, false,"NZDCHF_UP_S2_Entry_TP2_OCO3");
	                         Base.NZDCHF_OCO3_EO2_UP_S2 = false;
	
	                         Base.NZDCHF_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP3_UP_S2, false,"NZDCHF_UP_S2_Entry_TP3_OCO3");
	                         Base.NZDCHF_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.NZDCHF_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP4_UP_S2, false,"NZDCHF_UP_S2_Entry_TP4_OCO3");
	                         Base.NZDCHF_OCO3_EO4_UP_S2 = false;

							Base.NZDCHF_OCO3_UP_S2_IsReady = false;
							
							if (Base.NZDCHF_OCO3_UP_S2_IsReady == false && Base.NZDCHF_OCO2_UP_S2_IsReady == false && Base.NZDCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((NZDCHF_Signal_Condition_UP_1 || NZDCHF_Signal_Condition_UP_2 || NZDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_NZDCHF_UP_S2 && 
	                    Base.NZDCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.NZDCHF_OCO3_UP_S2_IsReady == false &&
	                    Base.NZDCHF_OCO4_UP_S2_IsReady == true &&
	                    Base.NZDCHF_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCHF_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP1_UP_S2, false,"NZDCHF_UP_S2_Entry_TP1_OCO4");
	                         Base.NZDCHF_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.NZDCHF_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP2_UP_S2, false,"NZDCHF_UP_S2_Entry_TP2_OCO4");
	                         Base.NZDCHF_OCO4_EO2_UP_S2 = false;
	
	                         Base.NZDCHF_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP3_UP_S2, false,"NZDCHF_UP_S2_Entry_TP3_OCO4");
	                         Base.NZDCHF_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.NZDCHF_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCHF_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP4_UP_S2, false,"NZDCHF_UP_S2_Entry_TP4_OCO4");
	                         Base.NZDCHF_OCO4_EO4_UP_S2 = false;

							Base.NZDCHF_OCO4_UP_S2_IsReady = false;
							
							if (Base.NZDCHF_OCO4_UP_S2_IsReady == false && Base.NZDCHF_OCO3_UP_S2_IsReady == false && Base.NZDCHF_OCO2_UP_S2_IsReady == false && Base.NZDCHF_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.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 CHFJPY_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public CHFJPY_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("CHFJPY OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CHFJPY OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CHFJPY OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CHFJPY OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CHFJPY OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CHFJPY OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CHFJPY OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        }
		        
				if (Base.CHFJPY_OCO1_EO1_UP_S2)
	                Base.CHFJPY_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.CHFJPY_OCO1_EO2_UP_S2)
	                Base.CHFJPY_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO1_EO3_UP_S2)
	                Base.CHFJPY_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO1_EO4_UP_S2)
	                Base.CHFJPY_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO1_EO5_UP_S2)
	                Base.CHFJPY_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO1_EO6_UP_S2)
	                Base.CHFJPY_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.CHFJPY_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP1,"TP1_CHFJPY_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP1_CHFJPY_UP_S2_OCO1"));
		                 };
		                Base.CHFJPY_UP_S2_OCO1Sets1.Add( Base.CHFJPY_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP2,"TP2_CHFJPY_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP2_CHFJPY_UP_S2_OCO1"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO1Sets2.Add( Base.CHFJPY_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP3,"TP3_CHFJPY_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP3_CHFJPY_UP_S2_OCO1"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO1Sets3.Add( Base.CHFJPY_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP4,"TP4_CHFJPY_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP4_CHFJPY_UP_S2_OCO1"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO1Sets4.Add( Base.CHFJPY_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP5,"TP5_CHFJPY_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP5_CHFJPY_UP_S2_OCO1"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO1Sets5.Add( Base.CHFJPY_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP6,"TP6_CHFJPY_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP6_CHFJPY_UP_S2_OCO1"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO1Sets6.Add( Base.CHFJPY_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int CHFJPY_OCO1S1_UP_S2 = 0;
	                for (; CHFJPY_OCO1S1_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets1.Count; CHFJPY_OCO1S1_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO1Sets1[CHFJPY_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO1Sets1[CHFJPY_OCO1S1_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO1Sets1.RemoveAt(CHFJPY_OCO1S1_UP_S2);
	                        CHFJPY_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int CHFJPY_OCO1S2_UP_S2 = 0;
	                for (; CHFJPY_OCO1S2_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets2.Count; CHFJPY_OCO1S2_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO1Sets2[CHFJPY_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO1Sets2[CHFJPY_OCO1S2_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO1Sets2.RemoveAt(CHFJPY_OCO1S2_UP_S2);
	                        CHFJPY_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO1S3_UP_S2 = 0;
	                for (; CHFJPY_OCO1S3_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets3.Count; CHFJPY_OCO1S3_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO1Sets3[CHFJPY_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO1Sets3[CHFJPY_OCO1S3_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO1Sets3.RemoveAt(CHFJPY_OCO1S3_UP_S2);
	                        CHFJPY_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO1S4_UP_S2 = 0;
	                for (; CHFJPY_OCO1S4_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets4.Count; CHFJPY_OCO1S4_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO1Sets4[CHFJPY_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO1Sets4[CHFJPY_OCO1S4_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO1Sets4.RemoveAt(CHFJPY_OCO1S4_UP_S2);
	                        CHFJPY_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CHFJPY_OCO1S5_UP_S2 = 0;
	                for (; CHFJPY_OCO1S5_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets5.Count; CHFJPY_OCO1S5_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO1Sets5[CHFJPY_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO1Sets5[CHFJPY_OCO1S5_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO1Sets5.RemoveAt(CHFJPY_OCO1S5_UP_S2);
	                        CHFJPY_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CHFJPY_OCO1S6_UP_S2 = 0;
	                for (; CHFJPY_OCO1S6_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets6.Count; CHFJPY_OCO1S6_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO1Sets6[CHFJPY_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO1Sets6[CHFJPY_OCO1S6_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO1Sets6.RemoveAt(CHFJPY_OCO1S6_UP_S2);
	                        CHFJPY_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.CHFJPY_OCO2_EO1_UP_S2)
	                Base.CHFJPY_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.CHFJPY_OCO2_EO2_UP_S2)
	                Base.CHFJPY_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO2_EO3_UP_S2)
	                Base.CHFJPY_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO2_EO4_UP_S2)
	                Base.CHFJPY_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO2_EO5_UP_S2)
	                Base.CHFJPY_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO2_EO6_UP_S2)
	                Base.CHFJPY_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.CHFJPY_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP1,"TP1_CHFJPY_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP1_CHFJPY_UP_S2_OCO2"));
		                 };
		                Base.CHFJPY_UP_S2_OCO2Sets1.Add( Base.CHFJPY_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP2,"TP2_CHFJPY_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP2_CHFJPY_UP_S2_OCO2"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO2Sets2.Add( Base.CHFJPY_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP3,"TP3_CHFJPY_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP3_CHFJPY_UP_S2_OCO2"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO2Sets3.Add( Base.CHFJPY_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP4,"TP4_CHFJPY_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP4_CHFJPY_UP_S2_OCO2"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO2Sets4.Add( Base.CHFJPY_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP5,"TP5_CHFJPY_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP5_CHFJPY_UP_S2_OCO2"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO2Sets5.Add( Base.CHFJPY_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP6,"TP6_CHFJPY_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP6_CHFJPY_UP_S2_OCO2"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO2Sets6.Add( Base.CHFJPY_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int CHFJPY_OCO2S1_UP_S2 = 0;
	                for (; CHFJPY_OCO2S1_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets1.Count; CHFJPY_OCO2S1_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO2Sets1[CHFJPY_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO2Sets1[CHFJPY_OCO2S1_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO2Sets1.RemoveAt(CHFJPY_OCO2S1_UP_S2);
	                        CHFJPY_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int CHFJPY_OCO2S2_UP_S2 = 0;
	                for (; CHFJPY_OCO2S2_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets2.Count; CHFJPY_OCO2S2_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO2Sets2[CHFJPY_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO2Sets2[CHFJPY_OCO2S2_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO2Sets2.RemoveAt(CHFJPY_OCO2S2_UP_S2);
	                        CHFJPY_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO2S3_UP_S2 = 0;
	                for (; CHFJPY_OCO2S3_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets3.Count; CHFJPY_OCO2S3_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO2Sets3[CHFJPY_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO2Sets3[CHFJPY_OCO2S3_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO2Sets3.RemoveAt(CHFJPY_OCO2S3_UP_S2);
	                        CHFJPY_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO2S4_UP_S2 = 0;
	                for (; CHFJPY_OCO2S4_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets4.Count; CHFJPY_OCO2S4_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO2Sets4[CHFJPY_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO2Sets4[CHFJPY_OCO2S4_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO2Sets4.RemoveAt(CHFJPY_OCO2S4_UP_S2);
	                        CHFJPY_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CHFJPY_OCO2S5_UP_S2 = 0;
	                for (; CHFJPY_OCO2S5_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets5.Count; CHFJPY_OCO2S5_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO2Sets5[CHFJPY_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO2Sets5[CHFJPY_OCO2S5_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO2Sets5.RemoveAt(CHFJPY_OCO2S5_UP_S2);
	                        CHFJPY_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CHFJPY_OCO2S6_UP_S2 = 0;
	                for (; CHFJPY_OCO2S6_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets6.Count; CHFJPY_OCO2S6_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO2Sets6[CHFJPY_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO2Sets6[CHFJPY_OCO2S6_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO2Sets6.RemoveAt(CHFJPY_OCO2S6_UP_S2);
	                        CHFJPY_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CHFJPY_OCO3_EO1_UP_S2)
	                Base.CHFJPY_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.CHFJPY_OCO3_EO2_UP_S2)
	                Base.CHFJPY_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO3_EO3_UP_S2)
	                Base.CHFJPY_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO3_EO4_UP_S2)
	                Base.CHFJPY_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO3_EO5_UP_S2)
	                Base.CHFJPY_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO3_EO6_UP_S2)
	                Base.CHFJPY_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.CHFJPY_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP1,"TP1_CHFJPY_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP1_CHFJPY_UP_S2_OCO3"));
		                 };
		                Base.CHFJPY_UP_S2_OCO3Sets1.Add( Base.CHFJPY_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP2,"TP2_CHFJPY_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP2_CHFJPY_UP_S2_OCO3"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO3Sets2.Add( Base.CHFJPY_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP3,"TP3_CHFJPY_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP3_CHFJPY_UP_S2_OCO3"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO3Sets3.Add( Base.CHFJPY_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP4,"TP4_CHFJPY_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP4_CHFJPY_UP_S2_OCO3"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO3Sets4.Add( Base.CHFJPY_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP5,"TP5_CHFJPY_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP5_CHFJPY_UP_S2_OCO3"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO3Sets5.Add( Base.CHFJPY_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP6,"TP6_CHFJPY_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP6_CHFJPY_UP_S2_OCO3"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO3Sets6.Add( Base.CHFJPY_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int CHFJPY_OCO3S1_UP_S2 = 0;
	                for (; CHFJPY_OCO3S1_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets1.Count; CHFJPY_OCO3S1_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO3Sets1[CHFJPY_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO3Sets1[CHFJPY_OCO3S1_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO3Sets1.RemoveAt(CHFJPY_OCO3S1_UP_S2);
	                        CHFJPY_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int CHFJPY_OCO3S2_UP_S2 = 0;
	                for (; CHFJPY_OCO3S2_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets2.Count; CHFJPY_OCO3S2_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO3Sets2[CHFJPY_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO3Sets2[CHFJPY_OCO3S2_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO3Sets2.RemoveAt(CHFJPY_OCO3S2_UP_S2);
	                        CHFJPY_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO3S3_UP_S2 = 0;
	                for (; CHFJPY_OCO3S3_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets3.Count; CHFJPY_OCO3S3_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO3Sets3[CHFJPY_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO3Sets3[CHFJPY_OCO3S3_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO3Sets3.RemoveAt(CHFJPY_OCO3S3_UP_S2);
	                        CHFJPY_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO3S4_UP_S2 = 0;
	                for (; CHFJPY_OCO3S4_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets4.Count; CHFJPY_OCO3S4_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO3Sets4[CHFJPY_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO3Sets4[CHFJPY_OCO3S4_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO3Sets4.RemoveAt(CHFJPY_OCO3S4_UP_S2);
	                        CHFJPY_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CHFJPY_OCO3S5_UP_S2 = 0;
	                for (; CHFJPY_OCO3S5_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets5.Count; CHFJPY_OCO3S5_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO3Sets5[CHFJPY_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO3Sets5[CHFJPY_OCO3S5_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO3Sets5.RemoveAt(CHFJPY_OCO3S5_UP_S2);
	                        CHFJPY_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CHFJPY_OCO3S6_UP_S2 = 0;
	                for (; CHFJPY_OCO3S6_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets6.Count; CHFJPY_OCO3S6_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO3Sets6[CHFJPY_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO3Sets6[CHFJPY_OCO3S6_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO3Sets6.RemoveAt(CHFJPY_OCO3S6_UP_S2);
	                        CHFJPY_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CHFJPY_OCO4_EO1_UP_S2)
	                Base.CHFJPY_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.CHFJPY_OCO4_EO2_UP_S2)
	                Base.CHFJPY_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO4_EO3_UP_S2)
	                Base.CHFJPY_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO4_EO4_UP_S2)
	                Base.CHFJPY_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO4_EO5_UP_S2)
	                Base.CHFJPY_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO4_EO6_UP_S2)
	                Base.CHFJPY_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.CHFJPY_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP1,"TP1_CHFJPY_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP1_CHFJPY_UP_S2_OCO4"));
		                 };
		                Base.CHFJPY_UP_S2_OCO4Sets1.Add( Base.CHFJPY_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP2,"TP2_CHFJPY_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP2_CHFJPY_UP_S2_OCO4"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO4Sets2.Add( Base.CHFJPY_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP3,"TP3_CHFJPY_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP3_CHFJPY_UP_S2_OCO4"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO4Sets3.Add( Base.CHFJPY_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP4,"TP4_CHFJPY_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP4_CHFJPY_UP_S2_OCO4"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO4Sets4.Add( Base.CHFJPY_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP5,"TP5_CHFJPY_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP5_CHFJPY_UP_S2_OCO4"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO4Sets5.Add( Base.CHFJPY_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_UP_S2_TP6,"TP6_CHFJPY_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_UP_S2_SL,"SL_TP6_CHFJPY_UP_S2_OCO4"));
		                 };
	                    Base.CHFJPY_UP_S2_OCO4Sets6.Add( Base.CHFJPY_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int CHFJPY_OCO4S1_UP_S2 = 0;
	                for (; CHFJPY_OCO4S1_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets1.Count; CHFJPY_OCO4S1_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO4Sets1[CHFJPY_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO4Sets1[CHFJPY_OCO4S1_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO4Sets1.RemoveAt(CHFJPY_OCO4S1_UP_S2);
	                        CHFJPY_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int CHFJPY_OCO4S2_UP_S2 = 0;
	                for (; CHFJPY_OCO4S2_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets2.Count; CHFJPY_OCO4S2_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO4Sets2[CHFJPY_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO4Sets2[CHFJPY_OCO4S2_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO4Sets2.RemoveAt(CHFJPY_OCO4S2_UP_S2);
	                        CHFJPY_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO4S3_UP_S2 = 0;
	                for (; CHFJPY_OCO4S3_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets3.Count; CHFJPY_OCO4S3_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO4Sets3[CHFJPY_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO4Sets3[CHFJPY_OCO4S3_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO4Sets3.RemoveAt(CHFJPY_OCO4S3_UP_S2);
	                        CHFJPY_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO4S4_UP_S2 = 0;
	                for (; CHFJPY_OCO4S4_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets4.Count; CHFJPY_OCO4S4_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO4Sets4[CHFJPY_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO4Sets4[CHFJPY_OCO4S4_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO4Sets4.RemoveAt(CHFJPY_OCO4S4_UP_S2);
	                        CHFJPY_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CHFJPY_OCO4S5_UP_S2 = 0;
	                for (; CHFJPY_OCO4S5_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets5.Count; CHFJPY_OCO4S5_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO4Sets5[CHFJPY_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO4Sets5[CHFJPY_OCO4S5_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO4Sets5.RemoveAt(CHFJPY_OCO4S5_UP_S2);
	                        CHFJPY_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CHFJPY_OCO4S6_UP_S2 = 0;
	                for (; CHFJPY_OCO4S6_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets6.Count; CHFJPY_OCO4S6_UP_S2++)
	                    if (Base.CHFJPY_UP_S2_OCO4Sets6[CHFJPY_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_UP_S2_OCO4Sets6[CHFJPY_OCO4S6_UP_S2].Filled();
	                        Base.CHFJPY_UP_S2_OCO4Sets6.RemoveAt(CHFJPY_OCO4S6_UP_S2);
	                        CHFJPY_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_NZDJPY_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_NZDJPY_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("NZDJPY_DOWN_S2_OCO1")))
			{
				Base.NZDJPY_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDJPY_DOWN_S2_OCO2")))
			{
				Base.NZDJPY_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDJPY_DOWN_S2_OCO3")))
			{
				Base.NZDJPY_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDJPY_DOWN_S2_OCO4")))
			{
				Base.NZDJPY_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("NZDJPY_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.NZDJPY_OCO1_EO1_DOWN_S2)
	                Base.NZDJPY_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDJPY_OCO1_EO2_DOWN_S2)
	                Base.NZDJPY_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO1_EO3_DOWN_S2)
	                Base.NZDJPY_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO1_EO4_DOWN_S2)
	                Base.NZDJPY_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO1_EO5_DOWN_S2)
	                Base.NZDJPY_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO1_EO6_DOWN_S2)
	                Base.NZDJPY_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDJPY_OCO1S1_DOWN_S2 = 0;
		                for (; NZDJPY_OCO1S1_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets1.Count; NZDJPY_OCO1S1_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO1Sets1[NZDJPY_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO1Sets1[NZDJPY_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.NZDJPY_DOWN_S2_OCO1Sets1.Clear();
		                        NZDJPY_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDJPY_OCO1S2_DOWN_S2 = 0;
		                for (; NZDJPY_OCO1S2_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets2.Count; NZDJPY_OCO1S2_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO1Sets2[NZDJPY_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO1Sets2[NZDJPY_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.NZDJPY_DOWN_S2_OCO1Sets2.Clear();
		                        NZDJPY_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO1S3_DOWN_S2 = 0;
		                for (; NZDJPY_OCO1S3_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets3.Count; NZDJPY_OCO1S3_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO1Sets3[NZDJPY_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO1Sets3[NZDJPY_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.NZDJPY_DOWN_S2_OCO1Sets3.Clear();
		                        NZDJPY_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO1S4_DOWN_S2 = 0;
		                for (; NZDJPY_OCO1S4_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets4.Count; NZDJPY_OCO1S4_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO1Sets4[NZDJPY_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO1Sets4[NZDJPY_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.NZDJPY_DOWN_S2_OCO1Sets4.Clear();
		                        NZDJPY_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO1S5_DOWN_S2 = 0;
		                for (; NZDJPY_OCO1S5_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets5.Count; NZDJPY_OCO1S5_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO1Sets5[NZDJPY_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO1Sets5[NZDJPY_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.NZDJPY_DOWN_S2_OCO1Sets5.Clear();
		                        NZDJPY_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO1S6_DOWN_S2 = 0;
		                for (; NZDJPY_OCO1S6_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets6.Count; NZDJPY_OCO1S6_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO1Sets6[NZDJPY_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO1Sets6[NZDJPY_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.NZDJPY_DOWN_S2_OCO1Sets6.Clear();
		                        NZDJPY_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDJPY_OCO2_EO1_DOWN_S2)
	                Base.NZDJPY_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDJPY_OCO2_EO2_DOWN_S2)
	                Base.NZDJPY_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO2_EO3_DOWN_S2)
	                Base.NZDJPY_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO2_EO4_DOWN_S2)
	                Base.NZDJPY_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO2_EO5_DOWN_S2)
	                Base.NZDJPY_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO2_EO6_DOWN_S2)
	                Base.NZDJPY_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDJPY_OCO2S1_DOWN_S2 = 0;
		                for (; NZDJPY_OCO2S1_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets1.Count; NZDJPY_OCO2S1_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO2Sets1[NZDJPY_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO2Sets1[NZDJPY_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.NZDJPY_DOWN_S2_OCO2Sets1.Clear();
		                        NZDJPY_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDJPY_OCO2S2_DOWN_S2 = 0;
		                for (; NZDJPY_OCO2S2_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets2.Count; NZDJPY_OCO2S2_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO2Sets2[NZDJPY_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO2Sets2[NZDJPY_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.NZDJPY_DOWN_S2_OCO2Sets2.Clear();
		                        NZDJPY_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO2S3_DOWN_S2 = 0;
		                for (; NZDJPY_OCO2S3_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets3.Count; NZDJPY_OCO2S3_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO2Sets3[NZDJPY_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO2Sets3[NZDJPY_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.NZDJPY_DOWN_S2_OCO2Sets3.Clear();
		                        NZDJPY_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO2S4_DOWN_S2 = 0;
		                for (; NZDJPY_OCO2S4_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets4.Count; NZDJPY_OCO2S4_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO2Sets4[NZDJPY_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO2Sets4[NZDJPY_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.NZDJPY_DOWN_S2_OCO2Sets4.Clear();
		                        NZDJPY_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO2S5_DOWN_S2 = 0;
		                for (; NZDJPY_OCO2S5_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets5.Count; NZDJPY_OCO2S5_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO2Sets5[NZDJPY_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO2Sets5[NZDJPY_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.NZDJPY_DOWN_S2_OCO2Sets5.Clear();
		                        NZDJPY_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO2S6_DOWN_S2 = 0;
		                for (; NZDJPY_OCO2S6_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets6.Count; NZDJPY_OCO2S6_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO2Sets6[NZDJPY_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO2Sets6[NZDJPY_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.NZDJPY_DOWN_S2_OCO2Sets6.Clear();
		                        NZDJPY_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDJPY_OCO3_EO1_DOWN_S2)
	                Base.NZDJPY_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDJPY_OCO3_EO2_DOWN_S2)
	                Base.NZDJPY_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO3_EO3_DOWN_S2)
	                Base.NZDJPY_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO3_EO4_DOWN_S2)
	                Base.NZDJPY_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO3_EO5_DOWN_S2)
	                Base.NZDJPY_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO3_EO6_DOWN_S2)
	                Base.NZDJPY_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDJPY_OCO3S1_DOWN_S2 = 0;
		                for (; NZDJPY_OCO3S1_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets1.Count; NZDJPY_OCO3S1_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO3Sets1[NZDJPY_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO3Sets1[NZDJPY_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.NZDJPY_DOWN_S2_OCO3Sets1.Clear();
		                        NZDJPY_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDJPY_OCO3S2_DOWN_S2 = 0;
		                for (; NZDJPY_OCO3S2_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets2.Count; NZDJPY_OCO3S2_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO3Sets2[NZDJPY_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO3Sets2[NZDJPY_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.NZDJPY_DOWN_S2_OCO3Sets2.Clear();
		                        NZDJPY_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO3S3_DOWN_S2 = 0;
		                for (; NZDJPY_OCO3S3_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets3.Count; NZDJPY_OCO3S3_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO3Sets3[NZDJPY_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO3Sets3[NZDJPY_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.NZDJPY_DOWN_S2_OCO3Sets3.Clear();
		                        NZDJPY_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO3S4_DOWN_S2 = 0;
		                for (; NZDJPY_OCO3S4_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets4.Count; NZDJPY_OCO3S4_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO3Sets4[NZDJPY_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO3Sets4[NZDJPY_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.NZDJPY_DOWN_S2_OCO3Sets4.Clear();
		                        NZDJPY_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO3S5_DOWN_S2 = 0;
		                for (; NZDJPY_OCO3S5_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets5.Count; NZDJPY_OCO3S5_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO3Sets5[NZDJPY_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO3Sets5[NZDJPY_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.NZDJPY_DOWN_S2_OCO3Sets5.Clear();
		                        NZDJPY_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO3S6_DOWN_S2 = 0;
		                for (; NZDJPY_OCO3S6_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets6.Count; NZDJPY_OCO3S6_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO3Sets6[NZDJPY_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO3Sets6[NZDJPY_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.NZDJPY_DOWN_S2_OCO3Sets6.Clear();
		                        NZDJPY_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDJPY_OCO4_EO1_DOWN_S2)
	                Base.NZDJPY_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDJPY_OCO4_EO2_DOWN_S2)
	                Base.NZDJPY_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO4_EO3_DOWN_S2)
	                Base.NZDJPY_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO4_EO4_DOWN_S2)
	                Base.NZDJPY_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO4_EO5_DOWN_S2)
	                Base.NZDJPY_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO4_EO6_DOWN_S2)
	                Base.NZDJPY_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDJPY_OCO4S1_DOWN_S2 = 0;
		                for (; NZDJPY_OCO4S1_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets1.Count; NZDJPY_OCO4S1_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO4Sets1[NZDJPY_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO4Sets1[NZDJPY_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.NZDJPY_DOWN_S2_OCO4Sets1.Clear();
		                        NZDJPY_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDJPY_OCO4S2_DOWN_S2 = 0;
		                for (; NZDJPY_OCO4S2_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets2.Count; NZDJPY_OCO4S2_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO4Sets2[NZDJPY_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO4Sets2[NZDJPY_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.NZDJPY_DOWN_S2_OCO4Sets2.Clear();
		                        NZDJPY_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO4S3_DOWN_S2 = 0;
		                for (; NZDJPY_OCO4S3_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets3.Count; NZDJPY_OCO4S3_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO4Sets3[NZDJPY_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO4Sets3[NZDJPY_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.NZDJPY_DOWN_S2_OCO4Sets3.Clear();
		                        NZDJPY_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO4S4_DOWN_S2 = 0;
		                for (; NZDJPY_OCO4S4_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets4.Count; NZDJPY_OCO4S4_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO4Sets4[NZDJPY_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO4Sets4[NZDJPY_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.NZDJPY_DOWN_S2_OCO4Sets4.Clear();
		                        NZDJPY_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO4S5_DOWN_S2 = 0;
		                for (; NZDJPY_OCO4S5_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets5.Count; NZDJPY_OCO4S5_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO4Sets5[NZDJPY_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO4Sets5[NZDJPY_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.NZDJPY_DOWN_S2_OCO4Sets5.Clear();
		                        NZDJPY_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO4S6_DOWN_S2 = 0;
		                for (; NZDJPY_OCO4S6_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets6.Count; NZDJPY_OCO4S6_DOWN_S2++)
		                    if (Base.NZDJPY_DOWN_S2_OCO4Sets6[NZDJPY_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_DOWN_S2_OCO4Sets6[NZDJPY_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.NZDJPY_DOWN_S2_OCO4Sets6.Clear();
		                        NZDJPY_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();
	            	}
	            	
					DOWM_NZDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_NZDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_NZDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_NZDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_NZDJPY_DOWN_S2 = DOWM_NZDJPY_DOWN_S2 || DOWT_NZDJPY_DOWN_S2 || DOWW_NZDJPY_DOWN_S2 || DOWTH_NZDJPY_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("NZDJPY"))
	            	{
	            		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.NZDJPY_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.NZDJPY_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.NZDJPY_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.NZDJPY_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.NZDJPY_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDJPY_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDJPY_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDJPY_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	                	NZDJPY_Signal_Condition_DOWN_S2 =  
	                									(
															//pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.04m &&
	                										
	                										//prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//prices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[1] > prices_ASK_Close[0] * 0.02m &&

	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 && //yuhukj
	                										
	                										//prices_BID_Open[0] - prices_ASK_Close[0] > 0 &&
 	                										
	                										//prices_BID_Close[0] > pricesM_ASK_High[0] && 
	                										//prices_ASK_High[0] > pricesM_ASK_High[0] && 
	                										
	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										pricesM_BID_Open[1] - pricesM_ASK_Close[1] > prices_BID_Close[0] * 0.001m &&

															pricesM_BID_High[1] - pricesM_ASK_Close[1] > prices_BID_Close[0] * 0.001m &&
	                										
	                										prices_ASK_High[0] > pricesM_ASK_High[0] &&
	                										//prices_BID_Close[0] < pricesM_BID_High[0] &&
	                										
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.03m
	                									);

	                    NZDJPY_DOWN_S2_SL  =  1m;
	                    NZDJPY_DOWN_S2_TP1 =  0.1m;
	                    NZDJPY_DOWN_S2_TP2 =  NZDJPY_DOWN_S2_SL * 0;
	                    NZDJPY_DOWN_S2_TP3 =  NZDJPY_DOWN_S2_SL * 0;
	                    NZDJPY_DOWN_S2_TP4 =  NZDJPY_DOWN_S2_SL * 0;
	                    NZDJPY_DOWN_S2_TP5 =  NZDJPY_DOWN_S2_SL * 0;
	                    NZDJPY_DOWN_S2_TP6 =  NZDJPY_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    NZDJPY_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    NZDJPY_quantity_SL_DOWN_S2 = NZDJPY_quantity_DOWN_S2;
	                    NZDJPY_quantity_TP1_DOWN_S2 = (int)Math.Floor(NZDJPY_quantity_DOWN_S2 * 1m);
	                    NZDJPY_quantity_TP2_DOWN_S2 = (int)Math.Floor(NZDJPY_quantity_TP1_DOWN_S2 * 0m);
	                    NZDJPY_quantity_TP3_DOWN_S2 = (int)Math.Floor(NZDJPY_quantity_TP2_DOWN_S2 * 0m);
	                    NZDJPY_quantity_TP4_DOWN_S2 = (int)Math.Floor(NZDJPY_quantity_TP3_DOWN_S2 * 0m);
	                    NZDJPY_quantity_TP5_DOWN_S2 = (int)Math.Floor(NZDJPY_quantity_TP4_DOWN_S2 * 0m);
	                    NZDJPY_quantity_TP6_DOWN_S2 = (int)Math.Floor(NZDJPY_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (NZDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDJPY_DOWN_S2 && 
	                    Base.NZDJPY_OCO1_DOWN_S2_IsReady == true &&
	                    Base.NZDJPY_OCO1_DOWN_S2_Monthly_IsReady == false)
	                    {
	                         Base.NZDJPY_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP1_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP1_OCO1");
	                         Base.NZDJPY_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDJPY_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP2_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP2_OCO1");
	                         Base.NZDJPY_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.NZDJPY_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP3_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP3_OCO1");
	                         Base.NZDJPY_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDJPY_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP4_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP4_OCO1");
	                         Base.NZDJPY_OCO1_EO4_DOWN_S2 = false;

							Base.NZDJPY_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.NZDJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (NZDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDJPY_DOWN_S2 && 
	                    Base.NZDJPY_OCO2_DOWN_S2_IsReady == true &&
	                    Base.NZDJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDJPY_OCO2_DOWN_S2_Monthly_IsReady == false)
	                    {
	                         Base.NZDJPY_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP1_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP1_OCO2");
	                         Base.NZDJPY_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDJPY_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP2_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP2_OCO2");
	                         Base.NZDJPY_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.NZDJPY_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP3_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP3_OCO2");
	                         Base.NZDJPY_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDJPY_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP4_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP4_OCO2");
	                         Base.NZDJPY_OCO2_EO4_DOWN_S2 = false;

							Base.NZDJPY_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.NZDJPY_OCO2_DOWN_S2_IsReady == false && Base.NZDJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (NZDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDJPY_DOWN_S2 &&
	                    Base.NZDJPY_OCO3_DOWN_S2_IsReady == true &&
	                    Base.NZDJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.NZDJPY_OCO3_DOWN_S2_Monthly_IsReady == false)
	                    {
	                         Base.NZDJPY_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP1_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP1_OCO3");
	                         Base.NZDJPY_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDJPY_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP2_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP2_OCO3");
	                         Base.NZDJPY_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.NZDJPY_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP3_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP3_OCO3");
	                         Base.NZDJPY_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDJPY_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP4_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP4_OCO3");
	                         Base.NZDJPY_OCO3_EO4_DOWN_S2 = false;

							Base.NZDJPY_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.NZDJPY_OCO3_DOWN_S2_IsReady == false && Base.NZDJPY_OCO2_DOWN_S2_IsReady == false && Base.NZDJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (NZDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDJPY_DOWN_S2 && 
	                    Base.NZDJPY_OCO4_DOWN_S2_IsReady == true &&
	                    Base.NZDJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.NZDJPY_OCO3_DOWN_S2_IsReady == false &&
	                    Base.NZDJPY_OCO4_DOWN_S2_Monthly_IsReady == false)
	                    {
	                         Base.NZDJPY_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP1_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP1_OCO4");
	                         Base.NZDJPY_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDJPY_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP2_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP2_OCO4");
	                         Base.NZDJPY_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.NZDJPY_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP3_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP3_OCO4");
	                         Base.NZDJPY_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDJPY_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDJPY_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP4_DOWN_S2, false,"NZDJPY_DOWN_S2_Entry_TP4_OCO4");
	                         Base.NZDJPY_OCO4_EO4_DOWN_S2 = false;

							Base.NZDJPY_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.NZDJPY_OCO4_DOWN_S2_IsReady == false && Base.NZDJPY_OCO3_DOWN_S2_IsReady == false && Base.NZDJPY_OCO2_DOWN_S2_IsReady == false && Base.NZDJPY_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_NZDCHF_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_NZDCHF_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("NZDCHF_DOWN_S2_OCO1")))
			{
				Base.NZDCHF_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCHF_DOWN_S2_OCO2")))
			{
				Base.NZDCHF_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCHF_DOWN_S2_OCO3")))
			{
				Base.NZDCHF_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCHF_DOWN_S2_OCO4")))
			{
				Base.NZDCHF_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("NZDCHF_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.NZDCHF_OCO1_EO1_DOWN_S2)
	                Base.NZDCHF_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDCHF_OCO1_EO2_DOWN_S2)
	                Base.NZDCHF_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO1_EO3_DOWN_S2)
	                Base.NZDCHF_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO1_EO4_DOWN_S2)
	                Base.NZDCHF_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO1_EO5_DOWN_S2)
	                Base.NZDCHF_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO1_EO6_DOWN_S2)
	                Base.NZDCHF_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCHF_OCO1S1_DOWN_S2 = 0;
		                for (; NZDCHF_OCO1S1_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets1.Count; NZDCHF_OCO1S1_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO1Sets1[NZDCHF_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO1Sets1[NZDCHF_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.NZDCHF_DOWN_S2_OCO1Sets1.Clear();
		                        NZDCHF_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCHF_OCO1S2_DOWN_S2 = 0;
		                for (; NZDCHF_OCO1S2_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets2.Count; NZDCHF_OCO1S2_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO1Sets2[NZDCHF_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO1Sets2[NZDCHF_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.NZDCHF_DOWN_S2_OCO1Sets2.Clear();
		                        NZDCHF_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO1S3_DOWN_S2 = 0;
		                for (; NZDCHF_OCO1S3_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets3.Count; NZDCHF_OCO1S3_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO1Sets3[NZDCHF_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO1Sets3[NZDCHF_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.NZDCHF_DOWN_S2_OCO1Sets3.Clear();
		                        NZDCHF_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO1S4_DOWN_S2 = 0;
		                for (; NZDCHF_OCO1S4_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets4.Count; NZDCHF_OCO1S4_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO1Sets4[NZDCHF_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO1Sets4[NZDCHF_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.NZDCHF_DOWN_S2_OCO1Sets4.Clear();
		                        NZDCHF_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO1S5_DOWN_S2 = 0;
		                for (; NZDCHF_OCO1S5_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets5.Count; NZDCHF_OCO1S5_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO1Sets5[NZDCHF_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO1Sets5[NZDCHF_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.NZDCHF_DOWN_S2_OCO1Sets5.Clear();
		                        NZDCHF_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO1S6_DOWN_S2 = 0;
		                for (; NZDCHF_OCO1S6_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets6.Count; NZDCHF_OCO1S6_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO1Sets6[NZDCHF_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO1Sets6[NZDCHF_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.NZDCHF_DOWN_S2_OCO1Sets6.Clear();
		                        NZDCHF_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDCHF_OCO2_EO1_DOWN_S2)
	                Base.NZDCHF_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDCHF_OCO2_EO2_DOWN_S2)
	                Base.NZDCHF_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO2_EO3_DOWN_S2)
	                Base.NZDCHF_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO2_EO4_DOWN_S2)
	                Base.NZDCHF_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO2_EO5_DOWN_S2)
	                Base.NZDCHF_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO2_EO6_DOWN_S2)
	                Base.NZDCHF_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCHF_OCO2S1_DOWN_S2 = 0;
		                for (; NZDCHF_OCO2S1_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets1.Count; NZDCHF_OCO2S1_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO2Sets1[NZDCHF_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO2Sets1[NZDCHF_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.NZDCHF_DOWN_S2_OCO2Sets1.Clear();
		                        NZDCHF_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCHF_OCO2S2_DOWN_S2 = 0;
		                for (; NZDCHF_OCO2S2_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets2.Count; NZDCHF_OCO2S2_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO2Sets2[NZDCHF_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO2Sets2[NZDCHF_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.NZDCHF_DOWN_S2_OCO2Sets2.Clear();
		                        NZDCHF_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO2S3_DOWN_S2 = 0;
		                for (; NZDCHF_OCO2S3_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets3.Count; NZDCHF_OCO2S3_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO2Sets3[NZDCHF_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO2Sets3[NZDCHF_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.NZDCHF_DOWN_S2_OCO2Sets3.Clear();
		                        NZDCHF_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO2S4_DOWN_S2 = 0;
		                for (; NZDCHF_OCO2S4_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets4.Count; NZDCHF_OCO2S4_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO2Sets4[NZDCHF_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO2Sets4[NZDCHF_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.NZDCHF_DOWN_S2_OCO2Sets4.Clear();
		                        NZDCHF_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO2S5_DOWN_S2 = 0;
		                for (; NZDCHF_OCO2S5_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets5.Count; NZDCHF_OCO2S5_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO2Sets5[NZDCHF_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO2Sets5[NZDCHF_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.NZDCHF_DOWN_S2_OCO2Sets5.Clear();
		                        NZDCHF_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO2S6_DOWN_S2 = 0;
		                for (; NZDCHF_OCO2S6_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets6.Count; NZDCHF_OCO2S6_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO2Sets6[NZDCHF_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO2Sets6[NZDCHF_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.NZDCHF_DOWN_S2_OCO2Sets6.Clear();
		                        NZDCHF_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDCHF_OCO3_EO1_DOWN_S2)
	                Base.NZDCHF_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDCHF_OCO3_EO2_DOWN_S2)
	                Base.NZDCHF_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO3_EO3_DOWN_S2)
	                Base.NZDCHF_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO3_EO4_DOWN_S2)
	                Base.NZDCHF_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO3_EO5_DOWN_S2)
	                Base.NZDCHF_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO3_EO6_DOWN_S2)
	                Base.NZDCHF_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCHF_OCO3S1_DOWN_S2 = 0;
		                for (; NZDCHF_OCO3S1_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets1.Count; NZDCHF_OCO3S1_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO3Sets1[NZDCHF_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO3Sets1[NZDCHF_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.NZDCHF_DOWN_S2_OCO3Sets1.Clear();
		                        NZDCHF_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCHF_OCO3S2_DOWN_S2 = 0;
		                for (; NZDCHF_OCO3S2_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets2.Count; NZDCHF_OCO3S2_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO3Sets2[NZDCHF_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO3Sets2[NZDCHF_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.NZDCHF_DOWN_S2_OCO3Sets2.Clear();
		                        NZDCHF_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO3S3_DOWN_S2 = 0;
		                for (; NZDCHF_OCO3S3_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets3.Count; NZDCHF_OCO3S3_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO3Sets3[NZDCHF_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO3Sets3[NZDCHF_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.NZDCHF_DOWN_S2_OCO3Sets3.Clear();
		                        NZDCHF_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO3S4_DOWN_S2 = 0;
		                for (; NZDCHF_OCO3S4_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets4.Count; NZDCHF_OCO3S4_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO3Sets4[NZDCHF_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO3Sets4[NZDCHF_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.NZDCHF_DOWN_S2_OCO3Sets4.Clear();
		                        NZDCHF_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO3S5_DOWN_S2 = 0;
		                for (; NZDCHF_OCO3S5_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets5.Count; NZDCHF_OCO3S5_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO3Sets5[NZDCHF_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO3Sets5[NZDCHF_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.NZDCHF_DOWN_S2_OCO3Sets5.Clear();
		                        NZDCHF_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO3S6_DOWN_S2 = 0;
		                for (; NZDCHF_OCO3S6_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets6.Count; NZDCHF_OCO3S6_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO3Sets6[NZDCHF_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO3Sets6[NZDCHF_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.NZDCHF_DOWN_S2_OCO3Sets6.Clear();
		                        NZDCHF_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDCHF_OCO4_EO1_DOWN_S2)
	                Base.NZDCHF_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDCHF_OCO4_EO2_DOWN_S2)
	                Base.NZDCHF_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO4_EO3_DOWN_S2)
	                Base.NZDCHF_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO4_EO4_DOWN_S2)
	                Base.NZDCHF_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO4_EO5_DOWN_S2)
	                Base.NZDCHF_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCHF_OCO4_EO6_DOWN_S2)
	                Base.NZDCHF_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCHF_OCO4S1_DOWN_S2 = 0;
		                for (; NZDCHF_OCO4S1_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets1.Count; NZDCHF_OCO4S1_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO4Sets1[NZDCHF_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO4Sets1[NZDCHF_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.NZDCHF_DOWN_S2_OCO4Sets1.Clear();
		                        NZDCHF_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCHF_OCO4S2_DOWN_S2 = 0;
		                for (; NZDCHF_OCO4S2_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets2.Count; NZDCHF_OCO4S2_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO4Sets2[NZDCHF_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO4Sets2[NZDCHF_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.NZDCHF_DOWN_S2_OCO4Sets2.Clear();
		                        NZDCHF_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO4S3_DOWN_S2 = 0;
		                for (; NZDCHF_OCO4S3_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets3.Count; NZDCHF_OCO4S3_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO4Sets3[NZDCHF_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO4Sets3[NZDCHF_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.NZDCHF_DOWN_S2_OCO4Sets3.Clear();
		                        NZDCHF_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCHF_OCO4S4_DOWN_S2 = 0;
		                for (; NZDCHF_OCO4S4_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets4.Count; NZDCHF_OCO4S4_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO4Sets4[NZDCHF_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO4Sets4[NZDCHF_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.NZDCHF_DOWN_S2_OCO4Sets4.Clear();
		                        NZDCHF_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO4S5_DOWN_S2 = 0;
		                for (; NZDCHF_OCO4S5_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets5.Count; NZDCHF_OCO4S5_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO4Sets5[NZDCHF_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO4Sets5[NZDCHF_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.NZDCHF_DOWN_S2_OCO4Sets5.Clear();
		                        NZDCHF_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCHF_OCO4S6_DOWN_S2 = 0;
		                for (; NZDCHF_OCO4S6_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets6.Count; NZDCHF_OCO4S6_DOWN_S2++)
		                    if (Base.NZDCHF_DOWN_S2_OCO4Sets6[NZDCHF_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCHF_DOWN_S2_OCO4Sets6[NZDCHF_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCHF", order.Quantity, false, "NZDCHF_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.NZDCHF_DOWN_S2_OCO4Sets6.Clear();
		                        NZDCHF_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();
	            	}
	            	
					DOWM_NZDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_NZDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_NZDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_NZDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_NZDCHF_DOWN_S2 = DOWM_NZDCHF_DOWN_S2 || DOWT_NZDCHF_DOWN_S2 || DOWW_NZDCHF_DOWN_S2 || DOWTH_NZDCHF_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("NZDCHF"))
	            	{
	            		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.NZDCHF_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.NZDCHF_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.NZDCHF_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.NZDCHF_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.NZDCHF_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDCHF_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDCHF_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDCHF_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.NZDCHF_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.NZDCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.NZDCHF_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.NZDCHF_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	NZDCHF_Signal_Condition_DOWN_S2 =  
	                									(
															//pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.02m &&
	                										
	                										//prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//prices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[0] > prices_ASK_Close[0] * 0.0165m &&
	                										
	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										
	                										prices_ASK_High[0] > pricesM_ASK_High[0] &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.0005m
	                									);
	                									
	                    NZDCHF_DOWN_S2_SL  =  0.01m;
	                    NZDCHF_DOWN_S2_TP1 =  0.002m;
	                    NZDCHF_DOWN_S2_TP2 =  NZDCHF_DOWN_S2_SL * 0;
	                    NZDCHF_DOWN_S2_TP3 =  NZDCHF_DOWN_S2_SL * 0;
	                    NZDCHF_DOWN_S2_TP4 =  NZDCHF_DOWN_S2_SL * 0;
	                    NZDCHF_DOWN_S2_TP5 =  NZDCHF_DOWN_S2_SL * 0;
	                    NZDCHF_DOWN_S2_TP6 =  NZDCHF_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    NZDCHF_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    NZDCHF_quantity_SL_DOWN_S2 = NZDCHF_quantity_DOWN_S2;
	                    NZDCHF_quantity_TP1_DOWN_S2 = (int)Math.Floor(NZDCHF_quantity_DOWN_S2 * 1m);
	                    NZDCHF_quantity_TP2_DOWN_S2 = (int)Math.Floor(NZDCHF_quantity_TP1_DOWN_S2 * 0m);
	                    NZDCHF_quantity_TP3_DOWN_S2 = (int)Math.Floor(NZDCHF_quantity_TP2_DOWN_S2 * 0m);
	                    NZDCHF_quantity_TP4_DOWN_S2 = (int)Math.Floor(NZDCHF_quantity_TP3_DOWN_S2 * 0m);
	                    NZDCHF_quantity_TP5_DOWN_S2 = (int)Math.Floor(NZDCHF_quantity_TP4_DOWN_S2 * 0m);
	                    NZDCHF_quantity_TP6_DOWN_S2 = (int)Math.Floor(NZDCHF_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (NZDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDCHF_DOWN_S2 && 
	                    Base.NZDCHF_OCO1_DOWN_S2_IsReady == true &&
	                    Base.NZDCHF_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCHF_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP1_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP1_OCO1");
	                         Base.NZDCHF_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDCHF_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP2_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP2_OCO1");
	                         Base.NZDCHF_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.NZDCHF_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP3_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP3_OCO1");
	                         Base.NZDCHF_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDCHF_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP4_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP4_OCO1");
	                         Base.NZDCHF_OCO1_EO4_DOWN_S2 = false;

							Base.NZDCHF_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.NZDCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (NZDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDCHF_DOWN_S2 && 
	                    Base.NZDCHF_OCO2_DOWN_S2_IsReady == true &&
	                    Base.NZDCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDCHF_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCHF_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP1_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP1_OCO2");
	                         Base.NZDCHF_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDCHF_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP2_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP2_OCO2");
	                         Base.NZDCHF_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.NZDCHF_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP3_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP3_OCO2");
	                         Base.NZDCHF_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDCHF_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP4_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP4_OCO2");
	                         Base.NZDCHF_OCO2_EO4_DOWN_S2 = false;

							Base.NZDCHF_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.NZDCHF_OCO2_DOWN_S2_IsReady == false && Base.NZDCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (NZDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDCHF_DOWN_S2 &&
	                    Base.NZDCHF_OCO3_DOWN_S2_IsReady == true &&
	                    Base.NZDCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.NZDCHF_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCHF_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP1_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP1_OCO3");
	                         Base.NZDCHF_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDCHF_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP2_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP2_OCO3");
	                         Base.NZDCHF_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.NZDCHF_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP3_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP3_OCO3");
	                         Base.NZDCHF_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDCHF_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP4_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP4_OCO3");
	                         Base.NZDCHF_OCO3_EO4_DOWN_S2 = false;

							Base.NZDCHF_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.NZDCHF_OCO3_DOWN_S2_IsReady == false && Base.NZDCHF_OCO2_DOWN_S2_IsReady == false && Base.NZDCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (NZDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDCHF_DOWN_S2 && 
	                    Base.NZDCHF_OCO4_DOWN_S2_IsReady == true &&
	                    Base.NZDCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.NZDCHF_OCO3_DOWN_S2_IsReady == false &&
	                    Base.NZDCHF_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCHF_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP1_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP1_OCO4");
	                         Base.NZDCHF_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDCHF_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP2_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP2_OCO4");
	                         Base.NZDCHF_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.NZDCHF_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP3_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP3_OCO4");
	                         Base.NZDCHF_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDCHF_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCHF_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCHF_quantity_TP4_DOWN_S2, false,"NZDCHF_DOWN_S2_Entry_TP4_OCO4");
	                         Base.NZDCHF_OCO4_EO4_DOWN_S2 = false;

							Base.NZDCHF_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.NZDCHF_OCO4_DOWN_S2_IsReady == false && Base.NZDCHF_OCO3_DOWN_S2_IsReady == false && Base.NZDCHF_OCO2_DOWN_S2_IsReady == false && Base.NZDCHF_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURUSD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURUSD_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(x=>x.Tag.Contains("EURUSD_UP_S2_OCO1")))
			{
				Base.EURUSD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURUSD_UP_S2_OCO2")))
			{
				Base.EURUSD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURUSD_UP_S2_OCO3")))
			{
				Base.EURUSD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURUSD_UP_S2_OCO4")))
			{
				Base.EURUSD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURUSD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.EURUSD_OCO1_EO1_UP_S2)
	                Base.EURUSD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.EURUSD_OCO1_EO2_UP_S2)
	                Base.EURUSD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO1_EO3_UP_S2)
	                Base.EURUSD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO1_EO4_UP_S2)
	                Base.EURUSD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO1_EO5_UP_S2)
	                Base.EURUSD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO1_EO6_UP_S2)
	                Base.EURUSD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURUSD_OCO1S1_UP_S2 = 0;
		                for (; EURUSD_OCO1S1_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets1.Count; EURUSD_OCO1S1_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO1Sets1[EURUSD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO1Sets1[EURUSD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.EURUSD_UP_S2_OCO1Sets1.Clear();
		                        EURUSD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURUSD_OCO1S2_UP_S2 = 0;
		                for (; EURUSD_OCO1S2_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets2.Count; EURUSD_OCO1S2_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO1Sets2[EURUSD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO1Sets2[EURUSD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.EURUSD_UP_S2_OCO1Sets2.Clear();
		                        EURUSD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO1S3_UP_S2 = 0;
		                for (; EURUSD_OCO1S3_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets3.Count; EURUSD_OCO1S3_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO1Sets3[EURUSD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO1Sets3[EURUSD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.EURUSD_UP_S2_OCO1Sets3.Clear();
		                        EURUSD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO1S4_UP_S2 = 0;
		                for (; EURUSD_OCO1S4_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets4.Count; EURUSD_OCO1S4_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO1Sets4[EURUSD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO1Sets4[EURUSD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.EURUSD_UP_S2_OCO1Sets4.Clear();
		                        EURUSD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO1S5_UP_S2 = 0;
		                for (; EURUSD_OCO1S5_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets5.Count; EURUSD_OCO1S5_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO1Sets5[EURUSD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO1Sets5[EURUSD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.EURUSD_UP_S2_OCO1Sets5.Clear();
		                        EURUSD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO1S6_UP_S2 = 0;
		                for (; EURUSD_OCO1S6_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets6.Count; EURUSD_OCO1S6_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO1Sets6[EURUSD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO1Sets6[EURUSD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.EURUSD_UP_S2_OCO1Sets6.Clear();
		                        EURUSD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURUSD_OCO2_EO1_UP_S2)
                	Base.EURUSD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.EURUSD_OCO2_EO2_UP_S2)
	                Base.EURUSD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO2_EO3_UP_S2)
	                Base.EURUSD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO2_EO4_UP_S2)
	                Base.EURUSD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO2_EO5_UP_S2)
	                Base.EURUSD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO2_EO6_UP_S2)
	                Base.EURUSD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURUSD_OCO2S1_UP_S2 = 0;
		                for (; EURUSD_OCO2S1_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets1.Count; EURUSD_OCO2S1_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO2Sets1[EURUSD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO2Sets1[EURUSD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.EURUSD_UP_S2_OCO2Sets1.Clear();
		                        EURUSD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURUSD_OCO2S2_UP_S2 = 0;
		                for (; EURUSD_OCO2S2_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets2.Count; EURUSD_OCO2S2_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO2Sets2[EURUSD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO2Sets2[EURUSD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.EURUSD_UP_S2_OCO2Sets2.Clear();
		                        EURUSD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO2S3_UP_S2 = 0;
		                for (; EURUSD_OCO2S3_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets3.Count; EURUSD_OCO2S3_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO2Sets3[EURUSD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO2Sets3[EURUSD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.EURUSD_UP_S2_OCO2Sets3.Clear();
		                        EURUSD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO2S4_UP_S2 = 0;
		                for (; EURUSD_OCO2S4_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets4.Count; EURUSD_OCO2S4_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO2Sets4[EURUSD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO2Sets4[EURUSD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.EURUSD_UP_S2_OCO2Sets4.Clear();
		                        EURUSD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO2S5_UP_S2 = 0;
		                for (; EURUSD_OCO2S5_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets5.Count; EURUSD_OCO2S5_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO2Sets5[EURUSD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO2Sets5[EURUSD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.EURUSD_UP_S2_OCO2Sets5.Clear();
		                        EURUSD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO2S6_UP_S2 = 0;
		                for (; EURUSD_OCO2S6_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets6.Count; EURUSD_OCO2S6_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO2Sets6[EURUSD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO2Sets6[EURUSD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.EURUSD_UP_S2_OCO2Sets6.Clear();
		                        EURUSD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURUSD_OCO3_EO1_UP_S2)
            		Base.EURUSD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.EURUSD_OCO3_EO2_UP_S2)
	                Base.EURUSD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO3_EO3_UP_S2)
	                Base.EURUSD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO3_EO4_UP_S2)
	                Base.EURUSD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO3_EO5_UP_S2)
	                Base.EURUSD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO3_EO6_UP_S2)
	                Base.EURUSD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURUSD_OCO3S1_UP_S2 = 0;
		                for (; EURUSD_OCO3S1_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets1.Count; EURUSD_OCO3S1_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO3Sets1[EURUSD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO3Sets1[EURUSD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.EURUSD_UP_S2_OCO3Sets1.Clear();
		                        EURUSD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURUSD_OCO3S2_UP_S2 = 0;
		                for (; EURUSD_OCO3S2_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets2.Count; EURUSD_OCO3S2_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO3Sets2[EURUSD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO3Sets2[EURUSD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.EURUSD_UP_S2_OCO3Sets2.Clear();
		                        EURUSD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO3S3_UP_S2 = 0;
		                for (; EURUSD_OCO3S3_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets3.Count; EURUSD_OCO3S3_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO3Sets3[EURUSD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO3Sets3[EURUSD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.EURUSD_UP_S2_OCO3Sets3.Clear();
		                        EURUSD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO3S4_UP_S2 = 0;
		                for (; EURUSD_OCO3S4_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets4.Count; EURUSD_OCO3S4_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO3Sets4[EURUSD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO3Sets4[EURUSD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.EURUSD_UP_S2_OCO3Sets4.Clear();
		                        EURUSD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO3S5_UP_S2 = 0;
		                for (; EURUSD_OCO3S5_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets5.Count; EURUSD_OCO3S5_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO3Sets5[EURUSD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO3Sets5[EURUSD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.EURUSD_UP_S2_OCO3Sets5.Clear();
		                        EURUSD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO3S6_UP_S2 = 0;
		                for (; EURUSD_OCO3S6_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets6.Count; EURUSD_OCO3S6_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO3Sets6[EURUSD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO3Sets6[EURUSD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.EURUSD_UP_S2_OCO3Sets6.Clear();
		                        EURUSD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURUSD_OCO4_EO1_UP_S2)
            		Base.EURUSD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.EURUSD_OCO4_EO2_UP_S2)
	                Base.EURUSD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO4_EO3_UP_S2)
	                Base.EURUSD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO4_EO4_UP_S2)
	                Base.EURUSD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO4_EO5_UP_S2)
	                Base.EURUSD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO4_EO6_UP_S2)
	                Base.EURUSD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURUSD_OCO4S1_UP_S2 = 0;
		                for (; EURUSD_OCO4S1_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets1.Count; EURUSD_OCO4S1_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO4Sets1[EURUSD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO4Sets1[EURUSD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.EURUSD_UP_S2_OCO4Sets1.Clear();
		                        EURUSD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURUSD_OCO4S2_UP_S2 = 0;
		                for (; EURUSD_OCO4S2_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets2.Count; EURUSD_OCO4S2_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO4Sets2[EURUSD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO4Sets2[EURUSD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.EURUSD_UP_S2_OCO4Sets2.Clear();
		                        EURUSD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO4S3_UP_S2 = 0;
		                for (; EURUSD_OCO4S3_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets3.Count; EURUSD_OCO4S3_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO4Sets3[EURUSD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO4Sets3[EURUSD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.EURUSD_UP_S2_OCO4Sets3.Clear();
		                        EURUSD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO4S4_UP_S2 = 0;
		                for (; EURUSD_OCO4S4_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets4.Count; EURUSD_OCO4S4_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO4Sets4[EURUSD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO4Sets4[EURUSD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.EURUSD_UP_S2_OCO4Sets4.Clear();
		                        EURUSD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO4S5_UP_S2 = 0;
		                for (; EURUSD_OCO4S5_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets5.Count; EURUSD_OCO4S5_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO4Sets5[EURUSD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO4Sets5[EURUSD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.EURUSD_UP_S2_OCO4Sets5.Clear();
		                        EURUSD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO4S6_UP_S2 = 0;
		                for (; EURUSD_OCO4S6_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets6.Count; EURUSD_OCO4S6_UP_S2++)
		                    if (Base.EURUSD_UP_S2_OCO4Sets6[EURUSD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_UP_S2_OCO4Sets6[EURUSD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.EURUSD_UP_S2_OCO4Sets6.Clear();
		                        EURUSD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_EURUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURUSD_UP_S2 = DOWM_EURUSD_UP_S2 || DOWT_EURUSD_UP_S2 || DOWW_EURUSD_UP_S2 || DOWTH_EURUSD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURUSD"))
	            	{
	            		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.EURUSD_OCO1_UP_S2_IsReady == false ||
	                    	Base.EURUSD_OCO2_UP_S2_IsReady == false ||
	                    	Base.EURUSD_OCO3_UP_S2_IsReady == false ||
	                    	Base.EURUSD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.EURUSD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.EURUSD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.EURUSD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.EURUSD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURUSD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.EURUSD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.EURUSD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.EURUSD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	EURUSD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											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.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*3
				                										
				                										)
			                							
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	EURUSD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*3
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	EURUSD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
		
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*3
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (EURUSD_Signal_Condition_UP_1)
	                	{
	                    	EURUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURUSD_Signal_Condition_UP_2)
	                	{
	                    	EURUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURUSD_Signal_Condition_UP_3)
	                	{
	                    	EURUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (EURUSD_Signal_Condition_UP_1)
	                	{
	                    	EURUSD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (EURUSD_Signal_Condition_UP_2)
	                	{
	                    	EURUSD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (EURUSD_Signal_Condition_UP_3)
	                	{
	                    	EURUSD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    EURUSD_UP_S2_TP2 =  EURUSD_UP_S2_SL * 0;
	                    EURUSD_UP_S2_TP3 =  EURUSD_UP_S2_SL * 0;
	                    EURUSD_UP_S2_TP4 =  EURUSD_UP_S2_SL * 0;
	                    EURUSD_UP_S2_TP5 =  EURUSD_UP_S2_SL * 0;
	                    EURUSD_UP_S2_TP6 =  EURUSD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURUSD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURUSD_quantity_SL_UP_S2 = EURUSD_quantity_UP_S2;
	                    EURUSD_quantity_TP1_UP_S2 = (int)Math.Floor(EURUSD_quantity_UP_S2 * 1m);
	                    EURUSD_quantity_TP2_UP_S2 = (int)Math.Floor(EURUSD_quantity_TP1_UP_S2 * 0m);
	                    EURUSD_quantity_TP3_UP_S2 = (int)Math.Floor(EURUSD_quantity_TP2_UP_S2 * 0m);
	                    EURUSD_quantity_TP4_UP_S2 = (int)Math.Floor(EURUSD_quantity_TP3_UP_S2 * 0m);
	                    EURUSD_quantity_TP5_UP_S2 = (int)Math.Floor(EURUSD_quantity_TP4_UP_S2 * 0m);
	                    EURUSD_quantity_TP6_UP_S2 = (int)Math.Floor(EURUSD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((EURUSD_Signal_Condition_UP_1 || EURUSD_Signal_Condition_UP_2 || EURUSD_Signal_Condition_UP_3)  && 
	                    DOWR_EURUSD_UP_S2 && 
	                    Base.EURUSD_OCO1_UP_S2_IsReady == true &&
	                    Base.EURUSD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURUSD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP1_UP_S2, false,"EURUSD_UP_S2_Entry_TP1_OCO1");
	                         Base.EURUSD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.EURUSD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP2_UP_S2, false,"EURUSD_UP_S2_Entry_TP2_OCO1");
	                         Base.EURUSD_OCO1_EO2_UP_S2 = false;
	
	                         Base.EURUSD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP3_UP_S2, false,"EURUSD_UP_S2_Entry_TP3_OCO1");
	                         Base.EURUSD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.EURUSD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP4_UP_S2, false,"EURUSD_UP_S2_Entry_TP4_OCO1");
	                         Base.EURUSD_OCO1_EO4_UP_S2 = false;

							Base.EURUSD_OCO1_UP_S2_IsReady = false;
							
							if (Base.EURUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((EURUSD_Signal_Condition_UP_1 || EURUSD_Signal_Condition_UP_2 || EURUSD_Signal_Condition_UP_3)  && 
	                    DOWR_EURUSD_UP_S2 && 
	                    Base.EURUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURUSD_OCO2_UP_S2_IsReady == true &&
	                    Base.EURUSD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURUSD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP1_UP_S2, false,"EURUSD_UP_S2_Entry_TP1_OCO2");
	                         Base.EURUSD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.EURUSD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP2_UP_S2, false,"EURUSD_UP_S2_Entry_TP2_OCO2");
	                         Base.EURUSD_OCO2_EO2_UP_S2 = false;
	
	                         Base.EURUSD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP3_UP_S2, false,"EURUSD_UP_S2_Entry_TP3_OCO2");
	                         Base.EURUSD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.EURUSD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP4_UP_S2, false,"EURUSD_UP_S2_Entry_TP4_OCO2");
	                         Base.EURUSD_OCO2_EO4_UP_S2 = false;

							Base.EURUSD_OCO2_UP_S2_IsReady = false;
							
							if (Base.EURUSD_OCO2_UP_S2_IsReady == false && Base.EURUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((EURUSD_Signal_Condition_UP_1 || EURUSD_Signal_Condition_UP_2 || EURUSD_Signal_Condition_UP_3)  && 
	                    DOWR_EURUSD_UP_S2 &&
	                    Base.EURUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURUSD_OCO2_UP_S2_IsReady == false &&
	                    Base.EURUSD_OCO3_UP_S2_IsReady == true &&
	                    Base.EURUSD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURUSD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP1_UP_S2, false,"EURUSD_UP_S2_Entry_TP1_OCO3");
	                         Base.EURUSD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.EURUSD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP2_UP_S2, false,"EURUSD_UP_S2_Entry_TP2_OCO3");
	                         Base.EURUSD_OCO3_EO2_UP_S2 = false;
	
	                         Base.EURUSD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP3_UP_S2, false,"EURUSD_UP_S2_Entry_TP3_OCO3");
	                         Base.EURUSD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.EURUSD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP4_UP_S2, false,"EURUSD_UP_S2_Entry_TP4_OCO3");
	                         Base.EURUSD_OCO3_EO4_UP_S2 = false;

							Base.EURUSD_OCO3_UP_S2_IsReady = false;
							
							if (Base.EURUSD_OCO3_UP_S2_IsReady == false && Base.EURUSD_OCO2_UP_S2_IsReady == false && Base.EURUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((EURUSD_Signal_Condition_UP_1 || EURUSD_Signal_Condition_UP_2 || EURUSD_Signal_Condition_UP_3)  && 
	                    DOWR_EURUSD_UP_S2 && 
	                    Base.EURUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURUSD_OCO2_UP_S2_IsReady == false &&
	                    Base.EURUSD_OCO3_UP_S2_IsReady == false &&
	                    Base.EURUSD_OCO4_UP_S2_IsReady == true &&
	                    Base.EURUSD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURUSD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP1_UP_S2, false,"EURUSD_UP_S2_Entry_TP1_OCO4");
	                         Base.EURUSD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.EURUSD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP2_UP_S2, false,"EURUSD_UP_S2_Entry_TP2_OCO4");
	                         Base.EURUSD_OCO4_EO2_UP_S2 = false;
	
	                         Base.EURUSD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP3_UP_S2, false,"EURUSD_UP_S2_Entry_TP3_OCO4");
	                         Base.EURUSD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.EURUSD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURUSD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP4_UP_S2, false,"EURUSD_UP_S2_Entry_TP4_OCO4");
	                         Base.EURUSD_OCO4_EO4_UP_S2 = false;

							Base.EURUSD_OCO4_UP_S2_IsReady = false;
							
							if (Base.EURUSD_OCO4_UP_S2_IsReady == false && Base.EURUSD_OCO3_UP_S2_IsReady == false && Base.EURUSD_OCO2_UP_S2_IsReady == false && Base.EURUSD_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_NZDJPY_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_NZDJPY_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(x=>x.Tag.Contains("NZDJPY_UP_S2_OCO1")))
			{
				Base.NZDJPY_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDJPY_UP_S2_OCO2")))
			{
				Base.NZDJPY_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDJPY_UP_S2_OCO3")))
			{
				Base.NZDJPY_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDJPY_UP_S2_OCO4")))
			{
				Base.NZDJPY_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("NZDJPY_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.NZDJPY_OCO1_EO1_UP_S2)
	                Base.NZDJPY_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDJPY_OCO1_EO2_UP_S2)
	                Base.NZDJPY_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO1_EO3_UP_S2)
	                Base.NZDJPY_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO1_EO4_UP_S2)
	                Base.NZDJPY_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO1_EO5_UP_S2)
	                Base.NZDJPY_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO1_EO6_UP_S2)
	                Base.NZDJPY_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDJPY_OCO1S1_UP_S2 = 0;
		                for (; NZDJPY_OCO1S1_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets1.Count; NZDJPY_OCO1S1_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO1Sets1[NZDJPY_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO1Sets1[NZDJPY_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_1__Time out_OCO1");
		                        Base.NZDJPY_UP_S2_OCO1Sets1.Clear();
		                        NZDJPY_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDJPY_OCO1S2_UP_S2 = 0;
		                for (; NZDJPY_OCO1S2_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets2.Count; NZDJPY_OCO1S2_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO1Sets2[NZDJPY_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO1Sets2[NZDJPY_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_2__Time out_OCO1");
		                        Base.NZDJPY_UP_S2_OCO1Sets2.Clear();
		                        NZDJPY_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO1S3_UP_S2 = 0;
		                for (; NZDJPY_OCO1S3_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets3.Count; NZDJPY_OCO1S3_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO1Sets3[NZDJPY_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO1Sets3[NZDJPY_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_3__Time out_OCO1");
		                        Base.NZDJPY_UP_S2_OCO1Sets3.Clear();
		                        NZDJPY_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO1S4_UP_S2 = 0;
		                for (; NZDJPY_OCO1S4_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets4.Count; NZDJPY_OCO1S4_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO1Sets4[NZDJPY_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO1Sets4[NZDJPY_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_4__Time out_OCO1");
		                        Base.NZDJPY_UP_S2_OCO1Sets4.Clear();
		                        NZDJPY_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO1S5_UP_S2 = 0;
		                for (; NZDJPY_OCO1S5_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets5.Count; NZDJPY_OCO1S5_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO1Sets5[NZDJPY_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO1Sets5[NZDJPY_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_5__Time out_OCO1");
		                        Base.NZDJPY_UP_S2_OCO1Sets5.Clear();
		                        NZDJPY_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO1S6_UP_S2 = 0;
		                for (; NZDJPY_OCO1S6_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets6.Count; NZDJPY_OCO1S6_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO1Sets6[NZDJPY_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO1Sets6[NZDJPY_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_6__Time out_OCO1");
		                        Base.NZDJPY_UP_S2_OCO1Sets6.Clear();
		                        NZDJPY_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.NZDJPY_OCO2_EO1_UP_S2)
                	Base.NZDJPY_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDJPY_OCO2_EO2_UP_S2)
	                Base.NZDJPY_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO2_EO3_UP_S2)
	                Base.NZDJPY_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO2_EO4_UP_S2)
	                Base.NZDJPY_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO2_EO5_UP_S2)
	                Base.NZDJPY_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO2_EO6_UP_S2)
	                Base.NZDJPY_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDJPY_OCO2S1_UP_S2 = 0;
		                for (; NZDJPY_OCO2S1_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets1.Count; NZDJPY_OCO2S1_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO2Sets1[NZDJPY_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO2Sets1[NZDJPY_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_1__Time out_OCO2");
		                        Base.NZDJPY_UP_S2_OCO2Sets1.Clear();
		                        NZDJPY_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDJPY_OCO2S2_UP_S2 = 0;
		                for (; NZDJPY_OCO2S2_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets2.Count; NZDJPY_OCO2S2_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO2Sets2[NZDJPY_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO2Sets2[NZDJPY_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_2__Time out_OCO2");
		                        Base.NZDJPY_UP_S2_OCO2Sets2.Clear();
		                        NZDJPY_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO2S3_UP_S2 = 0;
		                for (; NZDJPY_OCO2S3_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets3.Count; NZDJPY_OCO2S3_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO2Sets3[NZDJPY_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO2Sets3[NZDJPY_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_3__Time out_OCO2");
		                        Base.NZDJPY_UP_S2_OCO2Sets3.Clear();
		                        NZDJPY_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO2S4_UP_S2 = 0;
		                for (; NZDJPY_OCO2S4_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets4.Count; NZDJPY_OCO2S4_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO2Sets4[NZDJPY_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO2Sets4[NZDJPY_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_4__Time out_OCO2");
		                        Base.NZDJPY_UP_S2_OCO2Sets4.Clear();
		                        NZDJPY_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO2S5_UP_S2 = 0;
		                for (; NZDJPY_OCO2S5_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets5.Count; NZDJPY_OCO2S5_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO2Sets5[NZDJPY_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO2Sets5[NZDJPY_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_5__Time out_OCO2");
		                        Base.NZDJPY_UP_S2_OCO2Sets5.Clear();
		                        NZDJPY_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO2S6_UP_S2 = 0;
		                for (; NZDJPY_OCO2S6_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets6.Count; NZDJPY_OCO2S6_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO2Sets6[NZDJPY_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO2Sets6[NZDJPY_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_6__Time out_OCO2");
		                        Base.NZDJPY_UP_S2_OCO2Sets6.Clear();
		                        NZDJPY_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.NZDJPY_OCO3_EO1_UP_S2)
            		Base.NZDJPY_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDJPY_OCO3_EO2_UP_S2)
	                Base.NZDJPY_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO3_EO3_UP_S2)
	                Base.NZDJPY_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO3_EO4_UP_S2)
	                Base.NZDJPY_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO3_EO5_UP_S2)
	                Base.NZDJPY_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO3_EO6_UP_S2)
	                Base.NZDJPY_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDJPY_OCO3S1_UP_S2 = 0;
		                for (; NZDJPY_OCO3S1_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets1.Count; NZDJPY_OCO3S1_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO3Sets1[NZDJPY_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO3Sets1[NZDJPY_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_1__Time out_OCO3");
		                        Base.NZDJPY_UP_S2_OCO3Sets1.Clear();
		                        NZDJPY_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDJPY_OCO3S2_UP_S2 = 0;
		                for (; NZDJPY_OCO3S2_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets2.Count; NZDJPY_OCO3S2_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO3Sets2[NZDJPY_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO3Sets2[NZDJPY_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_2__Time out_OCO3");
		                        Base.NZDJPY_UP_S2_OCO3Sets2.Clear();
		                        NZDJPY_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO3S3_UP_S2 = 0;
		                for (; NZDJPY_OCO3S3_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets3.Count; NZDJPY_OCO3S3_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO3Sets3[NZDJPY_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO3Sets3[NZDJPY_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_3__Time out_OCO3");
		                        Base.NZDJPY_UP_S2_OCO3Sets3.Clear();
		                        NZDJPY_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO3S4_UP_S2 = 0;
		                for (; NZDJPY_OCO3S4_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets4.Count; NZDJPY_OCO3S4_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO3Sets4[NZDJPY_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO3Sets4[NZDJPY_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_4__Time out_OCO3");
		                        Base.NZDJPY_UP_S2_OCO3Sets4.Clear();
		                        NZDJPY_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO3S5_UP_S2 = 0;
		                for (; NZDJPY_OCO3S5_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets5.Count; NZDJPY_OCO3S5_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO3Sets5[NZDJPY_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO3Sets5[NZDJPY_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_5__Time out_OCO3");
		                        Base.NZDJPY_UP_S2_OCO3Sets5.Clear();
		                        NZDJPY_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO3S6_UP_S2 = 0;
		                for (; NZDJPY_OCO3S6_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets6.Count; NZDJPY_OCO3S6_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO3Sets6[NZDJPY_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO3Sets6[NZDJPY_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_6__Time out_OCO3");
		                        Base.NZDJPY_UP_S2_OCO3Sets6.Clear();
		                        NZDJPY_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDJPY_OCO4_EO1_UP_S2)
            		Base.NZDJPY_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDJPY_OCO4_EO2_UP_S2)
	                Base.NZDJPY_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO4_EO3_UP_S2)
	                Base.NZDJPY_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO4_EO4_UP_S2)
	                Base.NZDJPY_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO4_EO5_UP_S2)
	                Base.NZDJPY_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDJPY_OCO4_EO6_UP_S2)
	                Base.NZDJPY_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDJPY_OCO4S1_UP_S2 = 0;
		                for (; NZDJPY_OCO4S1_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets1.Count; NZDJPY_OCO4S1_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO4Sets1[NZDJPY_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO4Sets1[NZDJPY_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_1__Time out_OCO4");
		                        Base.NZDJPY_UP_S2_OCO4Sets1.Clear();
		                        NZDJPY_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDJPY_OCO4S2_UP_S2 = 0;
		                for (; NZDJPY_OCO4S2_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets2.Count; NZDJPY_OCO4S2_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO4Sets2[NZDJPY_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO4Sets2[NZDJPY_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_2__Time out_OCO4");
		                        Base.NZDJPY_UP_S2_OCO4Sets2.Clear();
		                        NZDJPY_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO4S3_UP_S2 = 0;
		                for (; NZDJPY_OCO4S3_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets3.Count; NZDJPY_OCO4S3_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO4Sets3[NZDJPY_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO4Sets3[NZDJPY_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_3__Time out_OCO4");
		                        Base.NZDJPY_UP_S2_OCO4Sets3.Clear();
		                        NZDJPY_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDJPY_OCO4S4_UP_S2 = 0;
		                for (; NZDJPY_OCO4S4_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets4.Count; NZDJPY_OCO4S4_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO4Sets4[NZDJPY_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO4Sets4[NZDJPY_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_4__Time out_OCO4");
		                        Base.NZDJPY_UP_S2_OCO4Sets4.Clear();
		                        NZDJPY_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO4S5_UP_S2 = 0;
		                for (; NZDJPY_OCO4S5_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets5.Count; NZDJPY_OCO4S5_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO4Sets5[NZDJPY_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO4Sets5[NZDJPY_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_5__Time out_OCO4");
		                        Base.NZDJPY_UP_S2_OCO4Sets5.Clear();
		                        NZDJPY_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDJPY_OCO4S6_UP_S2 = 0;
		                for (; NZDJPY_OCO4S6_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets6.Count; NZDJPY_OCO4S6_UP_S2++)
		                    if (Base.NZDJPY_UP_S2_OCO4Sets6[NZDJPY_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDJPY_UP_S2_OCO4Sets6[NZDJPY_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("NZDJPY", order.Quantity, false, "NZDJPY_UP_S2_Entry_6__Time out_OCO4");
		                        Base.NZDJPY_UP_S2_OCO4Sets6.Clear();
		                        NZDJPY_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_NZDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_NZDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_NZDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_NZDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_NZDJPY_UP_S2 = DOWM_NZDJPY_UP_S2 || DOWT_NZDJPY_UP_S2 || DOWW_NZDJPY_UP_S2 || DOWTH_NZDJPY_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("NZDJPY") && SY1D.Symbol.ID.Market == Market.FXCM)
	            	{
	            		if(SY1D.BQ[0].Open != 0)
	            		{
	            			algorithm.Debug("ID : " + SY1D.Symbol.ID.Market);
	            		}
	            		
	            		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.NZDJPY_OCO1_UP_S2_IsReady == false ||
	                    	Base.NZDJPY_OCO2_UP_S2_IsReady == false ||
	                    	Base.NZDJPY_OCO3_UP_S2_IsReady == false ||
	                    	Base.NZDJPY_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.NZDJPY_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDJPY_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDJPY_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDJPY_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.NZDJPY_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.NZDJPY_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.NZDJPY_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.NZDJPY_OCO4_UP_S2_Monthly_IsReady = true;
                    	}

	                	NZDJPY_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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.Yen_Min_SPRD
	                									);
	                									
	                	NZDJPY_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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.Yen_Min_SPRD
	                									);
	                									
	                									
	                	NZDJPY_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[0] < pricesM_BID_Low[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.Yen_Min_SPRD
	                									);
	                									
	                	if (NZDJPY_Signal_Condition_UP_1)
	                	{
	                    	NZDJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (NZDJPY_Signal_Condition_UP_2)
	                	{
	                    	NZDJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (NZDJPY_Signal_Condition_UP_3)
	                	{
	                    	NZDJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (NZDJPY_Signal_Condition_UP_1)
	                	{
	                    	NZDJPY_UP_S2_TP1  =  Base.Yen_TP_1 ;
	                	}
	                	
	                	if (NZDJPY_Signal_Condition_UP_2)
	                	{
	                    	NZDJPY_UP_S2_TP1  =  Base.Yen_TP_2 ;
	                	}
	                	
	                	if (NZDJPY_Signal_Condition_UP_3)
	                	{
	                    	NZDJPY_UP_S2_TP1  =  Base.Yen_TP_3 ;
	                	}

	                    NZDJPY_UP_S2_TP2 =  NZDJPY_UP_S2_SL * 0;
	                    NZDJPY_UP_S2_TP3 =  NZDJPY_UP_S2_SL * 0;
	                    NZDJPY_UP_S2_TP4 =  NZDJPY_UP_S2_SL * 0;
	                    NZDJPY_UP_S2_TP5 =  NZDJPY_UP_S2_SL * 0;
	                    NZDJPY_UP_S2_TP6 =  NZDJPY_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    NZDJPY_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    NZDJPY_quantity_SL_UP_S2 = NZDJPY_quantity_UP_S2;
	                    NZDJPY_quantity_TP1_UP_S2 = (int)Math.Floor(NZDJPY_quantity_UP_S2 * 1m);
	                    NZDJPY_quantity_TP2_UP_S2 = (int)Math.Floor(NZDJPY_quantity_TP1_UP_S2 * 0m);
	                    NZDJPY_quantity_TP3_UP_S2 = (int)Math.Floor(NZDJPY_quantity_TP2_UP_S2 * 0m);
	                    NZDJPY_quantity_TP4_UP_S2 = (int)Math.Floor(NZDJPY_quantity_TP3_UP_S2 * 0m);
	                    NZDJPY_quantity_TP5_UP_S2 = (int)Math.Floor(NZDJPY_quantity_TP4_UP_S2 * 0m);
	                    NZDJPY_quantity_TP6_UP_S2 = (int)Math.Floor(NZDJPY_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((NZDJPY_Signal_Condition_UP_1 || NZDJPY_Signal_Condition_UP_2 || NZDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_NZDJPY_UP_S2 && 
	                    Base.NZDJPY_OCO1_UP_S2_IsReady == true &&
	                    Base.NZDJPY_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDJPY_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP1_UP_S2, false,"NZDJPY_UP_S2_Entry_TP1_OCO1");
	                         Base.NZDJPY_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.NZDJPY_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP2_UP_S2, false,"NZDJPY_UP_S2_Entry_TP2_OCO1");
	                         Base.NZDJPY_OCO1_EO2_UP_S2 = false;
	
	                         Base.NZDJPY_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP3_UP_S2, false,"NZDJPY_UP_S2_Entry_TP3_OCO1");
	                         Base.NZDJPY_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.NZDJPY_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP4_UP_S2, false,"NZDJPY_UP_S2_Entry_TP4_OCO1");
	                         Base.NZDJPY_OCO1_EO4_UP_S2 = false;

							Base.NZDJPY_OCO1_UP_S2_IsReady = false;
							
							if (Base.NZDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco2:
	                    if ((NZDJPY_Signal_Condition_UP_1 || NZDJPY_Signal_Condition_UP_2 || NZDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_NZDJPY_UP_S2 && 
	                    Base.NZDJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDJPY_OCO2_UP_S2_IsReady == true &&
	                    Base.NZDJPY_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDJPY_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP1_UP_S2, false,"NZDJPY_UP_S2_Entry_TP1_OCO2");
	                         Base.NZDJPY_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.NZDJPY_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP2_UP_S2, false,"NZDJPY_UP_S2_Entry_TP2_OCO2");
	                         Base.NZDJPY_OCO2_EO2_UP_S2 = false;
	
	                         Base.NZDJPY_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP3_UP_S2, false,"NZDJPY_UP_S2_Entry_TP3_OCO2");
	                         Base.NZDJPY_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.NZDJPY_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP4_UP_S2, false,"NZDJPY_UP_S2_Entry_TP4_OCO2");
	                         Base.NZDJPY_OCO2_EO4_UP_S2 = false;

							Base.NZDJPY_OCO2_UP_S2_IsReady = false;
							
							if (Base.NZDJPY_OCO2_UP_S2_IsReady == false && Base.NZDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco3:
	                    if ((NZDJPY_Signal_Condition_UP_1 || NZDJPY_Signal_Condition_UP_2 || NZDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_NZDJPY_UP_S2 &&
	                    Base.NZDJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.NZDJPY_OCO3_UP_S2_IsReady == true &&
	                    Base.NZDJPY_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDJPY_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP1_UP_S2, false,"NZDJPY_UP_S2_Entry_TP1_OCO3");
	                         Base.NZDJPY_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.NZDJPY_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP2_UP_S2, false,"NZDJPY_UP_S2_Entry_TP2_OCO3");
	                         Base.NZDJPY_OCO3_EO2_UP_S2 = false;
	
	                         Base.NZDJPY_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP3_UP_S2, false,"NZDJPY_UP_S2_Entry_TP3_OCO3");
	                         Base.NZDJPY_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.NZDJPY_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP4_UP_S2, false,"NZDJPY_UP_S2_Entry_TP4_OCO3");
	                         Base.NZDJPY_OCO3_EO4_UP_S2 = false;

							Base.NZDJPY_OCO3_UP_S2_IsReady = false;
							
							if (Base.NZDJPY_OCO3_UP_S2_IsReady == false && Base.NZDJPY_OCO2_UP_S2_IsReady == false && Base.NZDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco4:
	                    if ((NZDJPY_Signal_Condition_UP_1 || NZDJPY_Signal_Condition_UP_2 || NZDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_NZDJPY_UP_S2 && 
	                    Base.NZDJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.NZDJPY_OCO3_UP_S2_IsReady == false &&
	                    Base.NZDJPY_OCO4_UP_S2_IsReady == true &&
	                    Base.NZDJPY_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDJPY_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP1_UP_S2, false,"NZDJPY_UP_S2_Entry_TP1_OCO4");
	                         Base.NZDJPY_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.NZDJPY_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP2_UP_S2, false,"NZDJPY_UP_S2_Entry_TP2_OCO4");
	                         Base.NZDJPY_OCO4_EO2_UP_S2 = false;
	
	                         Base.NZDJPY_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP3_UP_S2, false,"NZDJPY_UP_S2_Entry_TP3_OCO4");
	                         Base.NZDJPY_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.NZDJPY_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDJPY_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDJPY_quantity_TP4_UP_S2, false,"NZDJPY_UP_S2_Entry_TP4_OCO4");
	                         Base.NZDJPY_OCO4_EO4_UP_S2 = false;

							Base.NZDJPY_OCO4_UP_S2_IsReady = false;
							
							if (Base.NZDJPY_OCO4_UP_S2_IsReady == false && Base.NZDJPY_OCO3_UP_S2_IsReady == false && Base.NZDJPY_OCO2_UP_S2_IsReady == false && Base.NZDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_NZDCAD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_NZDCAD_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("NZDCAD_DOWN_S2_OCO1")))
			{
				Base.NZDCAD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCAD_DOWN_S2_OCO2")))
			{
				Base.NZDCAD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCAD_DOWN_S2_OCO3")))
			{
				Base.NZDCAD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCAD_DOWN_S2_OCO4")))
			{
				Base.NZDCAD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("NZDCAD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.NZDCAD_OCO1_EO1_DOWN_S2)
	                Base.NZDCAD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDCAD_OCO1_EO2_DOWN_S2)
	                Base.NZDCAD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO1_EO3_DOWN_S2)
	                Base.NZDCAD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO1_EO4_DOWN_S2)
	                Base.NZDCAD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO1_EO5_DOWN_S2)
	                Base.NZDCAD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO1_EO6_DOWN_S2)
	                Base.NZDCAD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCAD_OCO1S1_DOWN_S2 = 0;
		                for (; NZDCAD_OCO1S1_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets1.Count; NZDCAD_OCO1S1_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO1Sets1[NZDCAD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO1Sets1[NZDCAD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.NZDCAD_DOWN_S2_OCO1Sets1.Clear();
		                        NZDCAD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCAD_OCO1S2_DOWN_S2 = 0;
		                for (; NZDCAD_OCO1S2_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets2.Count; NZDCAD_OCO1S2_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO1Sets2[NZDCAD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO1Sets2[NZDCAD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.NZDCAD_DOWN_S2_OCO1Sets2.Clear();
		                        NZDCAD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO1S3_DOWN_S2 = 0;
		                for (; NZDCAD_OCO1S3_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets3.Count; NZDCAD_OCO1S3_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO1Sets3[NZDCAD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO1Sets3[NZDCAD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.NZDCAD_DOWN_S2_OCO1Sets3.Clear();
		                        NZDCAD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO1S4_DOWN_S2 = 0;
		                for (; NZDCAD_OCO1S4_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets4.Count; NZDCAD_OCO1S4_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO1Sets4[NZDCAD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO1Sets4[NZDCAD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.NZDCAD_DOWN_S2_OCO1Sets4.Clear();
		                        NZDCAD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO1S5_DOWN_S2 = 0;
		                for (; NZDCAD_OCO1S5_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets5.Count; NZDCAD_OCO1S5_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO1Sets5[NZDCAD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO1Sets5[NZDCAD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.NZDCAD_DOWN_S2_OCO1Sets5.Clear();
		                        NZDCAD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO1S6_DOWN_S2 = 0;
		                for (; NZDCAD_OCO1S6_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets6.Count; NZDCAD_OCO1S6_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO1Sets6[NZDCAD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO1Sets6[NZDCAD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.NZDCAD_DOWN_S2_OCO1Sets6.Clear();
		                        NZDCAD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDCAD_OCO2_EO1_DOWN_S2)
	                Base.NZDCAD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDCAD_OCO2_EO2_DOWN_S2)
	                Base.NZDCAD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO2_EO3_DOWN_S2)
	                Base.NZDCAD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO2_EO4_DOWN_S2)
	                Base.NZDCAD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO2_EO5_DOWN_S2)
	                Base.NZDCAD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO2_EO6_DOWN_S2)
	                Base.NZDCAD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCAD_OCO2S1_DOWN_S2 = 0;
		                for (; NZDCAD_OCO2S1_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets1.Count; NZDCAD_OCO2S1_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO2Sets1[NZDCAD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO2Sets1[NZDCAD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.NZDCAD_DOWN_S2_OCO2Sets1.Clear();
		                        NZDCAD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCAD_OCO2S2_DOWN_S2 = 0;
		                for (; NZDCAD_OCO2S2_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets2.Count; NZDCAD_OCO2S2_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO2Sets2[NZDCAD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO2Sets2[NZDCAD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.NZDCAD_DOWN_S2_OCO2Sets2.Clear();
		                        NZDCAD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO2S3_DOWN_S2 = 0;
		                for (; NZDCAD_OCO2S3_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets3.Count; NZDCAD_OCO2S3_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO2Sets3[NZDCAD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO2Sets3[NZDCAD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.NZDCAD_DOWN_S2_OCO2Sets3.Clear();
		                        NZDCAD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO2S4_DOWN_S2 = 0;
		                for (; NZDCAD_OCO2S4_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets4.Count; NZDCAD_OCO2S4_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO2Sets4[NZDCAD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO2Sets4[NZDCAD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.NZDCAD_DOWN_S2_OCO2Sets4.Clear();
		                        NZDCAD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO2S5_DOWN_S2 = 0;
		                for (; NZDCAD_OCO2S5_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets5.Count; NZDCAD_OCO2S5_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO2Sets5[NZDCAD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO2Sets5[NZDCAD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.NZDCAD_DOWN_S2_OCO2Sets5.Clear();
		                        NZDCAD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO2S6_DOWN_S2 = 0;
		                for (; NZDCAD_OCO2S6_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets6.Count; NZDCAD_OCO2S6_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO2Sets6[NZDCAD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO2Sets6[NZDCAD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.NZDCAD_DOWN_S2_OCO2Sets6.Clear();
		                        NZDCAD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDCAD_OCO3_EO1_DOWN_S2)
	                Base.NZDCAD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDCAD_OCO3_EO2_DOWN_S2)
	                Base.NZDCAD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO3_EO3_DOWN_S2)
	                Base.NZDCAD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO3_EO4_DOWN_S2)
	                Base.NZDCAD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO3_EO5_DOWN_S2)
	                Base.NZDCAD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO3_EO6_DOWN_S2)
	                Base.NZDCAD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCAD_OCO3S1_DOWN_S2 = 0;
		                for (; NZDCAD_OCO3S1_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets1.Count; NZDCAD_OCO3S1_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO3Sets1[NZDCAD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO3Sets1[NZDCAD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.NZDCAD_DOWN_S2_OCO3Sets1.Clear();
		                        NZDCAD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCAD_OCO3S2_DOWN_S2 = 0;
		                for (; NZDCAD_OCO3S2_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets2.Count; NZDCAD_OCO3S2_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO3Sets2[NZDCAD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO3Sets2[NZDCAD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.NZDCAD_DOWN_S2_OCO3Sets2.Clear();
		                        NZDCAD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO3S3_DOWN_S2 = 0;
		                for (; NZDCAD_OCO3S3_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets3.Count; NZDCAD_OCO3S3_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO3Sets3[NZDCAD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO3Sets3[NZDCAD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.NZDCAD_DOWN_S2_OCO3Sets3.Clear();
		                        NZDCAD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO3S4_DOWN_S2 = 0;
		                for (; NZDCAD_OCO3S4_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets4.Count; NZDCAD_OCO3S4_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO3Sets4[NZDCAD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO3Sets4[NZDCAD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.NZDCAD_DOWN_S2_OCO3Sets4.Clear();
		                        NZDCAD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO3S5_DOWN_S2 = 0;
		                for (; NZDCAD_OCO3S5_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets5.Count; NZDCAD_OCO3S5_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO3Sets5[NZDCAD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO3Sets5[NZDCAD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.NZDCAD_DOWN_S2_OCO3Sets5.Clear();
		                        NZDCAD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO3S6_DOWN_S2 = 0;
		                for (; NZDCAD_OCO3S6_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets6.Count; NZDCAD_OCO3S6_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO3Sets6[NZDCAD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO3Sets6[NZDCAD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.NZDCAD_DOWN_S2_OCO3Sets6.Clear();
		                        NZDCAD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDCAD_OCO4_EO1_DOWN_S2)
	                Base.NZDCAD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.NZDCAD_OCO4_EO2_DOWN_S2)
	                Base.NZDCAD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO4_EO3_DOWN_S2)
	                Base.NZDCAD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO4_EO4_DOWN_S2)
	                Base.NZDCAD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO4_EO5_DOWN_S2)
	                Base.NZDCAD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO4_EO6_DOWN_S2)
	                Base.NZDCAD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCAD_OCO4S1_DOWN_S2 = 0;
		                for (; NZDCAD_OCO4S1_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets1.Count; NZDCAD_OCO4S1_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO4Sets1[NZDCAD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO4Sets1[NZDCAD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.NZDCAD_DOWN_S2_OCO4Sets1.Clear();
		                        NZDCAD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCAD_OCO4S2_DOWN_S2 = 0;
		                for (; NZDCAD_OCO4S2_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets2.Count; NZDCAD_OCO4S2_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO4Sets2[NZDCAD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO4Sets2[NZDCAD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.NZDCAD_DOWN_S2_OCO4Sets2.Clear();
		                        NZDCAD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO4S3_DOWN_S2 = 0;
		                for (; NZDCAD_OCO4S3_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets3.Count; NZDCAD_OCO4S3_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO4Sets3[NZDCAD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO4Sets3[NZDCAD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.NZDCAD_DOWN_S2_OCO4Sets3.Clear();
		                        NZDCAD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO4S4_DOWN_S2 = 0;
		                for (; NZDCAD_OCO4S4_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets4.Count; NZDCAD_OCO4S4_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO4Sets4[NZDCAD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO4Sets4[NZDCAD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.NZDCAD_DOWN_S2_OCO4Sets4.Clear();
		                        NZDCAD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO4S5_DOWN_S2 = 0;
		                for (; NZDCAD_OCO4S5_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets5.Count; NZDCAD_OCO4S5_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO4Sets5[NZDCAD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO4Sets5[NZDCAD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.NZDCAD_DOWN_S2_OCO4Sets5.Clear();
		                        NZDCAD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO4S6_DOWN_S2 = 0;
		                for (; NZDCAD_OCO4S6_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets6.Count; NZDCAD_OCO4S6_DOWN_S2++)
		                    if (Base.NZDCAD_DOWN_S2_OCO4Sets6[NZDCAD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_DOWN_S2_OCO4Sets6[NZDCAD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.NZDCAD_DOWN_S2_OCO4Sets6.Clear();
		                        NZDCAD_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();
	            	}
	            	
					DOWM_NZDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_NZDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_NZDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_NZDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_NZDCAD_DOWN_S2 = DOWM_NZDCAD_DOWN_S2 || DOWT_NZDCAD_DOWN_S2 || DOWW_NZDCAD_DOWN_S2 || DOWTH_NZDCAD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("NZDCAD"))
	            	{
	            		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.NZDCAD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.NZDCAD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.NZDCAD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.NZDCAD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.NZDCAD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDCAD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDCAD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.NZDCAD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.NZDCAD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.NZDCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.NZDCAD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.NZDCAD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	NZDCAD_Signal_Condition_DOWN_S2 =  
	                									(
															//pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.04m &&
	                										
	                										//prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//prices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[1] > prices_ASK_Close[0] * 0.02m &&

	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 && //yuhukj
	                										
	                										//prices_BID_Open[0] - prices_ASK_Close[0] > 0 &&
 	                										
	                										//prices_BID_Close[0] > pricesM_ASK_High[0] && 
	                										//prices_ASK_High[0] > pricesM_ASK_High[0] && 
	                										
	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										pricesM_BID_Open[1] - pricesM_ASK_Close[1] > 0 &&

															pricesM_BID_High[1] - pricesM_ASK_Close[1] > prices_BID_Close[0] * 0.03m &&
	                										
	                										prices_ASK_High[0] > pricesM_ASK_High[0] &&
	                										//prices_BID_Close[0] < pricesM_BID_High[0] &&
	                										
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.001m   

	                									);

	                    NZDCAD_DOWN_S2_SL  =  0.02m;
	                    NZDCAD_DOWN_S2_TP1 =  0.0015m;
	                    NZDCAD_DOWN_S2_TP2 =  NZDCAD_DOWN_S2_SL * 0;
	                    NZDCAD_DOWN_S2_TP3 =  NZDCAD_DOWN_S2_SL * 0;
	                    NZDCAD_DOWN_S2_TP4 =  NZDCAD_DOWN_S2_SL * 0;
	                    NZDCAD_DOWN_S2_TP5 =  NZDCAD_DOWN_S2_SL * 0;
	                    NZDCAD_DOWN_S2_TP6 =  NZDCAD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    NZDCAD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    NZDCAD_quantity_SL_DOWN_S2 = NZDCAD_quantity_DOWN_S2;
	                    NZDCAD_quantity_TP1_DOWN_S2 = (int)Math.Floor(NZDCAD_quantity_DOWN_S2 * 1m);
	                    NZDCAD_quantity_TP2_DOWN_S2 = (int)Math.Floor(NZDCAD_quantity_TP1_DOWN_S2 * 0m);
	                    NZDCAD_quantity_TP3_DOWN_S2 = (int)Math.Floor(NZDCAD_quantity_TP2_DOWN_S2 * 0m);
	                    NZDCAD_quantity_TP4_DOWN_S2 = (int)Math.Floor(NZDCAD_quantity_TP3_DOWN_S2 * 0m);
	                    NZDCAD_quantity_TP5_DOWN_S2 = (int)Math.Floor(NZDCAD_quantity_TP4_DOWN_S2 * 0m);
	                    NZDCAD_quantity_TP6_DOWN_S2 = (int)Math.Floor(NZDCAD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (NZDCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDCAD_DOWN_S2 && 
	                    Base.NZDCAD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.NZDCAD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCAD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP1_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.NZDCAD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDCAD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP2_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.NZDCAD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.NZDCAD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP3_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.NZDCAD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDCAD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP4_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.NZDCAD_OCO1_EO4_DOWN_S2 = false;

							Base.NZDCAD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.NZDCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (NZDCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDCAD_DOWN_S2 && 
	                    Base.NZDCAD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.NZDCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDCAD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCAD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP1_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.NZDCAD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDCAD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP2_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.NZDCAD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.NZDCAD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP3_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.NZDCAD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDCAD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP4_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.NZDCAD_OCO2_EO4_DOWN_S2 = false;

							Base.NZDCAD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.NZDCAD_OCO2_DOWN_S2_IsReady == false && Base.NZDCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (NZDCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDCAD_DOWN_S2 &&
	                    Base.NZDCAD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.NZDCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.NZDCAD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCAD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP1_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.NZDCAD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDCAD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP2_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.NZDCAD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.NZDCAD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP3_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.NZDCAD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDCAD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP4_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.NZDCAD_OCO3_EO4_DOWN_S2 = false;

							Base.NZDCAD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.NZDCAD_OCO3_DOWN_S2_IsReady == false && Base.NZDCAD_OCO2_DOWN_S2_IsReady == false && Base.NZDCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (NZDCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_NZDCAD_DOWN_S2 && 
	                    Base.NZDCAD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.NZDCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.NZDCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.NZDCAD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.NZDCAD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCAD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP1_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.NZDCAD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.NZDCAD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP2_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.NZDCAD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.NZDCAD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP3_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.NZDCAD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.NZDCAD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         NZDCAD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP4_DOWN_S2, false,"NZDCAD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.NZDCAD_OCO4_EO4_DOWN_S2 = false;

							Base.NZDCAD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.NZDCAD_OCO4_DOWN_S2_IsReady == false && Base.NZDCAD_OCO3_DOWN_S2_IsReady == false && Base.NZDCAD_OCO2_DOWN_S2_IsReady == false && Base.NZDCAD_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDUSD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDUSD_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("AUDUSD_DOWN_S2_OCO1")))
			{
				Base.AUDUSD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDUSD_DOWN_S2_OCO2")))
			{
				Base.AUDUSD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDUSD_DOWN_S2_OCO3")))
			{
				Base.AUDUSD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDUSD_DOWN_S2_OCO4")))
			{
				Base.AUDUSD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDUSD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.AUDUSD_OCO1_EO1_DOWN_S2)
	                Base.AUDUSD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDUSD_OCO1_EO2_DOWN_S2)
	                Base.AUDUSD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO1_EO3_DOWN_S2)
	                Base.AUDUSD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO1_EO4_DOWN_S2)
	                Base.AUDUSD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO1_EO5_DOWN_S2)
	                Base.AUDUSD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO1_EO6_DOWN_S2)
	                Base.AUDUSD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDUSD_OCO1S1_DOWN_S2 = 0;
		                for (; AUDUSD_OCO1S1_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets1.Count; AUDUSD_OCO1S1_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO1Sets1[AUDUSD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO1Sets1[AUDUSD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.AUDUSD_DOWN_S2_OCO1Sets1.Clear();
		                        AUDUSD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDUSD_OCO1S2_DOWN_S2 = 0;
		                for (; AUDUSD_OCO1S2_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets2.Count; AUDUSD_OCO1S2_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO1Sets2[AUDUSD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO1Sets2[AUDUSD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.AUDUSD_DOWN_S2_OCO1Sets2.Clear();
		                        AUDUSD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO1S3_DOWN_S2 = 0;
		                for (; AUDUSD_OCO1S3_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets3.Count; AUDUSD_OCO1S3_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO1Sets3[AUDUSD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO1Sets3[AUDUSD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.AUDUSD_DOWN_S2_OCO1Sets3.Clear();
		                        AUDUSD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO1S4_DOWN_S2 = 0;
		                for (; AUDUSD_OCO1S4_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets4.Count; AUDUSD_OCO1S4_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO1Sets4[AUDUSD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO1Sets4[AUDUSD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.AUDUSD_DOWN_S2_OCO1Sets4.Clear();
		                        AUDUSD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO1S5_DOWN_S2 = 0;
		                for (; AUDUSD_OCO1S5_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets5.Count; AUDUSD_OCO1S5_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO1Sets5[AUDUSD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO1Sets5[AUDUSD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.AUDUSD_DOWN_S2_OCO1Sets5.Clear();
		                        AUDUSD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO1S6_DOWN_S2 = 0;
		                for (; AUDUSD_OCO1S6_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO1Sets6.Count; AUDUSD_OCO1S6_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO1Sets6[AUDUSD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO1Sets6[AUDUSD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.AUDUSD_DOWN_S2_OCO1Sets6.Clear();
		                        AUDUSD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDUSD_OCO2_EO1_DOWN_S2)
	                Base.AUDUSD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDUSD_OCO2_EO2_DOWN_S2)
	                Base.AUDUSD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO2_EO3_DOWN_S2)
	                Base.AUDUSD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO2_EO4_DOWN_S2)
	                Base.AUDUSD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO2_EO5_DOWN_S2)
	                Base.AUDUSD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO2_EO6_DOWN_S2)
	                Base.AUDUSD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDUSD_OCO2S1_DOWN_S2 = 0;
		                for (; AUDUSD_OCO2S1_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets1.Count; AUDUSD_OCO2S1_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO2Sets1[AUDUSD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO2Sets1[AUDUSD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.AUDUSD_DOWN_S2_OCO2Sets1.Clear();
		                        AUDUSD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDUSD_OCO2S2_DOWN_S2 = 0;
		                for (; AUDUSD_OCO2S2_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets2.Count; AUDUSD_OCO2S2_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO2Sets2[AUDUSD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO2Sets2[AUDUSD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.AUDUSD_DOWN_S2_OCO2Sets2.Clear();
		                        AUDUSD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO2S3_DOWN_S2 = 0;
		                for (; AUDUSD_OCO2S3_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets3.Count; AUDUSD_OCO2S3_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO2Sets3[AUDUSD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO2Sets3[AUDUSD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.AUDUSD_DOWN_S2_OCO2Sets3.Clear();
		                        AUDUSD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO2S4_DOWN_S2 = 0;
		                for (; AUDUSD_OCO2S4_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets4.Count; AUDUSD_OCO2S4_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO2Sets4[AUDUSD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO2Sets4[AUDUSD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.AUDUSD_DOWN_S2_OCO2Sets4.Clear();
		                        AUDUSD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO2S5_DOWN_S2 = 0;
		                for (; AUDUSD_OCO2S5_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets5.Count; AUDUSD_OCO2S5_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO2Sets5[AUDUSD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO2Sets5[AUDUSD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.AUDUSD_DOWN_S2_OCO2Sets5.Clear();
		                        AUDUSD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO2S6_DOWN_S2 = 0;
		                for (; AUDUSD_OCO2S6_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO2Sets6.Count; AUDUSD_OCO2S6_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO2Sets6[AUDUSD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO2Sets6[AUDUSD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.AUDUSD_DOWN_S2_OCO2Sets6.Clear();
		                        AUDUSD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDUSD_OCO3_EO1_DOWN_S2)
	                Base.AUDUSD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDUSD_OCO3_EO2_DOWN_S2)
	                Base.AUDUSD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO3_EO3_DOWN_S2)
	                Base.AUDUSD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO3_EO4_DOWN_S2)
	                Base.AUDUSD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO3_EO5_DOWN_S2)
	                Base.AUDUSD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO3_EO6_DOWN_S2)
	                Base.AUDUSD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDUSD_OCO3S1_DOWN_S2 = 0;
		                for (; AUDUSD_OCO3S1_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets1.Count; AUDUSD_OCO3S1_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO3Sets1[AUDUSD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO3Sets1[AUDUSD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.AUDUSD_DOWN_S2_OCO3Sets1.Clear();
		                        AUDUSD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDUSD_OCO3S2_DOWN_S2 = 0;
		                for (; AUDUSD_OCO3S2_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets2.Count; AUDUSD_OCO3S2_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO3Sets2[AUDUSD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO3Sets2[AUDUSD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.AUDUSD_DOWN_S2_OCO3Sets2.Clear();
		                        AUDUSD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO3S3_DOWN_S2 = 0;
		                for (; AUDUSD_OCO3S3_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets3.Count; AUDUSD_OCO3S3_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO3Sets3[AUDUSD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO3Sets3[AUDUSD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.AUDUSD_DOWN_S2_OCO3Sets3.Clear();
		                        AUDUSD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO3S4_DOWN_S2 = 0;
		                for (; AUDUSD_OCO3S4_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets4.Count; AUDUSD_OCO3S4_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO3Sets4[AUDUSD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO3Sets4[AUDUSD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.AUDUSD_DOWN_S2_OCO3Sets4.Clear();
		                        AUDUSD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO3S5_DOWN_S2 = 0;
		                for (; AUDUSD_OCO3S5_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets5.Count; AUDUSD_OCO3S5_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO3Sets5[AUDUSD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO3Sets5[AUDUSD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.AUDUSD_DOWN_S2_OCO3Sets5.Clear();
		                        AUDUSD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO3S6_DOWN_S2 = 0;
		                for (; AUDUSD_OCO3S6_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO3Sets6.Count; AUDUSD_OCO3S6_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO3Sets6[AUDUSD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO3Sets6[AUDUSD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.AUDUSD_DOWN_S2_OCO3Sets6.Clear();
		                        AUDUSD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDUSD_OCO4_EO1_DOWN_S2)
	                Base.AUDUSD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDUSD_OCO4_EO2_DOWN_S2)
	                Base.AUDUSD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO4_EO3_DOWN_S2)
	                Base.AUDUSD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO4_EO4_DOWN_S2)
	                Base.AUDUSD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO4_EO5_DOWN_S2)
	                Base.AUDUSD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO4_EO6_DOWN_S2)
	                Base.AUDUSD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDUSD_OCO4S1_DOWN_S2 = 0;
		                for (; AUDUSD_OCO4S1_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets1.Count; AUDUSD_OCO4S1_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO4Sets1[AUDUSD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO4Sets1[AUDUSD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.AUDUSD_DOWN_S2_OCO4Sets1.Clear();
		                        AUDUSD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDUSD_OCO4S2_DOWN_S2 = 0;
		                for (; AUDUSD_OCO4S2_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets2.Count; AUDUSD_OCO4S2_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO4Sets2[AUDUSD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO4Sets2[AUDUSD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.AUDUSD_DOWN_S2_OCO4Sets2.Clear();
		                        AUDUSD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO4S3_DOWN_S2 = 0;
		                for (; AUDUSD_OCO4S3_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets3.Count; AUDUSD_OCO4S3_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO4Sets3[AUDUSD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO4Sets3[AUDUSD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.AUDUSD_DOWN_S2_OCO4Sets3.Clear();
		                        AUDUSD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO4S4_DOWN_S2 = 0;
		                for (; AUDUSD_OCO4S4_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets4.Count; AUDUSD_OCO4S4_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO4Sets4[AUDUSD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO4Sets4[AUDUSD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.AUDUSD_DOWN_S2_OCO4Sets4.Clear();
		                        AUDUSD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO4S5_DOWN_S2 = 0;
		                for (; AUDUSD_OCO4S5_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets5.Count; AUDUSD_OCO4S5_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO4Sets5[AUDUSD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO4Sets5[AUDUSD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.AUDUSD_DOWN_S2_OCO4Sets5.Clear();
		                        AUDUSD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO4S6_DOWN_S2 = 0;
		                for (; AUDUSD_OCO4S6_DOWN_S2 < Base.AUDUSD_DOWN_S2_OCO4Sets6.Count; AUDUSD_OCO4S6_DOWN_S2++)
		                    if (Base.AUDUSD_DOWN_S2_OCO4Sets6[AUDUSD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_DOWN_S2_OCO4Sets6[AUDUSD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.AUDUSD_DOWN_S2_OCO4Sets6.Clear();
		                        AUDUSD_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();
	            	}
	            	
					DOWM_AUDUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDUSD_DOWN_S2 = DOWM_AUDUSD_DOWN_S2 || DOWT_AUDUSD_DOWN_S2 || DOWW_AUDUSD_DOWN_S2 || DOWTH_AUDUSD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDUSD"))
	            	{
	            		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.AUDUSD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.AUDUSD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.AUDUSD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.AUDUSD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.AUDUSD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDUSD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDUSD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDUSD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDUSD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDUSD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDUSD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDUSD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	AUDUSD_Signal_Condition_DOWN_S2 =  
	                									(
															pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.05m &&
	                										
	                										prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										prices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[0] > prices_ASK_Close[0] * 0.025m &&
	                										
	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										
	                										//prices_ASK_Close[0] > pricesM_ASK_High[0] &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.01m
	                									);
	                									
	                    AUDUSD_DOWN_S2_SL  =  0.01m;
	                    AUDUSD_DOWN_S2_TP1 =  0.001m;
	                    AUDUSD_DOWN_S2_TP2 =  AUDUSD_DOWN_S2_SL * 0;
	                    AUDUSD_DOWN_S2_TP3 =  AUDUSD_DOWN_S2_SL * 0;
	                    AUDUSD_DOWN_S2_TP4 =  AUDUSD_DOWN_S2_SL * 0;
	                    AUDUSD_DOWN_S2_TP5 =  AUDUSD_DOWN_S2_SL * 0;
	                    AUDUSD_DOWN_S2_TP6 =  AUDUSD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
		                    AUDUSD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
		                    AUDUSD_quantity_SL_DOWN_S2 = AUDUSD_quantity_DOWN_S2;
		                    AUDUSD_quantity_TP1_DOWN_S2 = (int)Math.Floor(AUDUSD_quantity_DOWN_S2 * 1m);
		                    AUDUSD_quantity_TP2_DOWN_S2 = (int)Math.Floor(AUDUSD_quantity_TP1_DOWN_S2 * 0m);
		                    AUDUSD_quantity_TP3_DOWN_S2 = (int)Math.Floor(AUDUSD_quantity_TP2_DOWN_S2 * 0m);
		                    AUDUSD_quantity_TP4_DOWN_S2 = (int)Math.Floor(AUDUSD_quantity_TP3_DOWN_S2 * 0m);
		                    AUDUSD_quantity_TP5_DOWN_S2 = (int)Math.Floor(AUDUSD_quantity_TP4_DOWN_S2 * 0m);
		                    AUDUSD_quantity_TP6_DOWN_S2 = (int)Math.Floor(AUDUSD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (AUDUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDUSD_DOWN_S2 && 
	                    Base.AUDUSD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.AUDUSD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDUSD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP1_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.AUDUSD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDUSD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP2_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.AUDUSD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.AUDUSD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP3_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.AUDUSD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDUSD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP4_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.AUDUSD_OCO1_EO4_DOWN_S2 = false;

							Base.AUDUSD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.AUDUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (AUDUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDUSD_DOWN_S2 && 
	                    Base.AUDUSD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.AUDUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDUSD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDUSD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP1_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.AUDUSD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDUSD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP2_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.AUDUSD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.AUDUSD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP3_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.AUDUSD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDUSD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP4_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.AUDUSD_OCO2_EO4_DOWN_S2 = false;

							Base.AUDUSD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.AUDUSD_OCO2_DOWN_S2_IsReady == false && Base.AUDUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (AUDUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDUSD_DOWN_S2 &&
	                    Base.AUDUSD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.AUDUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDUSD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDUSD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDUSD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP1_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.AUDUSD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDUSD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP2_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.AUDUSD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.AUDUSD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP3_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.AUDUSD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDUSD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP4_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.AUDUSD_OCO3_EO4_DOWN_S2 = false;

							Base.AUDUSD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.AUDUSD_OCO3_DOWN_S2_IsReady == false && Base.AUDUSD_OCO2_DOWN_S2_IsReady == false && Base.AUDUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (AUDUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDUSD_DOWN_S2 && 
	                    Base.AUDUSD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.AUDUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDUSD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDUSD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.AUDUSD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDUSD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP1_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.AUDUSD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDUSD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP2_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.AUDUSD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.AUDUSD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP3_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.AUDUSD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDUSD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDUSD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP4_DOWN_S2, false,"AUDUSD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.AUDUSD_OCO4_EO4_DOWN_S2 = false;

							Base.AUDUSD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.AUDUSD_OCO4_DOWN_S2_IsReady == false && Base.AUDUSD_OCO3_DOWN_S2_IsReady == false && Base.AUDUSD_OCO2_DOWN_S2_IsReady == false && Base.AUDUSD_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDUSD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDUSD_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(x=>x.Tag.Contains("AUDUSD_UP_S2_OCO1")))
			{
				Base.AUDUSD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDUSD_UP_S2_OCO2")))
			{
				Base.AUDUSD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDUSD_UP_S2_OCO3")))
			{
				Base.AUDUSD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDUSD_UP_S2_OCO4")))
			{
				Base.AUDUSD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDUSD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.AUDUSD_OCO1_EO1_UP_S2)
	                Base.AUDUSD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDUSD_OCO1_EO2_UP_S2)
	                Base.AUDUSD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO1_EO3_UP_S2)
	                Base.AUDUSD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO1_EO4_UP_S2)
	                Base.AUDUSD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO1_EO5_UP_S2)
	                Base.AUDUSD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO1_EO6_UP_S2)
	                Base.AUDUSD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDUSD_OCO1S1_UP_S2 = 0;
		                for (; AUDUSD_OCO1S1_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets1.Count; AUDUSD_OCO1S1_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO1Sets1[AUDUSD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO1Sets1[AUDUSD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.AUDUSD_UP_S2_OCO1Sets1.Clear();
		                        AUDUSD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDUSD_OCO1S2_UP_S2 = 0;
		                for (; AUDUSD_OCO1S2_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets2.Count; AUDUSD_OCO1S2_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO1Sets2[AUDUSD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO1Sets2[AUDUSD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.AUDUSD_UP_S2_OCO1Sets2.Clear();
		                        AUDUSD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO1S3_UP_S2 = 0;
		                for (; AUDUSD_OCO1S3_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets3.Count; AUDUSD_OCO1S3_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO1Sets3[AUDUSD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO1Sets3[AUDUSD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.AUDUSD_UP_S2_OCO1Sets3.Clear();
		                        AUDUSD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO1S4_UP_S2 = 0;
		                for (; AUDUSD_OCO1S4_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets4.Count; AUDUSD_OCO1S4_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO1Sets4[AUDUSD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO1Sets4[AUDUSD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.AUDUSD_UP_S2_OCO1Sets4.Clear();
		                        AUDUSD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO1S5_UP_S2 = 0;
		                for (; AUDUSD_OCO1S5_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets5.Count; AUDUSD_OCO1S5_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO1Sets5[AUDUSD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO1Sets5[AUDUSD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.AUDUSD_UP_S2_OCO1Sets5.Clear();
		                        AUDUSD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO1S6_UP_S2 = 0;
		                for (; AUDUSD_OCO1S6_UP_S2 < Base.AUDUSD_UP_S2_OCO1Sets6.Count; AUDUSD_OCO1S6_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO1Sets6[AUDUSD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO1Sets6[AUDUSD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.AUDUSD_UP_S2_OCO1Sets6.Clear();
		                        AUDUSD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDUSD_OCO2_EO1_UP_S2)
                	Base.AUDUSD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDUSD_OCO2_EO2_UP_S2)
	                Base.AUDUSD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO2_EO3_UP_S2)
	                Base.AUDUSD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO2_EO4_UP_S2)
	                Base.AUDUSD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO2_EO5_UP_S2)
	                Base.AUDUSD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO2_EO6_UP_S2)
	                Base.AUDUSD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDUSD_OCO2S1_UP_S2 = 0;
		                for (; AUDUSD_OCO2S1_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets1.Count; AUDUSD_OCO2S1_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO2Sets1[AUDUSD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO2Sets1[AUDUSD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.AUDUSD_UP_S2_OCO2Sets1.Clear();
		                        AUDUSD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDUSD_OCO2S2_UP_S2 = 0;
		                for (; AUDUSD_OCO2S2_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets2.Count; AUDUSD_OCO2S2_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO2Sets2[AUDUSD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO2Sets2[AUDUSD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.AUDUSD_UP_S2_OCO2Sets2.Clear();
		                        AUDUSD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO2S3_UP_S2 = 0;
		                for (; AUDUSD_OCO2S3_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets3.Count; AUDUSD_OCO2S3_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO2Sets3[AUDUSD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO2Sets3[AUDUSD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.AUDUSD_UP_S2_OCO2Sets3.Clear();
		                        AUDUSD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO2S4_UP_S2 = 0;
		                for (; AUDUSD_OCO2S4_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets4.Count; AUDUSD_OCO2S4_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO2Sets4[AUDUSD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO2Sets4[AUDUSD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.AUDUSD_UP_S2_OCO2Sets4.Clear();
		                        AUDUSD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO2S5_UP_S2 = 0;
		                for (; AUDUSD_OCO2S5_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets5.Count; AUDUSD_OCO2S5_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO2Sets5[AUDUSD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO2Sets5[AUDUSD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.AUDUSD_UP_S2_OCO2Sets5.Clear();
		                        AUDUSD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO2S6_UP_S2 = 0;
		                for (; AUDUSD_OCO2S6_UP_S2 < Base.AUDUSD_UP_S2_OCO2Sets6.Count; AUDUSD_OCO2S6_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO2Sets6[AUDUSD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO2Sets6[AUDUSD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.AUDUSD_UP_S2_OCO2Sets6.Clear();
		                        AUDUSD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDUSD_OCO3_EO1_UP_S2)
            		Base.AUDUSD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDUSD_OCO3_EO2_UP_S2)
	                Base.AUDUSD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO3_EO3_UP_S2)
	                Base.AUDUSD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO3_EO4_UP_S2)
	                Base.AUDUSD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO3_EO5_UP_S2)
	                Base.AUDUSD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO3_EO6_UP_S2)
	                Base.AUDUSD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDUSD_OCO3S1_UP_S2 = 0;
		                for (; AUDUSD_OCO3S1_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets1.Count; AUDUSD_OCO3S1_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO3Sets1[AUDUSD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO3Sets1[AUDUSD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.AUDUSD_UP_S2_OCO3Sets1.Clear();
		                        AUDUSD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDUSD_OCO3S2_UP_S2 = 0;
		                for (; AUDUSD_OCO3S2_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets2.Count; AUDUSD_OCO3S2_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO3Sets2[AUDUSD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO3Sets2[AUDUSD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.AUDUSD_UP_S2_OCO3Sets2.Clear();
		                        AUDUSD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO3S3_UP_S2 = 0;
		                for (; AUDUSD_OCO3S3_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets3.Count; AUDUSD_OCO3S3_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO3Sets3[AUDUSD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO3Sets3[AUDUSD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.AUDUSD_UP_S2_OCO3Sets3.Clear();
		                        AUDUSD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO3S4_UP_S2 = 0;
		                for (; AUDUSD_OCO3S4_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets4.Count; AUDUSD_OCO3S4_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO3Sets4[AUDUSD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO3Sets4[AUDUSD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.AUDUSD_UP_S2_OCO3Sets4.Clear();
		                        AUDUSD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO3S5_UP_S2 = 0;
		                for (; AUDUSD_OCO3S5_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets5.Count; AUDUSD_OCO3S5_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO3Sets5[AUDUSD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO3Sets5[AUDUSD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.AUDUSD_UP_S2_OCO3Sets5.Clear();
		                        AUDUSD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO3S6_UP_S2 = 0;
		                for (; AUDUSD_OCO3S6_UP_S2 < Base.AUDUSD_UP_S2_OCO3Sets6.Count; AUDUSD_OCO3S6_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO3Sets6[AUDUSD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO3Sets6[AUDUSD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.AUDUSD_UP_S2_OCO3Sets6.Clear();
		                        AUDUSD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDUSD_OCO4_EO1_UP_S2)
            		Base.AUDUSD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDUSD_OCO4_EO2_UP_S2)
	                Base.AUDUSD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO4_EO3_UP_S2)
	                Base.AUDUSD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO4_EO4_UP_S2)
	                Base.AUDUSD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO4_EO5_UP_S2)
	                Base.AUDUSD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDUSD_OCO4_EO6_UP_S2)
	                Base.AUDUSD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDUSD_OCO4S1_UP_S2 = 0;
		                for (; AUDUSD_OCO4S1_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets1.Count; AUDUSD_OCO4S1_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO4Sets1[AUDUSD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO4Sets1[AUDUSD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.AUDUSD_UP_S2_OCO4Sets1.Clear();
		                        AUDUSD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDUSD_OCO4S2_UP_S2 = 0;
		                for (; AUDUSD_OCO4S2_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets2.Count; AUDUSD_OCO4S2_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO4Sets2[AUDUSD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO4Sets2[AUDUSD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.AUDUSD_UP_S2_OCO4Sets2.Clear();
		                        AUDUSD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO4S3_UP_S2 = 0;
		                for (; AUDUSD_OCO4S3_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets3.Count; AUDUSD_OCO4S3_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO4Sets3[AUDUSD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO4Sets3[AUDUSD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.AUDUSD_UP_S2_OCO4Sets3.Clear();
		                        AUDUSD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDUSD_OCO4S4_UP_S2 = 0;
		                for (; AUDUSD_OCO4S4_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets4.Count; AUDUSD_OCO4S4_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO4Sets4[AUDUSD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO4Sets4[AUDUSD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.AUDUSD_UP_S2_OCO4Sets4.Clear();
		                        AUDUSD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO4S5_UP_S2 = 0;
		                for (; AUDUSD_OCO4S5_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets5.Count; AUDUSD_OCO4S5_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO4Sets5[AUDUSD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO4Sets5[AUDUSD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.AUDUSD_UP_S2_OCO4Sets5.Clear();
		                        AUDUSD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDUSD_OCO4S6_UP_S2 = 0;
		                for (; AUDUSD_OCO4S6_UP_S2 < Base.AUDUSD_UP_S2_OCO4Sets6.Count; AUDUSD_OCO4S6_UP_S2++)
		                    if (Base.AUDUSD_UP_S2_OCO4Sets6[AUDUSD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDUSD_UP_S2_OCO4Sets6[AUDUSD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDUSD", order.Quantity, false, "AUDUSD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.AUDUSD_UP_S2_OCO4Sets6.Clear();
		                        AUDUSD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_AUDUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDUSD_UP_S2 = DOWM_AUDUSD_UP_S2 || DOWT_AUDUSD_UP_S2 || DOWW_AUDUSD_UP_S2 || DOWTH_AUDUSD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDUSD"))
	            	{
	            		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.AUDUSD_OCO1_UP_S2_IsReady == false ||
	                    	Base.AUDUSD_OCO2_UP_S2_IsReady == false ||
	                    	Base.AUDUSD_OCO3_UP_S2_IsReady == false ||
	                    	Base.AUDUSD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.AUDUSD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDUSD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDUSD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDUSD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDUSD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.AUDUSD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.AUDUSD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.AUDUSD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	AUDUSD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                							
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	AUDUSD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	AUDUSD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
		
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (AUDUSD_Signal_Condition_UP_1)
	                	{
	                    	AUDUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDUSD_Signal_Condition_UP_2)
	                	{
	                    	AUDUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDUSD_Signal_Condition_UP_3)
	                	{
	                    	AUDUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (AUDUSD_Signal_Condition_UP_1)
	                	{
	                    	AUDUSD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (AUDUSD_Signal_Condition_UP_2)
	                	{
	                    	AUDUSD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (AUDUSD_Signal_Condition_UP_3)
	                	{
	                    	AUDUSD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    AUDUSD_UP_S2_TP2 =  AUDUSD_UP_S2_SL * 0;
	                    AUDUSD_UP_S2_TP3 =  AUDUSD_UP_S2_SL * 0;
	                    AUDUSD_UP_S2_TP4 =  AUDUSD_UP_S2_SL * 0;
	                    AUDUSD_UP_S2_TP5 =  AUDUSD_UP_S2_SL * 0;
	                    AUDUSD_UP_S2_TP6 =  AUDUSD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    AUDUSD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    AUDUSD_quantity_SL_UP_S2 = AUDUSD_quantity_UP_S2;
	                    AUDUSD_quantity_TP1_UP_S2 = (int)Math.Floor(AUDUSD_quantity_UP_S2 * 1m);
	                    AUDUSD_quantity_TP2_UP_S2 = (int)Math.Floor(AUDUSD_quantity_TP1_UP_S2 * 0m);
	                    AUDUSD_quantity_TP3_UP_S2 = (int)Math.Floor(AUDUSD_quantity_TP2_UP_S2 * 0m);
	                    AUDUSD_quantity_TP4_UP_S2 = (int)Math.Floor(AUDUSD_quantity_TP3_UP_S2 * 0m);
	                    AUDUSD_quantity_TP5_UP_S2 = (int)Math.Floor(AUDUSD_quantity_TP4_UP_S2 * 0m);
	                    AUDUSD_quantity_TP6_UP_S2 = (int)Math.Floor(AUDUSD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((AUDUSD_Signal_Condition_UP_1 || AUDUSD_Signal_Condition_UP_2 || AUDUSD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDUSD_UP_S2 && 
	                    Base.AUDUSD_OCO1_UP_S2_IsReady == true &&
	                    Base.AUDUSD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDUSD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP1_UP_S2, false,"AUDUSD_UP_S2_Entry_TP1_OCO1");
	                         Base.AUDUSD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.AUDUSD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP2_UP_S2, false,"AUDUSD_UP_S2_Entry_TP2_OCO1");
	                         Base.AUDUSD_OCO1_EO2_UP_S2 = false;
	
	                         Base.AUDUSD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP3_UP_S2, false,"AUDUSD_UP_S2_Entry_TP3_OCO1");
	                         Base.AUDUSD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.AUDUSD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP4_UP_S2, false,"AUDUSD_UP_S2_Entry_TP4_OCO1");
	                         Base.AUDUSD_OCO1_EO4_UP_S2 = false;

							Base.AUDUSD_OCO1_UP_S2_IsReady = false;
							
							if (Base.AUDUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((AUDUSD_Signal_Condition_UP_1 || AUDUSD_Signal_Condition_UP_2 || AUDUSD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDUSD_UP_S2 && 
	                    Base.AUDUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDUSD_OCO2_UP_S2_IsReady == true &&
	                    Base.AUDUSD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDUSD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP1_UP_S2, false,"AUDUSD_UP_S2_Entry_TP1_OCO2");
	                         Base.AUDUSD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.AUDUSD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP2_UP_S2, false,"AUDUSD_UP_S2_Entry_TP2_OCO2");
	                         Base.AUDUSD_OCO2_EO2_UP_S2 = false;
	
	                         Base.AUDUSD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP3_UP_S2, false,"AUDUSD_UP_S2_Entry_TP3_OCO2");
	                         Base.AUDUSD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.AUDUSD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP4_UP_S2, false,"AUDUSD_UP_S2_Entry_TP4_OCO2");
	                         Base.AUDUSD_OCO2_EO4_UP_S2 = false;

							Base.AUDUSD_OCO2_UP_S2_IsReady = false;
							
							if (Base.AUDUSD_OCO2_UP_S2_IsReady == false && Base.AUDUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((AUDUSD_Signal_Condition_UP_1 || AUDUSD_Signal_Condition_UP_2 || AUDUSD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDUSD_UP_S2 &&
	                    Base.AUDUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDUSD_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDUSD_OCO3_UP_S2_IsReady == true &&
	                    Base.AUDUSD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDUSD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP1_UP_S2, false,"AUDUSD_UP_S2_Entry_TP1_OCO3");
	                         Base.AUDUSD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.AUDUSD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP2_UP_S2, false,"AUDUSD_UP_S2_Entry_TP2_OCO3");
	                         Base.AUDUSD_OCO3_EO2_UP_S2 = false;
	
	                         Base.AUDUSD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP3_UP_S2, false,"AUDUSD_UP_S2_Entry_TP3_OCO3");
	                         Base.AUDUSD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.AUDUSD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP4_UP_S2, false,"AUDUSD_UP_S2_Entry_TP4_OCO3");
	                         Base.AUDUSD_OCO3_EO4_UP_S2 = false;

							Base.AUDUSD_OCO3_UP_S2_IsReady = false;
							
							if (Base.AUDUSD_OCO3_UP_S2_IsReady == false && Base.AUDUSD_OCO2_UP_S2_IsReady == false && Base.AUDUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((AUDUSD_Signal_Condition_UP_1 || AUDUSD_Signal_Condition_UP_2 || AUDUSD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDUSD_UP_S2 && 
	                    Base.AUDUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDUSD_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDUSD_OCO3_UP_S2_IsReady == false &&
	                    Base.AUDUSD_OCO4_UP_S2_IsReady == true &&
	                    Base.AUDUSD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDUSD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP1_UP_S2, false,"AUDUSD_UP_S2_Entry_TP1_OCO4");
	                         Base.AUDUSD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.AUDUSD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP2_UP_S2, false,"AUDUSD_UP_S2_Entry_TP2_OCO4");
	                         Base.AUDUSD_OCO4_EO2_UP_S2 = false;
	
	                         Base.AUDUSD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP3_UP_S2, false,"AUDUSD_UP_S2_Entry_TP3_OCO4");
	                         Base.AUDUSD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.AUDUSD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDUSD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDUSD_quantity_TP4_UP_S2, false,"AUDUSD_UP_S2_Entry_TP4_OCO4");
	                         Base.AUDUSD_OCO4_EO4_UP_S2 = false;

							Base.AUDUSD_OCO4_UP_S2_IsReady = false;
							
							if (Base.AUDUSD_OCO4_UP_S2_IsReady == false && Base.AUDUSD_OCO3_UP_S2_IsReady == false && Base.AUDUSD_OCO2_UP_S2_IsReady == false && Base.AUDUSD_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 _CHFJPY;
		
    	///oco1 up
    	public static OrderTicket CHFJPY_OCO1_MO1_UP_S2;
    	public static OrderTicket CHFJPY_OCO1_MO2_UP_S2;
    	public static OrderTicket CHFJPY_OCO1_MO3_UP_S2;
    	public static OrderTicket CHFJPY_OCO1_MO4_UP_S2;
    	public static OrderTicket CHFJPY_OCO1_MO5_UP_S2;
    	public static OrderTicket CHFJPY_OCO1_MO6_UP_S2;
    	
    	public static int CHFJPY_OCO1_EO1_UP_S2_ID ;
        public static int CHFJPY_OCO1_EO2_UP_S2_ID ;
        public static int CHFJPY_OCO1_EO3_UP_S2_ID ;
        public static int CHFJPY_OCO1_EO4_UP_S2_ID ;
        public static int CHFJPY_OCO1_EO5_UP_S2_ID ;
        public static int CHFJPY_OCO1_EO6_UP_S2_ID ;
        
        public static bool CHFJPY_OCO1_EO1_UP_S2 ;
        public static bool CHFJPY_OCO1_EO2_UP_S2 ;
        public static bool CHFJPY_OCO1_EO3_UP_S2 ;
        public static bool CHFJPY_OCO1_EO4_UP_S2 ;
        public static bool CHFJPY_OCO1_EO5_UP_S2 ;
        public static bool CHFJPY_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_UP_S2> CHFJPY_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_UP_S2> CHFJPY_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_UP_S2> CHFJPY_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_UP_S2> CHFJPY_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_UP_S2> CHFJPY_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_UP_S2> CHFJPY_OOFE_OCO1_UP_S2_6 ;
        
        public static CHFJPY_OCO1_UP_S2 CHFJPY_PFO_OCO1_UP_S2_1 ;
        public static CHFJPY_OCO1_UP_S2 CHFJPY_PFO_OCO1_UP_S2_2 ;
        public static CHFJPY_OCO1_UP_S2 CHFJPY_PFO_OCO1_UP_S2_3 ;
        public static CHFJPY_OCO1_UP_S2 CHFJPY_PFO_OCO1_UP_S2_4 ;
        public static CHFJPY_OCO1_UP_S2 CHFJPY_PFO_OCO1_UP_S2_5 ;
        public static CHFJPY_OCO1_UP_S2 CHFJPY_PFO_OCO1_UP_S2_6 ;
        
        public static List<CHFJPY_OCO1_UP_S2> CHFJPY_UP_S2_OCO1Sets1 = new List<CHFJPY_OCO1_UP_S2>();
        public static List<CHFJPY_OCO1_UP_S2> CHFJPY_UP_S2_OCO1Sets2 = new List<CHFJPY_OCO1_UP_S2>();
        public static List<CHFJPY_OCO1_UP_S2> CHFJPY_UP_S2_OCO1Sets3 = new List<CHFJPY_OCO1_UP_S2>();
        public static List<CHFJPY_OCO1_UP_S2> CHFJPY_UP_S2_OCO1Sets4 = new List<CHFJPY_OCO1_UP_S2>();
        public static List<CHFJPY_OCO1_UP_S2> CHFJPY_UP_S2_OCO1Sets5 = new List<CHFJPY_OCO1_UP_S2>();
        public static List<CHFJPY_OCO1_UP_S2> CHFJPY_UP_S2_OCO1Sets6 = new List<CHFJPY_OCO1_UP_S2>();
        
        public static bool CHFJPY_OCO1_UP_S2_IsReady = true;
        public static bool CHFJPY_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket CHFJPY_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO1_MO6_DOWN_S2 ;
    	
    	public static int CHFJPY_OCO1_EO1_DOWN_S2_ID ;
        public static int CHFJPY_OCO1_EO2_DOWN_S2_ID ;
        public static int CHFJPY_OCO1_EO3_DOWN_S2_ID ;
        public static int CHFJPY_OCO1_EO4_DOWN_S2_ID ;
        public static int CHFJPY_OCO1_EO5_DOWN_S2_ID ;
        public static int CHFJPY_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool CHFJPY_OCO1_EO1_DOWN_S2 ;
        public static bool CHFJPY_OCO1_EO2_DOWN_S2 ;
        public static bool CHFJPY_OCO1_EO3_DOWN_S2 ;
        public static bool CHFJPY_OCO1_EO4_DOWN_S2 ;
        public static bool CHFJPY_OCO1_EO5_DOWN_S2 ;
        public static bool CHFJPY_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_DOWN_S2> CHFJPY_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_DOWN_S2> CHFJPY_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_DOWN_S2> CHFJPY_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_DOWN_S2> CHFJPY_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_DOWN_S2> CHFJPY_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO1_DOWN_S2> CHFJPY_OOFE_OCO1_DOWN_S2_6 ;
        
        public static CHFJPY_OCO1_DOWN_S2 CHFJPY_PFO_OCO1_DOWN_S2_1 ;
        public static CHFJPY_OCO1_DOWN_S2 CHFJPY_PFO_OCO1_DOWN_S2_2 ;
        public static CHFJPY_OCO1_DOWN_S2 CHFJPY_PFO_OCO1_DOWN_S2_3 ;
        public static CHFJPY_OCO1_DOWN_S2 CHFJPY_PFO_OCO1_DOWN_S2_4 ;
        public static CHFJPY_OCO1_DOWN_S2 CHFJPY_PFO_OCO1_DOWN_S2_5 ;
        public static CHFJPY_OCO1_DOWN_S2 CHFJPY_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<CHFJPY_OCO1_DOWN_S2> CHFJPY_DOWN_S2_OCO1Sets1 = new List<CHFJPY_OCO1_DOWN_S2>();
        public static List<CHFJPY_OCO1_DOWN_S2> CHFJPY_DOWN_S2_OCO1Sets2 = new List<CHFJPY_OCO1_DOWN_S2>();
        public static List<CHFJPY_OCO1_DOWN_S2> CHFJPY_DOWN_S2_OCO1Sets3 = new List<CHFJPY_OCO1_DOWN_S2>();
        public static List<CHFJPY_OCO1_DOWN_S2> CHFJPY_DOWN_S2_OCO1Sets4 = new List<CHFJPY_OCO1_DOWN_S2>();
        public static List<CHFJPY_OCO1_DOWN_S2> CHFJPY_DOWN_S2_OCO1Sets5 = new List<CHFJPY_OCO1_DOWN_S2>();
        public static List<CHFJPY_OCO1_DOWN_S2> CHFJPY_DOWN_S2_OCO1Sets6 = new List<CHFJPY_OCO1_DOWN_S2>();
        
        public static bool CHFJPY_OCO1_DOWN_S2_IsReady = true;
        public static bool CHFJPY_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket CHFJPY_OCO2_MO1_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO2_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO3_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO4_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO5_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO6_UP_S2 ;
    	
    	public static int CHFJPY_OCO2_EO1_UP_S2_ID ;
        public static int CHFJPY_OCO2_EO2_UP_S2_ID ;
        public static int CHFJPY_OCO2_EO3_UP_S2_ID ;
        public static int CHFJPY_OCO2_EO4_UP_S2_ID ;
        public static int CHFJPY_OCO2_EO5_UP_S2_ID ;
        public static int CHFJPY_OCO2_EO6_UP_S2_ID ;
        
        public static bool CHFJPY_OCO2_EO1_UP_S2 ;
        public static bool CHFJPY_OCO2_EO2_UP_S2 ;
        public static bool CHFJPY_OCO2_EO3_UP_S2 ;
        public static bool CHFJPY_OCO2_EO4_UP_S2 ;
        public static bool CHFJPY_OCO2_EO5_UP_S2 ;
        public static bool CHFJPY_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_UP_S2> CHFJPY_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_UP_S2> CHFJPY_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_UP_S2> CHFJPY_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_UP_S2> CHFJPY_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_UP_S2> CHFJPY_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_UP_S2> CHFJPY_OOFE_OCO2_UP_S2_6 ;
        
        public static CHFJPY_OCO2_UP_S2 CHFJPY_PFO_OCO2_UP_S2_1 ;
        public static CHFJPY_OCO2_UP_S2 CHFJPY_PFO_OCO2_UP_S2_2 ;
        public static CHFJPY_OCO2_UP_S2 CHFJPY_PFO_OCO2_UP_S2_3 ;
        public static CHFJPY_OCO2_UP_S2 CHFJPY_PFO_OCO2_UP_S2_4 ;
        public static CHFJPY_OCO2_UP_S2 CHFJPY_PFO_OCO2_UP_S2_5 ;
        public static CHFJPY_OCO2_UP_S2 CHFJPY_PFO_OCO2_UP_S2_6 ;
        
        public static List<CHFJPY_OCO2_UP_S2> CHFJPY_UP_S2_OCO2Sets1 = new List<CHFJPY_OCO2_UP_S2>();
        public static List<CHFJPY_OCO2_UP_S2> CHFJPY_UP_S2_OCO2Sets2 = new List<CHFJPY_OCO2_UP_S2>();
        public static List<CHFJPY_OCO2_UP_S2> CHFJPY_UP_S2_OCO2Sets3 = new List<CHFJPY_OCO2_UP_S2>();
        public static List<CHFJPY_OCO2_UP_S2> CHFJPY_UP_S2_OCO2Sets4 = new List<CHFJPY_OCO2_UP_S2>();
        public static List<CHFJPY_OCO2_UP_S2> CHFJPY_UP_S2_OCO2Sets5 = new List<CHFJPY_OCO2_UP_S2>();
        public static List<CHFJPY_OCO2_UP_S2> CHFJPY_UP_S2_OCO2Sets6 = new List<CHFJPY_OCO2_UP_S2>();
        
        public static bool CHFJPY_OCO2_UP_S2_IsReady = true;
        public static bool CHFJPY_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket CHFJPY_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO2_MO6_DOWN_S2 ;
    	
    	public static int CHFJPY_OCO2_EO1_DOWN_S2_ID ;
        public static int CHFJPY_OCO2_EO2_DOWN_S2_ID ;
        public static int CHFJPY_OCO2_EO3_DOWN_S2_ID ;
        public static int CHFJPY_OCO2_EO4_DOWN_S2_ID ;
        public static int CHFJPY_OCO2_EO5_DOWN_S2_ID ;
        public static int CHFJPY_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool CHFJPY_OCO2_EO1_DOWN_S2 ;
        public static bool CHFJPY_OCO2_EO2_DOWN_S2 ;
        public static bool CHFJPY_OCO2_EO3_DOWN_S2 ;
        public static bool CHFJPY_OCO2_EO4_DOWN_S2 ;
        public static bool CHFJPY_OCO2_EO5_DOWN_S2 ;
        public static bool CHFJPY_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_DOWN_S2> CHFJPY_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_DOWN_S2> CHFJPY_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_DOWN_S2> CHFJPY_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_DOWN_S2> CHFJPY_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_DOWN_S2> CHFJPY_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO2_DOWN_S2> CHFJPY_OOFE_OCO2_DOWN_S2_6 ;
        
        public static CHFJPY_OCO2_DOWN_S2 CHFJPY_PFO_OCO2_DOWN_S2_1 ;
        public static CHFJPY_OCO2_DOWN_S2 CHFJPY_PFO_OCO2_DOWN_S2_2 ;
        public static CHFJPY_OCO2_DOWN_S2 CHFJPY_PFO_OCO2_DOWN_S2_3 ;
        public static CHFJPY_OCO2_DOWN_S2 CHFJPY_PFO_OCO2_DOWN_S2_4 ;
        public static CHFJPY_OCO2_DOWN_S2 CHFJPY_PFO_OCO2_DOWN_S2_5 ;
        public static CHFJPY_OCO2_DOWN_S2 CHFJPY_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<CHFJPY_OCO2_DOWN_S2> CHFJPY_DOWN_S2_OCO2Sets1 = new List<CHFJPY_OCO2_DOWN_S2>();
        public static List<CHFJPY_OCO2_DOWN_S2> CHFJPY_DOWN_S2_OCO2Sets2 = new List<CHFJPY_OCO2_DOWN_S2>();
        public static List<CHFJPY_OCO2_DOWN_S2> CHFJPY_DOWN_S2_OCO2Sets3 = new List<CHFJPY_OCO2_DOWN_S2>();
        public static List<CHFJPY_OCO2_DOWN_S2> CHFJPY_DOWN_S2_OCO2Sets4 = new List<CHFJPY_OCO2_DOWN_S2>();
        public static List<CHFJPY_OCO2_DOWN_S2> CHFJPY_DOWN_S2_OCO2Sets5 = new List<CHFJPY_OCO2_DOWN_S2>();
        public static List<CHFJPY_OCO2_DOWN_S2> CHFJPY_DOWN_S2_OCO2Sets6 = new List<CHFJPY_OCO2_DOWN_S2>();
        
        public static bool CHFJPY_OCO2_DOWN_S2_IsReady = true;
        public static bool CHFJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket CHFJPY_OCO3_MO1_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO2_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO3_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO4_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO5_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO6_UP_S2 ;
    	
    	public static int CHFJPY_OCO3_EO1_UP_S2_ID ;
        public static int CHFJPY_OCO3_EO2_UP_S2_ID ;
        public static int CHFJPY_OCO3_EO3_UP_S2_ID ;
        public static int CHFJPY_OCO3_EO4_UP_S2_ID ;
        public static int CHFJPY_OCO3_EO5_UP_S2_ID ;
        public static int CHFJPY_OCO3_EO6_UP_S2_ID ;
        
        public static bool CHFJPY_OCO3_EO1_UP_S2 ;
        public static bool CHFJPY_OCO3_EO2_UP_S2 ;
        public static bool CHFJPY_OCO3_EO3_UP_S2 ;
        public static bool CHFJPY_OCO3_EO4_UP_S2 ;
        public static bool CHFJPY_OCO3_EO5_UP_S2 ;
        public static bool CHFJPY_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_UP_S2> CHFJPY_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_UP_S2> CHFJPY_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_UP_S2> CHFJPY_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_UP_S2> CHFJPY_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_UP_S2> CHFJPY_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_UP_S2> CHFJPY_OOFE_OCO3_UP_S2_6 ;
        
        public static CHFJPY_OCO3_UP_S2 CHFJPY_PFO_OCO3_UP_S2_1 ;
        public static CHFJPY_OCO3_UP_S2 CHFJPY_PFO_OCO3_UP_S2_2 ;
        public static CHFJPY_OCO3_UP_S2 CHFJPY_PFO_OCO3_UP_S2_3 ;
        public static CHFJPY_OCO3_UP_S2 CHFJPY_PFO_OCO3_UP_S2_4 ;
        public static CHFJPY_OCO3_UP_S2 CHFJPY_PFO_OCO3_UP_S2_5 ;
        public static CHFJPY_OCO3_UP_S2 CHFJPY_PFO_OCO3_UP_S2_6 ;
        
        public static List<CHFJPY_OCO3_UP_S2> CHFJPY_UP_S2_OCO3Sets1 = new List<CHFJPY_OCO3_UP_S2>();
        public static List<CHFJPY_OCO3_UP_S2> CHFJPY_UP_S2_OCO3Sets2 = new List<CHFJPY_OCO3_UP_S2>();
        public static List<CHFJPY_OCO3_UP_S2> CHFJPY_UP_S2_OCO3Sets3 = new List<CHFJPY_OCO3_UP_S2>();
        public static List<CHFJPY_OCO3_UP_S2> CHFJPY_UP_S2_OCO3Sets4 = new List<CHFJPY_OCO3_UP_S2>();
        public static List<CHFJPY_OCO3_UP_S2> CHFJPY_UP_S2_OCO3Sets5 = new List<CHFJPY_OCO3_UP_S2>();
        public static List<CHFJPY_OCO3_UP_S2> CHFJPY_UP_S2_OCO3Sets6 = new List<CHFJPY_OCO3_UP_S2>();
        
        public static bool CHFJPY_OCO3_UP_S2_IsReady = true;
        public static bool CHFJPY_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket CHFJPY_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO3_MO6_DOWN_S2 ;
    	
    	public static int CHFJPY_OCO3_EO1_DOWN_S2_ID ;
        public static int CHFJPY_OCO3_EO2_DOWN_S2_ID ;
        public static int CHFJPY_OCO3_EO3_DOWN_S2_ID ;
        public static int CHFJPY_OCO3_EO4_DOWN_S2_ID ;
        public static int CHFJPY_OCO3_EO5_DOWN_S2_ID ;
        public static int CHFJPY_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool CHFJPY_OCO3_EO1_DOWN_S2 ;
        public static bool CHFJPY_OCO3_EO2_DOWN_S2 ;
        public static bool CHFJPY_OCO3_EO3_DOWN_S2 ;
        public static bool CHFJPY_OCO3_EO4_DOWN_S2 ;
        public static bool CHFJPY_OCO3_EO5_DOWN_S2 ;
        public static bool CHFJPY_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_DOWN_S2> CHFJPY_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_DOWN_S2> CHFJPY_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_DOWN_S2> CHFJPY_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_DOWN_S2> CHFJPY_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_DOWN_S2> CHFJPY_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO3_DOWN_S2> CHFJPY_OOFE_OCO3_DOWN_S2_6 ;
        
        public static CHFJPY_OCO3_DOWN_S2 CHFJPY_PFO_OCO3_DOWN_S2_1 ;
        public static CHFJPY_OCO3_DOWN_S2 CHFJPY_PFO_OCO3_DOWN_S2_2 ;
        public static CHFJPY_OCO3_DOWN_S2 CHFJPY_PFO_OCO3_DOWN_S2_3 ;
        public static CHFJPY_OCO3_DOWN_S2 CHFJPY_PFO_OCO3_DOWN_S2_4 ;
        public static CHFJPY_OCO3_DOWN_S2 CHFJPY_PFO_OCO3_DOWN_S2_5 ;
        public static CHFJPY_OCO3_DOWN_S2 CHFJPY_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<CHFJPY_OCO3_DOWN_S2> CHFJPY_DOWN_S2_OCO3Sets1 = new List<CHFJPY_OCO3_DOWN_S2>();
        public static List<CHFJPY_OCO3_DOWN_S2> CHFJPY_DOWN_S2_OCO3Sets2 = new List<CHFJPY_OCO3_DOWN_S2>();
        public static List<CHFJPY_OCO3_DOWN_S2> CHFJPY_DOWN_S2_OCO3Sets3 = new List<CHFJPY_OCO3_DOWN_S2>();
        public static List<CHFJPY_OCO3_DOWN_S2> CHFJPY_DOWN_S2_OCO3Sets4 = new List<CHFJPY_OCO3_DOWN_S2>();
        public static List<CHFJPY_OCO3_DOWN_S2> CHFJPY_DOWN_S2_OCO3Sets5 = new List<CHFJPY_OCO3_DOWN_S2>();
        public static List<CHFJPY_OCO3_DOWN_S2> CHFJPY_DOWN_S2_OCO3Sets6 = new List<CHFJPY_OCO3_DOWN_S2>();
        
        public static bool CHFJPY_OCO3_DOWN_S2_IsReady = true;
        public static bool CHFJPY_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket CHFJPY_OCO4_MO1_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO2_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO3_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO4_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO5_UP_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO6_UP_S2 ;
    	
    	public static int CHFJPY_OCO4_EO1_UP_S2_ID ;
        public static int CHFJPY_OCO4_EO2_UP_S2_ID ;
        public static int CHFJPY_OCO4_EO3_UP_S2_ID ;
        public static int CHFJPY_OCO4_EO4_UP_S2_ID ;
        public static int CHFJPY_OCO4_EO5_UP_S2_ID ;
        public static int CHFJPY_OCO4_EO6_UP_S2_ID ;
        
        public static bool CHFJPY_OCO4_EO1_UP_S2 ;
        public static bool CHFJPY_OCO4_EO2_UP_S2 ;
        public static bool CHFJPY_OCO4_EO3_UP_S2 ;
        public static bool CHFJPY_OCO4_EO4_UP_S2 ;
        public static bool CHFJPY_OCO4_EO5_UP_S2 ;
        public static bool CHFJPY_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_UP_S2> CHFJPY_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_UP_S2> CHFJPY_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_UP_S2> CHFJPY_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_UP_S2> CHFJPY_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_UP_S2> CHFJPY_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_UP_S2> CHFJPY_OOFE_OCO4_UP_S2_6 ;
        
        public static CHFJPY_OCO4_UP_S2 CHFJPY_PFO_OCO4_UP_S2_1 ;
        public static CHFJPY_OCO4_UP_S2 CHFJPY_PFO_OCO4_UP_S2_2 ;
        public static CHFJPY_OCO4_UP_S2 CHFJPY_PFO_OCO4_UP_S2_3 ;
        public static CHFJPY_OCO4_UP_S2 CHFJPY_PFO_OCO4_UP_S2_4 ;
        public static CHFJPY_OCO4_UP_S2 CHFJPY_PFO_OCO4_UP_S2_5 ;
        public static CHFJPY_OCO4_UP_S2 CHFJPY_PFO_OCO4_UP_S2_6 ;
        
        public static List<CHFJPY_OCO4_UP_S2> CHFJPY_UP_S2_OCO4Sets1 = new List<CHFJPY_OCO4_UP_S2>();
        public static List<CHFJPY_OCO4_UP_S2> CHFJPY_UP_S2_OCO4Sets2 = new List<CHFJPY_OCO4_UP_S2>();
        public static List<CHFJPY_OCO4_UP_S2> CHFJPY_UP_S2_OCO4Sets3 = new List<CHFJPY_OCO4_UP_S2>();
        public static List<CHFJPY_OCO4_UP_S2> CHFJPY_UP_S2_OCO4Sets4 = new List<CHFJPY_OCO4_UP_S2>();
        public static List<CHFJPY_OCO4_UP_S2> CHFJPY_UP_S2_OCO4Sets5 = new List<CHFJPY_OCO4_UP_S2>();
        public static List<CHFJPY_OCO4_UP_S2> CHFJPY_UP_S2_OCO4Sets6 = new List<CHFJPY_OCO4_UP_S2>();
        
        public static bool CHFJPY_OCO4_UP_S2_IsReady = true;
        public static bool CHFJPY_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket CHFJPY_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket CHFJPY_OCO4_MO6_DOWN_S2 ;
    	
    	public static int CHFJPY_OCO4_EO1_DOWN_S2_ID ;
        public static int CHFJPY_OCO4_EO2_DOWN_S2_ID ;
        public static int CHFJPY_OCO4_EO3_DOWN_S2_ID ;
        public static int CHFJPY_OCO4_EO4_DOWN_S2_ID ;
        public static int CHFJPY_OCO4_EO5_DOWN_S2_ID ;
        public static int CHFJPY_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool CHFJPY_OCO4_EO1_DOWN_S2 ;
        public static bool CHFJPY_OCO4_EO2_DOWN_S2 ;
        public static bool CHFJPY_OCO4_EO3_DOWN_S2 ;
        public static bool CHFJPY_OCO4_EO4_DOWN_S2 ;
        public static bool CHFJPY_OCO4_EO5_DOWN_S2 ;
        public static bool CHFJPY_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_DOWN_S2> CHFJPY_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_DOWN_S2> CHFJPY_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_DOWN_S2> CHFJPY_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_DOWN_S2> CHFJPY_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_DOWN_S2> CHFJPY_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CHFJPY_OCO4_DOWN_S2> CHFJPY_OOFE_OCO4_DOWN_S2_6 ;
        
        public static CHFJPY_OCO4_DOWN_S2 CHFJPY_PFO_OCO4_DOWN_S2_1 ;
        public static CHFJPY_OCO4_DOWN_S2 CHFJPY_PFO_OCO4_DOWN_S2_2 ;
        public static CHFJPY_OCO4_DOWN_S2 CHFJPY_PFO_OCO4_DOWN_S2_3 ;
        public static CHFJPY_OCO4_DOWN_S2 CHFJPY_PFO_OCO4_DOWN_S2_4 ;
        public static CHFJPY_OCO4_DOWN_S2 CHFJPY_PFO_OCO4_DOWN_S2_5 ;
        public static CHFJPY_OCO4_DOWN_S2 CHFJPY_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<CHFJPY_OCO4_DOWN_S2> CHFJPY_DOWN_S2_OCO4Sets1 = new List<CHFJPY_OCO4_DOWN_S2>();
        public static List<CHFJPY_OCO4_DOWN_S2> CHFJPY_DOWN_S2_OCO4Sets2 = new List<CHFJPY_OCO4_DOWN_S2>();
        public static List<CHFJPY_OCO4_DOWN_S2> CHFJPY_DOWN_S2_OCO4Sets3 = new List<CHFJPY_OCO4_DOWN_S2>();
        public static List<CHFJPY_OCO4_DOWN_S2> CHFJPY_DOWN_S2_OCO4Sets4 = new List<CHFJPY_OCO4_DOWN_S2>();
        public static List<CHFJPY_OCO4_DOWN_S2> CHFJPY_DOWN_S2_OCO4Sets5 = new List<CHFJPY_OCO4_DOWN_S2>();
        public static List<CHFJPY_OCO4_DOWN_S2> CHFJPY_DOWN_S2_OCO4Sets6 = new List<CHFJPY_OCO4_DOWN_S2>();
        
        public static bool CHFJPY_OCO4_DOWN_S2_IsReady = true;
        public static bool CHFJPY_OCO4_DOWN_S2_Monthly_IsReady = true;

        
////////////////////////////
		public static decimal CHFJPY_UP_S2_SL {get; set;}
		public static decimal CHFJPY_UP_S2_TP1 {get; set;}
		public static decimal CHFJPY_UP_S2_TP2 {get; set;}
		public static decimal CHFJPY_UP_S2_TP3 {get; set;}
		public static decimal CHFJPY_UP_S2_TP4 {get; set;}
		public static decimal CHFJPY_UP_S2_TP5 {get; set;}
		public static decimal CHFJPY_UP_S2_TP6 {get; set;}
		
		public static decimal CHFJPY_DOWN_S2_SL {get; set;}
		public static decimal CHFJPY_DOWN_S2_TP1 {get; set;}
		public static decimal CHFJPY_DOWN_S2_TP2 {get; set;}
		public static decimal CHFJPY_DOWN_S2_TP3 {get; set;}
		public static decimal CHFJPY_DOWN_S2_TP4 {get; set;}
		public static decimal CHFJPY_DOWN_S2_TP5 {get; set;}
		public static decimal CHFJPY_DOWN_S2_TP6 {get; set;}

        public static bool CHFJPY_Signal_Condition_UP_1 ;
        public static bool CHFJPY_Signal_Condition_UP_2 ;
        public static bool CHFJPY_Signal_Condition_UP_3 ;
        
        public static bool CHFJPY_Signal_Condition_DOWN_1 ;
        public static bool CHFJPY_Signal_Condition_DOWN_2 ;
        public static bool CHFJPY_Signal_Condition_DOWN_3 ;
        
        public static int CHFJPY_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int CHFJPY_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int CHFJPY_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int CHFJPY_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int CHFJPY_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int CHFJPY_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int CHFJPY_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int CHFJPY_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int CHFJPY_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int CHFJPY_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_CHFJPY_UP_S2 ;
        public static bool DOWM_CHFJPY_UP_S2 ;
        public static bool DOWT_CHFJPY_UP_S2 ;
        public static bool DOWW_CHFJPY_UP_S2 ;
        public static bool DOWTH_CHFJPY_UP_S2 ;
        
		public static bool DOWR_CHFJPY_DOWN_S2 ;
        public static bool DOWM_CHFJPY_DOWN_S2 ;
        public static bool DOWT_CHFJPY_DOWN_S2 ;
        public static bool DOWW_CHFJPY_DOWN_S2 ;
        public static bool DOWTH_CHFJPY_DOWN_S2 ;
        
        
		public static int CHFJPY_quantity_UP_S2 ;
		public static int CHFJPY_quantity_SL_UP_S2 ;
		public static int CHFJPY_quantity_TP1_UP_S2 ;
		public static int CHFJPY_quantity_TP2_UP_S2 ;
		public static int CHFJPY_quantity_TP3_UP_S2 ;
		public static int CHFJPY_quantity_TP4_UP_S2 ;
		public static int CHFJPY_quantity_TP5_UP_S2;
		public static int CHFJPY_quantity_TP6_UP_S2 ;
		
		public static int CHFJPY_quantity_DOWN_S2 ;
		public static int CHFJPY_quantity_SL_DOWN_S2 ;
		public static int CHFJPY_quantity_TP1_DOWN_S2 ;
		public static int CHFJPY_quantity_TP2_DOWN_S2 ;
		public static int CHFJPY_quantity_TP3_DOWN_S2 ;
		public static int CHFJPY_quantity_TP4_DOWN_S2 ;
		public static int CHFJPY_quantity_TP5_DOWN_S2;
		public static int CHFJPY_quantity_TP6_DOWN_S2 ;
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_NZDCAD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_NZDCAD_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(x=>x.Tag.Contains("NZDCAD_UP_S2_OCO1")))
			{
				Base.NZDCAD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCAD_UP_S2_OCO2")))
			{
				Base.NZDCAD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCAD_UP_S2_OCO3")))
			{
				Base.NZDCAD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("NZDCAD_UP_S2_OCO4")))
			{
				Base.NZDCAD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("NZDCAD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.NZDCAD_OCO1_EO1_UP_S2)
	                Base.NZDCAD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDCAD_OCO1_EO2_UP_S2)
	                Base.NZDCAD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO1_EO3_UP_S2)
	                Base.NZDCAD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO1_EO4_UP_S2)
	                Base.NZDCAD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO1_EO5_UP_S2)
	                Base.NZDCAD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO1_EO6_UP_S2)
	                Base.NZDCAD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCAD_OCO1S1_UP_S2 = 0;
		                for (; NZDCAD_OCO1S1_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets1.Count; NZDCAD_OCO1S1_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO1Sets1[NZDCAD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO1Sets1[NZDCAD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.NZDCAD_UP_S2_OCO1Sets1.Clear();
		                        NZDCAD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCAD_OCO1S2_UP_S2 = 0;
		                for (; NZDCAD_OCO1S2_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets2.Count; NZDCAD_OCO1S2_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO1Sets2[NZDCAD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO1Sets2[NZDCAD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.NZDCAD_UP_S2_OCO1Sets2.Clear();
		                        NZDCAD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO1S3_UP_S2 = 0;
		                for (; NZDCAD_OCO1S3_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets3.Count; NZDCAD_OCO1S3_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO1Sets3[NZDCAD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO1Sets3[NZDCAD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.NZDCAD_UP_S2_OCO1Sets3.Clear();
		                        NZDCAD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO1S4_UP_S2 = 0;
		                for (; NZDCAD_OCO1S4_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets4.Count; NZDCAD_OCO1S4_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO1Sets4[NZDCAD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO1Sets4[NZDCAD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.NZDCAD_UP_S2_OCO1Sets4.Clear();
		                        NZDCAD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO1S5_UP_S2 = 0;
		                for (; NZDCAD_OCO1S5_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets5.Count; NZDCAD_OCO1S5_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO1Sets5[NZDCAD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO1Sets5[NZDCAD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.NZDCAD_UP_S2_OCO1Sets5.Clear();
		                        NZDCAD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO1S6_UP_S2 = 0;
		                for (; NZDCAD_OCO1S6_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets6.Count; NZDCAD_OCO1S6_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO1Sets6[NZDCAD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO1Sets6[NZDCAD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.NZDCAD_UP_S2_OCO1Sets6.Clear();
		                        NZDCAD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.NZDCAD_OCO2_EO1_UP_S2)
                	Base.NZDCAD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDCAD_OCO2_EO2_UP_S2)
	                Base.NZDCAD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO2_EO3_UP_S2)
	                Base.NZDCAD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO2_EO4_UP_S2)
	                Base.NZDCAD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO2_EO5_UP_S2)
	                Base.NZDCAD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO2_EO6_UP_S2)
	                Base.NZDCAD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCAD_OCO2S1_UP_S2 = 0;
		                for (; NZDCAD_OCO2S1_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets1.Count; NZDCAD_OCO2S1_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO2Sets1[NZDCAD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO2Sets1[NZDCAD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.NZDCAD_UP_S2_OCO2Sets1.Clear();
		                        NZDCAD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCAD_OCO2S2_UP_S2 = 0;
		                for (; NZDCAD_OCO2S2_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets2.Count; NZDCAD_OCO2S2_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO2Sets2[NZDCAD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO2Sets2[NZDCAD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.NZDCAD_UP_S2_OCO2Sets2.Clear();
		                        NZDCAD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO2S3_UP_S2 = 0;
		                for (; NZDCAD_OCO2S3_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets3.Count; NZDCAD_OCO2S3_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO2Sets3[NZDCAD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO2Sets3[NZDCAD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.NZDCAD_UP_S2_OCO2Sets3.Clear();
		                        NZDCAD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO2S4_UP_S2 = 0;
		                for (; NZDCAD_OCO2S4_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets4.Count; NZDCAD_OCO2S4_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO2Sets4[NZDCAD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO2Sets4[NZDCAD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.NZDCAD_UP_S2_OCO2Sets4.Clear();
		                        NZDCAD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO2S5_UP_S2 = 0;
		                for (; NZDCAD_OCO2S5_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets5.Count; NZDCAD_OCO2S5_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO2Sets5[NZDCAD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO2Sets5[NZDCAD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.NZDCAD_UP_S2_OCO2Sets5.Clear();
		                        NZDCAD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO2S6_UP_S2 = 0;
		                for (; NZDCAD_OCO2S6_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets6.Count; NZDCAD_OCO2S6_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO2Sets6[NZDCAD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO2Sets6[NZDCAD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.NZDCAD_UP_S2_OCO2Sets6.Clear();
		                        NZDCAD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.NZDCAD_OCO3_EO1_UP_S2)
            		Base.NZDCAD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDCAD_OCO3_EO2_UP_S2)
	                Base.NZDCAD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO3_EO3_UP_S2)
	                Base.NZDCAD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO3_EO4_UP_S2)
	                Base.NZDCAD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO3_EO5_UP_S2)
	                Base.NZDCAD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO3_EO6_UP_S2)
	                Base.NZDCAD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCAD_OCO3S1_UP_S2 = 0;
		                for (; NZDCAD_OCO3S1_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets1.Count; NZDCAD_OCO3S1_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO3Sets1[NZDCAD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO3Sets1[NZDCAD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.NZDCAD_UP_S2_OCO3Sets1.Clear();
		                        NZDCAD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCAD_OCO3S2_UP_S2 = 0;
		                for (; NZDCAD_OCO3S2_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets2.Count; NZDCAD_OCO3S2_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO3Sets2[NZDCAD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO3Sets2[NZDCAD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.NZDCAD_UP_S2_OCO3Sets2.Clear();
		                        NZDCAD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO3S3_UP_S2 = 0;
		                for (; NZDCAD_OCO3S3_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets3.Count; NZDCAD_OCO3S3_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO3Sets3[NZDCAD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO3Sets3[NZDCAD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.NZDCAD_UP_S2_OCO3Sets3.Clear();
		                        NZDCAD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO3S4_UP_S2 = 0;
		                for (; NZDCAD_OCO3S4_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets4.Count; NZDCAD_OCO3S4_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO3Sets4[NZDCAD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO3Sets4[NZDCAD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.NZDCAD_UP_S2_OCO3Sets4.Clear();
		                        NZDCAD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO3S5_UP_S2 = 0;
		                for (; NZDCAD_OCO3S5_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets5.Count; NZDCAD_OCO3S5_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO3Sets5[NZDCAD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO3Sets5[NZDCAD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.NZDCAD_UP_S2_OCO3Sets5.Clear();
		                        NZDCAD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO3S6_UP_S2 = 0;
		                for (; NZDCAD_OCO3S6_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets6.Count; NZDCAD_OCO3S6_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO3Sets6[NZDCAD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO3Sets6[NZDCAD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.NZDCAD_UP_S2_OCO3Sets6.Clear();
		                        NZDCAD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.NZDCAD_OCO4_EO1_UP_S2)
            		Base.NZDCAD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.NZDCAD_OCO4_EO2_UP_S2)
	                Base.NZDCAD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO4_EO3_UP_S2)
	                Base.NZDCAD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO4_EO4_UP_S2)
	                Base.NZDCAD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO4_EO5_UP_S2)
	                Base.NZDCAD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.NZDCAD_OCO4_EO6_UP_S2)
	                Base.NZDCAD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.NZDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int NZDCAD_OCO4S1_UP_S2 = 0;
		                for (; NZDCAD_OCO4S1_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets1.Count; NZDCAD_OCO4S1_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO4Sets1[NZDCAD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO4Sets1[NZDCAD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.NZDCAD_UP_S2_OCO4Sets1.Clear();
		                        NZDCAD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int NZDCAD_OCO4S2_UP_S2 = 0;
		                for (; NZDCAD_OCO4S2_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets2.Count; NZDCAD_OCO4S2_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO4Sets2[NZDCAD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO4Sets2[NZDCAD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.NZDCAD_UP_S2_OCO4Sets2.Clear();
		                        NZDCAD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO4S3_UP_S2 = 0;
		                for (; NZDCAD_OCO4S3_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets3.Count; NZDCAD_OCO4S3_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO4Sets3[NZDCAD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO4Sets3[NZDCAD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.NZDCAD_UP_S2_OCO4Sets3.Clear();
		                        NZDCAD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int NZDCAD_OCO4S4_UP_S2 = 0;
		                for (; NZDCAD_OCO4S4_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets4.Count; NZDCAD_OCO4S4_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO4Sets4[NZDCAD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO4Sets4[NZDCAD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.NZDCAD_UP_S2_OCO4Sets4.Clear();
		                        NZDCAD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO4S5_UP_S2 = 0;
		                for (; NZDCAD_OCO4S5_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets5.Count; NZDCAD_OCO4S5_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO4Sets5[NZDCAD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO4Sets5[NZDCAD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.NZDCAD_UP_S2_OCO4Sets5.Clear();
		                        NZDCAD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int NZDCAD_OCO4S6_UP_S2 = 0;
		                for (; NZDCAD_OCO4S6_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets6.Count; NZDCAD_OCO4S6_UP_S2++)
		                    if (Base.NZDCAD_UP_S2_OCO4Sets6[NZDCAD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.NZDCAD_UP_S2_OCO4Sets6[NZDCAD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("NZDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("NZDCAD", order.Quantity, false, "NZDCAD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.NZDCAD_UP_S2_OCO4Sets6.Clear();
		                        NZDCAD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_NZDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_NZDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_NZDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_NZDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_NZDCAD_UP_S2 = DOWM_NZDCAD_UP_S2 || DOWT_NZDCAD_UP_S2 || DOWW_NZDCAD_UP_S2 || DOWTH_NZDCAD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("NZDCAD"))
	            	{
	            		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.NZDCAD_OCO1_UP_S2_IsReady == false ||
	                    	Base.NZDCAD_OCO2_UP_S2_IsReady == false ||
	                    	Base.NZDCAD_OCO3_UP_S2_IsReady == false ||
	                    	Base.NZDCAD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.NZDCAD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDCAD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDCAD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.NZDCAD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.NZDCAD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.NZDCAD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.NZDCAD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.NZDCAD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	NZDCAD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                	NZDCAD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                									
	                	NZDCAD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[0] < pricesM_BID_Low[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 (NZDCAD_Signal_Condition_UP_1)
	                	{
	                    	NZDCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (NZDCAD_Signal_Condition_UP_2)
	                	{
	                    	NZDCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (NZDCAD_Signal_Condition_UP_3)
	                	{
	                    	NZDCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (NZDCAD_Signal_Condition_UP_1)
	                	{
	                    	NZDCAD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (NZDCAD_Signal_Condition_UP_2)
	                	{
	                    	NZDCAD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (NZDCAD_Signal_Condition_UP_3)
	                	{
	                    	NZDCAD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    NZDCAD_UP_S2_TP2 =  NZDCAD_UP_S2_SL * 0;
	                    NZDCAD_UP_S2_TP3 =  NZDCAD_UP_S2_SL * 0;
	                    NZDCAD_UP_S2_TP4 =  NZDCAD_UP_S2_SL * 0;
	                    NZDCAD_UP_S2_TP5 =  NZDCAD_UP_S2_SL * 0;
	                    NZDCAD_UP_S2_TP6 =  NZDCAD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    NZDCAD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    NZDCAD_quantity_SL_UP_S2 = NZDCAD_quantity_UP_S2;
	                    NZDCAD_quantity_TP1_UP_S2 = (int)Math.Floor(NZDCAD_quantity_UP_S2 * 1m);
	                    NZDCAD_quantity_TP2_UP_S2 = (int)Math.Floor(NZDCAD_quantity_TP1_UP_S2 * 0m);
	                    NZDCAD_quantity_TP3_UP_S2 = (int)Math.Floor(NZDCAD_quantity_TP2_UP_S2 * 0m);
	                    NZDCAD_quantity_TP4_UP_S2 = (int)Math.Floor(NZDCAD_quantity_TP3_UP_S2 * 0m);
	                    NZDCAD_quantity_TP5_UP_S2 = (int)Math.Floor(NZDCAD_quantity_TP4_UP_S2 * 0m);
	                    NZDCAD_quantity_TP6_UP_S2 = (int)Math.Floor(NZDCAD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((NZDCAD_Signal_Condition_UP_1 || NZDCAD_Signal_Condition_UP_2 || NZDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_NZDCAD_UP_S2 && 
	                    Base.NZDCAD_OCO1_UP_S2_IsReady == true &&
	                    Base.NZDCAD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCAD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP1_UP_S2, false,"NZDCAD_UP_S2_Entry_TP1_OCO1");
	                         Base.NZDCAD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.NZDCAD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP2_UP_S2, false,"NZDCAD_UP_S2_Entry_TP2_OCO1");
	                         Base.NZDCAD_OCO1_EO2_UP_S2 = false;
	
	                         Base.NZDCAD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP3_UP_S2, false,"NZDCAD_UP_S2_Entry_TP3_OCO1");
	                         Base.NZDCAD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.NZDCAD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP4_UP_S2, false,"NZDCAD_UP_S2_Entry_TP4_OCO1");
	                         Base.NZDCAD_OCO1_EO4_UP_S2 = false;

							Base.NZDCAD_OCO1_UP_S2_IsReady = false;
							
							if (Base.NZDCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((NZDCAD_Signal_Condition_UP_1 || NZDCAD_Signal_Condition_UP_2 || NZDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_NZDCAD_UP_S2 && 
	                    Base.NZDCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDCAD_OCO2_UP_S2_IsReady == true &&
	                    Base.NZDCAD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCAD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP1_UP_S2, false,"NZDCAD_UP_S2_Entry_TP1_OCO2");
	                         Base.NZDCAD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.NZDCAD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP2_UP_S2, false,"NZDCAD_UP_S2_Entry_TP2_OCO2");
	                         Base.NZDCAD_OCO2_EO2_UP_S2 = false;
	
	                         Base.NZDCAD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP3_UP_S2, false,"NZDCAD_UP_S2_Entry_TP3_OCO2");
	                         Base.NZDCAD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.NZDCAD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP4_UP_S2, false,"NZDCAD_UP_S2_Entry_TP4_OCO2");
	                         Base.NZDCAD_OCO2_EO4_UP_S2 = false;

							Base.NZDCAD_OCO2_UP_S2_IsReady = false;
							
							if (Base.NZDCAD_OCO2_UP_S2_IsReady == false && Base.NZDCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((NZDCAD_Signal_Condition_UP_1 || NZDCAD_Signal_Condition_UP_2 || NZDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_NZDCAD_UP_S2 &&
	                    Base.NZDCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.NZDCAD_OCO3_UP_S2_IsReady == true &&
	                    Base.NZDCAD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCAD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP1_UP_S2, false,"NZDCAD_UP_S2_Entry_TP1_OCO3");
	                         Base.NZDCAD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.NZDCAD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP2_UP_S2, false,"NZDCAD_UP_S2_Entry_TP2_OCO3");
	                         Base.NZDCAD_OCO3_EO2_UP_S2 = false;
	
	                         Base.NZDCAD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP3_UP_S2, false,"NZDCAD_UP_S2_Entry_TP3_OCO3");
	                         Base.NZDCAD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.NZDCAD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP4_UP_S2, false,"NZDCAD_UP_S2_Entry_TP4_OCO3");
	                         Base.NZDCAD_OCO3_EO4_UP_S2 = false;

							Base.NZDCAD_OCO3_UP_S2_IsReady = false;
							
							if (Base.NZDCAD_OCO3_UP_S2_IsReady == false && Base.NZDCAD_OCO2_UP_S2_IsReady == false && Base.NZDCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((NZDCAD_Signal_Condition_UP_1 || NZDCAD_Signal_Condition_UP_2 || NZDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_NZDCAD_UP_S2 && 
	                    Base.NZDCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.NZDCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.NZDCAD_OCO3_UP_S2_IsReady == false &&
	                    Base.NZDCAD_OCO4_UP_S2_IsReady == true &&
	                    Base.NZDCAD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.NZDCAD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP1_UP_S2, false,"NZDCAD_UP_S2_Entry_TP1_OCO4");
	                         Base.NZDCAD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.NZDCAD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP2_UP_S2, false,"NZDCAD_UP_S2_Entry_TP2_OCO4");
	                         Base.NZDCAD_OCO4_EO2_UP_S2 = false;
	
	                         Base.NZDCAD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP3_UP_S2, false,"NZDCAD_UP_S2_Entry_TP3_OCO4");
	                         Base.NZDCAD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.NZDCAD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         NZDCAD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, NZDCAD_quantity_TP4_UP_S2, false,"NZDCAD_UP_S2_Entry_TP4_OCO4");
	                         Base.NZDCAD_OCO4_EO4_UP_S2 = false;

							Base.NZDCAD_OCO4_UP_S2_IsReady = false;
							
							if (Base.NZDCAD_OCO4_UP_S2_IsReady == false && Base.NZDCAD_OCO3_UP_S2_IsReady == false && Base.NZDCAD_OCO2_UP_S2_IsReady == false && Base.NZDCAD_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDNZD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDNZD_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("AUDNZD_DOWN_S2_OCO1")))
			{
				Base.AUDNZD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDNZD_DOWN_S2_OCO2")))
			{
				Base.AUDNZD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDNZD_DOWN_S2_OCO3")))
			{
				Base.AUDNZD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDNZD_DOWN_S2_OCO4")))
			{
				Base.AUDNZD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDNZD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.AUDNZD_OCO1_EO1_DOWN_S2)
	                Base.AUDNZD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDNZD_OCO1_EO2_DOWN_S2)
	                Base.AUDNZD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO1_EO3_DOWN_S2)
	                Base.AUDNZD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO1_EO4_DOWN_S2)
	                Base.AUDNZD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO1_EO5_DOWN_S2)
	                Base.AUDNZD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO1_EO6_DOWN_S2)
	                Base.AUDNZD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDNZD_OCO1S1_DOWN_S2 = 0;
		                for (; AUDNZD_OCO1S1_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets1.Count; AUDNZD_OCO1S1_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO1Sets1[AUDNZD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO1Sets1[AUDNZD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.AUDNZD_DOWN_S2_OCO1Sets1.Clear();
		                        AUDNZD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDNZD_OCO1S2_DOWN_S2 = 0;
		                for (; AUDNZD_OCO1S2_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets2.Count; AUDNZD_OCO1S2_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO1Sets2[AUDNZD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO1Sets2[AUDNZD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.AUDNZD_DOWN_S2_OCO1Sets2.Clear();
		                        AUDNZD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO1S3_DOWN_S2 = 0;
		                for (; AUDNZD_OCO1S3_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets3.Count; AUDNZD_OCO1S3_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO1Sets3[AUDNZD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO1Sets3[AUDNZD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.AUDNZD_DOWN_S2_OCO1Sets3.Clear();
		                        AUDNZD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO1S4_DOWN_S2 = 0;
		                for (; AUDNZD_OCO1S4_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets4.Count; AUDNZD_OCO1S4_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO1Sets4[AUDNZD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO1Sets4[AUDNZD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.AUDNZD_DOWN_S2_OCO1Sets4.Clear();
		                        AUDNZD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO1S5_DOWN_S2 = 0;
		                for (; AUDNZD_OCO1S5_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets5.Count; AUDNZD_OCO1S5_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO1Sets5[AUDNZD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO1Sets5[AUDNZD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.AUDNZD_DOWN_S2_OCO1Sets5.Clear();
		                        AUDNZD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO1S6_DOWN_S2 = 0;
		                for (; AUDNZD_OCO1S6_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO1Sets6.Count; AUDNZD_OCO1S6_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO1Sets6[AUDNZD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO1Sets6[AUDNZD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.AUDNZD_DOWN_S2_OCO1Sets6.Clear();
		                        AUDNZD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDNZD_OCO2_EO1_DOWN_S2)
	                Base.AUDNZD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDNZD_OCO2_EO2_DOWN_S2)
	                Base.AUDNZD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO2_EO3_DOWN_S2)
	                Base.AUDNZD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO2_EO4_DOWN_S2)
	                Base.AUDNZD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO2_EO5_DOWN_S2)
	                Base.AUDNZD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO2_EO6_DOWN_S2)
	                Base.AUDNZD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDNZD_OCO2S1_DOWN_S2 = 0;
		                for (; AUDNZD_OCO2S1_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets1.Count; AUDNZD_OCO2S1_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO2Sets1[AUDNZD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO2Sets1[AUDNZD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.AUDNZD_DOWN_S2_OCO2Sets1.Clear();
		                        AUDNZD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDNZD_OCO2S2_DOWN_S2 = 0;
		                for (; AUDNZD_OCO2S2_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets2.Count; AUDNZD_OCO2S2_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO2Sets2[AUDNZD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO2Sets2[AUDNZD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.AUDNZD_DOWN_S2_OCO2Sets2.Clear();
		                        AUDNZD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO2S3_DOWN_S2 = 0;
		                for (; AUDNZD_OCO2S3_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets3.Count; AUDNZD_OCO2S3_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO2Sets3[AUDNZD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO2Sets3[AUDNZD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.AUDNZD_DOWN_S2_OCO2Sets3.Clear();
		                        AUDNZD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO2S4_DOWN_S2 = 0;
		                for (; AUDNZD_OCO2S4_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets4.Count; AUDNZD_OCO2S4_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO2Sets4[AUDNZD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO2Sets4[AUDNZD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.AUDNZD_DOWN_S2_OCO2Sets4.Clear();
		                        AUDNZD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO2S5_DOWN_S2 = 0;
		                for (; AUDNZD_OCO2S5_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets5.Count; AUDNZD_OCO2S5_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO2Sets5[AUDNZD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO2Sets5[AUDNZD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.AUDNZD_DOWN_S2_OCO2Sets5.Clear();
		                        AUDNZD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO2S6_DOWN_S2 = 0;
		                for (; AUDNZD_OCO2S6_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO2Sets6.Count; AUDNZD_OCO2S6_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO2Sets6[AUDNZD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO2Sets6[AUDNZD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.AUDNZD_DOWN_S2_OCO2Sets6.Clear();
		                        AUDNZD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDNZD_OCO3_EO1_DOWN_S2)
	                Base.AUDNZD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDNZD_OCO3_EO2_DOWN_S2)
	                Base.AUDNZD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO3_EO3_DOWN_S2)
	                Base.AUDNZD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO3_EO4_DOWN_S2)
	                Base.AUDNZD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO3_EO5_DOWN_S2)
	                Base.AUDNZD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO3_EO6_DOWN_S2)
	                Base.AUDNZD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDNZD_OCO3S1_DOWN_S2 = 0;
		                for (; AUDNZD_OCO3S1_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets1.Count; AUDNZD_OCO3S1_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO3Sets1[AUDNZD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO3Sets1[AUDNZD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.AUDNZD_DOWN_S2_OCO3Sets1.Clear();
		                        AUDNZD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDNZD_OCO3S2_DOWN_S2 = 0;
		                for (; AUDNZD_OCO3S2_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets2.Count; AUDNZD_OCO3S2_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO3Sets2[AUDNZD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO3Sets2[AUDNZD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.AUDNZD_DOWN_S2_OCO3Sets2.Clear();
		                        AUDNZD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO3S3_DOWN_S2 = 0;
		                for (; AUDNZD_OCO3S3_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets3.Count; AUDNZD_OCO3S3_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO3Sets3[AUDNZD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO3Sets3[AUDNZD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.AUDNZD_DOWN_S2_OCO3Sets3.Clear();
		                        AUDNZD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO3S4_DOWN_S2 = 0;
		                for (; AUDNZD_OCO3S4_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets4.Count; AUDNZD_OCO3S4_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO3Sets4[AUDNZD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO3Sets4[AUDNZD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.AUDNZD_DOWN_S2_OCO3Sets4.Clear();
		                        AUDNZD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO3S5_DOWN_S2 = 0;
		                for (; AUDNZD_OCO3S5_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets5.Count; AUDNZD_OCO3S5_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO3Sets5[AUDNZD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO3Sets5[AUDNZD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.AUDNZD_DOWN_S2_OCO3Sets5.Clear();
		                        AUDNZD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO3S6_DOWN_S2 = 0;
		                for (; AUDNZD_OCO3S6_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO3Sets6.Count; AUDNZD_OCO3S6_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO3Sets6[AUDNZD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO3Sets6[AUDNZD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.AUDNZD_DOWN_S2_OCO3Sets6.Clear();
		                        AUDNZD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDNZD_OCO4_EO1_DOWN_S2)
	                Base.AUDNZD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDNZD_OCO4_EO2_DOWN_S2)
	                Base.AUDNZD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO4_EO3_DOWN_S2)
	                Base.AUDNZD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO4_EO4_DOWN_S2)
	                Base.AUDNZD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO4_EO5_DOWN_S2)
	                Base.AUDNZD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO4_EO6_DOWN_S2)
	                Base.AUDNZD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDNZD_OCO4S1_DOWN_S2 = 0;
		                for (; AUDNZD_OCO4S1_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets1.Count; AUDNZD_OCO4S1_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO4Sets1[AUDNZD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO4Sets1[AUDNZD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.AUDNZD_DOWN_S2_OCO4Sets1.Clear();
		                        AUDNZD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDNZD_OCO4S2_DOWN_S2 = 0;
		                for (; AUDNZD_OCO4S2_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets2.Count; AUDNZD_OCO4S2_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO4Sets2[AUDNZD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO4Sets2[AUDNZD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.AUDNZD_DOWN_S2_OCO4Sets2.Clear();
		                        AUDNZD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO4S3_DOWN_S2 = 0;
		                for (; AUDNZD_OCO4S3_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets3.Count; AUDNZD_OCO4S3_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO4Sets3[AUDNZD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO4Sets3[AUDNZD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.AUDNZD_DOWN_S2_OCO4Sets3.Clear();
		                        AUDNZD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO4S4_DOWN_S2 = 0;
		                for (; AUDNZD_OCO4S4_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets4.Count; AUDNZD_OCO4S4_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO4Sets4[AUDNZD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO4Sets4[AUDNZD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.AUDNZD_DOWN_S2_OCO4Sets4.Clear();
		                        AUDNZD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO4S5_DOWN_S2 = 0;
		                for (; AUDNZD_OCO4S5_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets5.Count; AUDNZD_OCO4S5_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO4Sets5[AUDNZD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO4Sets5[AUDNZD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.AUDNZD_DOWN_S2_OCO4Sets5.Clear();
		                        AUDNZD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO4S6_DOWN_S2 = 0;
		                for (; AUDNZD_OCO4S6_DOWN_S2 < Base.AUDNZD_DOWN_S2_OCO4Sets6.Count; AUDNZD_OCO4S6_DOWN_S2++)
		                    if (Base.AUDNZD_DOWN_S2_OCO4Sets6[AUDNZD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_DOWN_S2_OCO4Sets6[AUDNZD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.AUDNZD_DOWN_S2_OCO4Sets6.Clear();
		                        AUDNZD_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();
	            	}
	            	
					DOWM_AUDNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDNZD_DOWN_S2 = DOWM_AUDNZD_DOWN_S2 || DOWT_AUDNZD_DOWN_S2 || DOWW_AUDNZD_DOWN_S2 || DOWTH_AUDNZD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDNZD"))
	            	{
	            		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.AUDNZD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.AUDNZD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.AUDNZD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.AUDNZD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.AUDNZD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDNZD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDNZD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDNZD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDNZD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDNZD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDNZD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDNZD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	AUDNZD_Signal_Condition_DOWN_S2 =  
	                									(
																//pricesM_BID_High[0] - pricesM_BID_Open[0] > prices_BID_Close[0] * 0.001m &&
		                										//pricesM_BID_High[1] - pricesM_BID_Open[1] > prices_BID_Close[0] * 0.00001m &&
		                										
		                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > prices_BID_Close[0] * 0.02m &&
		                										//pricesM_ASK_Open[1] - pricesM_BID_Close[1] > prices_BID_Close[0] * 0.00001m &&
	
		                										prices_ASK_High[0] > (pricesM_ASK_High[0] - pricesM_BID_Low[0])/2 &&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < 0.0005m
	                									);
	                									
	                    AUDNZD_DOWN_S2_SL  =  0.01m;
	                    AUDNZD_DOWN_S2_TP1 =  0.005m;
	                    AUDNZD_DOWN_S2_TP2 =  AUDNZD_DOWN_S2_SL * 0;
	                    AUDNZD_DOWN_S2_TP3 =  AUDNZD_DOWN_S2_SL * 0;
	                    AUDNZD_DOWN_S2_TP4 =  AUDNZD_DOWN_S2_SL * 0;
	                    AUDNZD_DOWN_S2_TP5 =  AUDNZD_DOWN_S2_SL * 0;
	                    AUDNZD_DOWN_S2_TP6 =  AUDNZD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    AUDNZD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    AUDNZD_quantity_SL_DOWN_S2 = AUDNZD_quantity_DOWN_S2;
	                    AUDNZD_quantity_TP1_DOWN_S2 = (int)Math.Floor(AUDNZD_quantity_DOWN_S2 * 1m);
	                    AUDNZD_quantity_TP2_DOWN_S2 = (int)Math.Floor(AUDNZD_quantity_TP1_DOWN_S2 * 0m);
	                    AUDNZD_quantity_TP3_DOWN_S2 = (int)Math.Floor(AUDNZD_quantity_TP2_DOWN_S2 * 0m);
	                    AUDNZD_quantity_TP4_DOWN_S2 = (int)Math.Floor(AUDNZD_quantity_TP3_DOWN_S2 * 0m);
	                    AUDNZD_quantity_TP5_DOWN_S2 = (int)Math.Floor(AUDNZD_quantity_TP4_DOWN_S2 * 0m);
	                    AUDNZD_quantity_TP6_DOWN_S2 = (int)Math.Floor(AUDNZD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (AUDNZD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDNZD_DOWN_S2 && 
	                    Base.AUDNZD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.AUDNZD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDNZD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP1_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.AUDNZD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDNZD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP2_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.AUDNZD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.AUDNZD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP3_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.AUDNZD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDNZD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP4_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.AUDNZD_OCO1_EO4_DOWN_S2 = false;

							Base.AUDNZD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.AUDNZD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (AUDNZD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDNZD_DOWN_S2 && 
	                    Base.AUDNZD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.AUDNZD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDNZD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDNZD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP1_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.AUDNZD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDNZD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP2_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.AUDNZD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.AUDNZD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP3_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.AUDNZD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDNZD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP4_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.AUDNZD_OCO2_EO4_DOWN_S2 = false;

							Base.AUDNZD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.AUDNZD_OCO2_DOWN_S2_IsReady == false && Base.AUDNZD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (AUDNZD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDNZD_DOWN_S2 &&
	                    Base.AUDNZD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.AUDNZD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDNZD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDNZD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDNZD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP1_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.AUDNZD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDNZD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP2_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.AUDNZD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.AUDNZD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP3_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.AUDNZD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDNZD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP4_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.AUDNZD_OCO3_EO4_DOWN_S2 = false;

							Base.AUDNZD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.AUDNZD_OCO3_DOWN_S2_IsReady == false && Base.AUDNZD_OCO2_DOWN_S2_IsReady == false && Base.AUDNZD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (AUDNZD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDNZD_DOWN_S2 && 
	                    Base.AUDNZD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.AUDNZD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDNZD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDNZD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.AUDNZD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDNZD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP1_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.AUDNZD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDNZD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP2_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.AUDNZD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.AUDNZD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP3_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.AUDNZD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDNZD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDNZD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP4_DOWN_S2, false,"AUDNZD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.AUDNZD_OCO4_EO4_DOWN_S2 = false;

							Base.AUDNZD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.AUDNZD_OCO4_DOWN_S2_IsReady == false && Base.AUDNZD_OCO3_DOWN_S2_IsReady == false && Base.AUDNZD_OCO2_DOWN_S2_IsReady == false && Base.AUDNZD_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDNZD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDNZD_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(x=>x.Tag.Contains("AUDNZD_UP_S2_OCO1")))
			{
				Base.AUDNZD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDNZD_UP_S2_OCO2")))
			{
				Base.AUDNZD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDNZD_UP_S2_OCO3")))
			{
				Base.AUDNZD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDNZD_UP_S2_OCO4")))
			{
				Base.AUDNZD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDNZD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.AUDNZD_OCO1_EO1_UP_S2)
	                Base.AUDNZD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDNZD_OCO1_EO2_UP_S2)
	                Base.AUDNZD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO1_EO3_UP_S2)
	                Base.AUDNZD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO1_EO4_UP_S2)
	                Base.AUDNZD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO1_EO5_UP_S2)
	                Base.AUDNZD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO1_EO6_UP_S2)
	                Base.AUDNZD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDNZD_OCO1S1_UP_S2 = 0;
		                for (; AUDNZD_OCO1S1_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets1.Count; AUDNZD_OCO1S1_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO1Sets1[AUDNZD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO1Sets1[AUDNZD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.AUDNZD_UP_S2_OCO1Sets1.Clear();
		                        AUDNZD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDNZD_OCO1S2_UP_S2 = 0;
		                for (; AUDNZD_OCO1S2_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets2.Count; AUDNZD_OCO1S2_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO1Sets2[AUDNZD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO1Sets2[AUDNZD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.AUDNZD_UP_S2_OCO1Sets2.Clear();
		                        AUDNZD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO1S3_UP_S2 = 0;
		                for (; AUDNZD_OCO1S3_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets3.Count; AUDNZD_OCO1S3_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO1Sets3[AUDNZD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO1Sets3[AUDNZD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.AUDNZD_UP_S2_OCO1Sets3.Clear();
		                        AUDNZD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO1S4_UP_S2 = 0;
		                for (; AUDNZD_OCO1S4_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets4.Count; AUDNZD_OCO1S4_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO1Sets4[AUDNZD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO1Sets4[AUDNZD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.AUDNZD_UP_S2_OCO1Sets4.Clear();
		                        AUDNZD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO1S5_UP_S2 = 0;
		                for (; AUDNZD_OCO1S5_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets5.Count; AUDNZD_OCO1S5_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO1Sets5[AUDNZD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO1Sets5[AUDNZD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.AUDNZD_UP_S2_OCO1Sets5.Clear();
		                        AUDNZD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO1S6_UP_S2 = 0;
		                for (; AUDNZD_OCO1S6_UP_S2 < Base.AUDNZD_UP_S2_OCO1Sets6.Count; AUDNZD_OCO1S6_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO1Sets6[AUDNZD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO1Sets6[AUDNZD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.AUDNZD_UP_S2_OCO1Sets6.Clear();
		                        AUDNZD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDNZD_OCO2_EO1_UP_S2)
                	Base.AUDNZD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDNZD_OCO2_EO2_UP_S2)
	                Base.AUDNZD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO2_EO3_UP_S2)
	                Base.AUDNZD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO2_EO4_UP_S2)
	                Base.AUDNZD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO2_EO5_UP_S2)
	                Base.AUDNZD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO2_EO6_UP_S2)
	                Base.AUDNZD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDNZD_OCO2S1_UP_S2 = 0;
		                for (; AUDNZD_OCO2S1_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets1.Count; AUDNZD_OCO2S1_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO2Sets1[AUDNZD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO2Sets1[AUDNZD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.AUDNZD_UP_S2_OCO2Sets1.Clear();
		                        AUDNZD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDNZD_OCO2S2_UP_S2 = 0;
		                for (; AUDNZD_OCO2S2_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets2.Count; AUDNZD_OCO2S2_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO2Sets2[AUDNZD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO2Sets2[AUDNZD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.AUDNZD_UP_S2_OCO2Sets2.Clear();
		                        AUDNZD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO2S3_UP_S2 = 0;
		                for (; AUDNZD_OCO2S3_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets3.Count; AUDNZD_OCO2S3_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO2Sets3[AUDNZD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO2Sets3[AUDNZD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.AUDNZD_UP_S2_OCO2Sets3.Clear();
		                        AUDNZD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO2S4_UP_S2 = 0;
		                for (; AUDNZD_OCO2S4_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets4.Count; AUDNZD_OCO2S4_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO2Sets4[AUDNZD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO2Sets4[AUDNZD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.AUDNZD_UP_S2_OCO2Sets4.Clear();
		                        AUDNZD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO2S5_UP_S2 = 0;
		                for (; AUDNZD_OCO2S5_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets5.Count; AUDNZD_OCO2S5_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO2Sets5[AUDNZD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO2Sets5[AUDNZD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.AUDNZD_UP_S2_OCO2Sets5.Clear();
		                        AUDNZD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO2S6_UP_S2 = 0;
		                for (; AUDNZD_OCO2S6_UP_S2 < Base.AUDNZD_UP_S2_OCO2Sets6.Count; AUDNZD_OCO2S6_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO2Sets6[AUDNZD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO2Sets6[AUDNZD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.AUDNZD_UP_S2_OCO2Sets6.Clear();
		                        AUDNZD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDNZD_OCO3_EO1_UP_S2)
            		Base.AUDNZD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDNZD_OCO3_EO2_UP_S2)
	                Base.AUDNZD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO3_EO3_UP_S2)
	                Base.AUDNZD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO3_EO4_UP_S2)
	                Base.AUDNZD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO3_EO5_UP_S2)
	                Base.AUDNZD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO3_EO6_UP_S2)
	                Base.AUDNZD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDNZD_OCO3S1_UP_S2 = 0;
		                for (; AUDNZD_OCO3S1_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets1.Count; AUDNZD_OCO3S1_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO3Sets1[AUDNZD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO3Sets1[AUDNZD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.AUDNZD_UP_S2_OCO3Sets1.Clear();
		                        AUDNZD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDNZD_OCO3S2_UP_S2 = 0;
		                for (; AUDNZD_OCO3S2_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets2.Count; AUDNZD_OCO3S2_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO3Sets2[AUDNZD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO3Sets2[AUDNZD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.AUDNZD_UP_S2_OCO3Sets2.Clear();
		                        AUDNZD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO3S3_UP_S2 = 0;
		                for (; AUDNZD_OCO3S3_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets3.Count; AUDNZD_OCO3S3_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO3Sets3[AUDNZD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO3Sets3[AUDNZD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.AUDNZD_UP_S2_OCO3Sets3.Clear();
		                        AUDNZD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO3S4_UP_S2 = 0;
		                for (; AUDNZD_OCO3S4_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets4.Count; AUDNZD_OCO3S4_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO3Sets4[AUDNZD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO3Sets4[AUDNZD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.AUDNZD_UP_S2_OCO3Sets4.Clear();
		                        AUDNZD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO3S5_UP_S2 = 0;
		                for (; AUDNZD_OCO3S5_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets5.Count; AUDNZD_OCO3S5_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO3Sets5[AUDNZD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO3Sets5[AUDNZD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.AUDNZD_UP_S2_OCO3Sets5.Clear();
		                        AUDNZD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO3S6_UP_S2 = 0;
		                for (; AUDNZD_OCO3S6_UP_S2 < Base.AUDNZD_UP_S2_OCO3Sets6.Count; AUDNZD_OCO3S6_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO3Sets6[AUDNZD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO3Sets6[AUDNZD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.AUDNZD_UP_S2_OCO3Sets6.Clear();
		                        AUDNZD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDNZD_OCO4_EO1_UP_S2)
            		Base.AUDNZD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDNZD_OCO4_EO2_UP_S2)
	                Base.AUDNZD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO4_EO3_UP_S2)
	                Base.AUDNZD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO4_EO4_UP_S2)
	                Base.AUDNZD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO4_EO5_UP_S2)
	                Base.AUDNZD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDNZD_OCO4_EO6_UP_S2)
	                Base.AUDNZD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDNZD_OCO4S1_UP_S2 = 0;
		                for (; AUDNZD_OCO4S1_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets1.Count; AUDNZD_OCO4S1_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO4Sets1[AUDNZD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO4Sets1[AUDNZD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.AUDNZD_UP_S2_OCO4Sets1.Clear();
		                        AUDNZD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDNZD_OCO4S2_UP_S2 = 0;
		                for (; AUDNZD_OCO4S2_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets2.Count; AUDNZD_OCO4S2_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO4Sets2[AUDNZD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO4Sets2[AUDNZD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.AUDNZD_UP_S2_OCO4Sets2.Clear();
		                        AUDNZD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO4S3_UP_S2 = 0;
		                for (; AUDNZD_OCO4S3_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets3.Count; AUDNZD_OCO4S3_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO4Sets3[AUDNZD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO4Sets3[AUDNZD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.AUDNZD_UP_S2_OCO4Sets3.Clear();
		                        AUDNZD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDNZD_OCO4S4_UP_S2 = 0;
		                for (; AUDNZD_OCO4S4_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets4.Count; AUDNZD_OCO4S4_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO4Sets4[AUDNZD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO4Sets4[AUDNZD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.AUDNZD_UP_S2_OCO4Sets4.Clear();
		                        AUDNZD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO4S5_UP_S2 = 0;
		                for (; AUDNZD_OCO4S5_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets5.Count; AUDNZD_OCO4S5_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO4Sets5[AUDNZD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO4Sets5[AUDNZD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.AUDNZD_UP_S2_OCO4Sets5.Clear();
		                        AUDNZD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDNZD_OCO4S6_UP_S2 = 0;
		                for (; AUDNZD_OCO4S6_UP_S2 < Base.AUDNZD_UP_S2_OCO4Sets6.Count; AUDNZD_OCO4S6_UP_S2++)
		                    if (Base.AUDNZD_UP_S2_OCO4Sets6[AUDNZD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDNZD_UP_S2_OCO4Sets6[AUDNZD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDNZD", order.Quantity, false, "AUDNZD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.AUDNZD_UP_S2_OCO4Sets6.Clear();
		                        AUDNZD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_AUDNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDNZD_UP_S2 = DOWM_AUDNZD_UP_S2 || DOWT_AUDNZD_UP_S2 || DOWW_AUDNZD_UP_S2 || DOWTH_AUDNZD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDNZD"))
	            	{
	            		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.AUDNZD_OCO1_UP_S2_IsReady == false ||
	                    	Base.AUDNZD_OCO2_UP_S2_IsReady == false ||
	                    	Base.AUDNZD_OCO3_UP_S2_IsReady == false ||
	                    	Base.AUDNZD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.AUDNZD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDNZD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDNZD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDNZD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDNZD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.AUDNZD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.AUDNZD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.AUDNZD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	AUDNZD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											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.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*2
		                										
		                										)
		                							
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	AUDNZD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*2
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	AUDNZD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(

		                										prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*2
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (AUDNZD_Signal_Condition_UP_1)
	                	{
	                    	AUDNZD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDNZD_Signal_Condition_UP_2)
	                	{
	                    	AUDNZD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDNZD_Signal_Condition_UP_3)
	                	{
	                    	AUDNZD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (AUDNZD_Signal_Condition_UP_1)
	                	{
	                    	AUDNZD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (AUDNZD_Signal_Condition_UP_2)
	                	{
	                    	AUDNZD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (AUDNZD_Signal_Condition_UP_3)
	                	{
	                    	AUDNZD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    AUDNZD_UP_S2_TP2 =  AUDNZD_UP_S2_SL * 0;
	                    AUDNZD_UP_S2_TP3 =  AUDNZD_UP_S2_SL * 0;
	                    AUDNZD_UP_S2_TP4 =  AUDNZD_UP_S2_SL * 0;
	                    AUDNZD_UP_S2_TP5 =  AUDNZD_UP_S2_SL * 0;
	                    AUDNZD_UP_S2_TP6 =  AUDNZD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    AUDNZD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    AUDNZD_quantity_SL_UP_S2 = AUDNZD_quantity_UP_S2;
	                    AUDNZD_quantity_TP1_UP_S2 = (int)Math.Floor(AUDNZD_quantity_UP_S2 * 1m);
	                    AUDNZD_quantity_TP2_UP_S2 = (int)Math.Floor(AUDNZD_quantity_TP1_UP_S2 * 0m);
	                    AUDNZD_quantity_TP3_UP_S2 = (int)Math.Floor(AUDNZD_quantity_TP2_UP_S2 * 0m);
	                    AUDNZD_quantity_TP4_UP_S2 = (int)Math.Floor(AUDNZD_quantity_TP3_UP_S2 * 0m);
	                    AUDNZD_quantity_TP5_UP_S2 = (int)Math.Floor(AUDNZD_quantity_TP4_UP_S2 * 0m);
	                    AUDNZD_quantity_TP6_UP_S2 = (int)Math.Floor(AUDNZD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((AUDNZD_Signal_Condition_UP_1 || AUDNZD_Signal_Condition_UP_2 || AUDNZD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDNZD_UP_S2 && 
	                    Base.AUDNZD_OCO1_UP_S2_IsReady == true &&
	                    Base.AUDNZD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDNZD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP1_UP_S2, false,"AUDNZD_UP_S2_Entry_TP1_OCO1");
	                         Base.AUDNZD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.AUDNZD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP2_UP_S2, false,"AUDNZD_UP_S2_Entry_TP2_OCO1");
	                         Base.AUDNZD_OCO1_EO2_UP_S2 = false;
	
	                         Base.AUDNZD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP3_UP_S2, false,"AUDNZD_UP_S2_Entry_TP3_OCO1");
	                         Base.AUDNZD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.AUDNZD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP4_UP_S2, false,"AUDNZD_UP_S2_Entry_TP4_OCO1");
	                         Base.AUDNZD_OCO1_EO4_UP_S2 = false;

							Base.AUDNZD_OCO1_UP_S2_IsReady = false;
							
							if (Base.AUDNZD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((AUDNZD_Signal_Condition_UP_1 || AUDNZD_Signal_Condition_UP_2 || AUDNZD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDNZD_UP_S2 && 
	                    Base.AUDNZD_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDNZD_OCO2_UP_S2_IsReady == true &&
	                    Base.AUDNZD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDNZD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP1_UP_S2, false,"AUDNZD_UP_S2_Entry_TP1_OCO2");
	                         Base.AUDNZD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.AUDNZD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP2_UP_S2, false,"AUDNZD_UP_S2_Entry_TP2_OCO2");
	                         Base.AUDNZD_OCO2_EO2_UP_S2 = false;
	
	                         Base.AUDNZD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP3_UP_S2, false,"AUDNZD_UP_S2_Entry_TP3_OCO2");
	                         Base.AUDNZD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.AUDNZD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP4_UP_S2, false,"AUDNZD_UP_S2_Entry_TP4_OCO2");
	                         Base.AUDNZD_OCO2_EO4_UP_S2 = false;

							Base.AUDNZD_OCO2_UP_S2_IsReady = false;
							
							if (Base.AUDNZD_OCO2_UP_S2_IsReady == false && Base.AUDNZD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((AUDNZD_Signal_Condition_UP_1 || AUDNZD_Signal_Condition_UP_2 || AUDNZD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDNZD_UP_S2 &&
	                    Base.AUDNZD_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDNZD_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDNZD_OCO3_UP_S2_IsReady == true &&
	                    Base.AUDNZD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDNZD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP1_UP_S2, false,"AUDNZD_UP_S2_Entry_TP1_OCO3");
	                         Base.AUDNZD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.AUDNZD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP2_UP_S2, false,"AUDNZD_UP_S2_Entry_TP2_OCO3");
	                         Base.AUDNZD_OCO3_EO2_UP_S2 = false;
	
	                         Base.AUDNZD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP3_UP_S2, false,"AUDNZD_UP_S2_Entry_TP3_OCO3");
	                         Base.AUDNZD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.AUDNZD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP4_UP_S2, false,"AUDNZD_UP_S2_Entry_TP4_OCO3");
	                         Base.AUDNZD_OCO3_EO4_UP_S2 = false;

							Base.AUDNZD_OCO3_UP_S2_IsReady = false;
							
							if (Base.AUDNZD_OCO3_UP_S2_IsReady == false && Base.AUDNZD_OCO2_UP_S2_IsReady == false && Base.AUDNZD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((AUDNZD_Signal_Condition_UP_1 || AUDNZD_Signal_Condition_UP_2 || AUDNZD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDNZD_UP_S2 && 
	                    Base.AUDNZD_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDNZD_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDNZD_OCO3_UP_S2_IsReady == false &&
	                    Base.AUDNZD_OCO4_UP_S2_IsReady == true &&
	                    Base.AUDNZD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDNZD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP1_UP_S2, false,"AUDNZD_UP_S2_Entry_TP1_OCO4");
	                         Base.AUDNZD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.AUDNZD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP2_UP_S2, false,"AUDNZD_UP_S2_Entry_TP2_OCO4");
	                         Base.AUDNZD_OCO4_EO2_UP_S2 = false;
	
	                         Base.AUDNZD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP3_UP_S2, false,"AUDNZD_UP_S2_Entry_TP3_OCO4");
	                         Base.AUDNZD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.AUDNZD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDNZD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDNZD_quantity_TP4_UP_S2, false,"AUDNZD_UP_S2_Entry_TP4_OCO4");
	                         Base.AUDNZD_OCO4_EO4_UP_S2 = false;

							Base.AUDNZD_OCO4_UP_S2_IsReady = false;
							
							if (Base.AUDNZD_OCO4_UP_S2_IsReady == false && Base.AUDNZD_OCO3_UP_S2_IsReady == false && Base.AUDNZD_OCO2_UP_S2_IsReady == false && Base.AUDNZD_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDCHF_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDCHF_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("AUDCHF_DOWN_S2_OCO1")))
			{
				Base.AUDCHF_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCHF_DOWN_S2_OCO2")))
			{
				Base.AUDCHF_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCHF_DOWN_S2_OCO3")))
			{
				Base.AUDCHF_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCHF_DOWN_S2_OCO4")))
			{
				Base.AUDCHF_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDCHF_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.AUDCHF_OCO1_EO1_DOWN_S2)
	                Base.AUDCHF_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDCHF_OCO1_EO2_DOWN_S2)
	                Base.AUDCHF_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO1_EO3_DOWN_S2)
	                Base.AUDCHF_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO1_EO4_DOWN_S2)
	                Base.AUDCHF_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO1_EO5_DOWN_S2)
	                Base.AUDCHF_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO1_EO6_DOWN_S2)
	                Base.AUDCHF_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCHF_OCO1S1_DOWN_S2 = 0;
		                for (; AUDCHF_OCO1S1_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets1.Count; AUDCHF_OCO1S1_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO1Sets1[AUDCHF_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO1Sets1[AUDCHF_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.AUDCHF_DOWN_S2_OCO1Sets1.Clear();
		                        AUDCHF_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCHF_OCO1S2_DOWN_S2 = 0;
		                for (; AUDCHF_OCO1S2_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets2.Count; AUDCHF_OCO1S2_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO1Sets2[AUDCHF_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO1Sets2[AUDCHF_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.AUDCHF_DOWN_S2_OCO1Sets2.Clear();
		                        AUDCHF_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO1S3_DOWN_S2 = 0;
		                for (; AUDCHF_OCO1S3_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets3.Count; AUDCHF_OCO1S3_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO1Sets3[AUDCHF_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO1Sets3[AUDCHF_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.AUDCHF_DOWN_S2_OCO1Sets3.Clear();
		                        AUDCHF_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO1S4_DOWN_S2 = 0;
		                for (; AUDCHF_OCO1S4_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets4.Count; AUDCHF_OCO1S4_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO1Sets4[AUDCHF_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO1Sets4[AUDCHF_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.AUDCHF_DOWN_S2_OCO1Sets4.Clear();
		                        AUDCHF_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO1S5_DOWN_S2 = 0;
		                for (; AUDCHF_OCO1S5_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets5.Count; AUDCHF_OCO1S5_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO1Sets5[AUDCHF_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO1Sets5[AUDCHF_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.AUDCHF_DOWN_S2_OCO1Sets5.Clear();
		                        AUDCHF_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO1S6_DOWN_S2 = 0;
		                for (; AUDCHF_OCO1S6_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO1Sets6.Count; AUDCHF_OCO1S6_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO1Sets6[AUDCHF_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO1Sets6[AUDCHF_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.AUDCHF_DOWN_S2_OCO1Sets6.Clear();
		                        AUDCHF_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDCHF_OCO2_EO1_DOWN_S2)
	                Base.AUDCHF_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDCHF_OCO2_EO2_DOWN_S2)
	                Base.AUDCHF_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO2_EO3_DOWN_S2)
	                Base.AUDCHF_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO2_EO4_DOWN_S2)
	                Base.AUDCHF_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO2_EO5_DOWN_S2)
	                Base.AUDCHF_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO2_EO6_DOWN_S2)
	                Base.AUDCHF_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCHF_OCO2S1_DOWN_S2 = 0;
		                for (; AUDCHF_OCO2S1_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets1.Count; AUDCHF_OCO2S1_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO2Sets1[AUDCHF_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO2Sets1[AUDCHF_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.AUDCHF_DOWN_S2_OCO2Sets1.Clear();
		                        AUDCHF_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCHF_OCO2S2_DOWN_S2 = 0;
		                for (; AUDCHF_OCO2S2_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets2.Count; AUDCHF_OCO2S2_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO2Sets2[AUDCHF_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO2Sets2[AUDCHF_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.AUDCHF_DOWN_S2_OCO2Sets2.Clear();
		                        AUDCHF_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO2S3_DOWN_S2 = 0;
		                for (; AUDCHF_OCO2S3_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets3.Count; AUDCHF_OCO2S3_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO2Sets3[AUDCHF_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO2Sets3[AUDCHF_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.AUDCHF_DOWN_S2_OCO2Sets3.Clear();
		                        AUDCHF_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO2S4_DOWN_S2 = 0;
		                for (; AUDCHF_OCO2S4_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets4.Count; AUDCHF_OCO2S4_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO2Sets4[AUDCHF_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO2Sets4[AUDCHF_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.AUDCHF_DOWN_S2_OCO2Sets4.Clear();
		                        AUDCHF_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO2S5_DOWN_S2 = 0;
		                for (; AUDCHF_OCO2S5_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets5.Count; AUDCHF_OCO2S5_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO2Sets5[AUDCHF_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO2Sets5[AUDCHF_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.AUDCHF_DOWN_S2_OCO2Sets5.Clear();
		                        AUDCHF_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO2S6_DOWN_S2 = 0;
		                for (; AUDCHF_OCO2S6_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO2Sets6.Count; AUDCHF_OCO2S6_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO2Sets6[AUDCHF_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO2Sets6[AUDCHF_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.AUDCHF_DOWN_S2_OCO2Sets6.Clear();
		                        AUDCHF_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDCHF_OCO3_EO1_DOWN_S2)
	                Base.AUDCHF_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDCHF_OCO3_EO2_DOWN_S2)
	                Base.AUDCHF_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO3_EO3_DOWN_S2)
	                Base.AUDCHF_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO3_EO4_DOWN_S2)
	                Base.AUDCHF_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO3_EO5_DOWN_S2)
	                Base.AUDCHF_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO3_EO6_DOWN_S2)
	                Base.AUDCHF_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCHF_OCO3S1_DOWN_S2 = 0;
		                for (; AUDCHF_OCO3S1_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets1.Count; AUDCHF_OCO3S1_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO3Sets1[AUDCHF_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO3Sets1[AUDCHF_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.AUDCHF_DOWN_S2_OCO3Sets1.Clear();
		                        AUDCHF_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCHF_OCO3S2_DOWN_S2 = 0;
		                for (; AUDCHF_OCO3S2_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets2.Count; AUDCHF_OCO3S2_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO3Sets2[AUDCHF_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO3Sets2[AUDCHF_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.AUDCHF_DOWN_S2_OCO3Sets2.Clear();
		                        AUDCHF_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO3S3_DOWN_S2 = 0;
		                for (; AUDCHF_OCO3S3_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets3.Count; AUDCHF_OCO3S3_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO3Sets3[AUDCHF_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO3Sets3[AUDCHF_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.AUDCHF_DOWN_S2_OCO3Sets3.Clear();
		                        AUDCHF_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO3S4_DOWN_S2 = 0;
		                for (; AUDCHF_OCO3S4_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets4.Count; AUDCHF_OCO3S4_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO3Sets4[AUDCHF_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO3Sets4[AUDCHF_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.AUDCHF_DOWN_S2_OCO3Sets4.Clear();
		                        AUDCHF_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO3S5_DOWN_S2 = 0;
		                for (; AUDCHF_OCO3S5_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets5.Count; AUDCHF_OCO3S5_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO3Sets5[AUDCHF_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO3Sets5[AUDCHF_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.AUDCHF_DOWN_S2_OCO3Sets5.Clear();
		                        AUDCHF_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO3S6_DOWN_S2 = 0;
		                for (; AUDCHF_OCO3S6_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO3Sets6.Count; AUDCHF_OCO3S6_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO3Sets6[AUDCHF_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO3Sets6[AUDCHF_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.AUDCHF_DOWN_S2_OCO3Sets6.Clear();
		                        AUDCHF_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDCHF_OCO4_EO1_DOWN_S2)
	                Base.AUDCHF_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDCHF_OCO4_EO2_DOWN_S2)
	                Base.AUDCHF_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO4_EO3_DOWN_S2)
	                Base.AUDCHF_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO4_EO4_DOWN_S2)
	                Base.AUDCHF_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO4_EO5_DOWN_S2)
	                Base.AUDCHF_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO4_EO6_DOWN_S2)
	                Base.AUDCHF_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCHF_OCO4S1_DOWN_S2 = 0;
		                for (; AUDCHF_OCO4S1_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets1.Count; AUDCHF_OCO4S1_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO4Sets1[AUDCHF_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO4Sets1[AUDCHF_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.AUDCHF_DOWN_S2_OCO4Sets1.Clear();
		                        AUDCHF_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCHF_OCO4S2_DOWN_S2 = 0;
		                for (; AUDCHF_OCO4S2_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets2.Count; AUDCHF_OCO4S2_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO4Sets2[AUDCHF_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO4Sets2[AUDCHF_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.AUDCHF_DOWN_S2_OCO4Sets2.Clear();
		                        AUDCHF_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO4S3_DOWN_S2 = 0;
		                for (; AUDCHF_OCO4S3_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets3.Count; AUDCHF_OCO4S3_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO4Sets3[AUDCHF_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO4Sets3[AUDCHF_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.AUDCHF_DOWN_S2_OCO4Sets3.Clear();
		                        AUDCHF_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO4S4_DOWN_S2 = 0;
		                for (; AUDCHF_OCO4S4_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets4.Count; AUDCHF_OCO4S4_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO4Sets4[AUDCHF_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO4Sets4[AUDCHF_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.AUDCHF_DOWN_S2_OCO4Sets4.Clear();
		                        AUDCHF_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO4S5_DOWN_S2 = 0;
		                for (; AUDCHF_OCO4S5_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets5.Count; AUDCHF_OCO4S5_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO4Sets5[AUDCHF_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO4Sets5[AUDCHF_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.AUDCHF_DOWN_S2_OCO4Sets5.Clear();
		                        AUDCHF_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO4S6_DOWN_S2 = 0;
		                for (; AUDCHF_OCO4S6_DOWN_S2 < Base.AUDCHF_DOWN_S2_OCO4Sets6.Count; AUDCHF_OCO4S6_DOWN_S2++)
		                    if (Base.AUDCHF_DOWN_S2_OCO4Sets6[AUDCHF_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_DOWN_S2_OCO4Sets6[AUDCHF_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.AUDCHF_DOWN_S2_OCO4Sets6.Clear();
		                        AUDCHF_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();
	            	}
	            	
					DOWM_AUDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDCHF_DOWN_S2 = DOWM_AUDCHF_DOWN_S2 || DOWT_AUDCHF_DOWN_S2 || DOWW_AUDCHF_DOWN_S2 || DOWTH_AUDCHF_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDCHF"))
	            	{
	            		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.AUDCHF_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.AUDCHF_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.AUDCHF_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.AUDCHF_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.AUDCHF_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDCHF_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDCHF_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDCHF_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDCHF_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDCHF_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDCHF_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	AUDCHF_Signal_Condition_DOWN_S2 =  
	                									(
															pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.01m &&
	                										prices_ASK_Close[0] > pricesM_ASK_Close[0] &&
	                										prices_ASK_Close[0] < pricesM_ASK_High[0] &&
	                										
	                										//prices_ASK_High[0] > pricesM_ASK_High[0] &&
	                										
	                										//prices_ASK_High[0] - pricesM_BID_High[0] > prices_ASK_Close[0] * 0.000001m &&
	                										
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.02m 
	                									);
	                									
	                    AUDCHF_DOWN_S2_SL  =  0.01m;
	                    AUDCHF_DOWN_S2_TP1 =  0.0005m;
	                    AUDCHF_DOWN_S2_TP2 =  AUDCHF_DOWN_S2_SL * 0;
	                    AUDCHF_DOWN_S2_TP3 =  AUDCHF_DOWN_S2_SL * 0;
	                    AUDCHF_DOWN_S2_TP4 =  AUDCHF_DOWN_S2_SL * 0;
	                    AUDCHF_DOWN_S2_TP5 =  AUDCHF_DOWN_S2_SL * 0;
	                    AUDCHF_DOWN_S2_TP6 =  AUDCHF_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    AUDCHF_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    AUDCHF_quantity_SL_DOWN_S2 = AUDCHF_quantity_DOWN_S2;
	                    AUDCHF_quantity_TP1_DOWN_S2 = (int)Math.Floor(AUDCHF_quantity_DOWN_S2 * 1m);
	                    AUDCHF_quantity_TP2_DOWN_S2 = (int)Math.Floor(AUDCHF_quantity_TP1_DOWN_S2 * 0m);
	                    AUDCHF_quantity_TP3_DOWN_S2 = (int)Math.Floor(AUDCHF_quantity_TP2_DOWN_S2 * 0m);
	                    AUDCHF_quantity_TP4_DOWN_S2 = (int)Math.Floor(AUDCHF_quantity_TP3_DOWN_S2 * 0m);
	                    AUDCHF_quantity_TP5_DOWN_S2 = (int)Math.Floor(AUDCHF_quantity_TP4_DOWN_S2 * 0m);
	                    AUDCHF_quantity_TP6_DOWN_S2 = (int)Math.Floor(AUDCHF_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (AUDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDCHF_DOWN_S2 && 
	                    Base.AUDCHF_OCO1_DOWN_S2_IsReady == true &&
	                    Base.AUDCHF_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCHF_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP1_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP1_OCO1");
	                         Base.AUDCHF_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDCHF_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP2_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP2_OCO1");
	                         Base.AUDCHF_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.AUDCHF_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP3_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP3_OCO1");
	                         Base.AUDCHF_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDCHF_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP4_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP4_OCO1");
	                         Base.AUDCHF_OCO1_EO4_DOWN_S2 = false;

							Base.AUDCHF_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.AUDCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (AUDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDCHF_DOWN_S2 && 
	                    Base.AUDCHF_OCO2_DOWN_S2_IsReady == true &&
	                    Base.AUDCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDCHF_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCHF_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP1_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP1_OCO2");
	                         Base.AUDCHF_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDCHF_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP2_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP2_OCO2");
	                         Base.AUDCHF_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.AUDCHF_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP3_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP3_OCO2");
	                         Base.AUDCHF_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDCHF_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP4_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP4_OCO2");
	                         Base.AUDCHF_OCO2_EO4_DOWN_S2 = false;

							Base.AUDCHF_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.AUDCHF_OCO2_DOWN_S2_IsReady == false && Base.AUDCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (AUDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDCHF_DOWN_S2 &&
	                    Base.AUDCHF_OCO3_DOWN_S2_IsReady == true &&
	                    Base.AUDCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDCHF_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCHF_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP1_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP1_OCO3");
	                         Base.AUDCHF_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDCHF_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP2_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP2_OCO3");
	                         Base.AUDCHF_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.AUDCHF_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP3_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP3_OCO3");
	                         Base.AUDCHF_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDCHF_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP4_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP4_OCO3");
	                         Base.AUDCHF_OCO3_EO4_DOWN_S2 = false;

							Base.AUDCHF_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.AUDCHF_OCO3_DOWN_S2_IsReady == false && Base.AUDCHF_OCO2_DOWN_S2_IsReady == false && Base.AUDCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (AUDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDCHF_DOWN_S2 && 
	                    Base.AUDCHF_OCO4_DOWN_S2_IsReady == true &&
	                    Base.AUDCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDCHF_OCO3_DOWN_S2_IsReady == false &&
	                    Base.AUDCHF_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCHF_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP1_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP1_OCO4");
	                         Base.AUDCHF_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDCHF_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP2_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP2_OCO4");
	                         Base.AUDCHF_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.AUDCHF_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP3_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP3_OCO4");
	                         Base.AUDCHF_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDCHF_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCHF_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP4_DOWN_S2, false,"AUDCHF_DOWN_S2_Entry_TP4_OCO4");
	                         Base.AUDCHF_OCO4_EO4_DOWN_S2 = false;

							Base.AUDCHF_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.AUDCHF_OCO4_DOWN_S2_IsReady == false && Base.AUDCHF_OCO3_DOWN_S2_IsReady == false && Base.AUDCHF_OCO2_DOWN_S2_IsReady == false && Base.AUDCHF_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDCHF_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDCHF_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(x=>x.Tag.Contains("AUDCHF_UP_S2_OCO1")))
			{
				Base.AUDCHF_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCHF_UP_S2_OCO2")))
			{
				Base.AUDCHF_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCHF_UP_S2_OCO3")))
			{
				Base.AUDCHF_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCHF_UP_S2_OCO4")))
			{
				Base.AUDCHF_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDCHF_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.AUDCHF_OCO1_EO1_UP_S2)
	                Base.AUDCHF_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDCHF_OCO1_EO2_UP_S2)
	                Base.AUDCHF_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO1_EO3_UP_S2)
	                Base.AUDCHF_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO1_EO4_UP_S2)
	                Base.AUDCHF_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO1_EO5_UP_S2)
	                Base.AUDCHF_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO1_EO6_UP_S2)
	                Base.AUDCHF_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCHF_OCO1S1_UP_S2 = 0;
		                for (; AUDCHF_OCO1S1_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets1.Count; AUDCHF_OCO1S1_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO1Sets1[AUDCHF_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO1Sets1[AUDCHF_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_1__Time out_OCO1");
		                        Base.AUDCHF_UP_S2_OCO1Sets1.Clear();
		                        AUDCHF_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCHF_OCO1S2_UP_S2 = 0;
		                for (; AUDCHF_OCO1S2_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets2.Count; AUDCHF_OCO1S2_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO1Sets2[AUDCHF_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO1Sets2[AUDCHF_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_2__Time out_OCO1");
		                        Base.AUDCHF_UP_S2_OCO1Sets2.Clear();
		                        AUDCHF_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO1S3_UP_S2 = 0;
		                for (; AUDCHF_OCO1S3_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets3.Count; AUDCHF_OCO1S3_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO1Sets3[AUDCHF_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO1Sets3[AUDCHF_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_3__Time out_OCO1");
		                        Base.AUDCHF_UP_S2_OCO1Sets3.Clear();
		                        AUDCHF_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO1S4_UP_S2 = 0;
		                for (; AUDCHF_OCO1S4_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets4.Count; AUDCHF_OCO1S4_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO1Sets4[AUDCHF_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO1Sets4[AUDCHF_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_4__Time out_OCO1");
		                        Base.AUDCHF_UP_S2_OCO1Sets4.Clear();
		                        AUDCHF_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO1S5_UP_S2 = 0;
		                for (; AUDCHF_OCO1S5_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets5.Count; AUDCHF_OCO1S5_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO1Sets5[AUDCHF_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO1Sets5[AUDCHF_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_5__Time out_OCO1");
		                        Base.AUDCHF_UP_S2_OCO1Sets5.Clear();
		                        AUDCHF_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO1S6_UP_S2 = 0;
		                for (; AUDCHF_OCO1S6_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets6.Count; AUDCHF_OCO1S6_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO1Sets6[AUDCHF_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO1Sets6[AUDCHF_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_6__Time out_OCO1");
		                        Base.AUDCHF_UP_S2_OCO1Sets6.Clear();
		                        AUDCHF_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDCHF_OCO2_EO1_UP_S2)
                	Base.AUDCHF_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDCHF_OCO2_EO2_UP_S2)
	                Base.AUDCHF_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO2_EO3_UP_S2)
	                Base.AUDCHF_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO2_EO4_UP_S2)
	                Base.AUDCHF_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO2_EO5_UP_S2)
	                Base.AUDCHF_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO2_EO6_UP_S2)
	                Base.AUDCHF_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCHF_OCO2S1_UP_S2 = 0;
		                for (; AUDCHF_OCO2S1_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets1.Count; AUDCHF_OCO2S1_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO2Sets1[AUDCHF_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO2Sets1[AUDCHF_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_1__Time out_OCO2");
		                        Base.AUDCHF_UP_S2_OCO2Sets1.Clear();
		                        AUDCHF_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCHF_OCO2S2_UP_S2 = 0;
		                for (; AUDCHF_OCO2S2_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets2.Count; AUDCHF_OCO2S2_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO2Sets2[AUDCHF_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO2Sets2[AUDCHF_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_2__Time out_OCO2");
		                        Base.AUDCHF_UP_S2_OCO2Sets2.Clear();
		                        AUDCHF_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO2S3_UP_S2 = 0;
		                for (; AUDCHF_OCO2S3_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets3.Count; AUDCHF_OCO2S3_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO2Sets3[AUDCHF_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO2Sets3[AUDCHF_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_3__Time out_OCO2");
		                        Base.AUDCHF_UP_S2_OCO2Sets3.Clear();
		                        AUDCHF_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO2S4_UP_S2 = 0;
		                for (; AUDCHF_OCO2S4_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets4.Count; AUDCHF_OCO2S4_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO2Sets4[AUDCHF_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO2Sets4[AUDCHF_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_4__Time out_OCO2");
		                        Base.AUDCHF_UP_S2_OCO2Sets4.Clear();
		                        AUDCHF_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO2S5_UP_S2 = 0;
		                for (; AUDCHF_OCO2S5_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets5.Count; AUDCHF_OCO2S5_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO2Sets5[AUDCHF_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO2Sets5[AUDCHF_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_5__Time out_OCO2");
		                        Base.AUDCHF_UP_S2_OCO2Sets5.Clear();
		                        AUDCHF_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO2S6_UP_S2 = 0;
		                for (; AUDCHF_OCO2S6_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets6.Count; AUDCHF_OCO2S6_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO2Sets6[AUDCHF_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO2Sets6[AUDCHF_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_6__Time out_OCO2");
		                        Base.AUDCHF_UP_S2_OCO2Sets6.Clear();
		                        AUDCHF_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDCHF_OCO3_EO1_UP_S2)
            		Base.AUDCHF_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDCHF_OCO3_EO2_UP_S2)
	                Base.AUDCHF_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO3_EO3_UP_S2)
	                Base.AUDCHF_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO3_EO4_UP_S2)
	                Base.AUDCHF_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO3_EO5_UP_S2)
	                Base.AUDCHF_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO3_EO6_UP_S2)
	                Base.AUDCHF_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCHF_OCO3S1_UP_S2 = 0;
		                for (; AUDCHF_OCO3S1_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets1.Count; AUDCHF_OCO3S1_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO3Sets1[AUDCHF_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO3Sets1[AUDCHF_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_1__Time out_OCO3");
		                        Base.AUDCHF_UP_S2_OCO3Sets1.Clear();
		                        AUDCHF_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCHF_OCO3S2_UP_S2 = 0;
		                for (; AUDCHF_OCO3S2_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets2.Count; AUDCHF_OCO3S2_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO3Sets2[AUDCHF_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO3Sets2[AUDCHF_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_2__Time out_OCO3");
		                        Base.AUDCHF_UP_S2_OCO3Sets2.Clear();
		                        AUDCHF_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO3S3_UP_S2 = 0;
		                for (; AUDCHF_OCO3S3_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets3.Count; AUDCHF_OCO3S3_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO3Sets3[AUDCHF_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO3Sets3[AUDCHF_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_3__Time out_OCO3");
		                        Base.AUDCHF_UP_S2_OCO3Sets3.Clear();
		                        AUDCHF_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO3S4_UP_S2 = 0;
		                for (; AUDCHF_OCO3S4_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets4.Count; AUDCHF_OCO3S4_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO3Sets4[AUDCHF_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO3Sets4[AUDCHF_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_4__Time out_OCO3");
		                        Base.AUDCHF_UP_S2_OCO3Sets4.Clear();
		                        AUDCHF_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO3S5_UP_S2 = 0;
		                for (; AUDCHF_OCO3S5_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets5.Count; AUDCHF_OCO3S5_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO3Sets5[AUDCHF_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO3Sets5[AUDCHF_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_5__Time out_OCO3");
		                        Base.AUDCHF_UP_S2_OCO3Sets5.Clear();
		                        AUDCHF_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO3S6_UP_S2 = 0;
		                for (; AUDCHF_OCO3S6_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets6.Count; AUDCHF_OCO3S6_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO3Sets6[AUDCHF_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO3Sets6[AUDCHF_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_6__Time out_OCO3");
		                        Base.AUDCHF_UP_S2_OCO3Sets6.Clear();
		                        AUDCHF_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDCHF_OCO4_EO1_UP_S2)
            		Base.AUDCHF_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDCHF_OCO4_EO2_UP_S2)
	                Base.AUDCHF_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO4_EO3_UP_S2)
	                Base.AUDCHF_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO4_EO4_UP_S2)
	                Base.AUDCHF_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO4_EO5_UP_S2)
	                Base.AUDCHF_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDCHF_OCO4_EO6_UP_S2)
	                Base.AUDCHF_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCHF_OCO4S1_UP_S2 = 0;
		                for (; AUDCHF_OCO4S1_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets1.Count; AUDCHF_OCO4S1_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO4Sets1[AUDCHF_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO4Sets1[AUDCHF_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_1__Time out_OCO4");
		                        Base.AUDCHF_UP_S2_OCO4Sets1.Clear();
		                        AUDCHF_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCHF_OCO4S2_UP_S2 = 0;
		                for (; AUDCHF_OCO4S2_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets2.Count; AUDCHF_OCO4S2_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO4Sets2[AUDCHF_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO4Sets2[AUDCHF_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_2__Time out_OCO4");
		                        Base.AUDCHF_UP_S2_OCO4Sets2.Clear();
		                        AUDCHF_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO4S3_UP_S2 = 0;
		                for (; AUDCHF_OCO4S3_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets3.Count; AUDCHF_OCO4S3_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO4Sets3[AUDCHF_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO4Sets3[AUDCHF_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_3__Time out_OCO4");
		                        Base.AUDCHF_UP_S2_OCO4Sets3.Clear();
		                        AUDCHF_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCHF_OCO4S4_UP_S2 = 0;
		                for (; AUDCHF_OCO4S4_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets4.Count; AUDCHF_OCO4S4_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO4Sets4[AUDCHF_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO4Sets4[AUDCHF_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_4__Time out_OCO4");
		                        Base.AUDCHF_UP_S2_OCO4Sets4.Clear();
		                        AUDCHF_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO4S5_UP_S2 = 0;
		                for (; AUDCHF_OCO4S5_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets5.Count; AUDCHF_OCO4S5_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO4Sets5[AUDCHF_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO4Sets5[AUDCHF_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_5__Time out_OCO4");
		                        Base.AUDCHF_UP_S2_OCO4Sets5.Clear();
		                        AUDCHF_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCHF_OCO4S6_UP_S2 = 0;
		                for (; AUDCHF_OCO4S6_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets6.Count; AUDCHF_OCO4S6_UP_S2++)
		                    if (Base.AUDCHF_UP_S2_OCO4Sets6[AUDCHF_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCHF_UP_S2_OCO4Sets6[AUDCHF_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCHF", order.Quantity, false, "AUDCHF_UP_S2_Entry_6__Time out_OCO4");
		                        Base.AUDCHF_UP_S2_OCO4Sets6.Clear();
		                        AUDCHF_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_AUDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDCHF_UP_S2 = DOWM_AUDCHF_UP_S2 || DOWT_AUDCHF_UP_S2 || DOWW_AUDCHF_UP_S2 || DOWTH_AUDCHF_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDCHF"))
	            	{
	            		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.AUDCHF_OCO1_UP_S2_IsReady == false ||
	                    	Base.AUDCHF_OCO2_UP_S2_IsReady == false ||
	                    	Base.AUDCHF_OCO3_UP_S2_IsReady == false ||
	                    	Base.AUDCHF_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.AUDCHF_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDCHF_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDCHF_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDCHF_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDCHF_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.AUDCHF_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.AUDCHF_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.AUDCHF_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	AUDCHF_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                	AUDCHF_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                									
	                	AUDCHF_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[0] < pricesM_BID_Low[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 (AUDCHF_Signal_Condition_UP_1)
	                	{
	                    	AUDCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDCHF_Signal_Condition_UP_2)
	                	{
	                    	AUDCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDCHF_Signal_Condition_UP_3)
	                	{
	                    	AUDCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (AUDCHF_Signal_Condition_UP_1)
	                	{
	                    	AUDCHF_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (AUDCHF_Signal_Condition_UP_2)
	                	{
	                    	AUDCHF_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (AUDCHF_Signal_Condition_UP_3)
	                	{
	                    	AUDCHF_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    AUDCHF_UP_S2_TP2 =  AUDCHF_UP_S2_SL * 0;
	                    AUDCHF_UP_S2_TP3 =  AUDCHF_UP_S2_SL * 0;
	                    AUDCHF_UP_S2_TP4 =  AUDCHF_UP_S2_SL * 0;
	                    AUDCHF_UP_S2_TP5 =  AUDCHF_UP_S2_SL * 0;
	                    AUDCHF_UP_S2_TP6 =  AUDCHF_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    AUDCHF_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    AUDCHF_quantity_SL_UP_S2 = AUDCHF_quantity_UP_S2;
	                    AUDCHF_quantity_TP1_UP_S2 = (int)Math.Floor(AUDCHF_quantity_UP_S2 * 1m);
	                    AUDCHF_quantity_TP2_UP_S2 = (int)Math.Floor(AUDCHF_quantity_TP1_UP_S2 * 0m);
	                    AUDCHF_quantity_TP3_UP_S2 = (int)Math.Floor(AUDCHF_quantity_TP2_UP_S2 * 0m);
	                    AUDCHF_quantity_TP4_UP_S2 = (int)Math.Floor(AUDCHF_quantity_TP3_UP_S2 * 0m);
	                    AUDCHF_quantity_TP5_UP_S2 = (int)Math.Floor(AUDCHF_quantity_TP4_UP_S2 * 0m);
	                    AUDCHF_quantity_TP6_UP_S2 = (int)Math.Floor(AUDCHF_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((AUDCHF_Signal_Condition_UP_1 || AUDCHF_Signal_Condition_UP_2 || AUDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_AUDCHF_UP_S2 && 
	                    Base.AUDCHF_OCO1_UP_S2_IsReady == true &&
	                    Base.AUDCHF_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCHF_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP1_UP_S2, false,"AUDCHF_UP_S2_Entry_TP1_OCO1");
	                         Base.AUDCHF_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.AUDCHF_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP2_UP_S2, false,"AUDCHF_UP_S2_Entry_TP2_OCO1");
	                         Base.AUDCHF_OCO1_EO2_UP_S2 = false;
	
	                         Base.AUDCHF_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP3_UP_S2, false,"AUDCHF_UP_S2_Entry_TP3_OCO1");
	                         Base.AUDCHF_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.AUDCHF_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP4_UP_S2, false,"AUDCHF_UP_S2_Entry_TP4_OCO1");
	                         Base.AUDCHF_OCO1_EO4_UP_S2 = false;

							Base.AUDCHF_OCO1_UP_S2_IsReady = false;
							
							if (Base.AUDCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((AUDCHF_Signal_Condition_UP_1 || AUDCHF_Signal_Condition_UP_2 || AUDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_AUDCHF_UP_S2 && 
	                    Base.AUDCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDCHF_OCO2_UP_S2_IsReady == true &&
	                    Base.AUDCHF_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCHF_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP1_UP_S2, false,"AUDCHF_UP_S2_Entry_TP1_OCO2");
	                         Base.AUDCHF_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.AUDCHF_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP2_UP_S2, false,"AUDCHF_UP_S2_Entry_TP2_OCO2");
	                         Base.AUDCHF_OCO2_EO2_UP_S2 = false;
	
	                         Base.AUDCHF_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP3_UP_S2, false,"AUDCHF_UP_S2_Entry_TP3_OCO2");
	                         Base.AUDCHF_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.AUDCHF_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP4_UP_S2, false,"AUDCHF_UP_S2_Entry_TP4_OCO2");
	                         Base.AUDCHF_OCO2_EO4_UP_S2 = false;

							Base.AUDCHF_OCO2_UP_S2_IsReady = false;
							
							if (Base.AUDCHF_OCO2_UP_S2_IsReady == false && Base.AUDCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((AUDCHF_Signal_Condition_UP_1 || AUDCHF_Signal_Condition_UP_2 || AUDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_AUDCHF_UP_S2 &&
	                    Base.AUDCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDCHF_OCO3_UP_S2_IsReady == true &&
	                    Base.AUDCHF_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCHF_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP1_UP_S2, false,"AUDCHF_UP_S2_Entry_TP1_OCO3");
	                         Base.AUDCHF_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.AUDCHF_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP2_UP_S2, false,"AUDCHF_UP_S2_Entry_TP2_OCO3");
	                         Base.AUDCHF_OCO3_EO2_UP_S2 = false;
	
	                         Base.AUDCHF_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP3_UP_S2, false,"AUDCHF_UP_S2_Entry_TP3_OCO3");
	                         Base.AUDCHF_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.AUDCHF_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP4_UP_S2, false,"AUDCHF_UP_S2_Entry_TP4_OCO3");
	                         Base.AUDCHF_OCO3_EO4_UP_S2 = false;

							Base.AUDCHF_OCO3_UP_S2_IsReady = false;
							
							if (Base.AUDCHF_OCO3_UP_S2_IsReady == false && Base.AUDCHF_OCO2_UP_S2_IsReady == false && Base.AUDCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((AUDCHF_Signal_Condition_UP_1 || AUDCHF_Signal_Condition_UP_2 || AUDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_AUDCHF_UP_S2 && 
	                    Base.AUDCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDCHF_OCO3_UP_S2_IsReady == false &&
	                    Base.AUDCHF_OCO4_UP_S2_IsReady == true &&
	                    Base.AUDCHF_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCHF_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP1_UP_S2, false,"AUDCHF_UP_S2_Entry_TP1_OCO4");
	                         Base.AUDCHF_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.AUDCHF_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP2_UP_S2, false,"AUDCHF_UP_S2_Entry_TP2_OCO4");
	                         Base.AUDCHF_OCO4_EO2_UP_S2 = false;
	
	                         Base.AUDCHF_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP3_UP_S2, false,"AUDCHF_UP_S2_Entry_TP3_OCO4");
	                         Base.AUDCHF_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.AUDCHF_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCHF_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCHF_quantity_TP4_UP_S2, false,"AUDCHF_UP_S2_Entry_TP4_OCO4");
	                         Base.AUDCHF_OCO4_EO4_UP_S2 = false;

							Base.AUDCHF_OCO4_UP_S2_IsReady = false;
							
							if (Base.AUDCHF_OCO4_UP_S2_IsReady == false && Base.AUDCHF_OCO3_UP_S2_IsReady == false && Base.AUDCHF_OCO2_UP_S2_IsReady == false && Base.AUDCHF_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.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 AUDJPY_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDJPY_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("AUDJPY OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDJPY OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDJPY OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDJPY OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDJPY OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDJPY OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDJPY OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        }
		        
				if (Base.AUDJPY_OCO1_EO1_UP_S2)
	                Base.AUDJPY_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDJPY_OCO1_EO2_UP_S2)
	                Base.AUDJPY_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO1_EO3_UP_S2)
	                Base.AUDJPY_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO1_EO4_UP_S2)
	                Base.AUDJPY_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO1_EO5_UP_S2)
	                Base.AUDJPY_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO1_EO6_UP_S2)
	                Base.AUDJPY_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.AUDJPY_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP1,"TP1_AUDJPY_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP1_AUDJPY_UP_S2_OCO1"));
		                 };
		                Base.AUDJPY_UP_S2_OCO1Sets1.Add( Base.AUDJPY_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP2,"TP2_AUDJPY_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP2_AUDJPY_UP_S2_OCO1"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO1Sets2.Add( Base.AUDJPY_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP3,"TP3_AUDJPY_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP3_AUDJPY_UP_S2_OCO1"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO1Sets3.Add( Base.AUDJPY_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP4,"TP4_AUDJPY_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP4_AUDJPY_UP_S2_OCO1"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO1Sets4.Add( Base.AUDJPY_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP5,"TP5_AUDJPY_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP5_AUDJPY_UP_S2_OCO1"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO1Sets5.Add( Base.AUDJPY_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP6,"TP6_AUDJPY_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP6_AUDJPY_UP_S2_OCO1"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO1Sets6.Add( Base.AUDJPY_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDJPY_OCO1S1_UP_S2 = 0;
	                for (; AUDJPY_OCO1S1_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets1.Count; AUDJPY_OCO1S1_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO1Sets1[AUDJPY_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO1Sets1[AUDJPY_OCO1S1_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO1Sets1.RemoveAt(AUDJPY_OCO1S1_UP_S2);
	                        AUDJPY_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDJPY_OCO1S2_UP_S2 = 0;
	                for (; AUDJPY_OCO1S2_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets2.Count; AUDJPY_OCO1S2_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO1Sets2[AUDJPY_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO1Sets2[AUDJPY_OCO1S2_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO1Sets2.RemoveAt(AUDJPY_OCO1S2_UP_S2);
	                        AUDJPY_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO1S3_UP_S2 = 0;
	                for (; AUDJPY_OCO1S3_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets3.Count; AUDJPY_OCO1S3_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO1Sets3[AUDJPY_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO1Sets3[AUDJPY_OCO1S3_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO1Sets3.RemoveAt(AUDJPY_OCO1S3_UP_S2);
	                        AUDJPY_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO1S4_UP_S2 = 0;
	                for (; AUDJPY_OCO1S4_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets4.Count; AUDJPY_OCO1S4_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO1Sets4[AUDJPY_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO1Sets4[AUDJPY_OCO1S4_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO1Sets4.RemoveAt(AUDJPY_OCO1S4_UP_S2);
	                        AUDJPY_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDJPY_OCO1S5_UP_S2 = 0;
	                for (; AUDJPY_OCO1S5_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets5.Count; AUDJPY_OCO1S5_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO1Sets5[AUDJPY_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO1Sets5[AUDJPY_OCO1S5_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO1Sets5.RemoveAt(AUDJPY_OCO1S5_UP_S2);
	                        AUDJPY_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDJPY_OCO1S6_UP_S2 = 0;
	                for (; AUDJPY_OCO1S6_UP_S2 < Base.AUDJPY_UP_S2_OCO1Sets6.Count; AUDJPY_OCO1S6_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO1Sets6[AUDJPY_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO1Sets6[AUDJPY_OCO1S6_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO1Sets6.RemoveAt(AUDJPY_OCO1S6_UP_S2);
	                        AUDJPY_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.AUDJPY_OCO2_EO1_UP_S2)
	                Base.AUDJPY_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDJPY_OCO2_EO2_UP_S2)
	                Base.AUDJPY_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO2_EO3_UP_S2)
	                Base.AUDJPY_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO2_EO4_UP_S2)
	                Base.AUDJPY_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO2_EO5_UP_S2)
	                Base.AUDJPY_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO2_EO6_UP_S2)
	                Base.AUDJPY_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.AUDJPY_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP1,"TP1_AUDJPY_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP1_AUDJPY_UP_S2_OCO2"));
		                 };
		                Base.AUDJPY_UP_S2_OCO2Sets1.Add( Base.AUDJPY_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP2,"TP2_AUDJPY_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP2_AUDJPY_UP_S2_OCO2"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO2Sets2.Add( Base.AUDJPY_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP3,"TP3_AUDJPY_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP3_AUDJPY_UP_S2_OCO2"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO2Sets3.Add( Base.AUDJPY_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP4,"TP4_AUDJPY_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP4_AUDJPY_UP_S2_OCO2"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO2Sets4.Add( Base.AUDJPY_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP5,"TP5_AUDJPY_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP5_AUDJPY_UP_S2_OCO2"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO2Sets5.Add( Base.AUDJPY_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP6,"TP6_AUDJPY_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP6_AUDJPY_UP_S2_OCO2"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO2Sets6.Add( Base.AUDJPY_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDJPY_OCO2S1_UP_S2 = 0;
	                for (; AUDJPY_OCO2S1_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets1.Count; AUDJPY_OCO2S1_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO2Sets1[AUDJPY_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO2Sets1[AUDJPY_OCO2S1_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO2Sets1.RemoveAt(AUDJPY_OCO2S1_UP_S2);
	                        AUDJPY_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDJPY_OCO2S2_UP_S2 = 0;
	                for (; AUDJPY_OCO2S2_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets2.Count; AUDJPY_OCO2S2_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO2Sets2[AUDJPY_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO2Sets2[AUDJPY_OCO2S2_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO2Sets2.RemoveAt(AUDJPY_OCO2S2_UP_S2);
	                        AUDJPY_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO2S3_UP_S2 = 0;
	                for (; AUDJPY_OCO2S3_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets3.Count; AUDJPY_OCO2S3_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO2Sets3[AUDJPY_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO2Sets3[AUDJPY_OCO2S3_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO2Sets3.RemoveAt(AUDJPY_OCO2S3_UP_S2);
	                        AUDJPY_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO2S4_UP_S2 = 0;
	                for (; AUDJPY_OCO2S4_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets4.Count; AUDJPY_OCO2S4_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO2Sets4[AUDJPY_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO2Sets4[AUDJPY_OCO2S4_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO2Sets4.RemoveAt(AUDJPY_OCO2S4_UP_S2);
	                        AUDJPY_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDJPY_OCO2S5_UP_S2 = 0;
	                for (; AUDJPY_OCO2S5_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets5.Count; AUDJPY_OCO2S5_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO2Sets5[AUDJPY_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO2Sets5[AUDJPY_OCO2S5_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO2Sets5.RemoveAt(AUDJPY_OCO2S5_UP_S2);
	                        AUDJPY_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDJPY_OCO2S6_UP_S2 = 0;
	                for (; AUDJPY_OCO2S6_UP_S2 < Base.AUDJPY_UP_S2_OCO2Sets6.Count; AUDJPY_OCO2S6_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO2Sets6[AUDJPY_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO2Sets6[AUDJPY_OCO2S6_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO2Sets6.RemoveAt(AUDJPY_OCO2S6_UP_S2);
	                        AUDJPY_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDJPY_OCO3_EO1_UP_S2)
	                Base.AUDJPY_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDJPY_OCO3_EO2_UP_S2)
	                Base.AUDJPY_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO3_EO3_UP_S2)
	                Base.AUDJPY_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO3_EO4_UP_S2)
	                Base.AUDJPY_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO3_EO5_UP_S2)
	                Base.AUDJPY_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO3_EO6_UP_S2)
	                Base.AUDJPY_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.AUDJPY_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP1,"TP1_AUDJPY_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP1_AUDJPY_UP_S2_OCO3"));
		                 };
		                Base.AUDJPY_UP_S2_OCO3Sets1.Add( Base.AUDJPY_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP2,"TP2_AUDJPY_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP2_AUDJPY_UP_S2_OCO3"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO3Sets2.Add( Base.AUDJPY_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP3,"TP3_AUDJPY_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP3_AUDJPY_UP_S2_OCO3"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO3Sets3.Add( Base.AUDJPY_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP4,"TP4_AUDJPY_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP4_AUDJPY_UP_S2_OCO3"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO3Sets4.Add( Base.AUDJPY_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP5,"TP5_AUDJPY_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP5_AUDJPY_UP_S2_OCO3"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO3Sets5.Add( Base.AUDJPY_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP6,"TP6_AUDJPY_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP6_AUDJPY_UP_S2_OCO3"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO3Sets6.Add( Base.AUDJPY_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDJPY_OCO3S1_UP_S2 = 0;
	                for (; AUDJPY_OCO3S1_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets1.Count; AUDJPY_OCO3S1_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO3Sets1[AUDJPY_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO3Sets1[AUDJPY_OCO3S1_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO3Sets1.RemoveAt(AUDJPY_OCO3S1_UP_S2);
	                        AUDJPY_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDJPY_OCO3S2_UP_S2 = 0;
	                for (; AUDJPY_OCO3S2_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets2.Count; AUDJPY_OCO3S2_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO3Sets2[AUDJPY_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO3Sets2[AUDJPY_OCO3S2_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO3Sets2.RemoveAt(AUDJPY_OCO3S2_UP_S2);
	                        AUDJPY_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO3S3_UP_S2 = 0;
	                for (; AUDJPY_OCO3S3_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets3.Count; AUDJPY_OCO3S3_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO3Sets3[AUDJPY_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO3Sets3[AUDJPY_OCO3S3_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO3Sets3.RemoveAt(AUDJPY_OCO3S3_UP_S2);
	                        AUDJPY_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO3S4_UP_S2 = 0;
	                for (; AUDJPY_OCO3S4_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets4.Count; AUDJPY_OCO3S4_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO3Sets4[AUDJPY_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO3Sets4[AUDJPY_OCO3S4_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO3Sets4.RemoveAt(AUDJPY_OCO3S4_UP_S2);
	                        AUDJPY_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDJPY_OCO3S5_UP_S2 = 0;
	                for (; AUDJPY_OCO3S5_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets5.Count; AUDJPY_OCO3S5_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO3Sets5[AUDJPY_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO3Sets5[AUDJPY_OCO3S5_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO3Sets5.RemoveAt(AUDJPY_OCO3S5_UP_S2);
	                        AUDJPY_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDJPY_OCO3S6_UP_S2 = 0;
	                for (; AUDJPY_OCO3S6_UP_S2 < Base.AUDJPY_UP_S2_OCO3Sets6.Count; AUDJPY_OCO3S6_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO3Sets6[AUDJPY_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO3Sets6[AUDJPY_OCO3S6_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO3Sets6.RemoveAt(AUDJPY_OCO3S6_UP_S2);
	                        AUDJPY_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDJPY_OCO4_EO1_UP_S2)
	                Base.AUDJPY_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDJPY_OCO4_EO2_UP_S2)
	                Base.AUDJPY_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO4_EO3_UP_S2)
	                Base.AUDJPY_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO4_EO4_UP_S2)
	                Base.AUDJPY_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO4_EO5_UP_S2)
	                Base.AUDJPY_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO4_EO6_UP_S2)
	                Base.AUDJPY_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.AUDJPY_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP1,"TP1_AUDJPY_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP1_AUDJPY_UP_S2_OCO4"));
		                 };
		                Base.AUDJPY_UP_S2_OCO4Sets1.Add( Base.AUDJPY_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP2,"TP2_AUDJPY_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP2_AUDJPY_UP_S2_OCO4"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO4Sets2.Add( Base.AUDJPY_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP3,"TP3_AUDJPY_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP3_AUDJPY_UP_S2_OCO4"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO4Sets3.Add( Base.AUDJPY_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP4,"TP4_AUDJPY_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP4_AUDJPY_UP_S2_OCO4"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO4Sets4.Add( Base.AUDJPY_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP5,"TP5_AUDJPY_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP5_AUDJPY_UP_S2_OCO4"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO4Sets5.Add( Base.AUDJPY_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_UP_S2_TP6,"TP6_AUDJPY_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_UP_S2_SL,"SL_TP6_AUDJPY_UP_S2_OCO4"));
		                 };
	                    Base.AUDJPY_UP_S2_OCO4Sets6.Add( Base.AUDJPY_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDJPY_OCO4S1_UP_S2 = 0;
	                for (; AUDJPY_OCO4S1_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets1.Count; AUDJPY_OCO4S1_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO4Sets1[AUDJPY_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO4Sets1[AUDJPY_OCO4S1_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO4Sets1.RemoveAt(AUDJPY_OCO4S1_UP_S2);
	                        AUDJPY_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDJPY_OCO4S2_UP_S2 = 0;
	                for (; AUDJPY_OCO4S2_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets2.Count; AUDJPY_OCO4S2_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO4Sets2[AUDJPY_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO4Sets2[AUDJPY_OCO4S2_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO4Sets2.RemoveAt(AUDJPY_OCO4S2_UP_S2);
	                        AUDJPY_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO4S3_UP_S2 = 0;
	                for (; AUDJPY_OCO4S3_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets3.Count; AUDJPY_OCO4S3_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO4Sets3[AUDJPY_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO4Sets3[AUDJPY_OCO4S3_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO4Sets3.RemoveAt(AUDJPY_OCO4S3_UP_S2);
	                        AUDJPY_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO4S4_UP_S2 = 0;
	                for (; AUDJPY_OCO4S4_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets4.Count; AUDJPY_OCO4S4_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO4Sets4[AUDJPY_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO4Sets4[AUDJPY_OCO4S4_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO4Sets4.RemoveAt(AUDJPY_OCO4S4_UP_S2);
	                        AUDJPY_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDJPY_OCO4S5_UP_S2 = 0;
	                for (; AUDJPY_OCO4S5_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets5.Count; AUDJPY_OCO4S5_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO4Sets5[AUDJPY_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO4Sets5[AUDJPY_OCO4S5_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO4Sets5.RemoveAt(AUDJPY_OCO4S5_UP_S2);
	                        AUDJPY_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDJPY_OCO4S6_UP_S2 = 0;
	                for (; AUDJPY_OCO4S6_UP_S2 < Base.AUDJPY_UP_S2_OCO4Sets6.Count; AUDJPY_OCO4S6_UP_S2++)
	                    if (Base.AUDJPY_UP_S2_OCO4Sets6[AUDJPY_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_UP_S2_OCO4Sets6[AUDJPY_OCO4S6_UP_S2].Filled();
	                        Base.AUDJPY_UP_S2_OCO4Sets6.RemoveAt(AUDJPY_OCO4S6_UP_S2);
	                        AUDJPY_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDCAD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDCAD_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("AUDCAD_DOWN_S2_OCO1")))
			{
				Base.AUDCAD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCAD_DOWN_S2_OCO2")))
			{
				Base.AUDCAD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCAD_DOWN_S2_OCO3")))
			{
				Base.AUDCAD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCAD_DOWN_S2_OCO4")))
			{
				Base.AUDCAD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDCAD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.AUDCAD_OCO1_EO1_DOWN_S2)
	                Base.AUDCAD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDCAD_OCO1_EO2_DOWN_S2)
	                Base.AUDCAD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO1_EO3_DOWN_S2)
	                Base.AUDCAD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO1_EO4_DOWN_S2)
	                Base.AUDCAD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO1_EO5_DOWN_S2)
	                Base.AUDCAD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO1_EO6_DOWN_S2)
	                Base.AUDCAD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCAD_OCO1S1_DOWN_S2 = 0;
		                for (; AUDCAD_OCO1S1_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets1.Count; AUDCAD_OCO1S1_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO1Sets1[AUDCAD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO1Sets1[AUDCAD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.AUDCAD_DOWN_S2_OCO1Sets1.Clear();
		                        AUDCAD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCAD_OCO1S2_DOWN_S2 = 0;
		                for (; AUDCAD_OCO1S2_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets2.Count; AUDCAD_OCO1S2_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO1Sets2[AUDCAD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO1Sets2[AUDCAD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.AUDCAD_DOWN_S2_OCO1Sets2.Clear();
		                        AUDCAD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO1S3_DOWN_S2 = 0;
		                for (; AUDCAD_OCO1S3_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets3.Count; AUDCAD_OCO1S3_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO1Sets3[AUDCAD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO1Sets3[AUDCAD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.AUDCAD_DOWN_S2_OCO1Sets3.Clear();
		                        AUDCAD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO1S4_DOWN_S2 = 0;
		                for (; AUDCAD_OCO1S4_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets4.Count; AUDCAD_OCO1S4_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO1Sets4[AUDCAD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO1Sets4[AUDCAD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.AUDCAD_DOWN_S2_OCO1Sets4.Clear();
		                        AUDCAD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO1S5_DOWN_S2 = 0;
		                for (; AUDCAD_OCO1S5_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets5.Count; AUDCAD_OCO1S5_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO1Sets5[AUDCAD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO1Sets5[AUDCAD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.AUDCAD_DOWN_S2_OCO1Sets5.Clear();
		                        AUDCAD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO1S6_DOWN_S2 = 0;
		                for (; AUDCAD_OCO1S6_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets6.Count; AUDCAD_OCO1S6_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO1Sets6[AUDCAD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO1Sets6[AUDCAD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.AUDCAD_DOWN_S2_OCO1Sets6.Clear();
		                        AUDCAD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDCAD_OCO2_EO1_DOWN_S2)
	                Base.AUDCAD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDCAD_OCO2_EO2_DOWN_S2)
	                Base.AUDCAD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO2_EO3_DOWN_S2)
	                Base.AUDCAD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO2_EO4_DOWN_S2)
	                Base.AUDCAD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO2_EO5_DOWN_S2)
	                Base.AUDCAD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO2_EO6_DOWN_S2)
	                Base.AUDCAD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCAD_OCO2S1_DOWN_S2 = 0;
		                for (; AUDCAD_OCO2S1_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets1.Count; AUDCAD_OCO2S1_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO2Sets1[AUDCAD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO2Sets1[AUDCAD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.AUDCAD_DOWN_S2_OCO2Sets1.Clear();
		                        AUDCAD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCAD_OCO2S2_DOWN_S2 = 0;
		                for (; AUDCAD_OCO2S2_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets2.Count; AUDCAD_OCO2S2_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO2Sets2[AUDCAD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO2Sets2[AUDCAD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.AUDCAD_DOWN_S2_OCO2Sets2.Clear();
		                        AUDCAD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO2S3_DOWN_S2 = 0;
		                for (; AUDCAD_OCO2S3_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets3.Count; AUDCAD_OCO2S3_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO2Sets3[AUDCAD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO2Sets3[AUDCAD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.AUDCAD_DOWN_S2_OCO2Sets3.Clear();
		                        AUDCAD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO2S4_DOWN_S2 = 0;
		                for (; AUDCAD_OCO2S4_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets4.Count; AUDCAD_OCO2S4_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO2Sets4[AUDCAD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO2Sets4[AUDCAD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.AUDCAD_DOWN_S2_OCO2Sets4.Clear();
		                        AUDCAD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO2S5_DOWN_S2 = 0;
		                for (; AUDCAD_OCO2S5_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets5.Count; AUDCAD_OCO2S5_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO2Sets5[AUDCAD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO2Sets5[AUDCAD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.AUDCAD_DOWN_S2_OCO2Sets5.Clear();
		                        AUDCAD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO2S6_DOWN_S2 = 0;
		                for (; AUDCAD_OCO2S6_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets6.Count; AUDCAD_OCO2S6_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO2Sets6[AUDCAD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO2Sets6[AUDCAD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.AUDCAD_DOWN_S2_OCO2Sets6.Clear();
		                        AUDCAD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDCAD_OCO3_EO1_DOWN_S2)
	                Base.AUDCAD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDCAD_OCO3_EO2_DOWN_S2)
	                Base.AUDCAD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO3_EO3_DOWN_S2)
	                Base.AUDCAD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO3_EO4_DOWN_S2)
	                Base.AUDCAD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO3_EO5_DOWN_S2)
	                Base.AUDCAD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO3_EO6_DOWN_S2)
	                Base.AUDCAD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCAD_OCO3S1_DOWN_S2 = 0;
		                for (; AUDCAD_OCO3S1_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets1.Count; AUDCAD_OCO3S1_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO3Sets1[AUDCAD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO3Sets1[AUDCAD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.AUDCAD_DOWN_S2_OCO3Sets1.Clear();
		                        AUDCAD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCAD_OCO3S2_DOWN_S2 = 0;
		                for (; AUDCAD_OCO3S2_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets2.Count; AUDCAD_OCO3S2_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO3Sets2[AUDCAD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO3Sets2[AUDCAD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.AUDCAD_DOWN_S2_OCO3Sets2.Clear();
		                        AUDCAD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO3S3_DOWN_S2 = 0;
		                for (; AUDCAD_OCO3S3_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets3.Count; AUDCAD_OCO3S3_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO3Sets3[AUDCAD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO3Sets3[AUDCAD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.AUDCAD_DOWN_S2_OCO3Sets3.Clear();
		                        AUDCAD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO3S4_DOWN_S2 = 0;
		                for (; AUDCAD_OCO3S4_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets4.Count; AUDCAD_OCO3S4_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO3Sets4[AUDCAD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO3Sets4[AUDCAD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.AUDCAD_DOWN_S2_OCO3Sets4.Clear();
		                        AUDCAD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO3S5_DOWN_S2 = 0;
		                for (; AUDCAD_OCO3S5_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets5.Count; AUDCAD_OCO3S5_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO3Sets5[AUDCAD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO3Sets5[AUDCAD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.AUDCAD_DOWN_S2_OCO3Sets5.Clear();
		                        AUDCAD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO3S6_DOWN_S2 = 0;
		                for (; AUDCAD_OCO3S6_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets6.Count; AUDCAD_OCO3S6_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO3Sets6[AUDCAD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO3Sets6[AUDCAD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.AUDCAD_DOWN_S2_OCO3Sets6.Clear();
		                        AUDCAD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDCAD_OCO4_EO1_DOWN_S2)
	                Base.AUDCAD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.AUDCAD_OCO4_EO2_DOWN_S2)
	                Base.AUDCAD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO4_EO3_DOWN_S2)
	                Base.AUDCAD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO4_EO4_DOWN_S2)
	                Base.AUDCAD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO4_EO5_DOWN_S2)
	                Base.AUDCAD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO4_EO6_DOWN_S2)
	                Base.AUDCAD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCAD_OCO4S1_DOWN_S2 = 0;
		                for (; AUDCAD_OCO4S1_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets1.Count; AUDCAD_OCO4S1_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO4Sets1[AUDCAD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO4Sets1[AUDCAD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.AUDCAD_DOWN_S2_OCO4Sets1.Clear();
		                        AUDCAD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCAD_OCO4S2_DOWN_S2 = 0;
		                for (; AUDCAD_OCO4S2_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets2.Count; AUDCAD_OCO4S2_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO4Sets2[AUDCAD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO4Sets2[AUDCAD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.AUDCAD_DOWN_S2_OCO4Sets2.Clear();
		                        AUDCAD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO4S3_DOWN_S2 = 0;
		                for (; AUDCAD_OCO4S3_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets3.Count; AUDCAD_OCO4S3_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO4Sets3[AUDCAD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO4Sets3[AUDCAD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.AUDCAD_DOWN_S2_OCO4Sets3.Clear();
		                        AUDCAD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO4S4_DOWN_S2 = 0;
		                for (; AUDCAD_OCO4S4_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets4.Count; AUDCAD_OCO4S4_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO4Sets4[AUDCAD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO4Sets4[AUDCAD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.AUDCAD_DOWN_S2_OCO4Sets4.Clear();
		                        AUDCAD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO4S5_DOWN_S2 = 0;
		                for (; AUDCAD_OCO4S5_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets5.Count; AUDCAD_OCO4S5_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO4Sets5[AUDCAD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO4Sets5[AUDCAD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.AUDCAD_DOWN_S2_OCO4Sets5.Clear();
		                        AUDCAD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO4S6_DOWN_S2 = 0;
		                for (; AUDCAD_OCO4S6_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets6.Count; AUDCAD_OCO4S6_DOWN_S2++)
		                    if (Base.AUDCAD_DOWN_S2_OCO4Sets6[AUDCAD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_DOWN_S2_OCO4Sets6[AUDCAD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.AUDCAD_DOWN_S2_OCO4Sets6.Clear();
		                        AUDCAD_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();
	            	}
	            	
					DOWM_AUDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDCAD_DOWN_S2 = DOWM_AUDCAD_DOWN_S2 || DOWT_AUDCAD_DOWN_S2 || DOWW_AUDCAD_DOWN_S2 || DOWTH_AUDCAD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDCAD"))
	            	{
	            		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.AUDCAD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.AUDCAD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.AUDCAD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.AUDCAD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.AUDCAD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDCAD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDCAD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.AUDCAD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDCAD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDCAD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.AUDCAD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}


	                	AUDCAD_Signal_Condition_DOWN_S2 =  
	                									(
															prices_ASK_High[0] > pricesM_ASK_High[0] &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.01m 
	                									);
	                									
	                    AUDCAD_DOWN_S2_SL  =  0.01m;
	                    AUDCAD_DOWN_S2_TP1 =  0.003m;
	                    AUDCAD_DOWN_S2_TP2 =  AUDCAD_DOWN_S2_SL * 0;
	                    AUDCAD_DOWN_S2_TP3 =  AUDCAD_DOWN_S2_SL * 0;
	                    AUDCAD_DOWN_S2_TP4 =  AUDCAD_DOWN_S2_SL * 0;
	                    AUDCAD_DOWN_S2_TP5 =  AUDCAD_DOWN_S2_SL * 0;
	                    AUDCAD_DOWN_S2_TP6 =  AUDCAD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    AUDCAD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    AUDCAD_quantity_SL_DOWN_S2 = AUDCAD_quantity_DOWN_S2;
	                    AUDCAD_quantity_TP1_DOWN_S2 = (int)Math.Floor(AUDCAD_quantity_DOWN_S2 * 1m);
	                    AUDCAD_quantity_TP2_DOWN_S2 = (int)Math.Floor(AUDCAD_quantity_TP1_DOWN_S2 * 0m);
	                    AUDCAD_quantity_TP3_DOWN_S2 = (int)Math.Floor(AUDCAD_quantity_TP2_DOWN_S2 * 0m);
	                    AUDCAD_quantity_TP4_DOWN_S2 = (int)Math.Floor(AUDCAD_quantity_TP3_DOWN_S2 * 0m);
	                    AUDCAD_quantity_TP5_DOWN_S2 = (int)Math.Floor(AUDCAD_quantity_TP4_DOWN_S2 * 0m);
	                    AUDCAD_quantity_TP6_DOWN_S2 = (int)Math.Floor(AUDCAD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (AUDCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDCAD_DOWN_S2 && 
	                    Base.AUDCAD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.AUDCAD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCAD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP1_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.AUDCAD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDCAD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP2_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.AUDCAD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.AUDCAD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP3_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.AUDCAD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDCAD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP4_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.AUDCAD_OCO1_EO4_DOWN_S2 = false;

							Base.AUDCAD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.AUDCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (AUDCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDCAD_DOWN_S2 && 
	                    Base.AUDCAD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.AUDCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDCAD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCAD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP1_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.AUDCAD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDCAD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP2_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.AUDCAD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.AUDCAD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP3_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.AUDCAD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDCAD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP4_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.AUDCAD_OCO2_EO4_DOWN_S2 = false;

							Base.AUDCAD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.AUDCAD_OCO2_DOWN_S2_IsReady == false && Base.AUDCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (AUDCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDCAD_DOWN_S2 &&
	                    Base.AUDCAD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.AUDCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDCAD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCAD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP1_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.AUDCAD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDCAD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP2_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.AUDCAD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.AUDCAD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP3_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.AUDCAD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDCAD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP4_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.AUDCAD_OCO3_EO4_DOWN_S2 = false;

							Base.AUDCAD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.AUDCAD_OCO3_DOWN_S2_IsReady == false && Base.AUDCAD_OCO2_DOWN_S2_IsReady == false && Base.AUDCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (AUDCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_AUDCAD_DOWN_S2 && 
	                    Base.AUDCAD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.AUDCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.AUDCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.AUDCAD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.AUDCAD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCAD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP1_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.AUDCAD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.AUDCAD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP2_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.AUDCAD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.AUDCAD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP3_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.AUDCAD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.AUDCAD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         AUDCAD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP4_DOWN_S2, false,"AUDCAD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.AUDCAD_OCO4_EO4_DOWN_S2 = false;

							Base.AUDCAD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.AUDCAD_OCO4_DOWN_S2_IsReady == false && Base.AUDCAD_OCO3_DOWN_S2_IsReady == false && Base.AUDCAD_OCO2_DOWN_S2_IsReady == false && Base.AUDCAD_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_AUDCAD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_AUDCAD_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(x=>x.Tag.Contains("AUDCAD_UP_S2_OCO1")))
			{
				Base.AUDCAD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCAD_UP_S2_OCO2")))
			{
				Base.AUDCAD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCAD_UP_S2_OCO3")))
			{
				Base.AUDCAD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("AUDCAD_UP_S2_OCO4")))
			{
				Base.AUDCAD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("AUDCAD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.AUDCAD_OCO1_EO1_UP_S2)
	                Base.AUDCAD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDCAD_OCO1_EO2_UP_S2)
	                Base.AUDCAD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO1_EO3_UP_S2)
	                Base.AUDCAD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO1_EO4_UP_S2)
	                Base.AUDCAD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO1_EO5_UP_S2)
	                Base.AUDCAD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO1_EO6_UP_S2)
	                Base.AUDCAD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCAD_OCO1S1_UP_S2 = 0;
		                for (; AUDCAD_OCO1S1_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets1.Count; AUDCAD_OCO1S1_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO1Sets1[AUDCAD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO1Sets1[AUDCAD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.AUDCAD_UP_S2_OCO1Sets1.Clear();
		                        AUDCAD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCAD_OCO1S2_UP_S2 = 0;
		                for (; AUDCAD_OCO1S2_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets2.Count; AUDCAD_OCO1S2_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO1Sets2[AUDCAD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO1Sets2[AUDCAD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.AUDCAD_UP_S2_OCO1Sets2.Clear();
		                        AUDCAD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO1S3_UP_S2 = 0;
		                for (; AUDCAD_OCO1S3_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets3.Count; AUDCAD_OCO1S3_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO1Sets3[AUDCAD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO1Sets3[AUDCAD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.AUDCAD_UP_S2_OCO1Sets3.Clear();
		                        AUDCAD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO1S4_UP_S2 = 0;
		                for (; AUDCAD_OCO1S4_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets4.Count; AUDCAD_OCO1S4_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO1Sets4[AUDCAD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO1Sets4[AUDCAD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.AUDCAD_UP_S2_OCO1Sets4.Clear();
		                        AUDCAD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO1S5_UP_S2 = 0;
		                for (; AUDCAD_OCO1S5_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets5.Count; AUDCAD_OCO1S5_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO1Sets5[AUDCAD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO1Sets5[AUDCAD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.AUDCAD_UP_S2_OCO1Sets5.Clear();
		                        AUDCAD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO1S6_UP_S2 = 0;
		                for (; AUDCAD_OCO1S6_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets6.Count; AUDCAD_OCO1S6_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO1Sets6[AUDCAD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO1Sets6[AUDCAD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.AUDCAD_UP_S2_OCO1Sets6.Clear();
		                        AUDCAD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDCAD_OCO2_EO1_UP_S2)
                	Base.AUDCAD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDCAD_OCO2_EO2_UP_S2)
	                Base.AUDCAD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO2_EO3_UP_S2)
	                Base.AUDCAD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO2_EO4_UP_S2)
	                Base.AUDCAD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO2_EO5_UP_S2)
	                Base.AUDCAD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO2_EO6_UP_S2)
	                Base.AUDCAD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCAD_OCO2S1_UP_S2 = 0;
		                for (; AUDCAD_OCO2S1_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets1.Count; AUDCAD_OCO2S1_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO2Sets1[AUDCAD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO2Sets1[AUDCAD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.AUDCAD_UP_S2_OCO2Sets1.Clear();
		                        AUDCAD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCAD_OCO2S2_UP_S2 = 0;
		                for (; AUDCAD_OCO2S2_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets2.Count; AUDCAD_OCO2S2_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO2Sets2[AUDCAD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO2Sets2[AUDCAD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.AUDCAD_UP_S2_OCO2Sets2.Clear();
		                        AUDCAD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO2S3_UP_S2 = 0;
		                for (; AUDCAD_OCO2S3_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets3.Count; AUDCAD_OCO2S3_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO2Sets3[AUDCAD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO2Sets3[AUDCAD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.AUDCAD_UP_S2_OCO2Sets3.Clear();
		                        AUDCAD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO2S4_UP_S2 = 0;
		                for (; AUDCAD_OCO2S4_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets4.Count; AUDCAD_OCO2S4_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO2Sets4[AUDCAD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO2Sets4[AUDCAD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.AUDCAD_UP_S2_OCO2Sets4.Clear();
		                        AUDCAD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO2S5_UP_S2 = 0;
		                for (; AUDCAD_OCO2S5_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets5.Count; AUDCAD_OCO2S5_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO2Sets5[AUDCAD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO2Sets5[AUDCAD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.AUDCAD_UP_S2_OCO2Sets5.Clear();
		                        AUDCAD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO2S6_UP_S2 = 0;
		                for (; AUDCAD_OCO2S6_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets6.Count; AUDCAD_OCO2S6_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO2Sets6[AUDCAD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO2Sets6[AUDCAD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.AUDCAD_UP_S2_OCO2Sets6.Clear();
		                        AUDCAD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.AUDCAD_OCO3_EO1_UP_S2)
            		Base.AUDCAD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDCAD_OCO3_EO2_UP_S2)
	                Base.AUDCAD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO3_EO3_UP_S2)
	                Base.AUDCAD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO3_EO4_UP_S2)
	                Base.AUDCAD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO3_EO5_UP_S2)
	                Base.AUDCAD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO3_EO6_UP_S2)
	                Base.AUDCAD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCAD_OCO3S1_UP_S2 = 0;
		                for (; AUDCAD_OCO3S1_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets1.Count; AUDCAD_OCO3S1_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO3Sets1[AUDCAD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO3Sets1[AUDCAD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.AUDCAD_UP_S2_OCO3Sets1.Clear();
		                        AUDCAD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCAD_OCO3S2_UP_S2 = 0;
		                for (; AUDCAD_OCO3S2_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets2.Count; AUDCAD_OCO3S2_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO3Sets2[AUDCAD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO3Sets2[AUDCAD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.AUDCAD_UP_S2_OCO3Sets2.Clear();
		                        AUDCAD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO3S3_UP_S2 = 0;
		                for (; AUDCAD_OCO3S3_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets3.Count; AUDCAD_OCO3S3_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO3Sets3[AUDCAD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO3Sets3[AUDCAD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.AUDCAD_UP_S2_OCO3Sets3.Clear();
		                        AUDCAD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO3S4_UP_S2 = 0;
		                for (; AUDCAD_OCO3S4_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets4.Count; AUDCAD_OCO3S4_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO3Sets4[AUDCAD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO3Sets4[AUDCAD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.AUDCAD_UP_S2_OCO3Sets4.Clear();
		                        AUDCAD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO3S5_UP_S2 = 0;
		                for (; AUDCAD_OCO3S5_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets5.Count; AUDCAD_OCO3S5_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO3Sets5[AUDCAD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO3Sets5[AUDCAD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.AUDCAD_UP_S2_OCO3Sets5.Clear();
		                        AUDCAD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO3S6_UP_S2 = 0;
		                for (; AUDCAD_OCO3S6_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets6.Count; AUDCAD_OCO3S6_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO3Sets6[AUDCAD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO3Sets6[AUDCAD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.AUDCAD_UP_S2_OCO3Sets6.Clear();
		                        AUDCAD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.AUDCAD_OCO4_EO1_UP_S2)
            		Base.AUDCAD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.AUDCAD_OCO4_EO2_UP_S2)
	                Base.AUDCAD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO4_EO3_UP_S2)
	                Base.AUDCAD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO4_EO4_UP_S2)
	                Base.AUDCAD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO4_EO5_UP_S2)
	                Base.AUDCAD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.AUDCAD_OCO4_EO6_UP_S2)
	                Base.AUDCAD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.AUDCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int AUDCAD_OCO4S1_UP_S2 = 0;
		                for (; AUDCAD_OCO4S1_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets1.Count; AUDCAD_OCO4S1_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO4Sets1[AUDCAD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO4Sets1[AUDCAD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.AUDCAD_UP_S2_OCO4Sets1.Clear();
		                        AUDCAD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int AUDCAD_OCO4S2_UP_S2 = 0;
		                for (; AUDCAD_OCO4S2_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets2.Count; AUDCAD_OCO4S2_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO4Sets2[AUDCAD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO4Sets2[AUDCAD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.AUDCAD_UP_S2_OCO4Sets2.Clear();
		                        AUDCAD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO4S3_UP_S2 = 0;
		                for (; AUDCAD_OCO4S3_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets3.Count; AUDCAD_OCO4S3_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO4Sets3[AUDCAD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO4Sets3[AUDCAD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.AUDCAD_UP_S2_OCO4Sets3.Clear();
		                        AUDCAD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int AUDCAD_OCO4S4_UP_S2 = 0;
		                for (; AUDCAD_OCO4S4_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets4.Count; AUDCAD_OCO4S4_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO4Sets4[AUDCAD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO4Sets4[AUDCAD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.AUDCAD_UP_S2_OCO4Sets4.Clear();
		                        AUDCAD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO4S5_UP_S2 = 0;
		                for (; AUDCAD_OCO4S5_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets5.Count; AUDCAD_OCO4S5_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO4Sets5[AUDCAD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO4Sets5[AUDCAD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.AUDCAD_UP_S2_OCO4Sets5.Clear();
		                        AUDCAD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int AUDCAD_OCO4S6_UP_S2 = 0;
		                for (; AUDCAD_OCO4S6_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets6.Count; AUDCAD_OCO4S6_UP_S2++)
		                    if (Base.AUDCAD_UP_S2_OCO4Sets6[AUDCAD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.AUDCAD_UP_S2_OCO4Sets6[AUDCAD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("AUDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("AUDCAD", order.Quantity, false, "AUDCAD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.AUDCAD_UP_S2_OCO4Sets6.Clear();
		                        AUDCAD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_AUDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_AUDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_AUDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_AUDCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_AUDCAD_UP_S2 = DOWM_AUDCAD_UP_S2 || DOWT_AUDCAD_UP_S2 || DOWW_AUDCAD_UP_S2 || DOWTH_AUDCAD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("AUDCAD"))
	            	{
	            		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.AUDCAD_OCO1_UP_S2_IsReady == false ||
	                    	Base.AUDCAD_OCO2_UP_S2_IsReady == false ||
	                    	Base.AUDCAD_OCO3_UP_S2_IsReady == false ||
	                    	Base.AUDCAD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.AUDCAD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDCAD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDCAD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.AUDCAD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.AUDCAD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.AUDCAD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.AUDCAD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.AUDCAD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	AUDCAD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                	AUDCAD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                									
	                	AUDCAD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[0] < pricesM_BID_Low[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 (AUDCAD_Signal_Condition_UP_1)
	                	{
	                    	AUDCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDCAD_Signal_Condition_UP_2)
	                	{
	                    	AUDCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (AUDCAD_Signal_Condition_UP_3)
	                	{
	                    	AUDCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (AUDCAD_Signal_Condition_UP_1)
	                	{
	                    	AUDCAD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (AUDCAD_Signal_Condition_UP_2)
	                	{
	                    	AUDCAD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (AUDCAD_Signal_Condition_UP_3)
	                	{
	                    	AUDCAD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    AUDCAD_UP_S2_TP2 =  AUDCAD_UP_S2_SL * 0;
	                    AUDCAD_UP_S2_TP3 =  AUDCAD_UP_S2_SL * 0;
	                    AUDCAD_UP_S2_TP4 =  AUDCAD_UP_S2_SL * 0;
	                    AUDCAD_UP_S2_TP5 =  AUDCAD_UP_S2_SL * 0;
	                    AUDCAD_UP_S2_TP6 =  AUDCAD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    AUDCAD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    AUDCAD_quantity_SL_UP_S2 = AUDCAD_quantity_UP_S2;
	                    AUDCAD_quantity_TP1_UP_S2 = (int)Math.Floor(AUDCAD_quantity_UP_S2 * 1m);
	                    AUDCAD_quantity_TP2_UP_S2 = (int)Math.Floor(AUDCAD_quantity_TP1_UP_S2 * 0m);
	                    AUDCAD_quantity_TP3_UP_S2 = (int)Math.Floor(AUDCAD_quantity_TP2_UP_S2 * 0m);
	                    AUDCAD_quantity_TP4_UP_S2 = (int)Math.Floor(AUDCAD_quantity_TP3_UP_S2 * 0m);
	                    AUDCAD_quantity_TP5_UP_S2 = (int)Math.Floor(AUDCAD_quantity_TP4_UP_S2 * 0m);
	                    AUDCAD_quantity_TP6_UP_S2 = (int)Math.Floor(AUDCAD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((AUDCAD_Signal_Condition_UP_1 || AUDCAD_Signal_Condition_UP_2 || AUDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDCAD_UP_S2 && 
	                    Base.AUDCAD_OCO1_UP_S2_IsReady == true &&
	                    Base.AUDCAD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCAD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP1_UP_S2, false,"AUDCAD_UP_S2_Entry_TP1_OCO1");
	                         Base.AUDCAD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.AUDCAD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP2_UP_S2, false,"AUDCAD_UP_S2_Entry_TP2_OCO1");
	                         Base.AUDCAD_OCO1_EO2_UP_S2 = false;
	
	                         Base.AUDCAD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP3_UP_S2, false,"AUDCAD_UP_S2_Entry_TP3_OCO1");
	                         Base.AUDCAD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.AUDCAD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP4_UP_S2, false,"AUDCAD_UP_S2_Entry_TP4_OCO1");
	                         Base.AUDCAD_OCO1_EO4_UP_S2 = false;

							Base.AUDCAD_OCO1_UP_S2_IsReady = false;
							
							if (Base.AUDCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((AUDCAD_Signal_Condition_UP_1 || AUDCAD_Signal_Condition_UP_2 || AUDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDCAD_UP_S2 && 
	                    Base.AUDCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDCAD_OCO2_UP_S2_IsReady == true &&
	                    Base.AUDCAD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCAD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP1_UP_S2, false,"AUDCAD_UP_S2_Entry_TP1_OCO2");
	                         Base.AUDCAD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.AUDCAD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP2_UP_S2, false,"AUDCAD_UP_S2_Entry_TP2_OCO2");
	                         Base.AUDCAD_OCO2_EO2_UP_S2 = false;
	
	                         Base.AUDCAD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP3_UP_S2, false,"AUDCAD_UP_S2_Entry_TP3_OCO2");
	                         Base.AUDCAD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.AUDCAD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP4_UP_S2, false,"AUDCAD_UP_S2_Entry_TP4_OCO2");
	                         Base.AUDCAD_OCO2_EO4_UP_S2 = false;

							Base.AUDCAD_OCO2_UP_S2_IsReady = false;
							
							if (Base.AUDCAD_OCO2_UP_S2_IsReady == false && Base.AUDCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((AUDCAD_Signal_Condition_UP_1 || AUDCAD_Signal_Condition_UP_2 || AUDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDCAD_UP_S2 &&
	                    Base.AUDCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDCAD_OCO3_UP_S2_IsReady == true &&
	                    Base.AUDCAD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCAD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP1_UP_S2, false,"AUDCAD_UP_S2_Entry_TP1_OCO3");
	                         Base.AUDCAD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.AUDCAD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP2_UP_S2, false,"AUDCAD_UP_S2_Entry_TP2_OCO3");
	                         Base.AUDCAD_OCO3_EO2_UP_S2 = false;
	
	                         Base.AUDCAD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP3_UP_S2, false,"AUDCAD_UP_S2_Entry_TP3_OCO3");
	                         Base.AUDCAD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.AUDCAD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP4_UP_S2, false,"AUDCAD_UP_S2_Entry_TP4_OCO3");
	                         Base.AUDCAD_OCO3_EO4_UP_S2 = false;

							Base.AUDCAD_OCO3_UP_S2_IsReady = false;
							
							if (Base.AUDCAD_OCO3_UP_S2_IsReady == false && Base.AUDCAD_OCO2_UP_S2_IsReady == false && Base.AUDCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((AUDCAD_Signal_Condition_UP_1 || AUDCAD_Signal_Condition_UP_2 || AUDCAD_Signal_Condition_UP_3)  && 
	                    DOWR_AUDCAD_UP_S2 && 
	                    Base.AUDCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.AUDCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.AUDCAD_OCO3_UP_S2_IsReady == false &&
	                    Base.AUDCAD_OCO4_UP_S2_IsReady == true &&
	                    Base.AUDCAD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.AUDCAD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP1_UP_S2, false,"AUDCAD_UP_S2_Entry_TP1_OCO4");
	                         Base.AUDCAD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.AUDCAD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP2_UP_S2, false,"AUDCAD_UP_S2_Entry_TP2_OCO4");
	                         Base.AUDCAD_OCO4_EO2_UP_S2 = false;
	
	                         Base.AUDCAD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP3_UP_S2, false,"AUDCAD_UP_S2_Entry_TP3_OCO4");
	                         Base.AUDCAD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.AUDCAD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         AUDCAD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, AUDCAD_quantity_TP4_UP_S2, false,"AUDCAD_UP_S2_Entry_TP4_OCO4");
	                         Base.AUDCAD_OCO4_EO4_UP_S2 = false;

							Base.AUDCAD_OCO4_UP_S2_IsReady = false;
							
							if (Base.AUDCAD_OCO4_UP_S2_IsReady == false && Base.AUDCAD_OCO3_UP_S2_IsReady == false && Base.AUDCAD_OCO2_UP_S2_IsReady == false && Base.AUDCAD_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.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 AUDJPY_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDJPY_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("AUDJPY OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDJPY OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDJPY OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDJPY OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDJPY OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDJPY OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDJPY S2");
		        	}
		        }
		        
				if (Base.AUDJPY_OCO1_EO1_DOWN_S2)
	                Base.AUDJPY_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDJPY_OCO1_EO2_DOWN_S2)
	                Base.AUDJPY_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO1_EO3_DOWN_S2)
	                Base.AUDJPY_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO1_EO4_DOWN_S2)
	                Base.AUDJPY_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDJPY_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP1_AUDJPY_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP1,"TP1_AUDJPY_DOWN_S2_OCO1"));
		                 };
		                Base.AUDJPY_DOWN_S2_OCO1Sets1.Add( Base.AUDJPY_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP2_AUDJPY_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP2,"TP2_AUDJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO1Sets2.Add( Base.AUDJPY_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP3_AUDJPY_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP3,"TP3_AUDJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO1Sets3.Add( Base.AUDJPY_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP4_AUDJPY_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP4,"TP4_AUDJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO1Sets4.Add( Base.AUDJPY_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDJPY_OCO1S1_DOWN_S2 = 0;
	                for (; AUDJPY_OCO1S1_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets1.Count; AUDJPY_OCO1S1_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO1Sets1[AUDJPY_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO1Sets1[AUDJPY_OCO1S1_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO1Sets1.RemoveAt(AUDJPY_OCO1S1_DOWN_S2);
	                        AUDJPY_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDJPY_OCO1S2_DOWN_S2 = 0;
	                for (; AUDJPY_OCO1S2_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets2.Count; AUDJPY_OCO1S2_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO1Sets2[AUDJPY_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO1Sets2[AUDJPY_OCO1S2_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO1Sets2.RemoveAt(AUDJPY_OCO1S2_DOWN_S2);
	                        AUDJPY_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO1S3_DOWN_S2 = 0;
	                for (; AUDJPY_OCO1S3_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets3.Count; AUDJPY_OCO1S3_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO1Sets3[AUDJPY_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO1Sets3[AUDJPY_OCO1S3_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO1Sets3.RemoveAt(AUDJPY_OCO1S3_DOWN_S2);
	                        AUDJPY_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO1S4_DOWN_S2 = 0;
	                for (; AUDJPY_OCO1S4_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO1Sets4.Count; AUDJPY_OCO1S4_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO1Sets4[AUDJPY_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO1Sets4[AUDJPY_OCO1S4_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO1Sets4.RemoveAt(AUDJPY_OCO1S4_DOWN_S2);
	                        AUDJPY_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDJPY_OCO2_EO1_DOWN_S2)
	                Base.AUDJPY_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDJPY_OCO2_EO2_DOWN_S2)
	                Base.AUDJPY_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO2_EO3_DOWN_S2)
	                Base.AUDJPY_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO2_EO4_DOWN_S2)
	                Base.AUDJPY_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDJPY_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP1_AUDJPY_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP1,"TP1_AUDJPY_DOWN_S2_OCO2"));
		                 };
		                Base.AUDJPY_DOWN_S2_OCO2Sets1.Add( Base.AUDJPY_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP2_AUDJPY_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP2,"TP2_AUDJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO2Sets2.Add( Base.AUDJPY_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP3_AUDJPY_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP3,"TP3_AUDJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO2Sets3.Add( Base.AUDJPY_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP4_AUDJPY_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP4,"TP4_AUDJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO2Sets4.Add( Base.AUDJPY_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDJPY_OCO2S1_DOWN_S2 = 0;
	                for (; AUDJPY_OCO2S1_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets1.Count; AUDJPY_OCO2S1_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO2Sets1[AUDJPY_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO2Sets1[AUDJPY_OCO2S1_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO2Sets1.RemoveAt(AUDJPY_OCO2S1_DOWN_S2);
	                        AUDJPY_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDJPY_OCO2S2_DOWN_S2 = 0;
	                for (; AUDJPY_OCO2S2_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets2.Count; AUDJPY_OCO2S2_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO2Sets2[AUDJPY_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO2Sets2[AUDJPY_OCO2S2_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO2Sets2.RemoveAt(AUDJPY_OCO2S2_DOWN_S2);
	                        AUDJPY_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO2S3_DOWN_S2 = 0;
	                for (; AUDJPY_OCO2S3_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets3.Count; AUDJPY_OCO2S3_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO2Sets3[AUDJPY_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO2Sets3[AUDJPY_OCO2S3_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO2Sets3.RemoveAt(AUDJPY_OCO2S3_DOWN_S2);
	                        AUDJPY_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO2S4_DOWN_S2 = 0;
	                for (; AUDJPY_OCO2S4_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO2Sets4.Count; AUDJPY_OCO2S4_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO2Sets4[AUDJPY_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO2Sets4[AUDJPY_OCO2S4_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO2Sets4.RemoveAt(AUDJPY_OCO2S4_DOWN_S2);
	                        AUDJPY_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDJPY_OCO3_EO1_DOWN_S2)
	                Base.AUDJPY_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDJPY_OCO3_EO2_DOWN_S2)
	                Base.AUDJPY_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO3_EO3_DOWN_S2)
	                Base.AUDJPY_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO3_EO4_DOWN_S2)
	                Base.AUDJPY_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDJPY_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP1_AUDJPY_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP1,"TP1_AUDJPY_DOWN_S2_OCO3"));
		                 };
		                Base.AUDJPY_DOWN_S2_OCO3Sets1.Add( Base.AUDJPY_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP2_AUDJPY_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP2,"TP2_AUDJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO3Sets2.Add( Base.AUDJPY_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP3_AUDJPY_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP3,"TP3_AUDJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO3Sets3.Add( Base.AUDJPY_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP4_AUDJPY_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP4,"TP4_AUDJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO3Sets4.Add( Base.AUDJPY_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDJPY_OCO3S1_DOWN_S2 = 0;
	                for (; AUDJPY_OCO3S1_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets1.Count; AUDJPY_OCO3S1_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO3Sets1[AUDJPY_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO3Sets1[AUDJPY_OCO3S1_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO3Sets1.RemoveAt(AUDJPY_OCO3S1_DOWN_S2);
	                        AUDJPY_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDJPY_OCO3S2_DOWN_S2 = 0;
	                for (; AUDJPY_OCO3S2_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets2.Count; AUDJPY_OCO3S2_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO3Sets2[AUDJPY_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO3Sets2[AUDJPY_OCO3S2_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO3Sets2.RemoveAt(AUDJPY_OCO3S2_DOWN_S2);
	                        AUDJPY_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO3S3_DOWN_S2 = 0;
	                for (; AUDJPY_OCO3S3_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets3.Count; AUDJPY_OCO3S3_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO3Sets3[AUDJPY_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO3Sets3[AUDJPY_OCO3S3_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO3Sets3.RemoveAt(AUDJPY_OCO3S3_DOWN_S2);
	                        AUDJPY_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO3S4_DOWN_S2 = 0;
	                for (; AUDJPY_OCO3S4_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO3Sets4.Count; AUDJPY_OCO3S4_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO3Sets4[AUDJPY_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO3Sets4[AUDJPY_OCO3S4_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO3Sets4.RemoveAt(AUDJPY_OCO3S4_DOWN_S2);
	                        AUDJPY_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDJPY_OCO4_EO1_DOWN_S2)
	                Base.AUDJPY_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDJPY_OCO4_EO2_DOWN_S2)
	                Base.AUDJPY_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO4_EO3_DOWN_S2)
	                Base.AUDJPY_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDJPY_OCO4_EO4_DOWN_S2)
	                Base.AUDJPY_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDJPY_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP1_AUDJPY_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP1,"TP1_AUDJPY_DOWN_S2_OCO4"));
		                 };
		                Base.AUDJPY_DOWN_S2_OCO4Sets1.Add( Base.AUDJPY_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP2_AUDJPY_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP2,"TP2_AUDJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO4Sets2.Add( Base.AUDJPY_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP3_AUDJPY_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP3,"TP3_AUDJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO4Sets3.Add( Base.AUDJPY_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDJPY_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDJPY_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDJPY_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDJPY_DOWN_S2_SL,"SL_TP4_AUDJPY_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDJPY_DOWN_S2_TP4,"TP4_AUDJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDJPY_DOWN_S2_OCO4Sets4.Add( Base.AUDJPY_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDJPY_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDJPY_OCO4S1_DOWN_S2 = 0;
	                for (; AUDJPY_OCO4S1_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets1.Count; AUDJPY_OCO4S1_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO4Sets1[AUDJPY_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO4Sets1[AUDJPY_OCO4S1_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO4Sets1.RemoveAt(AUDJPY_OCO4S1_DOWN_S2);
	                        AUDJPY_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDJPY_OCO4S2_DOWN_S2 = 0;
	                for (; AUDJPY_OCO4S2_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets2.Count; AUDJPY_OCO4S2_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO4Sets2[AUDJPY_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO4Sets2[AUDJPY_OCO4S2_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO4Sets2.RemoveAt(AUDJPY_OCO4S2_DOWN_S2);
	                        AUDJPY_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO4S3_DOWN_S2 = 0;
	                for (; AUDJPY_OCO4S3_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets3.Count; AUDJPY_OCO4S3_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO4Sets3[AUDJPY_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO4Sets3[AUDJPY_OCO4S3_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO4Sets3.RemoveAt(AUDJPY_OCO4S3_DOWN_S2);
	                        AUDJPY_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDJPY_OCO4S4_DOWN_S2 = 0;
	                for (; AUDJPY_OCO4S4_DOWN_S2 < Base.AUDJPY_DOWN_S2_OCO4Sets4.Count; AUDJPY_OCO4S4_DOWN_S2++)
	                    if (Base.AUDJPY_DOWN_S2_OCO4Sets4[AUDJPY_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDJPY_DOWN_S2_OCO4Sets4[AUDJPY_OCO4S4_DOWN_S2].Filled();
	                        Base.AUDJPY_DOWN_S2_OCO4Sets4.RemoveAt(AUDJPY_OCO4S4_DOWN_S2);
	                        AUDJPY_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct NZDUSD_OCO1_DOWN_S2
    {
        public NZDUSD_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 =="TP1_NZDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD 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 =="TP1_NZDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD 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 NZDUSD_OCO1_UP_S2
    {
        public NZDUSD_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 =="TP1_NZDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD 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 =="TP1_NZDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDUSD 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 NZDUSD_OCO2_DOWN_S2
    {
        public NZDUSD_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 =="TP1_NZDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD 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 =="TP1_NZDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD 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 NZDUSD_OCO2_UP_S2
    {
        public NZDUSD_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 =="TP1_NZDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD 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 =="TP1_NZDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDUSD 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 NZDUSD_OCO3_DOWN_S2
    {
        public NZDUSD_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 =="TP1_NZDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD 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 =="TP1_NZDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD 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 NZDUSD_OCO3_UP_S2
    {
        public NZDUSD_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 =="TP1_NZDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD 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 =="TP1_NZDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDUSD 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 NZDUSD_OCO4_DOWN_S2
    {
        public NZDUSD_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 =="TP1_NZDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD 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 =="TP1_NZDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD 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 NZDUSD_OCO4_UP_S2
    {
        public NZDUSD_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 =="TP1_NZDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD 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 =="TP1_NZDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDUSD 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 NZDJPY_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public NZDJPY_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("NZDJPY OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDJPY OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDJPY OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDJPY OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDJPY OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDJPY OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDJPY OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        }
		        
				if (Base.NZDJPY_OCO1_EO1_UP_S2)
	                Base.NZDJPY_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDJPY_OCO1_EO2_UP_S2)
	                Base.NZDJPY_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO1_EO3_UP_S2)
	                Base.NZDJPY_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO1_EO4_UP_S2)
	                Base.NZDJPY_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO1_EO5_UP_S2)
	                Base.NZDJPY_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO1_EO6_UP_S2)
	                Base.NZDJPY_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.NZDJPY_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP1,"TP1_NZDJPY_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP1_NZDJPY_UP_S2_OCO1"));
		                 };
		                Base.NZDJPY_UP_S2_OCO1Sets1.Add( Base.NZDJPY_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP2,"TP2_NZDJPY_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP2_NZDJPY_UP_S2_OCO1"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO1Sets2.Add( Base.NZDJPY_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP3,"TP3_NZDJPY_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP3_NZDJPY_UP_S2_OCO1"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO1Sets3.Add( Base.NZDJPY_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP4,"TP4_NZDJPY_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP4_NZDJPY_UP_S2_OCO1"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO1Sets4.Add( Base.NZDJPY_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP5,"TP5_NZDJPY_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP5_NZDJPY_UP_S2_OCO1"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO1Sets5.Add( Base.NZDJPY_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP6,"TP6_NZDJPY_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP6_NZDJPY_UP_S2_OCO1"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO1Sets6.Add( Base.NZDJPY_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDJPY_OCO1S1_UP_S2 = 0;
	                for (; NZDJPY_OCO1S1_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets1.Count; NZDJPY_OCO1S1_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO1Sets1[NZDJPY_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO1Sets1[NZDJPY_OCO1S1_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO1Sets1.RemoveAt(NZDJPY_OCO1S1_UP_S2);
	                        NZDJPY_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDJPY_OCO1S2_UP_S2 = 0;
	                for (; NZDJPY_OCO1S2_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets2.Count; NZDJPY_OCO1S2_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO1Sets2[NZDJPY_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO1Sets2[NZDJPY_OCO1S2_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO1Sets2.RemoveAt(NZDJPY_OCO1S2_UP_S2);
	                        NZDJPY_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO1S3_UP_S2 = 0;
	                for (; NZDJPY_OCO1S3_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets3.Count; NZDJPY_OCO1S3_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO1Sets3[NZDJPY_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO1Sets3[NZDJPY_OCO1S3_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO1Sets3.RemoveAt(NZDJPY_OCO1S3_UP_S2);
	                        NZDJPY_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO1S4_UP_S2 = 0;
	                for (; NZDJPY_OCO1S4_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets4.Count; NZDJPY_OCO1S4_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO1Sets4[NZDJPY_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO1Sets4[NZDJPY_OCO1S4_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO1Sets4.RemoveAt(NZDJPY_OCO1S4_UP_S2);
	                        NZDJPY_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDJPY_OCO1S5_UP_S2 = 0;
	                for (; NZDJPY_OCO1S5_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets5.Count; NZDJPY_OCO1S5_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO1Sets5[NZDJPY_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO1Sets5[NZDJPY_OCO1S5_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO1Sets5.RemoveAt(NZDJPY_OCO1S5_UP_S2);
	                        NZDJPY_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDJPY_OCO1S6_UP_S2 = 0;
	                for (; NZDJPY_OCO1S6_UP_S2 < Base.NZDJPY_UP_S2_OCO1Sets6.Count; NZDJPY_OCO1S6_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO1Sets6[NZDJPY_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO1Sets6[NZDJPY_OCO1S6_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO1Sets6.RemoveAt(NZDJPY_OCO1S6_UP_S2);
	                        NZDJPY_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.NZDJPY_OCO2_EO1_UP_S2)
	                Base.NZDJPY_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDJPY_OCO2_EO2_UP_S2)
	                Base.NZDJPY_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO2_EO3_UP_S2)
	                Base.NZDJPY_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO2_EO4_UP_S2)
	                Base.NZDJPY_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO2_EO5_UP_S2)
	                Base.NZDJPY_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO2_EO6_UP_S2)
	                Base.NZDJPY_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.NZDJPY_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP1,"TP1_NZDJPY_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP1_NZDJPY_UP_S2_OCO2"));
		                 };
		                Base.NZDJPY_UP_S2_OCO2Sets1.Add( Base.NZDJPY_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP2,"TP2_NZDJPY_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP2_NZDJPY_UP_S2_OCO2"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO2Sets2.Add( Base.NZDJPY_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP3,"TP3_NZDJPY_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP3_NZDJPY_UP_S2_OCO2"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO2Sets3.Add( Base.NZDJPY_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP4,"TP4_NZDJPY_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP4_NZDJPY_UP_S2_OCO2"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO2Sets4.Add( Base.NZDJPY_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP5,"TP5_NZDJPY_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP5_NZDJPY_UP_S2_OCO2"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO2Sets5.Add( Base.NZDJPY_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP6,"TP6_NZDJPY_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP6_NZDJPY_UP_S2_OCO2"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO2Sets6.Add( Base.NZDJPY_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDJPY_OCO2S1_UP_S2 = 0;
	                for (; NZDJPY_OCO2S1_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets1.Count; NZDJPY_OCO2S1_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO2Sets1[NZDJPY_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO2Sets1[NZDJPY_OCO2S1_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO2Sets1.RemoveAt(NZDJPY_OCO2S1_UP_S2);
	                        NZDJPY_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDJPY_OCO2S2_UP_S2 = 0;
	                for (; NZDJPY_OCO2S2_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets2.Count; NZDJPY_OCO2S2_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO2Sets2[NZDJPY_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO2Sets2[NZDJPY_OCO2S2_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO2Sets2.RemoveAt(NZDJPY_OCO2S2_UP_S2);
	                        NZDJPY_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO2S3_UP_S2 = 0;
	                for (; NZDJPY_OCO2S3_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets3.Count; NZDJPY_OCO2S3_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO2Sets3[NZDJPY_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO2Sets3[NZDJPY_OCO2S3_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO2Sets3.RemoveAt(NZDJPY_OCO2S3_UP_S2);
	                        NZDJPY_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO2S4_UP_S2 = 0;
	                for (; NZDJPY_OCO2S4_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets4.Count; NZDJPY_OCO2S4_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO2Sets4[NZDJPY_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO2Sets4[NZDJPY_OCO2S4_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO2Sets4.RemoveAt(NZDJPY_OCO2S4_UP_S2);
	                        NZDJPY_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDJPY_OCO2S5_UP_S2 = 0;
	                for (; NZDJPY_OCO2S5_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets5.Count; NZDJPY_OCO2S5_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO2Sets5[NZDJPY_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO2Sets5[NZDJPY_OCO2S5_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO2Sets5.RemoveAt(NZDJPY_OCO2S5_UP_S2);
	                        NZDJPY_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDJPY_OCO2S6_UP_S2 = 0;
	                for (; NZDJPY_OCO2S6_UP_S2 < Base.NZDJPY_UP_S2_OCO2Sets6.Count; NZDJPY_OCO2S6_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO2Sets6[NZDJPY_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO2Sets6[NZDJPY_OCO2S6_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO2Sets6.RemoveAt(NZDJPY_OCO2S6_UP_S2);
	                        NZDJPY_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDJPY_OCO3_EO1_UP_S2)
	                Base.NZDJPY_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDJPY_OCO3_EO2_UP_S2)
	                Base.NZDJPY_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO3_EO3_UP_S2)
	                Base.NZDJPY_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO3_EO4_UP_S2)
	                Base.NZDJPY_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO3_EO5_UP_S2)
	                Base.NZDJPY_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO3_EO6_UP_S2)
	                Base.NZDJPY_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.NZDJPY_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP1,"TP1_NZDJPY_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP1_NZDJPY_UP_S2_OCO3"));
		                 };
		                Base.NZDJPY_UP_S2_OCO3Sets1.Add( Base.NZDJPY_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP2,"TP2_NZDJPY_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP2_NZDJPY_UP_S2_OCO3"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO3Sets2.Add( Base.NZDJPY_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP3,"TP3_NZDJPY_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP3_NZDJPY_UP_S2_OCO3"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO3Sets3.Add( Base.NZDJPY_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP4,"TP4_NZDJPY_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP4_NZDJPY_UP_S2_OCO3"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO3Sets4.Add( Base.NZDJPY_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP5,"TP5_NZDJPY_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP5_NZDJPY_UP_S2_OCO3"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO3Sets5.Add( Base.NZDJPY_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP6,"TP6_NZDJPY_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP6_NZDJPY_UP_S2_OCO3"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO3Sets6.Add( Base.NZDJPY_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDJPY_OCO3S1_UP_S2 = 0;
	                for (; NZDJPY_OCO3S1_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets1.Count; NZDJPY_OCO3S1_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO3Sets1[NZDJPY_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO3Sets1[NZDJPY_OCO3S1_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO3Sets1.RemoveAt(NZDJPY_OCO3S1_UP_S2);
	                        NZDJPY_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDJPY_OCO3S2_UP_S2 = 0;
	                for (; NZDJPY_OCO3S2_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets2.Count; NZDJPY_OCO3S2_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO3Sets2[NZDJPY_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO3Sets2[NZDJPY_OCO3S2_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO3Sets2.RemoveAt(NZDJPY_OCO3S2_UP_S2);
	                        NZDJPY_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO3S3_UP_S2 = 0;
	                for (; NZDJPY_OCO3S3_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets3.Count; NZDJPY_OCO3S3_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO3Sets3[NZDJPY_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO3Sets3[NZDJPY_OCO3S3_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO3Sets3.RemoveAt(NZDJPY_OCO3S3_UP_S2);
	                        NZDJPY_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO3S4_UP_S2 = 0;
	                for (; NZDJPY_OCO3S4_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets4.Count; NZDJPY_OCO3S4_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO3Sets4[NZDJPY_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO3Sets4[NZDJPY_OCO3S4_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO3Sets4.RemoveAt(NZDJPY_OCO3S4_UP_S2);
	                        NZDJPY_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDJPY_OCO3S5_UP_S2 = 0;
	                for (; NZDJPY_OCO3S5_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets5.Count; NZDJPY_OCO3S5_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO3Sets5[NZDJPY_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO3Sets5[NZDJPY_OCO3S5_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO3Sets5.RemoveAt(NZDJPY_OCO3S5_UP_S2);
	                        NZDJPY_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDJPY_OCO3S6_UP_S2 = 0;
	                for (; NZDJPY_OCO3S6_UP_S2 < Base.NZDJPY_UP_S2_OCO3Sets6.Count; NZDJPY_OCO3S6_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO3Sets6[NZDJPY_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO3Sets6[NZDJPY_OCO3S6_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO3Sets6.RemoveAt(NZDJPY_OCO3S6_UP_S2);
	                        NZDJPY_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDJPY_OCO4_EO1_UP_S2)
	                Base.NZDJPY_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDJPY_OCO4_EO2_UP_S2)
	                Base.NZDJPY_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO4_EO3_UP_S2)
	                Base.NZDJPY_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO4_EO4_UP_S2)
	                Base.NZDJPY_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO4_EO5_UP_S2)
	                Base.NZDJPY_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO4_EO6_UP_S2)
	                Base.NZDJPY_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.NZDJPY_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP1,"TP1_NZDJPY_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP1_NZDJPY_UP_S2_OCO4"));
		                 };
		                Base.NZDJPY_UP_S2_OCO4Sets1.Add( Base.NZDJPY_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP2,"TP2_NZDJPY_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP2_NZDJPY_UP_S2_OCO4"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO4Sets2.Add( Base.NZDJPY_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP3,"TP3_NZDJPY_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP3_NZDJPY_UP_S2_OCO4"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO4Sets3.Add( Base.NZDJPY_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP4,"TP4_NZDJPY_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP4_NZDJPY_UP_S2_OCO4"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO4Sets4.Add( Base.NZDJPY_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP5,"TP5_NZDJPY_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP5_NZDJPY_UP_S2_OCO4"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO4Sets5.Add( Base.NZDJPY_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_UP_S2_TP6,"TP6_NZDJPY_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_UP_S2_SL,"SL_TP6_NZDJPY_UP_S2_OCO4"));
		                 };
	                    Base.NZDJPY_UP_S2_OCO4Sets6.Add( Base.NZDJPY_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDJPY_OCO4S1_UP_S2 = 0;
	                for (; NZDJPY_OCO4S1_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets1.Count; NZDJPY_OCO4S1_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO4Sets1[NZDJPY_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO4Sets1[NZDJPY_OCO4S1_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO4Sets1.RemoveAt(NZDJPY_OCO4S1_UP_S2);
	                        NZDJPY_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDJPY_OCO4S2_UP_S2 = 0;
	                for (; NZDJPY_OCO4S2_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets2.Count; NZDJPY_OCO4S2_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO4Sets2[NZDJPY_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO4Sets2[NZDJPY_OCO4S2_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO4Sets2.RemoveAt(NZDJPY_OCO4S2_UP_S2);
	                        NZDJPY_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO4S3_UP_S2 = 0;
	                for (; NZDJPY_OCO4S3_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets3.Count; NZDJPY_OCO4S3_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO4Sets3[NZDJPY_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO4Sets3[NZDJPY_OCO4S3_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO4Sets3.RemoveAt(NZDJPY_OCO4S3_UP_S2);
	                        NZDJPY_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO4S4_UP_S2 = 0;
	                for (; NZDJPY_OCO4S4_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets4.Count; NZDJPY_OCO4S4_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO4Sets4[NZDJPY_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO4Sets4[NZDJPY_OCO4S4_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO4Sets4.RemoveAt(NZDJPY_OCO4S4_UP_S2);
	                        NZDJPY_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDJPY_OCO4S5_UP_S2 = 0;
	                for (; NZDJPY_OCO4S5_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets5.Count; NZDJPY_OCO4S5_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO4Sets5[NZDJPY_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO4Sets5[NZDJPY_OCO4S5_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO4Sets5.RemoveAt(NZDJPY_OCO4S5_UP_S2);
	                        NZDJPY_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDJPY_OCO4S6_UP_S2 = 0;
	                for (; NZDJPY_OCO4S6_UP_S2 < Base.NZDJPY_UP_S2_OCO4Sets6.Count; NZDJPY_OCO4S6_UP_S2++)
	                    if (Base.NZDJPY_UP_S2_OCO4Sets6[NZDJPY_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_UP_S2_OCO4Sets6[NZDJPY_OCO4S6_UP_S2].Filled();
	                        Base.NZDJPY_UP_S2_OCO4Sets6.RemoveAt(NZDJPY_OCO4S6_UP_S2);
	                        NZDJPY_OCO4S6_UP_S2 = 0;
	                        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.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 NZDJPY_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public NZDJPY_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("NZDJPY OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDJPY OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDJPY OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDJPY OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDJPY OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDJPY OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDJPY S2");
		        	}
		        }
		        
				if (Base.NZDJPY_OCO1_EO1_DOWN_S2)
	                Base.NZDJPY_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDJPY_OCO1_EO2_DOWN_S2)
	                Base.NZDJPY_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO1_EO3_DOWN_S2)
	                Base.NZDJPY_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO1_EO4_DOWN_S2)
	                Base.NZDJPY_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDJPY_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP1_NZDJPY_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP1,"TP1_NZDJPY_DOWN_S2_OCO1"));
		                 };
		                Base.NZDJPY_DOWN_S2_OCO1Sets1.Add( Base.NZDJPY_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP2_NZDJPY_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP2,"TP2_NZDJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO1Sets2.Add( Base.NZDJPY_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP3_NZDJPY_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP3,"TP3_NZDJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO1Sets3.Add( Base.NZDJPY_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP4_NZDJPY_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP4,"TP4_NZDJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO1Sets4.Add( Base.NZDJPY_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int NZDJPY_OCO1S1_DOWN_S2 = 0;
	                for (; NZDJPY_OCO1S1_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets1.Count; NZDJPY_OCO1S1_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO1Sets1[NZDJPY_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO1Sets1[NZDJPY_OCO1S1_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO1Sets1.RemoveAt(NZDJPY_OCO1S1_DOWN_S2);
	                        NZDJPY_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDJPY_OCO1S2_DOWN_S2 = 0;
	                for (; NZDJPY_OCO1S2_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets2.Count; NZDJPY_OCO1S2_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO1Sets2[NZDJPY_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO1Sets2[NZDJPY_OCO1S2_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO1Sets2.RemoveAt(NZDJPY_OCO1S2_DOWN_S2);
	                        NZDJPY_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO1S3_DOWN_S2 = 0;
	                for (; NZDJPY_OCO1S3_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets3.Count; NZDJPY_OCO1S3_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO1Sets3[NZDJPY_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO1Sets3[NZDJPY_OCO1S3_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO1Sets3.RemoveAt(NZDJPY_OCO1S3_DOWN_S2);
	                        NZDJPY_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO1S4_DOWN_S2 = 0;
	                for (; NZDJPY_OCO1S4_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO1Sets4.Count; NZDJPY_OCO1S4_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO1Sets4[NZDJPY_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO1Sets4[NZDJPY_OCO1S4_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO1Sets4.RemoveAt(NZDJPY_OCO1S4_DOWN_S2);
	                        NZDJPY_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDJPY_OCO2_EO1_DOWN_S2)
	                Base.NZDJPY_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDJPY_OCO2_EO2_DOWN_S2)
	                Base.NZDJPY_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO2_EO3_DOWN_S2)
	                Base.NZDJPY_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO2_EO4_DOWN_S2)
	                Base.NZDJPY_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDJPY_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP1_NZDJPY_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP1,"TP1_NZDJPY_DOWN_S2_OCO2"));
		                 };
		                Base.NZDJPY_DOWN_S2_OCO2Sets1.Add( Base.NZDJPY_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP2_NZDJPY_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP2,"TP2_NZDJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO2Sets2.Add( Base.NZDJPY_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP3_NZDJPY_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP3,"TP3_NZDJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO2Sets3.Add( Base.NZDJPY_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP4_NZDJPY_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP4,"TP4_NZDJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO2Sets4.Add( Base.NZDJPY_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int NZDJPY_OCO2S1_DOWN_S2 = 0;
	                for (; NZDJPY_OCO2S1_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets1.Count; NZDJPY_OCO2S1_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO2Sets1[NZDJPY_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO2Sets1[NZDJPY_OCO2S1_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO2Sets1.RemoveAt(NZDJPY_OCO2S1_DOWN_S2);
	                        NZDJPY_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDJPY_OCO2S2_DOWN_S2 = 0;
	                for (; NZDJPY_OCO2S2_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets2.Count; NZDJPY_OCO2S2_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO2Sets2[NZDJPY_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO2Sets2[NZDJPY_OCO2S2_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO2Sets2.RemoveAt(NZDJPY_OCO2S2_DOWN_S2);
	                        NZDJPY_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO2S3_DOWN_S2 = 0;
	                for (; NZDJPY_OCO2S3_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets3.Count; NZDJPY_OCO2S3_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO2Sets3[NZDJPY_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO2Sets3[NZDJPY_OCO2S3_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO2Sets3.RemoveAt(NZDJPY_OCO2S3_DOWN_S2);
	                        NZDJPY_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO2S4_DOWN_S2 = 0;
	                for (; NZDJPY_OCO2S4_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO2Sets4.Count; NZDJPY_OCO2S4_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO2Sets4[NZDJPY_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO2Sets4[NZDJPY_OCO2S4_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO2Sets4.RemoveAt(NZDJPY_OCO2S4_DOWN_S2);
	                        NZDJPY_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDJPY_OCO3_EO1_DOWN_S2)
	                Base.NZDJPY_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDJPY_OCO3_EO2_DOWN_S2)
	                Base.NZDJPY_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO3_EO3_DOWN_S2)
	                Base.NZDJPY_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO3_EO4_DOWN_S2)
	                Base.NZDJPY_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDJPY_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP1_NZDJPY_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP1,"TP1_NZDJPY_DOWN_S2_OCO3"));
		                 };
		                Base.NZDJPY_DOWN_S2_OCO3Sets1.Add( Base.NZDJPY_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP2_NZDJPY_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP2,"TP2_NZDJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO3Sets2.Add( Base.NZDJPY_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP3_NZDJPY_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP3,"TP3_NZDJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO3Sets3.Add( Base.NZDJPY_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP4_NZDJPY_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP4,"TP4_NZDJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO3Sets4.Add( Base.NZDJPY_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int NZDJPY_OCO3S1_DOWN_S2 = 0;
	                for (; NZDJPY_OCO3S1_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets1.Count; NZDJPY_OCO3S1_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO3Sets1[NZDJPY_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO3Sets1[NZDJPY_OCO3S1_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO3Sets1.RemoveAt(NZDJPY_OCO3S1_DOWN_S2);
	                        NZDJPY_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDJPY_OCO3S2_DOWN_S2 = 0;
	                for (; NZDJPY_OCO3S2_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets2.Count; NZDJPY_OCO3S2_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO3Sets2[NZDJPY_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO3Sets2[NZDJPY_OCO3S2_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO3Sets2.RemoveAt(NZDJPY_OCO3S2_DOWN_S2);
	                        NZDJPY_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO3S3_DOWN_S2 = 0;
	                for (; NZDJPY_OCO3S3_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets3.Count; NZDJPY_OCO3S3_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO3Sets3[NZDJPY_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO3Sets3[NZDJPY_OCO3S3_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO3Sets3.RemoveAt(NZDJPY_OCO3S3_DOWN_S2);
	                        NZDJPY_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO3S4_DOWN_S2 = 0;
	                for (; NZDJPY_OCO3S4_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO3Sets4.Count; NZDJPY_OCO3S4_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO3Sets4[NZDJPY_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO3Sets4[NZDJPY_OCO3S4_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO3Sets4.RemoveAt(NZDJPY_OCO3S4_DOWN_S2);
	                        NZDJPY_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDJPY_OCO4_EO1_DOWN_S2)
	                Base.NZDJPY_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDJPY_OCO4_EO2_DOWN_S2)
	                Base.NZDJPY_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO4_EO3_DOWN_S2)
	                Base.NZDJPY_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDJPY_OCO4_EO4_DOWN_S2)
	                Base.NZDJPY_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDJPY_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP1_NZDJPY_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP1,"TP1_NZDJPY_DOWN_S2_OCO4"));
		                 };
		                Base.NZDJPY_DOWN_S2_OCO4Sets1.Add( Base.NZDJPY_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP2_NZDJPY_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP2,"TP2_NZDJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO4Sets2.Add( Base.NZDJPY_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP3_NZDJPY_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP3,"TP3_NZDJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO4Sets3.Add( Base.NZDJPY_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDJPY_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDJPY_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDJPY_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDJPY_DOWN_S2_SL,"SL_TP4_NZDJPY_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDJPY_DOWN_S2_TP4,"TP4_NZDJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDJPY_DOWN_S2_OCO4Sets4.Add( Base.NZDJPY_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDJPY_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int NZDJPY_OCO4S1_DOWN_S2 = 0;
	                for (; NZDJPY_OCO4S1_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets1.Count; NZDJPY_OCO4S1_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO4Sets1[NZDJPY_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO4Sets1[NZDJPY_OCO4S1_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO4Sets1.RemoveAt(NZDJPY_OCO4S1_DOWN_S2);
	                        NZDJPY_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDJPY_OCO4S2_DOWN_S2 = 0;
	                for (; NZDJPY_OCO4S2_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets2.Count; NZDJPY_OCO4S2_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO4Sets2[NZDJPY_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO4Sets2[NZDJPY_OCO4S2_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO4Sets2.RemoveAt(NZDJPY_OCO4S2_DOWN_S2);
	                        NZDJPY_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO4S3_DOWN_S2 = 0;
	                for (; NZDJPY_OCO4S3_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets3.Count; NZDJPY_OCO4S3_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO4Sets3[NZDJPY_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO4Sets3[NZDJPY_OCO4S3_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO4Sets3.RemoveAt(NZDJPY_OCO4S3_DOWN_S2);
	                        NZDJPY_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDJPY_OCO4S4_DOWN_S2 = 0;
	                for (; NZDJPY_OCO4S4_DOWN_S2 < Base.NZDJPY_DOWN_S2_OCO4Sets4.Count; NZDJPY_OCO4S4_DOWN_S2++)
	                    if (Base.NZDJPY_DOWN_S2_OCO4Sets4[NZDJPY_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDJPY_DOWN_S2_OCO4Sets4[NZDJPY_OCO4S4_DOWN_S2].Filled();
	                        Base.NZDJPY_DOWN_S2_OCO4Sets4.RemoveAt(NZDJPY_OCO4S4_DOWN_S2);
	                        NZDJPY_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_CHFJPY_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_CHFJPY_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("CHFJPY_DOWN_S2_OCO1")))
			{
				Base.CHFJPY_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CHFJPY_DOWN_S2_OCO2")))
			{
				Base.CHFJPY_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CHFJPY_DOWN_S2_OCO3")))
			{
				Base.CHFJPY_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CHFJPY_DOWN_S2_OCO4")))
			{
				Base.CHFJPY_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("CHFJPY_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.CHFJPY_OCO1_EO1_DOWN_S2)
	                Base.CHFJPY_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.CHFJPY_OCO1_EO2_DOWN_S2)
	                Base.CHFJPY_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO1_EO3_DOWN_S2)
	                Base.CHFJPY_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO1_EO4_DOWN_S2)
	                Base.CHFJPY_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO1_EO5_DOWN_S2)
	                Base.CHFJPY_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO1_EO6_DOWN_S2)
	                Base.CHFJPY_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CHFJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int CHFJPY_OCO1S1_DOWN_S2 = 0;
		                for (; CHFJPY_OCO1S1_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets1.Count; CHFJPY_OCO1S1_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO1Sets1[CHFJPY_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO1Sets1[CHFJPY_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.CHFJPY_DOWN_S2_OCO1Sets1.Clear();
		                        CHFJPY_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int CHFJPY_OCO1S2_DOWN_S2 = 0;
		                for (; CHFJPY_OCO1S2_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets2.Count; CHFJPY_OCO1S2_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO1Sets2[CHFJPY_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO1Sets2[CHFJPY_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.CHFJPY_DOWN_S2_OCO1Sets2.Clear();
		                        CHFJPY_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO1S3_DOWN_S2 = 0;
		                for (; CHFJPY_OCO1S3_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets3.Count; CHFJPY_OCO1S3_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO1Sets3[CHFJPY_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO1Sets3[CHFJPY_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.CHFJPY_DOWN_S2_OCO1Sets3.Clear();
		                        CHFJPY_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO1S4_DOWN_S2 = 0;
		                for (; CHFJPY_OCO1S4_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets4.Count; CHFJPY_OCO1S4_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO1Sets4[CHFJPY_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO1Sets4[CHFJPY_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.CHFJPY_DOWN_S2_OCO1Sets4.Clear();
		                        CHFJPY_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO1S5_DOWN_S2 = 0;
		                for (; CHFJPY_OCO1S5_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets5.Count; CHFJPY_OCO1S5_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO1Sets5[CHFJPY_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO1Sets5[CHFJPY_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.CHFJPY_DOWN_S2_OCO1Sets5.Clear();
		                        CHFJPY_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO1S6_DOWN_S2 = 0;
		                for (; CHFJPY_OCO1S6_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets6.Count; CHFJPY_OCO1S6_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO1Sets6[CHFJPY_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO1Sets6[CHFJPY_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.CHFJPY_DOWN_S2_OCO1Sets6.Clear();
		                        CHFJPY_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.CHFJPY_OCO2_EO1_DOWN_S2)
	                Base.CHFJPY_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.CHFJPY_OCO2_EO2_DOWN_S2)
	                Base.CHFJPY_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO2_EO3_DOWN_S2)
	                Base.CHFJPY_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO2_EO4_DOWN_S2)
	                Base.CHFJPY_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO2_EO5_DOWN_S2)
	                Base.CHFJPY_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO2_EO6_DOWN_S2)
	                Base.CHFJPY_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CHFJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int CHFJPY_OCO2S1_DOWN_S2 = 0;
		                for (; CHFJPY_OCO2S1_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets1.Count; CHFJPY_OCO2S1_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO2Sets1[CHFJPY_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO2Sets1[CHFJPY_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.CHFJPY_DOWN_S2_OCO2Sets1.Clear();
		                        CHFJPY_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int CHFJPY_OCO2S2_DOWN_S2 = 0;
		                for (; CHFJPY_OCO2S2_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets2.Count; CHFJPY_OCO2S2_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO2Sets2[CHFJPY_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO2Sets2[CHFJPY_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.CHFJPY_DOWN_S2_OCO2Sets2.Clear();
		                        CHFJPY_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO2S3_DOWN_S2 = 0;
		                for (; CHFJPY_OCO2S3_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets3.Count; CHFJPY_OCO2S3_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO2Sets3[CHFJPY_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO2Sets3[CHFJPY_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.CHFJPY_DOWN_S2_OCO2Sets3.Clear();
		                        CHFJPY_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO2S4_DOWN_S2 = 0;
		                for (; CHFJPY_OCO2S4_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets4.Count; CHFJPY_OCO2S4_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO2Sets4[CHFJPY_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO2Sets4[CHFJPY_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.CHFJPY_DOWN_S2_OCO2Sets4.Clear();
		                        CHFJPY_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO2S5_DOWN_S2 = 0;
		                for (; CHFJPY_OCO2S5_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets5.Count; CHFJPY_OCO2S5_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO2Sets5[CHFJPY_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO2Sets5[CHFJPY_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.CHFJPY_DOWN_S2_OCO2Sets5.Clear();
		                        CHFJPY_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO2S6_DOWN_S2 = 0;
		                for (; CHFJPY_OCO2S6_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets6.Count; CHFJPY_OCO2S6_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO2Sets6[CHFJPY_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO2Sets6[CHFJPY_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.CHFJPY_DOWN_S2_OCO2Sets6.Clear();
		                        CHFJPY_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.CHFJPY_OCO3_EO1_DOWN_S2)
	                Base.CHFJPY_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.CHFJPY_OCO3_EO2_DOWN_S2)
	                Base.CHFJPY_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO3_EO3_DOWN_S2)
	                Base.CHFJPY_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO3_EO4_DOWN_S2)
	                Base.CHFJPY_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO3_EO5_DOWN_S2)
	                Base.CHFJPY_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO3_EO6_DOWN_S2)
	                Base.CHFJPY_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CHFJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int CHFJPY_OCO3S1_DOWN_S2 = 0;
		                for (; CHFJPY_OCO3S1_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets1.Count; CHFJPY_OCO3S1_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO3Sets1[CHFJPY_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO3Sets1[CHFJPY_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.CHFJPY_DOWN_S2_OCO3Sets1.Clear();
		                        CHFJPY_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int CHFJPY_OCO3S2_DOWN_S2 = 0;
		                for (; CHFJPY_OCO3S2_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets2.Count; CHFJPY_OCO3S2_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO3Sets2[CHFJPY_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO3Sets2[CHFJPY_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.CHFJPY_DOWN_S2_OCO3Sets2.Clear();
		                        CHFJPY_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO3S3_DOWN_S2 = 0;
		                for (; CHFJPY_OCO3S3_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets3.Count; CHFJPY_OCO3S3_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO3Sets3[CHFJPY_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO3Sets3[CHFJPY_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.CHFJPY_DOWN_S2_OCO3Sets3.Clear();
		                        CHFJPY_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO3S4_DOWN_S2 = 0;
		                for (; CHFJPY_OCO3S4_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets4.Count; CHFJPY_OCO3S4_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO3Sets4[CHFJPY_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO3Sets4[CHFJPY_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.CHFJPY_DOWN_S2_OCO3Sets4.Clear();
		                        CHFJPY_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO3S5_DOWN_S2 = 0;
		                for (; CHFJPY_OCO3S5_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets5.Count; CHFJPY_OCO3S5_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO3Sets5[CHFJPY_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO3Sets5[CHFJPY_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.CHFJPY_DOWN_S2_OCO3Sets5.Clear();
		                        CHFJPY_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO3S6_DOWN_S2 = 0;
		                for (; CHFJPY_OCO3S6_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets6.Count; CHFJPY_OCO3S6_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO3Sets6[CHFJPY_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO3Sets6[CHFJPY_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.CHFJPY_DOWN_S2_OCO3Sets6.Clear();
		                        CHFJPY_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.CHFJPY_OCO4_EO1_DOWN_S2)
	                Base.CHFJPY_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.CHFJPY_OCO4_EO2_DOWN_S2)
	                Base.CHFJPY_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO4_EO3_DOWN_S2)
	                Base.CHFJPY_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO4_EO4_DOWN_S2)
	                Base.CHFJPY_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO4_EO5_DOWN_S2)
	                Base.CHFJPY_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO4_EO6_DOWN_S2)
	                Base.CHFJPY_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CHFJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int CHFJPY_OCO4S1_DOWN_S2 = 0;
		                for (; CHFJPY_OCO4S1_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets1.Count; CHFJPY_OCO4S1_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO4Sets1[CHFJPY_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO4Sets1[CHFJPY_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.CHFJPY_DOWN_S2_OCO4Sets1.Clear();
		                        CHFJPY_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int CHFJPY_OCO4S2_DOWN_S2 = 0;
		                for (; CHFJPY_OCO4S2_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets2.Count; CHFJPY_OCO4S2_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO4Sets2[CHFJPY_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO4Sets2[CHFJPY_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.CHFJPY_DOWN_S2_OCO4Sets2.Clear();
		                        CHFJPY_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO4S3_DOWN_S2 = 0;
		                for (; CHFJPY_OCO4S3_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets3.Count; CHFJPY_OCO4S3_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO4Sets3[CHFJPY_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO4Sets3[CHFJPY_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.CHFJPY_DOWN_S2_OCO4Sets3.Clear();
		                        CHFJPY_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO4S4_DOWN_S2 = 0;
		                for (; CHFJPY_OCO4S4_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets4.Count; CHFJPY_OCO4S4_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO4Sets4[CHFJPY_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO4Sets4[CHFJPY_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.CHFJPY_DOWN_S2_OCO4Sets4.Clear();
		                        CHFJPY_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO4S5_DOWN_S2 = 0;
		                for (; CHFJPY_OCO4S5_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets5.Count; CHFJPY_OCO4S5_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO4Sets5[CHFJPY_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO4Sets5[CHFJPY_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.CHFJPY_DOWN_S2_OCO4Sets5.Clear();
		                        CHFJPY_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO4S6_DOWN_S2 = 0;
		                for (; CHFJPY_OCO4S6_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets6.Count; CHFJPY_OCO4S6_DOWN_S2++)
		                    if (Base.CHFJPY_DOWN_S2_OCO4Sets6[CHFJPY_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_DOWN_S2_OCO4Sets6[CHFJPY_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.CHFJPY_DOWN_S2_OCO4Sets6.Clear();
		                        CHFJPY_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();
	            	}
	            	
					DOWM_CHFJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_CHFJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_CHFJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_CHFJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_CHFJPY_DOWN_S2 = DOWM_CHFJPY_DOWN_S2 || DOWT_CHFJPY_DOWN_S2 || DOWW_CHFJPY_DOWN_S2 || DOWTH_CHFJPY_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("CHFJPY"))
	            	{
	            		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.CHFJPY_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.CHFJPY_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.CHFJPY_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.CHFJPY_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.CHFJPY_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.CHFJPY_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.CHFJPY_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.CHFJPY_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.CHFJPY_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.CHFJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.CHFJPY_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.CHFJPY_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	CHFJPY_Signal_Condition_DOWN_1 =	
	                									(
		                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > Base.Yen_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.Yen_Min_SPRD
	                									);
	                									
	                	CHFJPY_Signal_Condition_DOWN_2 =	
	                									(
		                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > Base.Yen_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.Yen_Min_SPRD
	                									);
	                									
	                									
	                	CHFJPY_Signal_Condition_DOWN_3 =	
	                									(
		                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > Base.Yen_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.Yen_Min_SPRD
	                									);
	                									
	                	if (CHFJPY_Signal_Condition_DOWN_1)
	                	{
	                    	CHFJPY_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (CHFJPY_Signal_Condition_DOWN_2)
	                	{
	                    	CHFJPY_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (CHFJPY_Signal_Condition_DOWN_3)
	                	{
	                    	CHFJPY_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	
	                	if (CHFJPY_Signal_Condition_DOWN_1)
	                	{
	                    	CHFJPY_DOWN_S2_TP1  =  0.05m ;
	                	}
	                	
	                	if (CHFJPY_Signal_Condition_DOWN_2)
	                	{
	                    	CHFJPY_DOWN_S2_TP1  =  0.05m ;
	                	}
	                	
	                	if (CHFJPY_Signal_Condition_DOWN_3)
	                	{
	                    	CHFJPY_DOWN_S2_TP1  =  0.05m ;
	                	}
	                	
	                    CHFJPY_DOWN_S2_TP2 =  CHFJPY_DOWN_S2_SL * 0;
	                    CHFJPY_DOWN_S2_TP3 =  CHFJPY_DOWN_S2_SL * 0;
	                    CHFJPY_DOWN_S2_TP4 =  CHFJPY_DOWN_S2_SL * 0;
	                    CHFJPY_DOWN_S2_TP5 =  CHFJPY_DOWN_S2_SL * 0;
	                    CHFJPY_DOWN_S2_TP6 =  CHFJPY_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0 && CHFJPY_DOWN_S2_SL !=  0)
	                    {
	                    CHFJPY_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)*0.015m);
	                    CHFJPY_quantity_SL_DOWN_S2 = CHFJPY_quantity_DOWN_S2;
	                    CHFJPY_quantity_TP1_DOWN_S2 = (CHFJPY_quantity_DOWN_S2 );
	                    CHFJPY_quantity_TP2_DOWN_S2 = (CHFJPY_quantity_TP1_DOWN_S2 * 0);
	                    CHFJPY_quantity_TP3_DOWN_S2 = (CHFJPY_quantity_TP2_DOWN_S2 * 0);
	                    CHFJPY_quantity_TP4_DOWN_S2 = (CHFJPY_quantity_TP3_DOWN_S2 * 0);
	                    CHFJPY_quantity_TP5_DOWN_S2 = (CHFJPY_quantity_TP4_DOWN_S2 * 0);
	                    CHFJPY_quantity_TP6_DOWN_S2 = (CHFJPY_quantity_TP5_DOWN_S2 * 0);
	                    }
	                    
	                    oco1:
	                    if ((CHFJPY_Signal_Condition_DOWN_1 || CHFJPY_Signal_Condition_DOWN_2 || CHFJPY_Signal_Condition_DOWN_3)  && 
	                    DOWR_CHFJPY_DOWN_S2 && 
	                    Base.CHFJPY_OCO1_DOWN_S2_IsReady == true &&
	                    Base.CHFJPY_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.CHFJPY_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP1_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP1_OCO1");
	                         Base.CHFJPY_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.CHFJPY_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP2_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP2_OCO1");
	                         Base.CHFJPY_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.CHFJPY_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP3_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP3_OCO1");
	                         Base.CHFJPY_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.CHFJPY_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP4_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP4_OCO1");
	                         Base.CHFJPY_OCO1_EO4_DOWN_S2 = false;

							Base.CHFJPY_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.CHFJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((CHFJPY_Signal_Condition_DOWN_1 || CHFJPY_Signal_Condition_DOWN_2 || CHFJPY_Signal_Condition_DOWN_3)  && 
	                    DOWR_CHFJPY_DOWN_S2 && 
	                    Base.CHFJPY_OCO2_DOWN_S2_IsReady == true &&
	                    Base.CHFJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.CHFJPY_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.CHFJPY_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP1_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP1_OCO2");
	                         Base.CHFJPY_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.CHFJPY_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP2_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP2_OCO2");
	                         Base.CHFJPY_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.CHFJPY_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP3_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP3_OCO2");
	                         Base.CHFJPY_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.CHFJPY_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP4_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP4_OCO2");
	                         Base.CHFJPY_OCO2_EO4_DOWN_S2 = false;

							Base.CHFJPY_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.CHFJPY_OCO2_DOWN_S2_IsReady == false && Base.CHFJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((CHFJPY_Signal_Condition_DOWN_1 || CHFJPY_Signal_Condition_DOWN_2 || CHFJPY_Signal_Condition_DOWN_3)  && 
	                    DOWR_CHFJPY_DOWN_S2 &&
	                    Base.CHFJPY_OCO3_DOWN_S2_IsReady == true &&
	                    Base.CHFJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.CHFJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.CHFJPY_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.CHFJPY_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP1_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP1_OCO3");
	                         Base.CHFJPY_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.CHFJPY_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP2_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP2_OCO3");
	                         Base.CHFJPY_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.CHFJPY_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP3_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP3_OCO3");
	                         Base.CHFJPY_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.CHFJPY_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP4_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP4_OCO3");
	                         Base.CHFJPY_OCO3_EO4_DOWN_S2 = false;

							Base.CHFJPY_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.CHFJPY_OCO3_DOWN_S2_IsReady == false && Base.CHFJPY_OCO2_DOWN_S2_IsReady == false && Base.CHFJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((CHFJPY_Signal_Condition_DOWN_1 || CHFJPY_Signal_Condition_DOWN_2 || CHFJPY_Signal_Condition_DOWN_3)  && 
	                    DOWR_CHFJPY_DOWN_S2 && 
	                    Base.CHFJPY_OCO4_DOWN_S2_IsReady == true &&
	                    Base.CHFJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.CHFJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.CHFJPY_OCO3_DOWN_S2_IsReady == false &&
	                    Base.CHFJPY_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.CHFJPY_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP1_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP1_OCO4");
	                         Base.CHFJPY_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.CHFJPY_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP2_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP2_OCO4");
	                         Base.CHFJPY_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.CHFJPY_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP3_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP3_OCO4");
	                         Base.CHFJPY_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.CHFJPY_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CHFJPY_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP4_DOWN_S2, false,"CHFJPY_DOWN_S2_Entry_TP4_OCO4");
	                         Base.CHFJPY_OCO4_EO4_DOWN_S2 = false;

							Base.CHFJPY_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.CHFJPY_OCO4_DOWN_S2_IsReady == false && Base.CHFJPY_OCO3_DOWN_S2_IsReady == false && Base.CHFJPY_OCO2_DOWN_S2_IsReady == false && Base.CHFJPY_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.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 CADJPY_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public CADJPY_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("CADJPY OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CADJPY OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CADJPY OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CADJPY OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CADJPY OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CADJPY OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CADJPY OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        }
		        
				if (Base.CADJPY_OCO1_EO1_UP_S2)
	                Base.CADJPY_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.CADJPY_OCO1_EO2_UP_S2)
	                Base.CADJPY_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO1_EO3_UP_S2)
	                Base.CADJPY_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO1_EO4_UP_S2)
	                Base.CADJPY_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO1_EO5_UP_S2)
	                Base.CADJPY_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO1_EO6_UP_S2)
	                Base.CADJPY_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CADJPY_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.CADJPY_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP1,"TP1_CADJPY_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP1_CADJPY_UP_S2_OCO1"));
		                 };
		                Base.CADJPY_UP_S2_OCO1Sets1.Add( Base.CADJPY_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CADJPY_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP2,"TP2_CADJPY_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP2_CADJPY_UP_S2_OCO1"));
		                 };
	                    Base.CADJPY_UP_S2_OCO1Sets2.Add( Base.CADJPY_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP3,"TP3_CADJPY_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP3_CADJPY_UP_S2_OCO1"));
		                 };
	                    Base.CADJPY_UP_S2_OCO1Sets3.Add( Base.CADJPY_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP4,"TP4_CADJPY_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP4_CADJPY_UP_S2_OCO1"));
		                 };
	                    Base.CADJPY_UP_S2_OCO1Sets4.Add( Base.CADJPY_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP5,"TP5_CADJPY_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP5_CADJPY_UP_S2_OCO1"));
		                 };
	                    Base.CADJPY_UP_S2_OCO1Sets5.Add( Base.CADJPY_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP6,"TP6_CADJPY_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP6_CADJPY_UP_S2_OCO1"));
		                 };
	                    Base.CADJPY_UP_S2_OCO1Sets6.Add( Base.CADJPY_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int CADJPY_OCO1S1_UP_S2 = 0;
	                for (; CADJPY_OCO1S1_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets1.Count; CADJPY_OCO1S1_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO1Sets1[CADJPY_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO1Sets1[CADJPY_OCO1S1_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO1Sets1.RemoveAt(CADJPY_OCO1S1_UP_S2);
	                        CADJPY_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int CADJPY_OCO1S2_UP_S2 = 0;
	                for (; CADJPY_OCO1S2_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets2.Count; CADJPY_OCO1S2_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO1Sets2[CADJPY_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO1Sets2[CADJPY_OCO1S2_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO1Sets2.RemoveAt(CADJPY_OCO1S2_UP_S2);
	                        CADJPY_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO1S3_UP_S2 = 0;
	                for (; CADJPY_OCO1S3_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets3.Count; CADJPY_OCO1S3_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO1Sets3[CADJPY_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO1Sets3[CADJPY_OCO1S3_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO1Sets3.RemoveAt(CADJPY_OCO1S3_UP_S2);
	                        CADJPY_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO1S4_UP_S2 = 0;
	                for (; CADJPY_OCO1S4_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets4.Count; CADJPY_OCO1S4_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO1Sets4[CADJPY_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO1Sets4[CADJPY_OCO1S4_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO1Sets4.RemoveAt(CADJPY_OCO1S4_UP_S2);
	                        CADJPY_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CADJPY_OCO1S5_UP_S2 = 0;
	                for (; CADJPY_OCO1S5_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets5.Count; CADJPY_OCO1S5_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO1Sets5[CADJPY_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO1Sets5[CADJPY_OCO1S5_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO1Sets5.RemoveAt(CADJPY_OCO1S5_UP_S2);
	                        CADJPY_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CADJPY_OCO1S6_UP_S2 = 0;
	                for (; CADJPY_OCO1S6_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets6.Count; CADJPY_OCO1S6_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO1Sets6[CADJPY_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO1Sets6[CADJPY_OCO1S6_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO1Sets6.RemoveAt(CADJPY_OCO1S6_UP_S2);
	                        CADJPY_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.CADJPY_OCO2_EO1_UP_S2)
	                Base.CADJPY_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.CADJPY_OCO2_EO2_UP_S2)
	                Base.CADJPY_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO2_EO3_UP_S2)
	                Base.CADJPY_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO2_EO4_UP_S2)
	                Base.CADJPY_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO2_EO5_UP_S2)
	                Base.CADJPY_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO2_EO6_UP_S2)
	                Base.CADJPY_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CADJPY_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.CADJPY_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP1,"TP1_CADJPY_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP1_CADJPY_UP_S2_OCO2"));
		                 };
		                Base.CADJPY_UP_S2_OCO2Sets1.Add( Base.CADJPY_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CADJPY_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP2,"TP2_CADJPY_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP2_CADJPY_UP_S2_OCO2"));
		                 };
	                    Base.CADJPY_UP_S2_OCO2Sets2.Add( Base.CADJPY_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP3,"TP3_CADJPY_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP3_CADJPY_UP_S2_OCO2"));
		                 };
	                    Base.CADJPY_UP_S2_OCO2Sets3.Add( Base.CADJPY_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP4,"TP4_CADJPY_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP4_CADJPY_UP_S2_OCO2"));
		                 };
	                    Base.CADJPY_UP_S2_OCO2Sets4.Add( Base.CADJPY_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP5,"TP5_CADJPY_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP5_CADJPY_UP_S2_OCO2"));
		                 };
	                    Base.CADJPY_UP_S2_OCO2Sets5.Add( Base.CADJPY_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP6,"TP6_CADJPY_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP6_CADJPY_UP_S2_OCO2"));
		                 };
	                    Base.CADJPY_UP_S2_OCO2Sets6.Add( Base.CADJPY_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int CADJPY_OCO2S1_UP_S2 = 0;
	                for (; CADJPY_OCO2S1_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets1.Count; CADJPY_OCO2S1_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO2Sets1[CADJPY_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO2Sets1[CADJPY_OCO2S1_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO2Sets1.RemoveAt(CADJPY_OCO2S1_UP_S2);
	                        CADJPY_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int CADJPY_OCO2S2_UP_S2 = 0;
	                for (; CADJPY_OCO2S2_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets2.Count; CADJPY_OCO2S2_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO2Sets2[CADJPY_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO2Sets2[CADJPY_OCO2S2_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO2Sets2.RemoveAt(CADJPY_OCO2S2_UP_S2);
	                        CADJPY_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO2S3_UP_S2 = 0;
	                for (; CADJPY_OCO2S3_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets3.Count; CADJPY_OCO2S3_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO2Sets3[CADJPY_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO2Sets3[CADJPY_OCO2S3_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO2Sets3.RemoveAt(CADJPY_OCO2S3_UP_S2);
	                        CADJPY_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO2S4_UP_S2 = 0;
	                for (; CADJPY_OCO2S4_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets4.Count; CADJPY_OCO2S4_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO2Sets4[CADJPY_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO2Sets4[CADJPY_OCO2S4_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO2Sets4.RemoveAt(CADJPY_OCO2S4_UP_S2);
	                        CADJPY_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CADJPY_OCO2S5_UP_S2 = 0;
	                for (; CADJPY_OCO2S5_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets5.Count; CADJPY_OCO2S5_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO2Sets5[CADJPY_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO2Sets5[CADJPY_OCO2S5_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO2Sets5.RemoveAt(CADJPY_OCO2S5_UP_S2);
	                        CADJPY_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CADJPY_OCO2S6_UP_S2 = 0;
	                for (; CADJPY_OCO2S6_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets6.Count; CADJPY_OCO2S6_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO2Sets6[CADJPY_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO2Sets6[CADJPY_OCO2S6_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO2Sets6.RemoveAt(CADJPY_OCO2S6_UP_S2);
	                        CADJPY_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CADJPY_OCO3_EO1_UP_S2)
	                Base.CADJPY_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.CADJPY_OCO3_EO2_UP_S2)
	                Base.CADJPY_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO3_EO3_UP_S2)
	                Base.CADJPY_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO3_EO4_UP_S2)
	                Base.CADJPY_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO3_EO5_UP_S2)
	                Base.CADJPY_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO3_EO6_UP_S2)
	                Base.CADJPY_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CADJPY_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.CADJPY_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP1,"TP1_CADJPY_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP1_CADJPY_UP_S2_OCO3"));
		                 };
		                Base.CADJPY_UP_S2_OCO3Sets1.Add( Base.CADJPY_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CADJPY_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP2,"TP2_CADJPY_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP2_CADJPY_UP_S2_OCO3"));
		                 };
	                    Base.CADJPY_UP_S2_OCO3Sets2.Add( Base.CADJPY_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP3,"TP3_CADJPY_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP3_CADJPY_UP_S2_OCO3"));
		                 };
	                    Base.CADJPY_UP_S2_OCO3Sets3.Add( Base.CADJPY_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP4,"TP4_CADJPY_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP4_CADJPY_UP_S2_OCO3"));
		                 };
	                    Base.CADJPY_UP_S2_OCO3Sets4.Add( Base.CADJPY_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP5,"TP5_CADJPY_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP5_CADJPY_UP_S2_OCO3"));
		                 };
	                    Base.CADJPY_UP_S2_OCO3Sets5.Add( Base.CADJPY_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP6,"TP6_CADJPY_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP6_CADJPY_UP_S2_OCO3"));
		                 };
	                    Base.CADJPY_UP_S2_OCO3Sets6.Add( Base.CADJPY_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int CADJPY_OCO3S1_UP_S2 = 0;
	                for (; CADJPY_OCO3S1_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets1.Count; CADJPY_OCO3S1_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO3Sets1[CADJPY_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO3Sets1[CADJPY_OCO3S1_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO3Sets1.RemoveAt(CADJPY_OCO3S1_UP_S2);
	                        CADJPY_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int CADJPY_OCO3S2_UP_S2 = 0;
	                for (; CADJPY_OCO3S2_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets2.Count; CADJPY_OCO3S2_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO3Sets2[CADJPY_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO3Sets2[CADJPY_OCO3S2_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO3Sets2.RemoveAt(CADJPY_OCO3S2_UP_S2);
	                        CADJPY_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO3S3_UP_S2 = 0;
	                for (; CADJPY_OCO3S3_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets3.Count; CADJPY_OCO3S3_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO3Sets3[CADJPY_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO3Sets3[CADJPY_OCO3S3_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO3Sets3.RemoveAt(CADJPY_OCO3S3_UP_S2);
	                        CADJPY_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO3S4_UP_S2 = 0;
	                for (; CADJPY_OCO3S4_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets4.Count; CADJPY_OCO3S4_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO3Sets4[CADJPY_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO3Sets4[CADJPY_OCO3S4_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO3Sets4.RemoveAt(CADJPY_OCO3S4_UP_S2);
	                        CADJPY_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CADJPY_OCO3S5_UP_S2 = 0;
	                for (; CADJPY_OCO3S5_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets5.Count; CADJPY_OCO3S5_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO3Sets5[CADJPY_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO3Sets5[CADJPY_OCO3S5_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO3Sets5.RemoveAt(CADJPY_OCO3S5_UP_S2);
	                        CADJPY_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CADJPY_OCO3S6_UP_S2 = 0;
	                for (; CADJPY_OCO3S6_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets6.Count; CADJPY_OCO3S6_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO3Sets6[CADJPY_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO3Sets6[CADJPY_OCO3S6_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO3Sets6.RemoveAt(CADJPY_OCO3S6_UP_S2);
	                        CADJPY_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CADJPY_OCO4_EO1_UP_S2)
	                Base.CADJPY_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.CADJPY_OCO4_EO2_UP_S2)
	                Base.CADJPY_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO4_EO3_UP_S2)
	                Base.CADJPY_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO4_EO4_UP_S2)
	                Base.CADJPY_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO4_EO5_UP_S2)
	                Base.CADJPY_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO4_EO6_UP_S2)
	                Base.CADJPY_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CADJPY_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.CADJPY_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP1,"TP1_CADJPY_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP1_CADJPY_UP_S2_OCO4"));
		                 };
		                Base.CADJPY_UP_S2_OCO4Sets1.Add( Base.CADJPY_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CADJPY_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP2,"TP2_CADJPY_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP2_CADJPY_UP_S2_OCO4"));
		                 };
	                    Base.CADJPY_UP_S2_OCO4Sets2.Add( Base.CADJPY_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP3,"TP3_CADJPY_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP3_CADJPY_UP_S2_OCO4"));
		                 };
	                    Base.CADJPY_UP_S2_OCO4Sets3.Add( Base.CADJPY_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP4,"TP4_CADJPY_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP4_CADJPY_UP_S2_OCO4"));
		                 };
	                    Base.CADJPY_UP_S2_OCO4Sets4.Add( Base.CADJPY_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP5,"TP5_CADJPY_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP5_CADJPY_UP_S2_OCO4"));
		                 };
	                    Base.CADJPY_UP_S2_OCO4Sets5.Add( Base.CADJPY_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_UP_S2_TP6,"TP6_CADJPY_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_UP_S2_SL,"SL_TP6_CADJPY_UP_S2_OCO4"));
		                 };
	                    Base.CADJPY_UP_S2_OCO4Sets6.Add( Base.CADJPY_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int CADJPY_OCO4S1_UP_S2 = 0;
	                for (; CADJPY_OCO4S1_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets1.Count; CADJPY_OCO4S1_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO4Sets1[CADJPY_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO4Sets1[CADJPY_OCO4S1_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO4Sets1.RemoveAt(CADJPY_OCO4S1_UP_S2);
	                        CADJPY_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int CADJPY_OCO4S2_UP_S2 = 0;
	                for (; CADJPY_OCO4S2_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets2.Count; CADJPY_OCO4S2_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO4Sets2[CADJPY_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO4Sets2[CADJPY_OCO4S2_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO4Sets2.RemoveAt(CADJPY_OCO4S2_UP_S2);
	                        CADJPY_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO4S3_UP_S2 = 0;
	                for (; CADJPY_OCO4S3_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets3.Count; CADJPY_OCO4S3_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO4Sets3[CADJPY_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO4Sets3[CADJPY_OCO4S3_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO4Sets3.RemoveAt(CADJPY_OCO4S3_UP_S2);
	                        CADJPY_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO4S4_UP_S2 = 0;
	                for (; CADJPY_OCO4S4_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets4.Count; CADJPY_OCO4S4_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO4Sets4[CADJPY_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO4Sets4[CADJPY_OCO4S4_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO4Sets4.RemoveAt(CADJPY_OCO4S4_UP_S2);
	                        CADJPY_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CADJPY_OCO4S5_UP_S2 = 0;
	                for (; CADJPY_OCO4S5_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets5.Count; CADJPY_OCO4S5_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO4Sets5[CADJPY_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO4Sets5[CADJPY_OCO4S5_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO4Sets5.RemoveAt(CADJPY_OCO4S5_UP_S2);
	                        CADJPY_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int CADJPY_OCO4S6_UP_S2 = 0;
	                for (; CADJPY_OCO4S6_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets6.Count; CADJPY_OCO4S6_UP_S2++)
	                    if (Base.CADJPY_UP_S2_OCO4Sets6[CADJPY_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_UP_S2_OCO4Sets6[CADJPY_OCO4S6_UP_S2].Filled();
	                        Base.CADJPY_UP_S2_OCO4Sets6.RemoveAt(CADJPY_OCO4S6_UP_S2);
	                        CADJPY_OCO4S6_UP_S2 = 0;
	                        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.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 CADJPY_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public CADJPY_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("CADJPY OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CADJPY OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CADJPY OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CADJPY OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("CADJPY OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CADJPY OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CADJPY S2");
		        	}
		        }
		        
				if (Base.CADJPY_OCO1_EO1_DOWN_S2)
	                Base.CADJPY_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.CADJPY_OCO1_EO2_DOWN_S2)
	                Base.CADJPY_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO1_EO3_DOWN_S2)
	                Base.CADJPY_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO1_EO4_DOWN_S2)
	                Base.CADJPY_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CADJPY_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.CADJPY_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP1_CADJPY_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP1,"TP1_CADJPY_DOWN_S2_OCO1"));
		                 };
		                Base.CADJPY_DOWN_S2_OCO1Sets1.Add( Base.CADJPY_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CADJPY_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP2_CADJPY_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP2,"TP2_CADJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO1Sets2.Add( Base.CADJPY_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP3_CADJPY_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP3,"TP3_CADJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO1Sets3.Add( Base.CADJPY_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP4_CADJPY_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP4,"TP4_CADJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO1Sets4.Add( Base.CADJPY_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int CADJPY_OCO1S1_DOWN_S2 = 0;
	                for (; CADJPY_OCO1S1_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets1.Count; CADJPY_OCO1S1_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO1Sets1[CADJPY_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO1Sets1[CADJPY_OCO1S1_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO1Sets1.RemoveAt(CADJPY_OCO1S1_DOWN_S2);
	                        CADJPY_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int CADJPY_OCO1S2_DOWN_S2 = 0;
	                for (; CADJPY_OCO1S2_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets2.Count; CADJPY_OCO1S2_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO1Sets2[CADJPY_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO1Sets2[CADJPY_OCO1S2_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO1Sets2.RemoveAt(CADJPY_OCO1S2_DOWN_S2);
	                        CADJPY_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO1S3_DOWN_S2 = 0;
	                for (; CADJPY_OCO1S3_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets3.Count; CADJPY_OCO1S3_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO1Sets3[CADJPY_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO1Sets3[CADJPY_OCO1S3_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO1Sets3.RemoveAt(CADJPY_OCO1S3_DOWN_S2);
	                        CADJPY_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO1S4_DOWN_S2 = 0;
	                for (; CADJPY_OCO1S4_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets4.Count; CADJPY_OCO1S4_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO1Sets4[CADJPY_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO1Sets4[CADJPY_OCO1S4_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO1Sets4.RemoveAt(CADJPY_OCO1S4_DOWN_S2);
	                        CADJPY_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CADJPY_OCO2_EO1_DOWN_S2)
	                Base.CADJPY_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.CADJPY_OCO2_EO2_DOWN_S2)
	                Base.CADJPY_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO2_EO3_DOWN_S2)
	                Base.CADJPY_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO2_EO4_DOWN_S2)
	                Base.CADJPY_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CADJPY_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.CADJPY_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP1_CADJPY_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP1,"TP1_CADJPY_DOWN_S2_OCO2"));
		                 };
		                Base.CADJPY_DOWN_S2_OCO2Sets1.Add( Base.CADJPY_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CADJPY_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP2_CADJPY_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP2,"TP2_CADJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO2Sets2.Add( Base.CADJPY_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP3_CADJPY_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP3,"TP3_CADJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO2Sets3.Add( Base.CADJPY_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP4_CADJPY_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP4,"TP4_CADJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO2Sets4.Add( Base.CADJPY_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int CADJPY_OCO2S1_DOWN_S2 = 0;
	                for (; CADJPY_OCO2S1_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets1.Count; CADJPY_OCO2S1_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO2Sets1[CADJPY_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO2Sets1[CADJPY_OCO2S1_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO2Sets1.RemoveAt(CADJPY_OCO2S1_DOWN_S2);
	                        CADJPY_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int CADJPY_OCO2S2_DOWN_S2 = 0;
	                for (; CADJPY_OCO2S2_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets2.Count; CADJPY_OCO2S2_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO2Sets2[CADJPY_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO2Sets2[CADJPY_OCO2S2_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO2Sets2.RemoveAt(CADJPY_OCO2S2_DOWN_S2);
	                        CADJPY_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO2S3_DOWN_S2 = 0;
	                for (; CADJPY_OCO2S3_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets3.Count; CADJPY_OCO2S3_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO2Sets3[CADJPY_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO2Sets3[CADJPY_OCO2S3_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO2Sets3.RemoveAt(CADJPY_OCO2S3_DOWN_S2);
	                        CADJPY_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO2S4_DOWN_S2 = 0;
	                for (; CADJPY_OCO2S4_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets4.Count; CADJPY_OCO2S4_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO2Sets4[CADJPY_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO2Sets4[CADJPY_OCO2S4_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO2Sets4.RemoveAt(CADJPY_OCO2S4_DOWN_S2);
	                        CADJPY_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CADJPY_OCO3_EO1_DOWN_S2)
	                Base.CADJPY_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.CADJPY_OCO3_EO2_DOWN_S2)
	                Base.CADJPY_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO3_EO3_DOWN_S2)
	                Base.CADJPY_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO3_EO4_DOWN_S2)
	                Base.CADJPY_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CADJPY_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.CADJPY_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP1_CADJPY_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP1,"TP1_CADJPY_DOWN_S2_OCO3"));
		                 };
		                Base.CADJPY_DOWN_S2_OCO3Sets1.Add( Base.CADJPY_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CADJPY_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP2_CADJPY_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP2,"TP2_CADJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO3Sets2.Add( Base.CADJPY_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP3_CADJPY_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP3,"TP3_CADJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO3Sets3.Add( Base.CADJPY_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP4_CADJPY_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP4,"TP4_CADJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO3Sets4.Add( Base.CADJPY_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int CADJPY_OCO3S1_DOWN_S2 = 0;
	                for (; CADJPY_OCO3S1_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets1.Count; CADJPY_OCO3S1_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO3Sets1[CADJPY_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO3Sets1[CADJPY_OCO3S1_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO3Sets1.RemoveAt(CADJPY_OCO3S1_DOWN_S2);
	                        CADJPY_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int CADJPY_OCO3S2_DOWN_S2 = 0;
	                for (; CADJPY_OCO3S2_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets2.Count; CADJPY_OCO3S2_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO3Sets2[CADJPY_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO3Sets2[CADJPY_OCO3S2_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO3Sets2.RemoveAt(CADJPY_OCO3S2_DOWN_S2);
	                        CADJPY_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO3S3_DOWN_S2 = 0;
	                for (; CADJPY_OCO3S3_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets3.Count; CADJPY_OCO3S3_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO3Sets3[CADJPY_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO3Sets3[CADJPY_OCO3S3_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO3Sets3.RemoveAt(CADJPY_OCO3S3_DOWN_S2);
	                        CADJPY_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO3S4_DOWN_S2 = 0;
	                for (; CADJPY_OCO3S4_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets4.Count; CADJPY_OCO3S4_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO3Sets4[CADJPY_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO3Sets4[CADJPY_OCO3S4_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO3Sets4.RemoveAt(CADJPY_OCO3S4_DOWN_S2);
	                        CADJPY_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CADJPY_OCO4_EO1_DOWN_S2)
	                Base.CADJPY_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.CADJPY_OCO4_EO2_DOWN_S2)
	                Base.CADJPY_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO4_EO3_DOWN_S2)
	                Base.CADJPY_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CADJPY_OCO4_EO4_DOWN_S2)
	                Base.CADJPY_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CADJPY_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.CADJPY_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP1_CADJPY_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP1,"TP1_CADJPY_DOWN_S2_OCO4"));
		                 };
		                Base.CADJPY_DOWN_S2_OCO4Sets1.Add( Base.CADJPY_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CADJPY_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP2_CADJPY_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP2,"TP2_CADJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO4Sets2.Add( Base.CADJPY_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP3_CADJPY_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP3,"TP3_CADJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO4Sets3.Add( Base.CADJPY_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CADJPY_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.CADJPY_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CADJPY_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CADJPY_DOWN_S2_SL,"SL_TP4_CADJPY_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CADJPY_DOWN_S2_TP4,"TP4_CADJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.CADJPY_DOWN_S2_OCO4Sets4.Add( Base.CADJPY_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CADJPY_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int CADJPY_OCO4S1_DOWN_S2 = 0;
	                for (; CADJPY_OCO4S1_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets1.Count; CADJPY_OCO4S1_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO4Sets1[CADJPY_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO4Sets1[CADJPY_OCO4S1_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO4Sets1.RemoveAt(CADJPY_OCO4S1_DOWN_S2);
	                        CADJPY_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int CADJPY_OCO4S2_DOWN_S2 = 0;
	                for (; CADJPY_OCO4S2_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets2.Count; CADJPY_OCO4S2_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO4Sets2[CADJPY_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO4Sets2[CADJPY_OCO4S2_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO4Sets2.RemoveAt(CADJPY_OCO4S2_DOWN_S2);
	                        CADJPY_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO4S3_DOWN_S2 = 0;
	                for (; CADJPY_OCO4S3_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets3.Count; CADJPY_OCO4S3_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO4Sets3[CADJPY_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO4Sets3[CADJPY_OCO4S3_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO4Sets3.RemoveAt(CADJPY_OCO4S3_DOWN_S2);
	                        CADJPY_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CADJPY_OCO4S4_DOWN_S2 = 0;
	                for (; CADJPY_OCO4S4_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets4.Count; CADJPY_OCO4S4_DOWN_S2++)
	                    if (Base.CADJPY_DOWN_S2_OCO4Sets4[CADJPY_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CADJPY_DOWN_S2_OCO4Sets4[CADJPY_OCO4S4_DOWN_S2].Filled();
	                        Base.CADJPY_DOWN_S2_OCO4Sets4.RemoveAt(CADJPY_OCO4S4_DOWN_S2);
	                        CADJPY_OCO4S4_DOWN_S2 = 0;
	                        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 _AUDJPY;
		
    	///oco1 up
    	public static OrderTicket AUDJPY_OCO1_MO1_UP_S2;
    	public static OrderTicket AUDJPY_OCO1_MO2_UP_S2;
    	public static OrderTicket AUDJPY_OCO1_MO3_UP_S2;
    	public static OrderTicket AUDJPY_OCO1_MO4_UP_S2;
    	public static OrderTicket AUDJPY_OCO1_MO5_UP_S2;
    	public static OrderTicket AUDJPY_OCO1_MO6_UP_S2;
    	
    	public static int AUDJPY_OCO1_EO1_UP_S2_ID ;
        public static int AUDJPY_OCO1_EO2_UP_S2_ID ;
        public static int AUDJPY_OCO1_EO3_UP_S2_ID ;
        public static int AUDJPY_OCO1_EO4_UP_S2_ID ;
        public static int AUDJPY_OCO1_EO5_UP_S2_ID ;
        public static int AUDJPY_OCO1_EO6_UP_S2_ID ;
        
        public static bool AUDJPY_OCO1_EO1_UP_S2 ;
        public static bool AUDJPY_OCO1_EO2_UP_S2 ;
        public static bool AUDJPY_OCO1_EO3_UP_S2 ;
        public static bool AUDJPY_OCO1_EO4_UP_S2 ;
        public static bool AUDJPY_OCO1_EO5_UP_S2 ;
        public static bool AUDJPY_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_UP_S2> AUDJPY_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_UP_S2> AUDJPY_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_UP_S2> AUDJPY_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_UP_S2> AUDJPY_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_UP_S2> AUDJPY_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_UP_S2> AUDJPY_OOFE_OCO1_UP_S2_6 ;
        
        public static AUDJPY_OCO1_UP_S2 AUDJPY_PFO_OCO1_UP_S2_1 ;
        public static AUDJPY_OCO1_UP_S2 AUDJPY_PFO_OCO1_UP_S2_2 ;
        public static AUDJPY_OCO1_UP_S2 AUDJPY_PFO_OCO1_UP_S2_3 ;
        public static AUDJPY_OCO1_UP_S2 AUDJPY_PFO_OCO1_UP_S2_4 ;
        public static AUDJPY_OCO1_UP_S2 AUDJPY_PFO_OCO1_UP_S2_5 ;
        public static AUDJPY_OCO1_UP_S2 AUDJPY_PFO_OCO1_UP_S2_6 ;
        
        public static List<AUDJPY_OCO1_UP_S2> AUDJPY_UP_S2_OCO1Sets1 = new List<AUDJPY_OCO1_UP_S2>();
        public static List<AUDJPY_OCO1_UP_S2> AUDJPY_UP_S2_OCO1Sets2 = new List<AUDJPY_OCO1_UP_S2>();
        public static List<AUDJPY_OCO1_UP_S2> AUDJPY_UP_S2_OCO1Sets3 = new List<AUDJPY_OCO1_UP_S2>();
        public static List<AUDJPY_OCO1_UP_S2> AUDJPY_UP_S2_OCO1Sets4 = new List<AUDJPY_OCO1_UP_S2>();
        public static List<AUDJPY_OCO1_UP_S2> AUDJPY_UP_S2_OCO1Sets5 = new List<AUDJPY_OCO1_UP_S2>();
        public static List<AUDJPY_OCO1_UP_S2> AUDJPY_UP_S2_OCO1Sets6 = new List<AUDJPY_OCO1_UP_S2>();
        
        public static bool AUDJPY_OCO1_UP_S2_IsReady = true;
		public static bool AUDJPY_OCO1_UP_S2_Monthly_IsReady = true;
        
        //oco1 down
		public static OrderTicket AUDJPY_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO1_MO6_DOWN_S2 ;
    	
    	public static int AUDJPY_OCO1_EO1_DOWN_S2_ID ;
        public static int AUDJPY_OCO1_EO2_DOWN_S2_ID ;
        public static int AUDJPY_OCO1_EO3_DOWN_S2_ID ;
        public static int AUDJPY_OCO1_EO4_DOWN_S2_ID ;
        public static int AUDJPY_OCO1_EO5_DOWN_S2_ID ;
        public static int AUDJPY_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool AUDJPY_OCO1_EO1_DOWN_S2 ;
        public static bool AUDJPY_OCO1_EO2_DOWN_S2 ;
        public static bool AUDJPY_OCO1_EO3_DOWN_S2 ;
        public static bool AUDJPY_OCO1_EO4_DOWN_S2 ;
        public static bool AUDJPY_OCO1_EO5_DOWN_S2 ;
        public static bool AUDJPY_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_DOWN_S2> AUDJPY_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_DOWN_S2> AUDJPY_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_DOWN_S2> AUDJPY_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_DOWN_S2> AUDJPY_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_DOWN_S2> AUDJPY_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO1_DOWN_S2> AUDJPY_OOFE_OCO1_DOWN_S2_6 ;
        
        public static AUDJPY_OCO1_DOWN_S2 AUDJPY_PFO_OCO1_DOWN_S2_1 ;
        public static AUDJPY_OCO1_DOWN_S2 AUDJPY_PFO_OCO1_DOWN_S2_2 ;
        public static AUDJPY_OCO1_DOWN_S2 AUDJPY_PFO_OCO1_DOWN_S2_3 ;
        public static AUDJPY_OCO1_DOWN_S2 AUDJPY_PFO_OCO1_DOWN_S2_4 ;
        public static AUDJPY_OCO1_DOWN_S2 AUDJPY_PFO_OCO1_DOWN_S2_5 ;
        public static AUDJPY_OCO1_DOWN_S2 AUDJPY_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<AUDJPY_OCO1_DOWN_S2> AUDJPY_DOWN_S2_OCO1Sets1 = new List<AUDJPY_OCO1_DOWN_S2>();
        public static List<AUDJPY_OCO1_DOWN_S2> AUDJPY_DOWN_S2_OCO1Sets2 = new List<AUDJPY_OCO1_DOWN_S2>();
        public static List<AUDJPY_OCO1_DOWN_S2> AUDJPY_DOWN_S2_OCO1Sets3 = new List<AUDJPY_OCO1_DOWN_S2>();
        public static List<AUDJPY_OCO1_DOWN_S2> AUDJPY_DOWN_S2_OCO1Sets4 = new List<AUDJPY_OCO1_DOWN_S2>();
        public static List<AUDJPY_OCO1_DOWN_S2> AUDJPY_DOWN_S2_OCO1Sets5 = new List<AUDJPY_OCO1_DOWN_S2>();
        public static List<AUDJPY_OCO1_DOWN_S2> AUDJPY_DOWN_S2_OCO1Sets6 = new List<AUDJPY_OCO1_DOWN_S2>();
        
        public static bool AUDJPY_OCO1_DOWN_S2_IsReady = true;
		public static bool AUDJPY_OCO1_DOWN_S2_Monthly_IsReady = true;
        
        //oco2 up
        public static OrderTicket AUDJPY_OCO2_MO1_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO2_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO3_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO4_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO5_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO6_UP_S2 ;
    	
    	public static int AUDJPY_OCO2_EO1_UP_S2_ID ;
        public static int AUDJPY_OCO2_EO2_UP_S2_ID ;
        public static int AUDJPY_OCO2_EO3_UP_S2_ID ;
        public static int AUDJPY_OCO2_EO4_UP_S2_ID ;
        public static int AUDJPY_OCO2_EO5_UP_S2_ID ;
        public static int AUDJPY_OCO2_EO6_UP_S2_ID ;
        
        public static bool AUDJPY_OCO2_EO1_UP_S2 ;
        public static bool AUDJPY_OCO2_EO2_UP_S2 ;
        public static bool AUDJPY_OCO2_EO3_UP_S2 ;
        public static bool AUDJPY_OCO2_EO4_UP_S2 ;
        public static bool AUDJPY_OCO2_EO5_UP_S2 ;
        public static bool AUDJPY_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_UP_S2> AUDJPY_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_UP_S2> AUDJPY_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_UP_S2> AUDJPY_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_UP_S2> AUDJPY_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_UP_S2> AUDJPY_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_UP_S2> AUDJPY_OOFE_OCO2_UP_S2_6 ;
        
        public static AUDJPY_OCO2_UP_S2 AUDJPY_PFO_OCO2_UP_S2_1 ;
        public static AUDJPY_OCO2_UP_S2 AUDJPY_PFO_OCO2_UP_S2_2 ;
        public static AUDJPY_OCO2_UP_S2 AUDJPY_PFO_OCO2_UP_S2_3 ;
        public static AUDJPY_OCO2_UP_S2 AUDJPY_PFO_OCO2_UP_S2_4 ;
        public static AUDJPY_OCO2_UP_S2 AUDJPY_PFO_OCO2_UP_S2_5 ;
        public static AUDJPY_OCO2_UP_S2 AUDJPY_PFO_OCO2_UP_S2_6 ;
        
        public static List<AUDJPY_OCO2_UP_S2> AUDJPY_UP_S2_OCO2Sets1 = new List<AUDJPY_OCO2_UP_S2>();
        public static List<AUDJPY_OCO2_UP_S2> AUDJPY_UP_S2_OCO2Sets2 = new List<AUDJPY_OCO2_UP_S2>();
        public static List<AUDJPY_OCO2_UP_S2> AUDJPY_UP_S2_OCO2Sets3 = new List<AUDJPY_OCO2_UP_S2>();
        public static List<AUDJPY_OCO2_UP_S2> AUDJPY_UP_S2_OCO2Sets4 = new List<AUDJPY_OCO2_UP_S2>();
        public static List<AUDJPY_OCO2_UP_S2> AUDJPY_UP_S2_OCO2Sets5 = new List<AUDJPY_OCO2_UP_S2>();
        public static List<AUDJPY_OCO2_UP_S2> AUDJPY_UP_S2_OCO2Sets6 = new List<AUDJPY_OCO2_UP_S2>();
        
        public static bool AUDJPY_OCO2_UP_S2_IsReady = true;
		public static bool AUDJPY_OCO2_UP_S2_Monthly_IsReady = true;
        
        //oco2 down
        public static OrderTicket AUDJPY_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO2_MO6_DOWN_S2 ;
    	
    	public static int AUDJPY_OCO2_EO1_DOWN_S2_ID ;
        public static int AUDJPY_OCO2_EO2_DOWN_S2_ID ;
        public static int AUDJPY_OCO2_EO3_DOWN_S2_ID ;
        public static int AUDJPY_OCO2_EO4_DOWN_S2_ID ;
        public static int AUDJPY_OCO2_EO5_DOWN_S2_ID ;
        public static int AUDJPY_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool AUDJPY_OCO2_EO1_DOWN_S2 ;
        public static bool AUDJPY_OCO2_EO2_DOWN_S2 ;
        public static bool AUDJPY_OCO2_EO3_DOWN_S2 ;
        public static bool AUDJPY_OCO2_EO4_DOWN_S2 ;
        public static bool AUDJPY_OCO2_EO5_DOWN_S2 ;
        public static bool AUDJPY_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_DOWN_S2> AUDJPY_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_DOWN_S2> AUDJPY_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_DOWN_S2> AUDJPY_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_DOWN_S2> AUDJPY_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_DOWN_S2> AUDJPY_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO2_DOWN_S2> AUDJPY_OOFE_OCO2_DOWN_S2_6 ;
        
        public static AUDJPY_OCO2_DOWN_S2 AUDJPY_PFO_OCO2_DOWN_S2_1 ;
        public static AUDJPY_OCO2_DOWN_S2 AUDJPY_PFO_OCO2_DOWN_S2_2 ;
        public static AUDJPY_OCO2_DOWN_S2 AUDJPY_PFO_OCO2_DOWN_S2_3 ;
        public static AUDJPY_OCO2_DOWN_S2 AUDJPY_PFO_OCO2_DOWN_S2_4 ;
        public static AUDJPY_OCO2_DOWN_S2 AUDJPY_PFO_OCO2_DOWN_S2_5 ;
        public static AUDJPY_OCO2_DOWN_S2 AUDJPY_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<AUDJPY_OCO2_DOWN_S2> AUDJPY_DOWN_S2_OCO2Sets1 = new List<AUDJPY_OCO2_DOWN_S2>();
        public static List<AUDJPY_OCO2_DOWN_S2> AUDJPY_DOWN_S2_OCO2Sets2 = new List<AUDJPY_OCO2_DOWN_S2>();
        public static List<AUDJPY_OCO2_DOWN_S2> AUDJPY_DOWN_S2_OCO2Sets3 = new List<AUDJPY_OCO2_DOWN_S2>();
        public static List<AUDJPY_OCO2_DOWN_S2> AUDJPY_DOWN_S2_OCO2Sets4 = new List<AUDJPY_OCO2_DOWN_S2>();
        public static List<AUDJPY_OCO2_DOWN_S2> AUDJPY_DOWN_S2_OCO2Sets5 = new List<AUDJPY_OCO2_DOWN_S2>();
        public static List<AUDJPY_OCO2_DOWN_S2> AUDJPY_DOWN_S2_OCO2Sets6 = new List<AUDJPY_OCO2_DOWN_S2>();
        
        public static bool AUDJPY_OCO2_DOWN_S2_IsReady = true;
		public static bool AUDJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
        
        //oco3 up
        public static OrderTicket AUDJPY_OCO3_MO1_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO2_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO3_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO4_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO5_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO6_UP_S2 ;
    	
    	public static int AUDJPY_OCO3_EO1_UP_S2_ID ;
        public static int AUDJPY_OCO3_EO2_UP_S2_ID ;
        public static int AUDJPY_OCO3_EO3_UP_S2_ID ;
        public static int AUDJPY_OCO3_EO4_UP_S2_ID ;
        public static int AUDJPY_OCO3_EO5_UP_S2_ID ;
        public static int AUDJPY_OCO3_EO6_UP_S2_ID ;
        
        public static bool AUDJPY_OCO3_EO1_UP_S2 ;
        public static bool AUDJPY_OCO3_EO2_UP_S2 ;
        public static bool AUDJPY_OCO3_EO3_UP_S2 ;
        public static bool AUDJPY_OCO3_EO4_UP_S2 ;
        public static bool AUDJPY_OCO3_EO5_UP_S2 ;
        public static bool AUDJPY_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_UP_S2> AUDJPY_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_UP_S2> AUDJPY_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_UP_S2> AUDJPY_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_UP_S2> AUDJPY_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_UP_S2> AUDJPY_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_UP_S2> AUDJPY_OOFE_OCO3_UP_S2_6 ;
        
        public static AUDJPY_OCO3_UP_S2 AUDJPY_PFO_OCO3_UP_S2_1 ;
        public static AUDJPY_OCO3_UP_S2 AUDJPY_PFO_OCO3_UP_S2_2 ;
        public static AUDJPY_OCO3_UP_S2 AUDJPY_PFO_OCO3_UP_S2_3 ;
        public static AUDJPY_OCO3_UP_S2 AUDJPY_PFO_OCO3_UP_S2_4 ;
        public static AUDJPY_OCO3_UP_S2 AUDJPY_PFO_OCO3_UP_S2_5 ;
        public static AUDJPY_OCO3_UP_S2 AUDJPY_PFO_OCO3_UP_S2_6 ;
        
        public static List<AUDJPY_OCO3_UP_S2> AUDJPY_UP_S2_OCO3Sets1 = new List<AUDJPY_OCO3_UP_S2>();
        public static List<AUDJPY_OCO3_UP_S2> AUDJPY_UP_S2_OCO3Sets2 = new List<AUDJPY_OCO3_UP_S2>();
        public static List<AUDJPY_OCO3_UP_S2> AUDJPY_UP_S2_OCO3Sets3 = new List<AUDJPY_OCO3_UP_S2>();
        public static List<AUDJPY_OCO3_UP_S2> AUDJPY_UP_S2_OCO3Sets4 = new List<AUDJPY_OCO3_UP_S2>();
        public static List<AUDJPY_OCO3_UP_S2> AUDJPY_UP_S2_OCO3Sets5 = new List<AUDJPY_OCO3_UP_S2>();
        public static List<AUDJPY_OCO3_UP_S2> AUDJPY_UP_S2_OCO3Sets6 = new List<AUDJPY_OCO3_UP_S2>();
        
        public static bool AUDJPY_OCO3_UP_S2_IsReady = true;
		public static bool AUDJPY_OCO3_UP_S2_Monthly_IsReady = true;
        
        //oco3 down
        public static OrderTicket AUDJPY_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO3_MO6_DOWN_S2 ;
    	
    	public static int AUDJPY_OCO3_EO1_DOWN_S2_ID ;
        public static int AUDJPY_OCO3_EO2_DOWN_S2_ID ;
        public static int AUDJPY_OCO3_EO3_DOWN_S2_ID ;
        public static int AUDJPY_OCO3_EO4_DOWN_S2_ID ;
        public static int AUDJPY_OCO3_EO5_DOWN_S2_ID ;
        public static int AUDJPY_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool AUDJPY_OCO3_EO1_DOWN_S2 ;
        public static bool AUDJPY_OCO3_EO2_DOWN_S2 ;
        public static bool AUDJPY_OCO3_EO3_DOWN_S2 ;
        public static bool AUDJPY_OCO3_EO4_DOWN_S2 ;
        public static bool AUDJPY_OCO3_EO5_DOWN_S2 ;
        public static bool AUDJPY_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_DOWN_S2> AUDJPY_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_DOWN_S2> AUDJPY_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_DOWN_S2> AUDJPY_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_DOWN_S2> AUDJPY_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_DOWN_S2> AUDJPY_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO3_DOWN_S2> AUDJPY_OOFE_OCO3_DOWN_S2_6 ;
        
        public static AUDJPY_OCO3_DOWN_S2 AUDJPY_PFO_OCO3_DOWN_S2_1 ;
        public static AUDJPY_OCO3_DOWN_S2 AUDJPY_PFO_OCO3_DOWN_S2_2 ;
        public static AUDJPY_OCO3_DOWN_S2 AUDJPY_PFO_OCO3_DOWN_S2_3 ;
        public static AUDJPY_OCO3_DOWN_S2 AUDJPY_PFO_OCO3_DOWN_S2_4 ;
        public static AUDJPY_OCO3_DOWN_S2 AUDJPY_PFO_OCO3_DOWN_S2_5 ;
        public static AUDJPY_OCO3_DOWN_S2 AUDJPY_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<AUDJPY_OCO3_DOWN_S2> AUDJPY_DOWN_S2_OCO3Sets1 = new List<AUDJPY_OCO3_DOWN_S2>();
        public static List<AUDJPY_OCO3_DOWN_S2> AUDJPY_DOWN_S2_OCO3Sets2 = new List<AUDJPY_OCO3_DOWN_S2>();
        public static List<AUDJPY_OCO3_DOWN_S2> AUDJPY_DOWN_S2_OCO3Sets3 = new List<AUDJPY_OCO3_DOWN_S2>();
        public static List<AUDJPY_OCO3_DOWN_S2> AUDJPY_DOWN_S2_OCO3Sets4 = new List<AUDJPY_OCO3_DOWN_S2>();
        public static List<AUDJPY_OCO3_DOWN_S2> AUDJPY_DOWN_S2_OCO3Sets5 = new List<AUDJPY_OCO3_DOWN_S2>();
        public static List<AUDJPY_OCO3_DOWN_S2> AUDJPY_DOWN_S2_OCO3Sets6 = new List<AUDJPY_OCO3_DOWN_S2>();
        
        public static bool AUDJPY_OCO3_DOWN_S2_IsReady = true;
		public static bool AUDJPY_OCO3_DOWN_S2_Monthly_IsReady = true;
        
        //oco4 up
        public static OrderTicket AUDJPY_OCO4_MO1_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO2_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO3_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO4_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO5_UP_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO6_UP_S2 ;
    	
    	public static int AUDJPY_OCO4_EO1_UP_S2_ID ;
        public static int AUDJPY_OCO4_EO2_UP_S2_ID ;
        public static int AUDJPY_OCO4_EO3_UP_S2_ID ;
        public static int AUDJPY_OCO4_EO4_UP_S2_ID ;
        public static int AUDJPY_OCO4_EO5_UP_S2_ID ;
        public static int AUDJPY_OCO4_EO6_UP_S2_ID ;
        
        public static bool AUDJPY_OCO4_EO1_UP_S2 ;
        public static bool AUDJPY_OCO4_EO2_UP_S2 ;
        public static bool AUDJPY_OCO4_EO3_UP_S2 ;
        public static bool AUDJPY_OCO4_EO4_UP_S2 ;
        public static bool AUDJPY_OCO4_EO5_UP_S2 ;
        public static bool AUDJPY_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_UP_S2> AUDJPY_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_UP_S2> AUDJPY_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_UP_S2> AUDJPY_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_UP_S2> AUDJPY_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_UP_S2> AUDJPY_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_UP_S2> AUDJPY_OOFE_OCO4_UP_S2_6 ;
        
        public static AUDJPY_OCO4_UP_S2 AUDJPY_PFO_OCO4_UP_S2_1 ;
        public static AUDJPY_OCO4_UP_S2 AUDJPY_PFO_OCO4_UP_S2_2 ;
        public static AUDJPY_OCO4_UP_S2 AUDJPY_PFO_OCO4_UP_S2_3 ;
        public static AUDJPY_OCO4_UP_S2 AUDJPY_PFO_OCO4_UP_S2_4 ;
        public static AUDJPY_OCO4_UP_S2 AUDJPY_PFO_OCO4_UP_S2_5 ;
        public static AUDJPY_OCO4_UP_S2 AUDJPY_PFO_OCO4_UP_S2_6 ;
        
        public static List<AUDJPY_OCO4_UP_S2> AUDJPY_UP_S2_OCO4Sets1 = new List<AUDJPY_OCO4_UP_S2>();
        public static List<AUDJPY_OCO4_UP_S2> AUDJPY_UP_S2_OCO4Sets2 = new List<AUDJPY_OCO4_UP_S2>();
        public static List<AUDJPY_OCO4_UP_S2> AUDJPY_UP_S2_OCO4Sets3 = new List<AUDJPY_OCO4_UP_S2>();
        public static List<AUDJPY_OCO4_UP_S2> AUDJPY_UP_S2_OCO4Sets4 = new List<AUDJPY_OCO4_UP_S2>();
        public static List<AUDJPY_OCO4_UP_S2> AUDJPY_UP_S2_OCO4Sets5 = new List<AUDJPY_OCO4_UP_S2>();
        public static List<AUDJPY_OCO4_UP_S2> AUDJPY_UP_S2_OCO4Sets6 = new List<AUDJPY_OCO4_UP_S2>();
        
        public static bool AUDJPY_OCO4_UP_S2_IsReady = true;
		public static bool AUDJPY_OCO4_UP_S2_Monthly_IsReady = true;
        
        //oco4 down
        public static OrderTicket AUDJPY_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket AUDJPY_OCO4_MO6_DOWN_S2 ;
    	
    	public static int AUDJPY_OCO4_EO1_DOWN_S2_ID ;
        public static int AUDJPY_OCO4_EO2_DOWN_S2_ID ;
        public static int AUDJPY_OCO4_EO3_DOWN_S2_ID ;
        public static int AUDJPY_OCO4_EO4_DOWN_S2_ID ;
        public static int AUDJPY_OCO4_EO5_DOWN_S2_ID ;
        public static int AUDJPY_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool AUDJPY_OCO4_EO1_DOWN_S2 ;
        public static bool AUDJPY_OCO4_EO2_DOWN_S2 ;
        public static bool AUDJPY_OCO4_EO3_DOWN_S2 ;
        public static bool AUDJPY_OCO4_EO4_DOWN_S2 ;
        public static bool AUDJPY_OCO4_EO5_DOWN_S2 ;
        public static bool AUDJPY_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_DOWN_S2> AUDJPY_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_DOWN_S2> AUDJPY_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_DOWN_S2> AUDJPY_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_DOWN_S2> AUDJPY_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_DOWN_S2> AUDJPY_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDJPY_OCO4_DOWN_S2> AUDJPY_OOFE_OCO4_DOWN_S2_6 ;
        
        public static AUDJPY_OCO4_DOWN_S2 AUDJPY_PFO_OCO4_DOWN_S2_1 ;
        public static AUDJPY_OCO4_DOWN_S2 AUDJPY_PFO_OCO4_DOWN_S2_2 ;
        public static AUDJPY_OCO4_DOWN_S2 AUDJPY_PFO_OCO4_DOWN_S2_3 ;
        public static AUDJPY_OCO4_DOWN_S2 AUDJPY_PFO_OCO4_DOWN_S2_4 ;
        public static AUDJPY_OCO4_DOWN_S2 AUDJPY_PFO_OCO4_DOWN_S2_5 ;
        public static AUDJPY_OCO4_DOWN_S2 AUDJPY_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<AUDJPY_OCO4_DOWN_S2> AUDJPY_DOWN_S2_OCO4Sets1 = new List<AUDJPY_OCO4_DOWN_S2>();
        public static List<AUDJPY_OCO4_DOWN_S2> AUDJPY_DOWN_S2_OCO4Sets2 = new List<AUDJPY_OCO4_DOWN_S2>();
        public static List<AUDJPY_OCO4_DOWN_S2> AUDJPY_DOWN_S2_OCO4Sets3 = new List<AUDJPY_OCO4_DOWN_S2>();
        public static List<AUDJPY_OCO4_DOWN_S2> AUDJPY_DOWN_S2_OCO4Sets4 = new List<AUDJPY_OCO4_DOWN_S2>();
        public static List<AUDJPY_OCO4_DOWN_S2> AUDJPY_DOWN_S2_OCO4Sets5 = new List<AUDJPY_OCO4_DOWN_S2>();
        public static List<AUDJPY_OCO4_DOWN_S2> AUDJPY_DOWN_S2_OCO4Sets6 = new List<AUDJPY_OCO4_DOWN_S2>();
        
        public static bool AUDJPY_OCO4_DOWN_S2_IsReady = true;
		public static bool AUDJPY_OCO4_DOWN_S2_Monthly_IsReady = true;
        
        
////////////////////////////
		public static decimal AUDJPY_UP_S2_SL {get; set;}
		public static decimal AUDJPY_UP_S2_TP1 {get; set;}
		public static decimal AUDJPY_UP_S2_TP2 {get; set;}
		public static decimal AUDJPY_UP_S2_TP3 {get; set;}
		public static decimal AUDJPY_UP_S2_TP4 {get; set;}
		public static decimal AUDJPY_UP_S2_TP5 {get; set;}
		public static decimal AUDJPY_UP_S2_TP6 {get; set;}
		
		public static decimal AUDJPY_DOWN_S2_SL {get; set;}
		public static decimal AUDJPY_DOWN_S2_TP1 {get; set;}
		public static decimal AUDJPY_DOWN_S2_TP2 {get; set;}
		public static decimal AUDJPY_DOWN_S2_TP3 {get; set;}
		public static decimal AUDJPY_DOWN_S2_TP4 {get; set;}
		public static decimal AUDJPY_DOWN_S2_TP5 {get; set;}
		public static decimal AUDJPY_DOWN_S2_TP6 {get; set;}

        public static bool AUDJPY_Signal_Condition_UP_1 ;
        public static bool AUDJPY_Signal_Condition_UP_2 ;
        public static bool AUDJPY_Signal_Condition_UP_3 ;
        public static bool AUDJPY_Signal_Condition_DOWN_S2 ;
        
        public static int AUDJPY_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int AUDJPY_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDJPY_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDJPY_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDJPY_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int AUDJPY_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int AUDJPY_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDJPY_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDJPY_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDJPY_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_AUDJPY_UP_S2 ;
        public static bool DOWM_AUDJPY_UP_S2 ;
        public static bool DOWT_AUDJPY_UP_S2 ;
        public static bool DOWW_AUDJPY_UP_S2 ;
        public static bool DOWTH_AUDJPY_UP_S2 ;
        
		public static bool DOWR_AUDJPY_DOWN_S2 ;
        public static bool DOWM_AUDJPY_DOWN_S2 ;
        public static bool DOWT_AUDJPY_DOWN_S2 ;
        public static bool DOWW_AUDJPY_DOWN_S2 ;
        public static bool DOWTH_AUDJPY_DOWN_S2 ;
        
        
		public static int AUDJPY_quantity_UP_S2 ;
		public static int AUDJPY_quantity_SL_UP_S2 ;
		public static int AUDJPY_quantity_TP1_UP_S2 ;
		public static int AUDJPY_quantity_TP2_UP_S2 ;
		public static int AUDJPY_quantity_TP3_UP_S2 ;
		public static int AUDJPY_quantity_TP4_UP_S2 ;
		public static int AUDJPY_quantity_TP5_UP_S2;
		public static int AUDJPY_quantity_TP6_UP_S2 ;
		
		public static int AUDJPY_quantity_DOWN_S2 ;
		public static int AUDJPY_quantity_SL_DOWN_S2 ;
		public static int AUDJPY_quantity_TP1_DOWN_S2 ;
		public static int AUDJPY_quantity_TP2_DOWN_S2 ;
		public static int AUDJPY_quantity_TP3_DOWN_S2 ;
		public static int AUDJPY_quantity_TP4_DOWN_S2 ;
		public static int AUDJPY_quantity_TP5_DOWN_S2;
		public static int AUDJPY_quantity_TP6_DOWN_S2 ;
    }
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct NZDCHF_OCO1_DOWN_S2
    {
        public NZDCHF_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 =="TP1_NZDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF 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 =="TP1_NZDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF 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 NZDCHF_OCO1_UP_S2
    {
        public NZDCHF_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 =="TP1_NZDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF 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 =="TP1_NZDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCHF 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 NZDCHF_OCO2_DOWN_S2
    {
        public NZDCHF_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 =="TP1_NZDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF 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 =="TP1_NZDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF 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 NZDCHF_OCO2_UP_S2
    {
        public NZDCHF_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 =="TP1_NZDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF 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 =="TP1_NZDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCHF 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 NZDCHF_OCO3_DOWN_S2
    {
        public NZDCHF_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 =="TP1_NZDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF 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 =="TP1_NZDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF 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 NZDCHF_OCO3_UP_S2
    {
        public NZDCHF_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 =="TP1_NZDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF 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 =="TP1_NZDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCHF 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 NZDCHF_OCO4_DOWN_S2
    {
        public NZDCHF_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 =="TP1_NZDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF 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 =="TP1_NZDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF 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 NZDCHF_OCO4_UP_S2
    {
        public NZDCHF_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 =="TP1_NZDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF 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 =="TP1_NZDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCHF 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.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct NZDCAD_OCO1_DOWN_S2
    {
        public NZDCAD_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 =="TP1_NZDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD 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 =="TP1_NZDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD 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 NZDCAD_OCO1_UP_S2
    {
        public NZDCAD_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 =="TP1_NZDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD 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 =="TP1_NZDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_NZDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_NZDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_NZDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_NZDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("NZDCAD 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 NZDCAD_OCO2_DOWN_S2
    {
        public NZDCAD_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 =="TP1_NZDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD 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 =="TP1_NZDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD 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 NZDCAD_OCO2_UP_S2
    {
        public NZDCAD_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 =="TP1_NZDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD 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 =="TP1_NZDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_NZDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_NZDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_NZDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_NZDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("NZDCAD 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 NZDCAD_OCO3_DOWN_S2
    {
        public NZDCAD_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 =="TP1_NZDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD 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 =="TP1_NZDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD 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 NZDCAD_OCO3_UP_S2
    {
        public NZDCAD_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 =="TP1_NZDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD 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 =="TP1_NZDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_NZDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_NZDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_NZDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_NZDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("NZDCAD 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 NZDCAD_OCO4_DOWN_S2
    {
        public NZDCAD_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 =="TP1_NZDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD 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 =="TP1_NZDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD 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 NZDCAD_OCO4_UP_S2
    {
        public NZDCAD_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 =="TP1_NZDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD 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 =="TP1_NZDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_NZDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_NZDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_NZDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_NZDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_NZDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_NZDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_NZDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("NZDCAD 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_USDCAD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_USDCAD_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())
			{
				algorithm.Liquidate();
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCAD_DOWN_S2_OCO1")))
			{
				Base.USDCAD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCAD_DOWN_S2_OCO2")))
			{
				Base.USDCAD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCAD_DOWN_S2_OCO3")))
			{
				Base.USDCAD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCAD_DOWN_S2_OCO4")))
			{
				Base.USDCAD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("USDCAD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.USDCAD_OCO1_EO1_DOWN_S2)
	                Base.USDCAD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDCAD_OCO1_EO2_DOWN_S2)
	                Base.USDCAD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO1_EO3_DOWN_S2)
	                Base.USDCAD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO1_EO4_DOWN_S2)
	                Base.USDCAD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO1_EO5_DOWN_S2)
	                Base.USDCAD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO1_EO6_DOWN_S2)
	                Base.USDCAD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCAD_OCO1S1_DOWN_S2 = 0;
		                for (; USDCAD_OCO1S1_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets1.Count; USDCAD_OCO1S1_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO1Sets1[USDCAD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO1Sets1[USDCAD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.USDCAD_DOWN_S2_OCO1Sets1.Clear();
		                        USDCAD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDCAD_OCO1S2_DOWN_S2 = 0;
		                for (; USDCAD_OCO1S2_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets2.Count; USDCAD_OCO1S2_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO1Sets2[USDCAD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO1Sets2[USDCAD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.USDCAD_DOWN_S2_OCO1Sets2.Clear();
		                        USDCAD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO1S3_DOWN_S2 = 0;
		                for (; USDCAD_OCO1S3_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets3.Count; USDCAD_OCO1S3_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO1Sets3[USDCAD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO1Sets3[USDCAD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.USDCAD_DOWN_S2_OCO1Sets3.Clear();
		                        USDCAD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO1S4_DOWN_S2 = 0;
		                for (; USDCAD_OCO1S4_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets4.Count; USDCAD_OCO1S4_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO1Sets4[USDCAD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO1Sets4[USDCAD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.USDCAD_DOWN_S2_OCO1Sets4.Clear();
		                        USDCAD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO1S5_DOWN_S2 = 0;
		                for (; USDCAD_OCO1S5_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets5.Count; USDCAD_OCO1S5_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO1Sets5[USDCAD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO1Sets5[USDCAD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.USDCAD_DOWN_S2_OCO1Sets5.Clear();
		                        USDCAD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO1S6_DOWN_S2 = 0;
		                for (; USDCAD_OCO1S6_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets6.Count; USDCAD_OCO1S6_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO1Sets6[USDCAD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO1Sets6[USDCAD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.USDCAD_DOWN_S2_OCO1Sets6.Clear();
		                        USDCAD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDCAD_OCO2_EO1_DOWN_S2)
	                Base.USDCAD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDCAD_OCO2_EO2_DOWN_S2)
	                Base.USDCAD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO2_EO3_DOWN_S2)
	                Base.USDCAD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO2_EO4_DOWN_S2)
	                Base.USDCAD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO2_EO5_DOWN_S2)
	                Base.USDCAD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO2_EO6_DOWN_S2)
	                Base.USDCAD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCAD_OCO2S1_DOWN_S2 = 0;
		                for (; USDCAD_OCO2S1_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets1.Count; USDCAD_OCO2S1_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO2Sets1[USDCAD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO2Sets1[USDCAD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.USDCAD_DOWN_S2_OCO2Sets1.Clear();
		                        USDCAD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDCAD_OCO2S2_DOWN_S2 = 0;
		                for (; USDCAD_OCO2S2_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets2.Count; USDCAD_OCO2S2_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO2Sets2[USDCAD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO2Sets2[USDCAD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.USDCAD_DOWN_S2_OCO2Sets2.Clear();
		                        USDCAD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO2S3_DOWN_S2 = 0;
		                for (; USDCAD_OCO2S3_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets3.Count; USDCAD_OCO2S3_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO2Sets3[USDCAD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO2Sets3[USDCAD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.USDCAD_DOWN_S2_OCO2Sets3.Clear();
		                        USDCAD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO2S4_DOWN_S2 = 0;
		                for (; USDCAD_OCO2S4_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets4.Count; USDCAD_OCO2S4_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO2Sets4[USDCAD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO2Sets4[USDCAD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.USDCAD_DOWN_S2_OCO2Sets4.Clear();
		                        USDCAD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO2S5_DOWN_S2 = 0;
		                for (; USDCAD_OCO2S5_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets5.Count; USDCAD_OCO2S5_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO2Sets5[USDCAD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO2Sets5[USDCAD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.USDCAD_DOWN_S2_OCO2Sets5.Clear();
		                        USDCAD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO2S6_DOWN_S2 = 0;
		                for (; USDCAD_OCO2S6_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets6.Count; USDCAD_OCO2S6_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO2Sets6[USDCAD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO2Sets6[USDCAD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.USDCAD_DOWN_S2_OCO2Sets6.Clear();
		                        USDCAD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDCAD_OCO3_EO1_DOWN_S2)
	                Base.USDCAD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDCAD_OCO3_EO2_DOWN_S2)
	                Base.USDCAD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO3_EO3_DOWN_S2)
	                Base.USDCAD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO3_EO4_DOWN_S2)
	                Base.USDCAD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO3_EO5_DOWN_S2)
	                Base.USDCAD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO3_EO6_DOWN_S2)
	                Base.USDCAD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCAD_OCO3S1_DOWN_S2 = 0;
		                for (; USDCAD_OCO3S1_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets1.Count; USDCAD_OCO3S1_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO3Sets1[USDCAD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO3Sets1[USDCAD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.USDCAD_DOWN_S2_OCO3Sets1.Clear();
		                        USDCAD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDCAD_OCO3S2_DOWN_S2 = 0;
		                for (; USDCAD_OCO3S2_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets2.Count; USDCAD_OCO3S2_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO3Sets2[USDCAD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO3Sets2[USDCAD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.USDCAD_DOWN_S2_OCO3Sets2.Clear();
		                        USDCAD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO3S3_DOWN_S2 = 0;
		                for (; USDCAD_OCO3S3_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets3.Count; USDCAD_OCO3S3_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO3Sets3[USDCAD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO3Sets3[USDCAD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.USDCAD_DOWN_S2_OCO3Sets3.Clear();
		                        USDCAD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO3S4_DOWN_S2 = 0;
		                for (; USDCAD_OCO3S4_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets4.Count; USDCAD_OCO3S4_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO3Sets4[USDCAD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO3Sets4[USDCAD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.USDCAD_DOWN_S2_OCO3Sets4.Clear();
		                        USDCAD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO3S5_DOWN_S2 = 0;
		                for (; USDCAD_OCO3S5_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets5.Count; USDCAD_OCO3S5_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO3Sets5[USDCAD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO3Sets5[USDCAD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.USDCAD_DOWN_S2_OCO3Sets5.Clear();
		                        USDCAD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO3S6_DOWN_S2 = 0;
		                for (; USDCAD_OCO3S6_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets6.Count; USDCAD_OCO3S6_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO3Sets6[USDCAD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO3Sets6[USDCAD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.USDCAD_DOWN_S2_OCO3Sets6.Clear();
		                        USDCAD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDCAD_OCO4_EO1_DOWN_S2)
	                Base.USDCAD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDCAD_OCO4_EO2_DOWN_S2)
	                Base.USDCAD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO4_EO3_DOWN_S2)
	                Base.USDCAD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO4_EO4_DOWN_S2)
	                Base.USDCAD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO4_EO5_DOWN_S2)
	                Base.USDCAD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDCAD_OCO4_EO6_DOWN_S2)
	                Base.USDCAD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCAD_OCO4S1_DOWN_S2 = 0;
		                for (; USDCAD_OCO4S1_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets1.Count; USDCAD_OCO4S1_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO4Sets1[USDCAD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO4Sets1[USDCAD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.USDCAD_DOWN_S2_OCO4Sets1.Clear();
		                        USDCAD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDCAD_OCO4S2_DOWN_S2 = 0;
		                for (; USDCAD_OCO4S2_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets2.Count; USDCAD_OCO4S2_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO4Sets2[USDCAD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO4Sets2[USDCAD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.USDCAD_DOWN_S2_OCO4Sets2.Clear();
		                        USDCAD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO4S3_DOWN_S2 = 0;
		                for (; USDCAD_OCO4S3_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets3.Count; USDCAD_OCO4S3_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO4Sets3[USDCAD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO4Sets3[USDCAD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.USDCAD_DOWN_S2_OCO4Sets3.Clear();
		                        USDCAD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCAD_OCO4S4_DOWN_S2 = 0;
		                for (; USDCAD_OCO4S4_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets4.Count; USDCAD_OCO4S4_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO4Sets4[USDCAD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO4Sets4[USDCAD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.USDCAD_DOWN_S2_OCO4Sets4.Clear();
		                        USDCAD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO4S5_DOWN_S2 = 0;
		                for (; USDCAD_OCO4S5_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets5.Count; USDCAD_OCO4S5_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO4Sets5[USDCAD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO4Sets5[USDCAD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.USDCAD_DOWN_S2_OCO4Sets5.Clear();
		                        USDCAD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCAD_OCO4S6_DOWN_S2 = 0;
		                for (; USDCAD_OCO4S6_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets6.Count; USDCAD_OCO4S6_DOWN_S2++)
		                    if (Base.USDCAD_DOWN_S2_OCO4Sets6[USDCAD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCAD_DOWN_S2_OCO4Sets6[USDCAD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCAD", order.Quantity, false, "USDCAD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.USDCAD_DOWN_S2_OCO4Sets6.Clear();
		                        USDCAD_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();
	            	}

					DOWM_USDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_USDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_USDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_USDCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_USDCAD_DOWN_S2 = DOWM_USDCAD_DOWN_S2 || DOWT_USDCAD_DOWN_S2 || DOWW_USDCAD_DOWN_S2 || DOWTH_USDCAD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("USDCAD"))
	            	{
	            		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.USDCAD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.USDCAD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.USDCAD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.USDCAD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.USDCAD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.USDCAD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.USDCAD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.USDCAD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.USDCAD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.USDCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.USDCAD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.USDCAD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	USDCAD_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
	                									);
	                									
	                	USDCAD_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
	                									);
	                									
	                									
	                	USDCAD_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 (USDCAD_Signal_Condition_DOWN_1)
	                	{
	                    	USDCAD_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (USDCAD_Signal_Condition_DOWN_2)
	                	{
	                    	USDCAD_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (USDCAD_Signal_Condition_DOWN_3)
	                	{
	                    	USDCAD_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	
	                	if (USDCAD_Signal_Condition_DOWN_1)
	                	{
	                    	USDCAD_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.05m ;
	                	}
	                	
	                	if (USDCAD_Signal_Condition_DOWN_2)
	                	{
	                    	USDCAD_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.1m ;
	                	}
	                	
	                	if (USDCAD_Signal_Condition_DOWN_3)
	                	{
	                    	USDCAD_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.2m ;
	                	}
	                	
	                    USDCAD_DOWN_S2_TP2 =  USDCAD_DOWN_S2_SL * 0;
	                    USDCAD_DOWN_S2_TP3 =  USDCAD_DOWN_S2_SL * 0;
	                    USDCAD_DOWN_S2_TP4 =  USDCAD_DOWN_S2_SL * 0;
	                    USDCAD_DOWN_S2_TP5 =  USDCAD_DOWN_S2_SL * 0;
	                    USDCAD_DOWN_S2_TP6 =  USDCAD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0 && USDCAD_DOWN_S2_SL !=  0)
	                    {
	                    USDCAD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)*0.015m);
	                    USDCAD_quantity_SL_DOWN_S2 = USDCAD_quantity_DOWN_S2;
	                    USDCAD_quantity_TP1_DOWN_S2 = (USDCAD_quantity_DOWN_S2 );
	                    USDCAD_quantity_TP2_DOWN_S2 = (USDCAD_quantity_TP1_DOWN_S2 * 0);
	                    USDCAD_quantity_TP3_DOWN_S2 = (USDCAD_quantity_TP2_DOWN_S2 * 0);
	                    USDCAD_quantity_TP4_DOWN_S2 = (USDCAD_quantity_TP3_DOWN_S2 * 0);
	                    USDCAD_quantity_TP5_DOWN_S2 = (USDCAD_quantity_TP4_DOWN_S2 * 0);
	                    USDCAD_quantity_TP6_DOWN_S2 = (USDCAD_quantity_TP5_DOWN_S2 * 0);
	                    }
	                    
	                    oco1:
	                    if ((USDCAD_Signal_Condition_DOWN_1 || USDCAD_Signal_Condition_DOWN_2 || USDCAD_Signal_Condition_DOWN_3)  && 
	                    DOWR_USDCAD_DOWN_S2 && 
	                    Base.USDCAD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.USDCAD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCAD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP1_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.USDCAD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.USDCAD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP2_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.USDCAD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.USDCAD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP3_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.USDCAD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.USDCAD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP4_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.USDCAD_OCO1_EO4_DOWN_S2 = false;

							Base.USDCAD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.USDCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((USDCAD_Signal_Condition_DOWN_1 || USDCAD_Signal_Condition_DOWN_2 || USDCAD_Signal_Condition_DOWN_3)  && 
	                    DOWR_USDCAD_DOWN_S2 && 
	                    Base.USDCAD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.USDCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.USDCAD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCAD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP1_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.USDCAD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.USDCAD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP2_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.USDCAD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.USDCAD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP3_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.USDCAD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.USDCAD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP4_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.USDCAD_OCO2_EO4_DOWN_S2 = false;

							Base.USDCAD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.USDCAD_OCO2_DOWN_S2_IsReady == false && Base.USDCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((USDCAD_Signal_Condition_DOWN_1 || USDCAD_Signal_Condition_DOWN_2 || USDCAD_Signal_Condition_DOWN_3)  && 
	                    DOWR_USDCAD_DOWN_S2 &&
	                    Base.USDCAD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.USDCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.USDCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.USDCAD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCAD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP1_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.USDCAD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.USDCAD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP2_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.USDCAD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.USDCAD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP3_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.USDCAD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.USDCAD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP4_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.USDCAD_OCO3_EO4_DOWN_S2 = false;

							Base.USDCAD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.USDCAD_OCO3_DOWN_S2_IsReady == false && Base.USDCAD_OCO2_DOWN_S2_IsReady == false && Base.USDCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((USDCAD_Signal_Condition_DOWN_1 || USDCAD_Signal_Condition_DOWN_2 || USDCAD_Signal_Condition_DOWN_3)  && 
	                    DOWR_USDCAD_DOWN_S2 && 
	                    Base.USDCAD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.USDCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.USDCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.USDCAD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.USDCAD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCAD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP1_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.USDCAD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.USDCAD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP2_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.USDCAD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.USDCAD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP3_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.USDCAD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.USDCAD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCAD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCAD_quantity_TP4_DOWN_S2, false,"USDCAD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.USDCAD_OCO4_EO4_DOWN_S2 = false;

							Base.USDCAD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.USDCAD_OCO4_DOWN_S2_IsReady == false && Base.USDCAD_OCO3_DOWN_S2_IsReady == false && Base.USDCAD_OCO2_DOWN_S2_IsReady == false && Base.USDCAD_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.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 GBPUSD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPUSD_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("GBPUSD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPUSD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPUSD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPUSD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPUSD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPUSD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPUSD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        }
		        
				if (Base.GBPUSD_OCO1_EO1_UP_S2)
	                Base.GBPUSD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPUSD_OCO1_EO2_UP_S2)
	                Base.GBPUSD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO1_EO3_UP_S2)
	                Base.GBPUSD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO1_EO4_UP_S2)
	                Base.GBPUSD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO1_EO5_UP_S2)
	                Base.GBPUSD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO1_EO6_UP_S2)
	                Base.GBPUSD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.GBPUSD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP1,"TP1_GBPUSD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP1_GBPUSD_UP_S2_OCO1"));
		                 };
		                Base.GBPUSD_UP_S2_OCO1Sets1.Add( Base.GBPUSD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP2,"TP2_GBPUSD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP2_GBPUSD_UP_S2_OCO1"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO1Sets2.Add( Base.GBPUSD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP3,"TP3_GBPUSD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP3_GBPUSD_UP_S2_OCO1"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO1Sets3.Add( Base.GBPUSD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP4,"TP4_GBPUSD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP4_GBPUSD_UP_S2_OCO1"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO1Sets4.Add( Base.GBPUSD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP5,"TP5_GBPUSD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP5_GBPUSD_UP_S2_OCO1"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO1Sets5.Add( Base.GBPUSD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP6,"TP6_GBPUSD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP6_GBPUSD_UP_S2_OCO1"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO1Sets6.Add( Base.GBPUSD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPUSD_OCO1S1_UP_S2 = 0;
	                for (; GBPUSD_OCO1S1_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets1.Count; GBPUSD_OCO1S1_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO1Sets1[GBPUSD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO1Sets1[GBPUSD_OCO1S1_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO1Sets1.RemoveAt(GBPUSD_OCO1S1_UP_S2);
	                        GBPUSD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPUSD_OCO1S2_UP_S2 = 0;
	                for (; GBPUSD_OCO1S2_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets2.Count; GBPUSD_OCO1S2_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO1Sets2[GBPUSD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO1Sets2[GBPUSD_OCO1S2_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO1Sets2.RemoveAt(GBPUSD_OCO1S2_UP_S2);
	                        GBPUSD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO1S3_UP_S2 = 0;
	                for (; GBPUSD_OCO1S3_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets3.Count; GBPUSD_OCO1S3_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO1Sets3[GBPUSD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO1Sets3[GBPUSD_OCO1S3_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO1Sets3.RemoveAt(GBPUSD_OCO1S3_UP_S2);
	                        GBPUSD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO1S4_UP_S2 = 0;
	                for (; GBPUSD_OCO1S4_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets4.Count; GBPUSD_OCO1S4_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO1Sets4[GBPUSD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO1Sets4[GBPUSD_OCO1S4_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO1Sets4.RemoveAt(GBPUSD_OCO1S4_UP_S2);
	                        GBPUSD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPUSD_OCO1S5_UP_S2 = 0;
	                for (; GBPUSD_OCO1S5_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets5.Count; GBPUSD_OCO1S5_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO1Sets5[GBPUSD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO1Sets5[GBPUSD_OCO1S5_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO1Sets5.RemoveAt(GBPUSD_OCO1S5_UP_S2);
	                        GBPUSD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPUSD_OCO1S6_UP_S2 = 0;
	                for (; GBPUSD_OCO1S6_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets6.Count; GBPUSD_OCO1S6_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO1Sets6[GBPUSD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO1Sets6[GBPUSD_OCO1S6_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO1Sets6.RemoveAt(GBPUSD_OCO1S6_UP_S2);
	                        GBPUSD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.GBPUSD_OCO2_EO1_UP_S2)
	                Base.GBPUSD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPUSD_OCO2_EO2_UP_S2)
	                Base.GBPUSD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO2_EO3_UP_S2)
	                Base.GBPUSD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO2_EO4_UP_S2)
	                Base.GBPUSD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO2_EO5_UP_S2)
	                Base.GBPUSD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO2_EO6_UP_S2)
	                Base.GBPUSD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.GBPUSD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP1,"TP1_GBPUSD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP1_GBPUSD_UP_S2_OCO2"));
		                 };
		                Base.GBPUSD_UP_S2_OCO2Sets1.Add( Base.GBPUSD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP2,"TP2_GBPUSD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP2_GBPUSD_UP_S2_OCO2"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO2Sets2.Add( Base.GBPUSD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP3,"TP3_GBPUSD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP3_GBPUSD_UP_S2_OCO2"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO2Sets3.Add( Base.GBPUSD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP4,"TP4_GBPUSD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP4_GBPUSD_UP_S2_OCO2"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO2Sets4.Add( Base.GBPUSD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP5,"TP5_GBPUSD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP5_GBPUSD_UP_S2_OCO2"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO2Sets5.Add( Base.GBPUSD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP6,"TP6_GBPUSD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP6_GBPUSD_UP_S2_OCO2"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO2Sets6.Add( Base.GBPUSD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPUSD_OCO2S1_UP_S2 = 0;
	                for (; GBPUSD_OCO2S1_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets1.Count; GBPUSD_OCO2S1_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO2Sets1[GBPUSD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO2Sets1[GBPUSD_OCO2S1_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO2Sets1.RemoveAt(GBPUSD_OCO2S1_UP_S2);
	                        GBPUSD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPUSD_OCO2S2_UP_S2 = 0;
	                for (; GBPUSD_OCO2S2_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets2.Count; GBPUSD_OCO2S2_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO2Sets2[GBPUSD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO2Sets2[GBPUSD_OCO2S2_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO2Sets2.RemoveAt(GBPUSD_OCO2S2_UP_S2);
	                        GBPUSD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO2S3_UP_S2 = 0;
	                for (; GBPUSD_OCO2S3_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets3.Count; GBPUSD_OCO2S3_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO2Sets3[GBPUSD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO2Sets3[GBPUSD_OCO2S3_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO2Sets3.RemoveAt(GBPUSD_OCO2S3_UP_S2);
	                        GBPUSD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO2S4_UP_S2 = 0;
	                for (; GBPUSD_OCO2S4_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets4.Count; GBPUSD_OCO2S4_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO2Sets4[GBPUSD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO2Sets4[GBPUSD_OCO2S4_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO2Sets4.RemoveAt(GBPUSD_OCO2S4_UP_S2);
	                        GBPUSD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPUSD_OCO2S5_UP_S2 = 0;
	                for (; GBPUSD_OCO2S5_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets5.Count; GBPUSD_OCO2S5_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO2Sets5[GBPUSD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO2Sets5[GBPUSD_OCO2S5_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO2Sets5.RemoveAt(GBPUSD_OCO2S5_UP_S2);
	                        GBPUSD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPUSD_OCO2S6_UP_S2 = 0;
	                for (; GBPUSD_OCO2S6_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets6.Count; GBPUSD_OCO2S6_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO2Sets6[GBPUSD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO2Sets6[GBPUSD_OCO2S6_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO2Sets6.RemoveAt(GBPUSD_OCO2S6_UP_S2);
	                        GBPUSD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPUSD_OCO3_EO1_UP_S2)
	                Base.GBPUSD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPUSD_OCO3_EO2_UP_S2)
	                Base.GBPUSD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO3_EO3_UP_S2)
	                Base.GBPUSD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO3_EO4_UP_S2)
	                Base.GBPUSD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO3_EO5_UP_S2)
	                Base.GBPUSD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO3_EO6_UP_S2)
	                Base.GBPUSD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.GBPUSD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP1,"TP1_GBPUSD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP1_GBPUSD_UP_S2_OCO3"));
		                 };
		                Base.GBPUSD_UP_S2_OCO3Sets1.Add( Base.GBPUSD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP2,"TP2_GBPUSD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP2_GBPUSD_UP_S2_OCO3"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO3Sets2.Add( Base.GBPUSD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP3,"TP3_GBPUSD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP3_GBPUSD_UP_S2_OCO3"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO3Sets3.Add( Base.GBPUSD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP4,"TP4_GBPUSD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP4_GBPUSD_UP_S2_OCO3"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO3Sets4.Add( Base.GBPUSD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP5,"TP5_GBPUSD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP5_GBPUSD_UP_S2_OCO3"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO3Sets5.Add( Base.GBPUSD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP6,"TP6_GBPUSD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP6_GBPUSD_UP_S2_OCO3"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO3Sets6.Add( Base.GBPUSD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPUSD_OCO3S1_UP_S2 = 0;
	                for (; GBPUSD_OCO3S1_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets1.Count; GBPUSD_OCO3S1_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO3Sets1[GBPUSD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO3Sets1[GBPUSD_OCO3S1_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO3Sets1.RemoveAt(GBPUSD_OCO3S1_UP_S2);
	                        GBPUSD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPUSD_OCO3S2_UP_S2 = 0;
	                for (; GBPUSD_OCO3S2_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets2.Count; GBPUSD_OCO3S2_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO3Sets2[GBPUSD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO3Sets2[GBPUSD_OCO3S2_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO3Sets2.RemoveAt(GBPUSD_OCO3S2_UP_S2);
	                        GBPUSD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO3S3_UP_S2 = 0;
	                for (; GBPUSD_OCO3S3_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets3.Count; GBPUSD_OCO3S3_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO3Sets3[GBPUSD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO3Sets3[GBPUSD_OCO3S3_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO3Sets3.RemoveAt(GBPUSD_OCO3S3_UP_S2);
	                        GBPUSD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO3S4_UP_S2 = 0;
	                for (; GBPUSD_OCO3S4_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets4.Count; GBPUSD_OCO3S4_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO3Sets4[GBPUSD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO3Sets4[GBPUSD_OCO3S4_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO3Sets4.RemoveAt(GBPUSD_OCO3S4_UP_S2);
	                        GBPUSD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPUSD_OCO3S5_UP_S2 = 0;
	                for (; GBPUSD_OCO3S5_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets5.Count; GBPUSD_OCO3S5_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO3Sets5[GBPUSD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO3Sets5[GBPUSD_OCO3S5_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO3Sets5.RemoveAt(GBPUSD_OCO3S5_UP_S2);
	                        GBPUSD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPUSD_OCO3S6_UP_S2 = 0;
	                for (; GBPUSD_OCO3S6_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets6.Count; GBPUSD_OCO3S6_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO3Sets6[GBPUSD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO3Sets6[GBPUSD_OCO3S6_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO3Sets6.RemoveAt(GBPUSD_OCO3S6_UP_S2);
	                        GBPUSD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPUSD_OCO4_EO1_UP_S2)
	                Base.GBPUSD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPUSD_OCO4_EO2_UP_S2)
	                Base.GBPUSD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO4_EO3_UP_S2)
	                Base.GBPUSD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO4_EO4_UP_S2)
	                Base.GBPUSD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO4_EO5_UP_S2)
	                Base.GBPUSD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO4_EO6_UP_S2)
	                Base.GBPUSD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.GBPUSD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP1,"TP1_GBPUSD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP1_GBPUSD_UP_S2_OCO4"));
		                 };
		                Base.GBPUSD_UP_S2_OCO4Sets1.Add( Base.GBPUSD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP2,"TP2_GBPUSD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP2_GBPUSD_UP_S2_OCO4"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO4Sets2.Add( Base.GBPUSD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP3,"TP3_GBPUSD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP3_GBPUSD_UP_S2_OCO4"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO4Sets3.Add( Base.GBPUSD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP4,"TP4_GBPUSD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP4_GBPUSD_UP_S2_OCO4"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO4Sets4.Add( Base.GBPUSD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP5,"TP5_GBPUSD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP5_GBPUSD_UP_S2_OCO4"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO4Sets5.Add( Base.GBPUSD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_UP_S2_TP6,"TP6_GBPUSD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_UP_S2_SL,"SL_TP6_GBPUSD_UP_S2_OCO4"));
		                 };
	                    Base.GBPUSD_UP_S2_OCO4Sets6.Add( Base.GBPUSD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPUSD_OCO4S1_UP_S2 = 0;
	                for (; GBPUSD_OCO4S1_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets1.Count; GBPUSD_OCO4S1_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO4Sets1[GBPUSD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO4Sets1[GBPUSD_OCO4S1_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO4Sets1.RemoveAt(GBPUSD_OCO4S1_UP_S2);
	                        GBPUSD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPUSD_OCO4S2_UP_S2 = 0;
	                for (; GBPUSD_OCO4S2_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets2.Count; GBPUSD_OCO4S2_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO4Sets2[GBPUSD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO4Sets2[GBPUSD_OCO4S2_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO4Sets2.RemoveAt(GBPUSD_OCO4S2_UP_S2);
	                        GBPUSD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO4S3_UP_S2 = 0;
	                for (; GBPUSD_OCO4S3_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets3.Count; GBPUSD_OCO4S3_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO4Sets3[GBPUSD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO4Sets3[GBPUSD_OCO4S3_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO4Sets3.RemoveAt(GBPUSD_OCO4S3_UP_S2);
	                        GBPUSD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO4S4_UP_S2 = 0;
	                for (; GBPUSD_OCO4S4_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets4.Count; GBPUSD_OCO4S4_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO4Sets4[GBPUSD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO4Sets4[GBPUSD_OCO4S4_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO4Sets4.RemoveAt(GBPUSD_OCO4S4_UP_S2);
	                        GBPUSD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPUSD_OCO4S5_UP_S2 = 0;
	                for (; GBPUSD_OCO4S5_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets5.Count; GBPUSD_OCO4S5_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO4Sets5[GBPUSD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO4Sets5[GBPUSD_OCO4S5_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO4Sets5.RemoveAt(GBPUSD_OCO4S5_UP_S2);
	                        GBPUSD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPUSD_OCO4S6_UP_S2 = 0;
	                for (; GBPUSD_OCO4S6_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets6.Count; GBPUSD_OCO4S6_UP_S2++)
	                    if (Base.GBPUSD_UP_S2_OCO4Sets6[GBPUSD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_UP_S2_OCO4Sets6[GBPUSD_OCO4S6_UP_S2].Filled();
	                        Base.GBPUSD_UP_S2_OCO4Sets6.RemoveAt(GBPUSD_OCO4S6_UP_S2);
	                        GBPUSD_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct GBPUSD_OCO1_DOWN_S2
    {
        public GBPUSD_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 =="TP1_GBPUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD 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 =="TP1_GBPUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD 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 GBPUSD_OCO1_UP_S2
    {
        public GBPUSD_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 =="TP1_GBPUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD 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 =="TP1_GBPUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPUSD 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 GBPUSD_OCO2_DOWN_S2
    {
        public GBPUSD_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 =="TP1_GBPUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD 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 =="TP1_GBPUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD 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 GBPUSD_OCO2_UP_S2
    {
        public GBPUSD_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 =="TP1_GBPUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD 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 =="TP1_GBPUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPUSD 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 GBPUSD_OCO3_DOWN_S2
    {
        public GBPUSD_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 =="TP1_GBPUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD 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 =="TP1_GBPUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD 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 GBPUSD_OCO3_UP_S2
    {
        public GBPUSD_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 =="TP1_GBPUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD 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 =="TP1_GBPUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPUSD 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 GBPUSD_OCO4_DOWN_S2
    {
        public GBPUSD_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 =="TP1_GBPUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD 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 =="TP1_GBPUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD 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 GBPUSD_OCO4_UP_S2
    {
        public GBPUSD_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 =="TP1_GBPUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD 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 =="TP1_GBPUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPUSD 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 GBPUSD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPUSD_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("GBPUSD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPUSD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPUSD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPUSD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPUSD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPUSD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPUSD S2");
		        	}
		        }
		        
				if (Base.GBPUSD_OCO1_EO1_DOWN_S2)
	                Base.GBPUSD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPUSD_OCO1_EO2_DOWN_S2)
	                Base.GBPUSD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO1_EO3_DOWN_S2)
	                Base.GBPUSD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO1_EO4_DOWN_S2)
	                Base.GBPUSD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPUSD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP1_GBPUSD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP1,"TP1_GBPUSD_DOWN_S2_OCO1"));
		                 };
		                Base.GBPUSD_DOWN_S2_OCO1Sets1.Add( Base.GBPUSD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP2_GBPUSD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP2,"TP2_GBPUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO1Sets2.Add( Base.GBPUSD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP3_GBPUSD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP3,"TP3_GBPUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO1Sets3.Add( Base.GBPUSD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP4_GBPUSD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP4,"TP4_GBPUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO1Sets4.Add( Base.GBPUSD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPUSD_OCO1S1_DOWN_S2 = 0;
	                for (; GBPUSD_OCO1S1_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets1.Count; GBPUSD_OCO1S1_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO1Sets1[GBPUSD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO1Sets1[GBPUSD_OCO1S1_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO1Sets1.RemoveAt(GBPUSD_OCO1S1_DOWN_S2);
	                        GBPUSD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPUSD_OCO1S2_DOWN_S2 = 0;
	                for (; GBPUSD_OCO1S2_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets2.Count; GBPUSD_OCO1S2_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO1Sets2[GBPUSD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO1Sets2[GBPUSD_OCO1S2_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO1Sets2.RemoveAt(GBPUSD_OCO1S2_DOWN_S2);
	                        GBPUSD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO1S3_DOWN_S2 = 0;
	                for (; GBPUSD_OCO1S3_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets3.Count; GBPUSD_OCO1S3_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO1Sets3[GBPUSD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO1Sets3[GBPUSD_OCO1S3_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO1Sets3.RemoveAt(GBPUSD_OCO1S3_DOWN_S2);
	                        GBPUSD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO1S4_DOWN_S2 = 0;
	                for (; GBPUSD_OCO1S4_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets4.Count; GBPUSD_OCO1S4_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO1Sets4[GBPUSD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO1Sets4[GBPUSD_OCO1S4_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO1Sets4.RemoveAt(GBPUSD_OCO1S4_DOWN_S2);
	                        GBPUSD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPUSD_OCO2_EO1_DOWN_S2)
	                Base.GBPUSD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPUSD_OCO2_EO2_DOWN_S2)
	                Base.GBPUSD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO2_EO3_DOWN_S2)
	                Base.GBPUSD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO2_EO4_DOWN_S2)
	                Base.GBPUSD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPUSD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP1_GBPUSD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP1,"TP1_GBPUSD_DOWN_S2_OCO2"));
		                 };
		                Base.GBPUSD_DOWN_S2_OCO2Sets1.Add( Base.GBPUSD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP2_GBPUSD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP2,"TP2_GBPUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO2Sets2.Add( Base.GBPUSD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP3_GBPUSD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP3,"TP3_GBPUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO2Sets3.Add( Base.GBPUSD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP4_GBPUSD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP4,"TP4_GBPUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO2Sets4.Add( Base.GBPUSD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPUSD_OCO2S1_DOWN_S2 = 0;
	                for (; GBPUSD_OCO2S1_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets1.Count; GBPUSD_OCO2S1_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO2Sets1[GBPUSD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO2Sets1[GBPUSD_OCO2S1_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO2Sets1.RemoveAt(GBPUSD_OCO2S1_DOWN_S2);
	                        GBPUSD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPUSD_OCO2S2_DOWN_S2 = 0;
	                for (; GBPUSD_OCO2S2_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets2.Count; GBPUSD_OCO2S2_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO2Sets2[GBPUSD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO2Sets2[GBPUSD_OCO2S2_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO2Sets2.RemoveAt(GBPUSD_OCO2S2_DOWN_S2);
	                        GBPUSD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO2S3_DOWN_S2 = 0;
	                for (; GBPUSD_OCO2S3_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets3.Count; GBPUSD_OCO2S3_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO2Sets3[GBPUSD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO2Sets3[GBPUSD_OCO2S3_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO2Sets3.RemoveAt(GBPUSD_OCO2S3_DOWN_S2);
	                        GBPUSD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO2S4_DOWN_S2 = 0;
	                for (; GBPUSD_OCO2S4_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets4.Count; GBPUSD_OCO2S4_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO2Sets4[GBPUSD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO2Sets4[GBPUSD_OCO2S4_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO2Sets4.RemoveAt(GBPUSD_OCO2S4_DOWN_S2);
	                        GBPUSD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPUSD_OCO3_EO1_DOWN_S2)
	                Base.GBPUSD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPUSD_OCO3_EO2_DOWN_S2)
	                Base.GBPUSD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO3_EO3_DOWN_S2)
	                Base.GBPUSD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO3_EO4_DOWN_S2)
	                Base.GBPUSD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPUSD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP1_GBPUSD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP1,"TP1_GBPUSD_DOWN_S2_OCO3"));
		                 };
		                Base.GBPUSD_DOWN_S2_OCO3Sets1.Add( Base.GBPUSD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP2_GBPUSD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP2,"TP2_GBPUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO3Sets2.Add( Base.GBPUSD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP3_GBPUSD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP3,"TP3_GBPUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO3Sets3.Add( Base.GBPUSD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP4_GBPUSD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP4,"TP4_GBPUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO3Sets4.Add( Base.GBPUSD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPUSD_OCO3S1_DOWN_S2 = 0;
	                for (; GBPUSD_OCO3S1_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets1.Count; GBPUSD_OCO3S1_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO3Sets1[GBPUSD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO3Sets1[GBPUSD_OCO3S1_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO3Sets1.RemoveAt(GBPUSD_OCO3S1_DOWN_S2);
	                        GBPUSD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPUSD_OCO3S2_DOWN_S2 = 0;
	                for (; GBPUSD_OCO3S2_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets2.Count; GBPUSD_OCO3S2_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO3Sets2[GBPUSD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO3Sets2[GBPUSD_OCO3S2_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO3Sets2.RemoveAt(GBPUSD_OCO3S2_DOWN_S2);
	                        GBPUSD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO3S3_DOWN_S2 = 0;
	                for (; GBPUSD_OCO3S3_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets3.Count; GBPUSD_OCO3S3_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO3Sets3[GBPUSD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO3Sets3[GBPUSD_OCO3S3_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO3Sets3.RemoveAt(GBPUSD_OCO3S3_DOWN_S2);
	                        GBPUSD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO3S4_DOWN_S2 = 0;
	                for (; GBPUSD_OCO3S4_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets4.Count; GBPUSD_OCO3S4_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO3Sets4[GBPUSD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO3Sets4[GBPUSD_OCO3S4_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO3Sets4.RemoveAt(GBPUSD_OCO3S4_DOWN_S2);
	                        GBPUSD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPUSD_OCO4_EO1_DOWN_S2)
	                Base.GBPUSD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPUSD_OCO4_EO2_DOWN_S2)
	                Base.GBPUSD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO4_EO3_DOWN_S2)
	                Base.GBPUSD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPUSD_OCO4_EO4_DOWN_S2)
	                Base.GBPUSD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPUSD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP1_GBPUSD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP1,"TP1_GBPUSD_DOWN_S2_OCO4"));
		                 };
		                Base.GBPUSD_DOWN_S2_OCO4Sets1.Add( Base.GBPUSD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP2_GBPUSD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP2,"TP2_GBPUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO4Sets2.Add( Base.GBPUSD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP3_GBPUSD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP3,"TP3_GBPUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO4Sets3.Add( Base.GBPUSD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPUSD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPUSD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPUSD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPUSD_DOWN_S2_SL,"SL_TP4_GBPUSD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPUSD_DOWN_S2_TP4,"TP4_GBPUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPUSD_DOWN_S2_OCO4Sets4.Add( Base.GBPUSD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPUSD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPUSD_OCO4S1_DOWN_S2 = 0;
	                for (; GBPUSD_OCO4S1_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets1.Count; GBPUSD_OCO4S1_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO4Sets1[GBPUSD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO4Sets1[GBPUSD_OCO4S1_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO4Sets1.RemoveAt(GBPUSD_OCO4S1_DOWN_S2);
	                        GBPUSD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPUSD_OCO4S2_DOWN_S2 = 0;
	                for (; GBPUSD_OCO4S2_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets2.Count; GBPUSD_OCO4S2_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO4Sets2[GBPUSD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO4Sets2[GBPUSD_OCO4S2_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO4Sets2.RemoveAt(GBPUSD_OCO4S2_DOWN_S2);
	                        GBPUSD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO4S3_DOWN_S2 = 0;
	                for (; GBPUSD_OCO4S3_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets3.Count; GBPUSD_OCO4S3_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO4Sets3[GBPUSD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO4Sets3[GBPUSD_OCO4S3_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO4Sets3.RemoveAt(GBPUSD_OCO4S3_DOWN_S2);
	                        GBPUSD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPUSD_OCO4S4_DOWN_S2 = 0;
	                for (; GBPUSD_OCO4S4_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets4.Count; GBPUSD_OCO4S4_DOWN_S2++)
	                    if (Base.GBPUSD_DOWN_S2_OCO4Sets4[GBPUSD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPUSD_DOWN_S2_OCO4Sets4[GBPUSD_OCO4S4_DOWN_S2].Filled();
	                        Base.GBPUSD_DOWN_S2_OCO4Sets4.RemoveAt(GBPUSD_OCO4S4_DOWN_S2);
	                        GBPUSD_OCO4S4_DOWN_S2 = 0;
	                        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.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 GBPNZD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPNZD_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("GBPNZD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPNZD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPNZD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPNZD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPNZD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPNZD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPNZD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        }
		        
				if (Base.GBPNZD_OCO1_EO1_UP_S2)
	                Base.GBPNZD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPNZD_OCO1_EO2_UP_S2)
	                Base.GBPNZD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO1_EO3_UP_S2)
	                Base.GBPNZD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO1_EO4_UP_S2)
	                Base.GBPNZD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO1_EO5_UP_S2)
	                Base.GBPNZD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO1_EO6_UP_S2)
	                Base.GBPNZD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.GBPNZD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP1,"TP1_GBPNZD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP1_GBPNZD_UP_S2_OCO1"));
		                 };
		                Base.GBPNZD_UP_S2_OCO1Sets1.Add( Base.GBPNZD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP2,"TP2_GBPNZD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP2_GBPNZD_UP_S2_OCO1"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO1Sets2.Add( Base.GBPNZD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP3,"TP3_GBPNZD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP3_GBPNZD_UP_S2_OCO1"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO1Sets3.Add( Base.GBPNZD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP4,"TP4_GBPNZD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP4_GBPNZD_UP_S2_OCO1"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO1Sets4.Add( Base.GBPNZD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP5,"TP5_GBPNZD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP5_GBPNZD_UP_S2_OCO1"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO1Sets5.Add( Base.GBPNZD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP6,"TP6_GBPNZD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP6_GBPNZD_UP_S2_OCO1"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO1Sets6.Add( Base.GBPNZD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPNZD_OCO1S1_UP_S2 = 0;
	                for (; GBPNZD_OCO1S1_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets1.Count; GBPNZD_OCO1S1_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO1Sets1[GBPNZD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO1Sets1[GBPNZD_OCO1S1_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO1Sets1.RemoveAt(GBPNZD_OCO1S1_UP_S2);
	                        GBPNZD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPNZD_OCO1S2_UP_S2 = 0;
	                for (; GBPNZD_OCO1S2_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets2.Count; GBPNZD_OCO1S2_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO1Sets2[GBPNZD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO1Sets2[GBPNZD_OCO1S2_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO1Sets2.RemoveAt(GBPNZD_OCO1S2_UP_S2);
	                        GBPNZD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO1S3_UP_S2 = 0;
	                for (; GBPNZD_OCO1S3_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets3.Count; GBPNZD_OCO1S3_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO1Sets3[GBPNZD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO1Sets3[GBPNZD_OCO1S3_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO1Sets3.RemoveAt(GBPNZD_OCO1S3_UP_S2);
	                        GBPNZD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO1S4_UP_S2 = 0;
	                for (; GBPNZD_OCO1S4_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets4.Count; GBPNZD_OCO1S4_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO1Sets4[GBPNZD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO1Sets4[GBPNZD_OCO1S4_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO1Sets4.RemoveAt(GBPNZD_OCO1S4_UP_S2);
	                        GBPNZD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPNZD_OCO1S5_UP_S2 = 0;
	                for (; GBPNZD_OCO1S5_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets5.Count; GBPNZD_OCO1S5_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO1Sets5[GBPNZD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO1Sets5[GBPNZD_OCO1S5_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO1Sets5.RemoveAt(GBPNZD_OCO1S5_UP_S2);
	                        GBPNZD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPNZD_OCO1S6_UP_S2 = 0;
	                for (; GBPNZD_OCO1S6_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets6.Count; GBPNZD_OCO1S6_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO1Sets6[GBPNZD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO1Sets6[GBPNZD_OCO1S6_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO1Sets6.RemoveAt(GBPNZD_OCO1S6_UP_S2);
	                        GBPNZD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.GBPNZD_OCO2_EO1_UP_S2)
	                Base.GBPNZD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPNZD_OCO2_EO2_UP_S2)
	                Base.GBPNZD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO2_EO3_UP_S2)
	                Base.GBPNZD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO2_EO4_UP_S2)
	                Base.GBPNZD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO2_EO5_UP_S2)
	                Base.GBPNZD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO2_EO6_UP_S2)
	                Base.GBPNZD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.GBPNZD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP1,"TP1_GBPNZD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP1_GBPNZD_UP_S2_OCO2"));
		                 };
		                Base.GBPNZD_UP_S2_OCO2Sets1.Add( Base.GBPNZD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP2,"TP2_GBPNZD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP2_GBPNZD_UP_S2_OCO2"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO2Sets2.Add( Base.GBPNZD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP3,"TP3_GBPNZD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP3_GBPNZD_UP_S2_OCO2"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO2Sets3.Add( Base.GBPNZD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP4,"TP4_GBPNZD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP4_GBPNZD_UP_S2_OCO2"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO2Sets4.Add( Base.GBPNZD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP5,"TP5_GBPNZD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP5_GBPNZD_UP_S2_OCO2"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO2Sets5.Add( Base.GBPNZD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP6,"TP6_GBPNZD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP6_GBPNZD_UP_S2_OCO2"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO2Sets6.Add( Base.GBPNZD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPNZD_OCO2S1_UP_S2 = 0;
	                for (; GBPNZD_OCO2S1_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets1.Count; GBPNZD_OCO2S1_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO2Sets1[GBPNZD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO2Sets1[GBPNZD_OCO2S1_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO2Sets1.RemoveAt(GBPNZD_OCO2S1_UP_S2);
	                        GBPNZD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPNZD_OCO2S2_UP_S2 = 0;
	                for (; GBPNZD_OCO2S2_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets2.Count; GBPNZD_OCO2S2_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO2Sets2[GBPNZD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO2Sets2[GBPNZD_OCO2S2_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO2Sets2.RemoveAt(GBPNZD_OCO2S2_UP_S2);
	                        GBPNZD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO2S3_UP_S2 = 0;
	                for (; GBPNZD_OCO2S3_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets3.Count; GBPNZD_OCO2S3_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO2Sets3[GBPNZD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO2Sets3[GBPNZD_OCO2S3_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO2Sets3.RemoveAt(GBPNZD_OCO2S3_UP_S2);
	                        GBPNZD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO2S4_UP_S2 = 0;
	                for (; GBPNZD_OCO2S4_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets4.Count; GBPNZD_OCO2S4_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO2Sets4[GBPNZD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO2Sets4[GBPNZD_OCO2S4_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO2Sets4.RemoveAt(GBPNZD_OCO2S4_UP_S2);
	                        GBPNZD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPNZD_OCO2S5_UP_S2 = 0;
	                for (; GBPNZD_OCO2S5_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets5.Count; GBPNZD_OCO2S5_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO2Sets5[GBPNZD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO2Sets5[GBPNZD_OCO2S5_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO2Sets5.RemoveAt(GBPNZD_OCO2S5_UP_S2);
	                        GBPNZD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPNZD_OCO2S6_UP_S2 = 0;
	                for (; GBPNZD_OCO2S6_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets6.Count; GBPNZD_OCO2S6_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO2Sets6[GBPNZD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO2Sets6[GBPNZD_OCO2S6_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO2Sets6.RemoveAt(GBPNZD_OCO2S6_UP_S2);
	                        GBPNZD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPNZD_OCO3_EO1_UP_S2)
	                Base.GBPNZD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPNZD_OCO3_EO2_UP_S2)
	                Base.GBPNZD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO3_EO3_UP_S2)
	                Base.GBPNZD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO3_EO4_UP_S2)
	                Base.GBPNZD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO3_EO5_UP_S2)
	                Base.GBPNZD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO3_EO6_UP_S2)
	                Base.GBPNZD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.GBPNZD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP1,"TP1_GBPNZD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP1_GBPNZD_UP_S2_OCO3"));
		                 };
		                Base.GBPNZD_UP_S2_OCO3Sets1.Add( Base.GBPNZD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP2,"TP2_GBPNZD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP2_GBPNZD_UP_S2_OCO3"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO3Sets2.Add( Base.GBPNZD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP3,"TP3_GBPNZD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP3_GBPNZD_UP_S2_OCO3"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO3Sets3.Add( Base.GBPNZD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP4,"TP4_GBPNZD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP4_GBPNZD_UP_S2_OCO3"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO3Sets4.Add( Base.GBPNZD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP5,"TP5_GBPNZD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP5_GBPNZD_UP_S2_OCO3"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO3Sets5.Add( Base.GBPNZD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP6,"TP6_GBPNZD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP6_GBPNZD_UP_S2_OCO3"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO3Sets6.Add( Base.GBPNZD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPNZD_OCO3S1_UP_S2 = 0;
	                for (; GBPNZD_OCO3S1_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets1.Count; GBPNZD_OCO3S1_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO3Sets1[GBPNZD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO3Sets1[GBPNZD_OCO3S1_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO3Sets1.RemoveAt(GBPNZD_OCO3S1_UP_S2);
	                        GBPNZD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPNZD_OCO3S2_UP_S2 = 0;
	                for (; GBPNZD_OCO3S2_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets2.Count; GBPNZD_OCO3S2_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO3Sets2[GBPNZD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO3Sets2[GBPNZD_OCO3S2_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO3Sets2.RemoveAt(GBPNZD_OCO3S2_UP_S2);
	                        GBPNZD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO3S3_UP_S2 = 0;
	                for (; GBPNZD_OCO3S3_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets3.Count; GBPNZD_OCO3S3_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO3Sets3[GBPNZD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO3Sets3[GBPNZD_OCO3S3_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO3Sets3.RemoveAt(GBPNZD_OCO3S3_UP_S2);
	                        GBPNZD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO3S4_UP_S2 = 0;
	                for (; GBPNZD_OCO3S4_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets4.Count; GBPNZD_OCO3S4_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO3Sets4[GBPNZD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO3Sets4[GBPNZD_OCO3S4_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO3Sets4.RemoveAt(GBPNZD_OCO3S4_UP_S2);
	                        GBPNZD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPNZD_OCO3S5_UP_S2 = 0;
	                for (; GBPNZD_OCO3S5_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets5.Count; GBPNZD_OCO3S5_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO3Sets5[GBPNZD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO3Sets5[GBPNZD_OCO3S5_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO3Sets5.RemoveAt(GBPNZD_OCO3S5_UP_S2);
	                        GBPNZD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPNZD_OCO3S6_UP_S2 = 0;
	                for (; GBPNZD_OCO3S6_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets6.Count; GBPNZD_OCO3S6_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO3Sets6[GBPNZD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO3Sets6[GBPNZD_OCO3S6_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO3Sets6.RemoveAt(GBPNZD_OCO3S6_UP_S2);
	                        GBPNZD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPNZD_OCO4_EO1_UP_S2)
	                Base.GBPNZD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPNZD_OCO4_EO2_UP_S2)
	                Base.GBPNZD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO4_EO3_UP_S2)
	                Base.GBPNZD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO4_EO4_UP_S2)
	                Base.GBPNZD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO4_EO5_UP_S2)
	                Base.GBPNZD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO4_EO6_UP_S2)
	                Base.GBPNZD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.GBPNZD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP1,"TP1_GBPNZD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP1_GBPNZD_UP_S2_OCO4"));
		                 };
		                Base.GBPNZD_UP_S2_OCO4Sets1.Add( Base.GBPNZD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP2,"TP2_GBPNZD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP2_GBPNZD_UP_S2_OCO4"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO4Sets2.Add( Base.GBPNZD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP3,"TP3_GBPNZD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP3_GBPNZD_UP_S2_OCO4"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO4Sets3.Add( Base.GBPNZD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP4,"TP4_GBPNZD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP4_GBPNZD_UP_S2_OCO4"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO4Sets4.Add( Base.GBPNZD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP5,"TP5_GBPNZD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP5_GBPNZD_UP_S2_OCO4"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO4Sets5.Add( Base.GBPNZD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_UP_S2_TP6,"TP6_GBPNZD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_UP_S2_SL,"SL_TP6_GBPNZD_UP_S2_OCO4"));
		                 };
	                    Base.GBPNZD_UP_S2_OCO4Sets6.Add( Base.GBPNZD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPNZD_OCO4S1_UP_S2 = 0;
	                for (; GBPNZD_OCO4S1_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets1.Count; GBPNZD_OCO4S1_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO4Sets1[GBPNZD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO4Sets1[GBPNZD_OCO4S1_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO4Sets1.RemoveAt(GBPNZD_OCO4S1_UP_S2);
	                        GBPNZD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPNZD_OCO4S2_UP_S2 = 0;
	                for (; GBPNZD_OCO4S2_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets2.Count; GBPNZD_OCO4S2_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO4Sets2[GBPNZD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO4Sets2[GBPNZD_OCO4S2_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO4Sets2.RemoveAt(GBPNZD_OCO4S2_UP_S2);
	                        GBPNZD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO4S3_UP_S2 = 0;
	                for (; GBPNZD_OCO4S3_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets3.Count; GBPNZD_OCO4S3_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO4Sets3[GBPNZD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO4Sets3[GBPNZD_OCO4S3_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO4Sets3.RemoveAt(GBPNZD_OCO4S3_UP_S2);
	                        GBPNZD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO4S4_UP_S2 = 0;
	                for (; GBPNZD_OCO4S4_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets4.Count; GBPNZD_OCO4S4_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO4Sets4[GBPNZD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO4Sets4[GBPNZD_OCO4S4_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO4Sets4.RemoveAt(GBPNZD_OCO4S4_UP_S2);
	                        GBPNZD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPNZD_OCO4S5_UP_S2 = 0;
	                for (; GBPNZD_OCO4S5_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets5.Count; GBPNZD_OCO4S5_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO4Sets5[GBPNZD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO4Sets5[GBPNZD_OCO4S5_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO4Sets5.RemoveAt(GBPNZD_OCO4S5_UP_S2);
	                        GBPNZD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPNZD_OCO4S6_UP_S2 = 0;
	                for (; GBPNZD_OCO4S6_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets6.Count; GBPNZD_OCO4S6_UP_S2++)
	                    if (Base.GBPNZD_UP_S2_OCO4Sets6[GBPNZD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_UP_S2_OCO4Sets6[GBPNZD_OCO4S6_UP_S2].Filled();
	                        Base.GBPNZD_UP_S2_OCO4Sets6.RemoveAt(GBPNZD_OCO4S6_UP_S2);
	                        GBPNZD_OCO4S6_UP_S2 = 0;
	                        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.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 GBPNZD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPNZD_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("GBPNZD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPNZD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPNZD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPNZD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPNZD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPNZD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPNZD S2");
		        	}
		        }
		        
				if (Base.GBPNZD_OCO1_EO1_DOWN_S2)
	                Base.GBPNZD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPNZD_OCO1_EO2_DOWN_S2)
	                Base.GBPNZD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO1_EO3_DOWN_S2)
	                Base.GBPNZD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO1_EO4_DOWN_S2)
	                Base.GBPNZD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPNZD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP1_GBPNZD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP1,"TP1_GBPNZD_DOWN_S2_OCO1"));
		                 };
		                Base.GBPNZD_DOWN_S2_OCO1Sets1.Add( Base.GBPNZD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP2_GBPNZD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP2,"TP2_GBPNZD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO1Sets2.Add( Base.GBPNZD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP3_GBPNZD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP3,"TP3_GBPNZD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO1Sets3.Add( Base.GBPNZD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP4_GBPNZD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP4,"TP4_GBPNZD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO1Sets4.Add( Base.GBPNZD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPNZD_OCO1S1_DOWN_S2 = 0;
	                for (; GBPNZD_OCO1S1_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets1.Count; GBPNZD_OCO1S1_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO1Sets1[GBPNZD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO1Sets1[GBPNZD_OCO1S1_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO1Sets1.RemoveAt(GBPNZD_OCO1S1_DOWN_S2);
	                        GBPNZD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPNZD_OCO1S2_DOWN_S2 = 0;
	                for (; GBPNZD_OCO1S2_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets2.Count; GBPNZD_OCO1S2_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO1Sets2[GBPNZD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO1Sets2[GBPNZD_OCO1S2_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO1Sets2.RemoveAt(GBPNZD_OCO1S2_DOWN_S2);
	                        GBPNZD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO1S3_DOWN_S2 = 0;
	                for (; GBPNZD_OCO1S3_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets3.Count; GBPNZD_OCO1S3_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO1Sets3[GBPNZD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO1Sets3[GBPNZD_OCO1S3_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO1Sets3.RemoveAt(GBPNZD_OCO1S3_DOWN_S2);
	                        GBPNZD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO1S4_DOWN_S2 = 0;
	                for (; GBPNZD_OCO1S4_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets4.Count; GBPNZD_OCO1S4_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO1Sets4[GBPNZD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO1Sets4[GBPNZD_OCO1S4_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO1Sets4.RemoveAt(GBPNZD_OCO1S4_DOWN_S2);
	                        GBPNZD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPNZD_OCO2_EO1_DOWN_S2)
	                Base.GBPNZD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPNZD_OCO2_EO2_DOWN_S2)
	                Base.GBPNZD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO2_EO3_DOWN_S2)
	                Base.GBPNZD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO2_EO4_DOWN_S2)
	                Base.GBPNZD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPNZD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP1_GBPNZD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP1,"TP1_GBPNZD_DOWN_S2_OCO2"));
		                 };
		                Base.GBPNZD_DOWN_S2_OCO2Sets1.Add( Base.GBPNZD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP2_GBPNZD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP2,"TP2_GBPNZD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO2Sets2.Add( Base.GBPNZD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP3_GBPNZD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP3,"TP3_GBPNZD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO2Sets3.Add( Base.GBPNZD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP4_GBPNZD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP4,"TP4_GBPNZD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO2Sets4.Add( Base.GBPNZD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPNZD_OCO2S1_DOWN_S2 = 0;
	                for (; GBPNZD_OCO2S1_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets1.Count; GBPNZD_OCO2S1_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO2Sets1[GBPNZD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO2Sets1[GBPNZD_OCO2S1_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO2Sets1.RemoveAt(GBPNZD_OCO2S1_DOWN_S2);
	                        GBPNZD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPNZD_OCO2S2_DOWN_S2 = 0;
	                for (; GBPNZD_OCO2S2_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets2.Count; GBPNZD_OCO2S2_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO2Sets2[GBPNZD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO2Sets2[GBPNZD_OCO2S2_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO2Sets2.RemoveAt(GBPNZD_OCO2S2_DOWN_S2);
	                        GBPNZD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO2S3_DOWN_S2 = 0;
	                for (; GBPNZD_OCO2S3_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets3.Count; GBPNZD_OCO2S3_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO2Sets3[GBPNZD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO2Sets3[GBPNZD_OCO2S3_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO2Sets3.RemoveAt(GBPNZD_OCO2S3_DOWN_S2);
	                        GBPNZD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO2S4_DOWN_S2 = 0;
	                for (; GBPNZD_OCO2S4_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets4.Count; GBPNZD_OCO2S4_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO2Sets4[GBPNZD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO2Sets4[GBPNZD_OCO2S4_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO2Sets4.RemoveAt(GBPNZD_OCO2S4_DOWN_S2);
	                        GBPNZD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPNZD_OCO3_EO1_DOWN_S2)
	                Base.GBPNZD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPNZD_OCO3_EO2_DOWN_S2)
	                Base.GBPNZD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO3_EO3_DOWN_S2)
	                Base.GBPNZD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO3_EO4_DOWN_S2)
	                Base.GBPNZD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPNZD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP1_GBPNZD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP1,"TP1_GBPNZD_DOWN_S2_OCO3"));
		                 };
		                Base.GBPNZD_DOWN_S2_OCO3Sets1.Add( Base.GBPNZD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP2_GBPNZD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP2,"TP2_GBPNZD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO3Sets2.Add( Base.GBPNZD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP3_GBPNZD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP3,"TP3_GBPNZD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO3Sets3.Add( Base.GBPNZD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP4_GBPNZD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP4,"TP4_GBPNZD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO3Sets4.Add( Base.GBPNZD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPNZD_OCO3S1_DOWN_S2 = 0;
	                for (; GBPNZD_OCO3S1_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets1.Count; GBPNZD_OCO3S1_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO3Sets1[GBPNZD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO3Sets1[GBPNZD_OCO3S1_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO3Sets1.RemoveAt(GBPNZD_OCO3S1_DOWN_S2);
	                        GBPNZD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPNZD_OCO3S2_DOWN_S2 = 0;
	                for (; GBPNZD_OCO3S2_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets2.Count; GBPNZD_OCO3S2_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO3Sets2[GBPNZD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO3Sets2[GBPNZD_OCO3S2_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO3Sets2.RemoveAt(GBPNZD_OCO3S2_DOWN_S2);
	                        GBPNZD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO3S3_DOWN_S2 = 0;
	                for (; GBPNZD_OCO3S3_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets3.Count; GBPNZD_OCO3S3_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO3Sets3[GBPNZD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO3Sets3[GBPNZD_OCO3S3_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO3Sets3.RemoveAt(GBPNZD_OCO3S3_DOWN_S2);
	                        GBPNZD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO3S4_DOWN_S2 = 0;
	                for (; GBPNZD_OCO3S4_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets4.Count; GBPNZD_OCO3S4_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO3Sets4[GBPNZD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO3Sets4[GBPNZD_OCO3S4_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO3Sets4.RemoveAt(GBPNZD_OCO3S4_DOWN_S2);
	                        GBPNZD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPNZD_OCO4_EO1_DOWN_S2)
	                Base.GBPNZD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPNZD_OCO4_EO2_DOWN_S2)
	                Base.GBPNZD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO4_EO3_DOWN_S2)
	                Base.GBPNZD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPNZD_OCO4_EO4_DOWN_S2)
	                Base.GBPNZD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPNZD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP1_GBPNZD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP1,"TP1_GBPNZD_DOWN_S2_OCO4"));
		                 };
		                Base.GBPNZD_DOWN_S2_OCO4Sets1.Add( Base.GBPNZD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP2_GBPNZD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP2,"TP2_GBPNZD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO4Sets2.Add( Base.GBPNZD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP3_GBPNZD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP3,"TP3_GBPNZD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO4Sets3.Add( Base.GBPNZD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPNZD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPNZD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPNZD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPNZD_DOWN_S2_SL,"SL_TP4_GBPNZD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPNZD_DOWN_S2_TP4,"TP4_GBPNZD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPNZD_DOWN_S2_OCO4Sets4.Add( Base.GBPNZD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPNZD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPNZD_OCO4S1_DOWN_S2 = 0;
	                for (; GBPNZD_OCO4S1_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets1.Count; GBPNZD_OCO4S1_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO4Sets1[GBPNZD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO4Sets1[GBPNZD_OCO4S1_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO4Sets1.RemoveAt(GBPNZD_OCO4S1_DOWN_S2);
	                        GBPNZD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPNZD_OCO4S2_DOWN_S2 = 0;
	                for (; GBPNZD_OCO4S2_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets2.Count; GBPNZD_OCO4S2_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO4Sets2[GBPNZD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO4Sets2[GBPNZD_OCO4S2_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO4Sets2.RemoveAt(GBPNZD_OCO4S2_DOWN_S2);
	                        GBPNZD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO4S3_DOWN_S2 = 0;
	                for (; GBPNZD_OCO4S3_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets3.Count; GBPNZD_OCO4S3_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO4Sets3[GBPNZD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO4Sets3[GBPNZD_OCO4S3_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO4Sets3.RemoveAt(GBPNZD_OCO4S3_DOWN_S2);
	                        GBPNZD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPNZD_OCO4S4_DOWN_S2 = 0;
	                for (; GBPNZD_OCO4S4_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets4.Count; GBPNZD_OCO4S4_DOWN_S2++)
	                    if (Base.GBPNZD_DOWN_S2_OCO4Sets4[GBPNZD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPNZD_DOWN_S2_OCO4Sets4[GBPNZD_OCO4S4_DOWN_S2].Filled();
	                        Base.GBPNZD_DOWN_S2_OCO4Sets4.RemoveAt(GBPNZD_OCO4S4_DOWN_S2);
	                        GBPNZD_OCO4S4_DOWN_S2 = 0;
	                        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 _CADJPY;
		
    	///oco1 up
    	public static OrderTicket CADJPY_OCO1_MO1_UP_S2;
    	public static OrderTicket CADJPY_OCO1_MO2_UP_S2;
    	public static OrderTicket CADJPY_OCO1_MO3_UP_S2;
    	public static OrderTicket CADJPY_OCO1_MO4_UP_S2;
    	public static OrderTicket CADJPY_OCO1_MO5_UP_S2;
    	public static OrderTicket CADJPY_OCO1_MO6_UP_S2;
    	
    	public static int CADJPY_OCO1_EO1_UP_S2_ID ;
        public static int CADJPY_OCO1_EO2_UP_S2_ID ;
        public static int CADJPY_OCO1_EO3_UP_S2_ID ;
        public static int CADJPY_OCO1_EO4_UP_S2_ID ;
        public static int CADJPY_OCO1_EO5_UP_S2_ID ;
        public static int CADJPY_OCO1_EO6_UP_S2_ID ;
        
        public static bool CADJPY_OCO1_EO1_UP_S2 ;
        public static bool CADJPY_OCO1_EO2_UP_S2 ;
        public static bool CADJPY_OCO1_EO3_UP_S2 ;
        public static bool CADJPY_OCO1_EO4_UP_S2 ;
        public static bool CADJPY_OCO1_EO5_UP_S2 ;
        public static bool CADJPY_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_UP_S2> CADJPY_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_UP_S2> CADJPY_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_UP_S2> CADJPY_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_UP_S2> CADJPY_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_UP_S2> CADJPY_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_UP_S2> CADJPY_OOFE_OCO1_UP_S2_6 ;
        
        public static CADJPY_OCO1_UP_S2 CADJPY_PFO_OCO1_UP_S2_1 ;
        public static CADJPY_OCO1_UP_S2 CADJPY_PFO_OCO1_UP_S2_2 ;
        public static CADJPY_OCO1_UP_S2 CADJPY_PFO_OCO1_UP_S2_3 ;
        public static CADJPY_OCO1_UP_S2 CADJPY_PFO_OCO1_UP_S2_4 ;
        public static CADJPY_OCO1_UP_S2 CADJPY_PFO_OCO1_UP_S2_5 ;
        public static CADJPY_OCO1_UP_S2 CADJPY_PFO_OCO1_UP_S2_6 ;
        
        public static List<CADJPY_OCO1_UP_S2> CADJPY_UP_S2_OCO1Sets1 = new List<CADJPY_OCO1_UP_S2>();
        public static List<CADJPY_OCO1_UP_S2> CADJPY_UP_S2_OCO1Sets2 = new List<CADJPY_OCO1_UP_S2>();
        public static List<CADJPY_OCO1_UP_S2> CADJPY_UP_S2_OCO1Sets3 = new List<CADJPY_OCO1_UP_S2>();
        public static List<CADJPY_OCO1_UP_S2> CADJPY_UP_S2_OCO1Sets4 = new List<CADJPY_OCO1_UP_S2>();
        public static List<CADJPY_OCO1_UP_S2> CADJPY_UP_S2_OCO1Sets5 = new List<CADJPY_OCO1_UP_S2>();
        public static List<CADJPY_OCO1_UP_S2> CADJPY_UP_S2_OCO1Sets6 = new List<CADJPY_OCO1_UP_S2>();
        
        public static bool CADJPY_OCO1_UP_S2_IsReady = true;
        public static bool CADJPY_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket CADJPY_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO1_MO6_DOWN_S2 ;
    	
    	public static int CADJPY_OCO1_EO1_DOWN_S2_ID ;
        public static int CADJPY_OCO1_EO2_DOWN_S2_ID ;
        public static int CADJPY_OCO1_EO3_DOWN_S2_ID ;
        public static int CADJPY_OCO1_EO4_DOWN_S2_ID ;
        public static int CADJPY_OCO1_EO5_DOWN_S2_ID ;
        public static int CADJPY_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool CADJPY_OCO1_EO1_DOWN_S2 ;
        public static bool CADJPY_OCO1_EO2_DOWN_S2 ;
        public static bool CADJPY_OCO1_EO3_DOWN_S2 ;
        public static bool CADJPY_OCO1_EO4_DOWN_S2 ;
        public static bool CADJPY_OCO1_EO5_DOWN_S2 ;
        public static bool CADJPY_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_DOWN_S2> CADJPY_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_DOWN_S2> CADJPY_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_DOWN_S2> CADJPY_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_DOWN_S2> CADJPY_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_DOWN_S2> CADJPY_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO1_DOWN_S2> CADJPY_OOFE_OCO1_DOWN_S2_6 ;
        
        public static CADJPY_OCO1_DOWN_S2 CADJPY_PFO_OCO1_DOWN_S2_1 ;
        public static CADJPY_OCO1_DOWN_S2 CADJPY_PFO_OCO1_DOWN_S2_2 ;
        public static CADJPY_OCO1_DOWN_S2 CADJPY_PFO_OCO1_DOWN_S2_3 ;
        public static CADJPY_OCO1_DOWN_S2 CADJPY_PFO_OCO1_DOWN_S2_4 ;
        public static CADJPY_OCO1_DOWN_S2 CADJPY_PFO_OCO1_DOWN_S2_5 ;
        public static CADJPY_OCO1_DOWN_S2 CADJPY_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<CADJPY_OCO1_DOWN_S2> CADJPY_DOWN_S2_OCO1Sets1 = new List<CADJPY_OCO1_DOWN_S2>();
        public static List<CADJPY_OCO1_DOWN_S2> CADJPY_DOWN_S2_OCO1Sets2 = new List<CADJPY_OCO1_DOWN_S2>();
        public static List<CADJPY_OCO1_DOWN_S2> CADJPY_DOWN_S2_OCO1Sets3 = new List<CADJPY_OCO1_DOWN_S2>();
        public static List<CADJPY_OCO1_DOWN_S2> CADJPY_DOWN_S2_OCO1Sets4 = new List<CADJPY_OCO1_DOWN_S2>();
        public static List<CADJPY_OCO1_DOWN_S2> CADJPY_DOWN_S2_OCO1Sets5 = new List<CADJPY_OCO1_DOWN_S2>();
        public static List<CADJPY_OCO1_DOWN_S2> CADJPY_DOWN_S2_OCO1Sets6 = new List<CADJPY_OCO1_DOWN_S2>();
        
        public static bool CADJPY_OCO1_DOWN_S2_IsReady = true;
        public static bool CADJPY_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket CADJPY_OCO2_MO1_UP_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO2_UP_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO3_UP_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO4_UP_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO5_UP_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO6_UP_S2 ;
    	
    	public static int CADJPY_OCO2_EO1_UP_S2_ID ;
        public static int CADJPY_OCO2_EO2_UP_S2_ID ;
        public static int CADJPY_OCO2_EO3_UP_S2_ID ;
        public static int CADJPY_OCO2_EO4_UP_S2_ID ;
        public static int CADJPY_OCO2_EO5_UP_S2_ID ;
        public static int CADJPY_OCO2_EO6_UP_S2_ID ;
        
        public static bool CADJPY_OCO2_EO1_UP_S2 ;
        public static bool CADJPY_OCO2_EO2_UP_S2 ;
        public static bool CADJPY_OCO2_EO3_UP_S2 ;
        public static bool CADJPY_OCO2_EO4_UP_S2 ;
        public static bool CADJPY_OCO2_EO5_UP_S2 ;
        public static bool CADJPY_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_UP_S2> CADJPY_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_UP_S2> CADJPY_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_UP_S2> CADJPY_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_UP_S2> CADJPY_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_UP_S2> CADJPY_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_UP_S2> CADJPY_OOFE_OCO2_UP_S2_6 ;
        
        public static CADJPY_OCO2_UP_S2 CADJPY_PFO_OCO2_UP_S2_1 ;
        public static CADJPY_OCO2_UP_S2 CADJPY_PFO_OCO2_UP_S2_2 ;
        public static CADJPY_OCO2_UP_S2 CADJPY_PFO_OCO2_UP_S2_3 ;
        public static CADJPY_OCO2_UP_S2 CADJPY_PFO_OCO2_UP_S2_4 ;
        public static CADJPY_OCO2_UP_S2 CADJPY_PFO_OCO2_UP_S2_5 ;
        public static CADJPY_OCO2_UP_S2 CADJPY_PFO_OCO2_UP_S2_6 ;
        
        public static List<CADJPY_OCO2_UP_S2> CADJPY_UP_S2_OCO2Sets1 = new List<CADJPY_OCO2_UP_S2>();
        public static List<CADJPY_OCO2_UP_S2> CADJPY_UP_S2_OCO2Sets2 = new List<CADJPY_OCO2_UP_S2>();
        public static List<CADJPY_OCO2_UP_S2> CADJPY_UP_S2_OCO2Sets3 = new List<CADJPY_OCO2_UP_S2>();
        public static List<CADJPY_OCO2_UP_S2> CADJPY_UP_S2_OCO2Sets4 = new List<CADJPY_OCO2_UP_S2>();
        public static List<CADJPY_OCO2_UP_S2> CADJPY_UP_S2_OCO2Sets5 = new List<CADJPY_OCO2_UP_S2>();
        public static List<CADJPY_OCO2_UP_S2> CADJPY_UP_S2_OCO2Sets6 = new List<CADJPY_OCO2_UP_S2>();
        
        public static bool CADJPY_OCO2_UP_S2_IsReady = true;
        public static bool CADJPY_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket CADJPY_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO2_MO6_DOWN_S2 ;
    	
    	public static int CADJPY_OCO2_EO1_DOWN_S2_ID ;
        public static int CADJPY_OCO2_EO2_DOWN_S2_ID ;
        public static int CADJPY_OCO2_EO3_DOWN_S2_ID ;
        public static int CADJPY_OCO2_EO4_DOWN_S2_ID ;
        public static int CADJPY_OCO2_EO5_DOWN_S2_ID ;
        public static int CADJPY_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool CADJPY_OCO2_EO1_DOWN_S2 ;
        public static bool CADJPY_OCO2_EO2_DOWN_S2 ;
        public static bool CADJPY_OCO2_EO3_DOWN_S2 ;
        public static bool CADJPY_OCO2_EO4_DOWN_S2 ;
        public static bool CADJPY_OCO2_EO5_DOWN_S2 ;
        public static bool CADJPY_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_DOWN_S2> CADJPY_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_DOWN_S2> CADJPY_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_DOWN_S2> CADJPY_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_DOWN_S2> CADJPY_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_DOWN_S2> CADJPY_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO2_DOWN_S2> CADJPY_OOFE_OCO2_DOWN_S2_6 ;
        
        public static CADJPY_OCO2_DOWN_S2 CADJPY_PFO_OCO2_DOWN_S2_1 ;
        public static CADJPY_OCO2_DOWN_S2 CADJPY_PFO_OCO2_DOWN_S2_2 ;
        public static CADJPY_OCO2_DOWN_S2 CADJPY_PFO_OCO2_DOWN_S2_3 ;
        public static CADJPY_OCO2_DOWN_S2 CADJPY_PFO_OCO2_DOWN_S2_4 ;
        public static CADJPY_OCO2_DOWN_S2 CADJPY_PFO_OCO2_DOWN_S2_5 ;
        public static CADJPY_OCO2_DOWN_S2 CADJPY_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<CADJPY_OCO2_DOWN_S2> CADJPY_DOWN_S2_OCO2Sets1 = new List<CADJPY_OCO2_DOWN_S2>();
        public static List<CADJPY_OCO2_DOWN_S2> CADJPY_DOWN_S2_OCO2Sets2 = new List<CADJPY_OCO2_DOWN_S2>();
        public static List<CADJPY_OCO2_DOWN_S2> CADJPY_DOWN_S2_OCO2Sets3 = new List<CADJPY_OCO2_DOWN_S2>();
        public static List<CADJPY_OCO2_DOWN_S2> CADJPY_DOWN_S2_OCO2Sets4 = new List<CADJPY_OCO2_DOWN_S2>();
        public static List<CADJPY_OCO2_DOWN_S2> CADJPY_DOWN_S2_OCO2Sets5 = new List<CADJPY_OCO2_DOWN_S2>();
        public static List<CADJPY_OCO2_DOWN_S2> CADJPY_DOWN_S2_OCO2Sets6 = new List<CADJPY_OCO2_DOWN_S2>();
        
        public static bool CADJPY_OCO2_DOWN_S2_IsReady = true;
        public static bool CADJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket CADJPY_OCO3_MO1_UP_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO2_UP_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO3_UP_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO4_UP_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO5_UP_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO6_UP_S2 ;
    	
    	public static int CADJPY_OCO3_EO1_UP_S2_ID ;
        public static int CADJPY_OCO3_EO2_UP_S2_ID ;
        public static int CADJPY_OCO3_EO3_UP_S2_ID ;
        public static int CADJPY_OCO3_EO4_UP_S2_ID ;
        public static int CADJPY_OCO3_EO5_UP_S2_ID ;
        public static int CADJPY_OCO3_EO6_UP_S2_ID ;
        
        public static bool CADJPY_OCO3_EO1_UP_S2 ;
        public static bool CADJPY_OCO3_EO2_UP_S2 ;
        public static bool CADJPY_OCO3_EO3_UP_S2 ;
        public static bool CADJPY_OCO3_EO4_UP_S2 ;
        public static bool CADJPY_OCO3_EO5_UP_S2 ;
        public static bool CADJPY_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_UP_S2> CADJPY_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_UP_S2> CADJPY_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_UP_S2> CADJPY_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_UP_S2> CADJPY_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_UP_S2> CADJPY_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_UP_S2> CADJPY_OOFE_OCO3_UP_S2_6 ;
        
        public static CADJPY_OCO3_UP_S2 CADJPY_PFO_OCO3_UP_S2_1 ;
        public static CADJPY_OCO3_UP_S2 CADJPY_PFO_OCO3_UP_S2_2 ;
        public static CADJPY_OCO3_UP_S2 CADJPY_PFO_OCO3_UP_S2_3 ;
        public static CADJPY_OCO3_UP_S2 CADJPY_PFO_OCO3_UP_S2_4 ;
        public static CADJPY_OCO3_UP_S2 CADJPY_PFO_OCO3_UP_S2_5 ;
        public static CADJPY_OCO3_UP_S2 CADJPY_PFO_OCO3_UP_S2_6 ;
        
        public static List<CADJPY_OCO3_UP_S2> CADJPY_UP_S2_OCO3Sets1 = new List<CADJPY_OCO3_UP_S2>();
        public static List<CADJPY_OCO3_UP_S2> CADJPY_UP_S2_OCO3Sets2 = new List<CADJPY_OCO3_UP_S2>();
        public static List<CADJPY_OCO3_UP_S2> CADJPY_UP_S2_OCO3Sets3 = new List<CADJPY_OCO3_UP_S2>();
        public static List<CADJPY_OCO3_UP_S2> CADJPY_UP_S2_OCO3Sets4 = new List<CADJPY_OCO3_UP_S2>();
        public static List<CADJPY_OCO3_UP_S2> CADJPY_UP_S2_OCO3Sets5 = new List<CADJPY_OCO3_UP_S2>();
        public static List<CADJPY_OCO3_UP_S2> CADJPY_UP_S2_OCO3Sets6 = new List<CADJPY_OCO3_UP_S2>();
        
        public static bool CADJPY_OCO3_UP_S2_IsReady = true;
        public static bool CADJPY_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket CADJPY_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO3_MO6_DOWN_S2 ;
    	
    	public static int CADJPY_OCO3_EO1_DOWN_S2_ID ;
        public static int CADJPY_OCO3_EO2_DOWN_S2_ID ;
        public static int CADJPY_OCO3_EO3_DOWN_S2_ID ;
        public static int CADJPY_OCO3_EO4_DOWN_S2_ID ;
        public static int CADJPY_OCO3_EO5_DOWN_S2_ID ;
        public static int CADJPY_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool CADJPY_OCO3_EO1_DOWN_S2 ;
        public static bool CADJPY_OCO3_EO2_DOWN_S2 ;
        public static bool CADJPY_OCO3_EO3_DOWN_S2 ;
        public static bool CADJPY_OCO3_EO4_DOWN_S2 ;
        public static bool CADJPY_OCO3_EO5_DOWN_S2 ;
        public static bool CADJPY_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_DOWN_S2> CADJPY_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_DOWN_S2> CADJPY_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_DOWN_S2> CADJPY_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_DOWN_S2> CADJPY_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_DOWN_S2> CADJPY_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO3_DOWN_S2> CADJPY_OOFE_OCO3_DOWN_S2_6 ;
        
        public static CADJPY_OCO3_DOWN_S2 CADJPY_PFO_OCO3_DOWN_S2_1 ;
        public static CADJPY_OCO3_DOWN_S2 CADJPY_PFO_OCO3_DOWN_S2_2 ;
        public static CADJPY_OCO3_DOWN_S2 CADJPY_PFO_OCO3_DOWN_S2_3 ;
        public static CADJPY_OCO3_DOWN_S2 CADJPY_PFO_OCO3_DOWN_S2_4 ;
        public static CADJPY_OCO3_DOWN_S2 CADJPY_PFO_OCO3_DOWN_S2_5 ;
        public static CADJPY_OCO3_DOWN_S2 CADJPY_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<CADJPY_OCO3_DOWN_S2> CADJPY_DOWN_S2_OCO3Sets1 = new List<CADJPY_OCO3_DOWN_S2>();
        public static List<CADJPY_OCO3_DOWN_S2> CADJPY_DOWN_S2_OCO3Sets2 = new List<CADJPY_OCO3_DOWN_S2>();
        public static List<CADJPY_OCO3_DOWN_S2> CADJPY_DOWN_S2_OCO3Sets3 = new List<CADJPY_OCO3_DOWN_S2>();
        public static List<CADJPY_OCO3_DOWN_S2> CADJPY_DOWN_S2_OCO3Sets4 = new List<CADJPY_OCO3_DOWN_S2>();
        public static List<CADJPY_OCO3_DOWN_S2> CADJPY_DOWN_S2_OCO3Sets5 = new List<CADJPY_OCO3_DOWN_S2>();
        public static List<CADJPY_OCO3_DOWN_S2> CADJPY_DOWN_S2_OCO3Sets6 = new List<CADJPY_OCO3_DOWN_S2>();
        
        public static bool CADJPY_OCO3_DOWN_S2_IsReady = true;
        public static bool CADJPY_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket CADJPY_OCO4_MO1_UP_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO2_UP_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO3_UP_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO4_UP_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO5_UP_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO6_UP_S2 ;
    	
    	public static int CADJPY_OCO4_EO1_UP_S2_ID ;
        public static int CADJPY_OCO4_EO2_UP_S2_ID ;
        public static int CADJPY_OCO4_EO3_UP_S2_ID ;
        public static int CADJPY_OCO4_EO4_UP_S2_ID ;
        public static int CADJPY_OCO4_EO5_UP_S2_ID ;
        public static int CADJPY_OCO4_EO6_UP_S2_ID ;
        
        public static bool CADJPY_OCO4_EO1_UP_S2 ;
        public static bool CADJPY_OCO4_EO2_UP_S2 ;
        public static bool CADJPY_OCO4_EO3_UP_S2 ;
        public static bool CADJPY_OCO4_EO4_UP_S2 ;
        public static bool CADJPY_OCO4_EO5_UP_S2 ;
        public static bool CADJPY_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_UP_S2> CADJPY_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_UP_S2> CADJPY_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_UP_S2> CADJPY_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_UP_S2> CADJPY_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_UP_S2> CADJPY_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_UP_S2> CADJPY_OOFE_OCO4_UP_S2_6 ;
        
        public static CADJPY_OCO4_UP_S2 CADJPY_PFO_OCO4_UP_S2_1 ;
        public static CADJPY_OCO4_UP_S2 CADJPY_PFO_OCO4_UP_S2_2 ;
        public static CADJPY_OCO4_UP_S2 CADJPY_PFO_OCO4_UP_S2_3 ;
        public static CADJPY_OCO4_UP_S2 CADJPY_PFO_OCO4_UP_S2_4 ;
        public static CADJPY_OCO4_UP_S2 CADJPY_PFO_OCO4_UP_S2_5 ;
        public static CADJPY_OCO4_UP_S2 CADJPY_PFO_OCO4_UP_S2_6 ;
        
        public static List<CADJPY_OCO4_UP_S2> CADJPY_UP_S2_OCO4Sets1 = new List<CADJPY_OCO4_UP_S2>();
        public static List<CADJPY_OCO4_UP_S2> CADJPY_UP_S2_OCO4Sets2 = new List<CADJPY_OCO4_UP_S2>();
        public static List<CADJPY_OCO4_UP_S2> CADJPY_UP_S2_OCO4Sets3 = new List<CADJPY_OCO4_UP_S2>();
        public static List<CADJPY_OCO4_UP_S2> CADJPY_UP_S2_OCO4Sets4 = new List<CADJPY_OCO4_UP_S2>();
        public static List<CADJPY_OCO4_UP_S2> CADJPY_UP_S2_OCO4Sets5 = new List<CADJPY_OCO4_UP_S2>();
        public static List<CADJPY_OCO4_UP_S2> CADJPY_UP_S2_OCO4Sets6 = new List<CADJPY_OCO4_UP_S2>();
        
        public static bool CADJPY_OCO4_UP_S2_IsReady = true;
        public static bool CADJPY_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket CADJPY_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket CADJPY_OCO4_MO6_DOWN_S2 ;
    	
    	public static int CADJPY_OCO4_EO1_DOWN_S2_ID ;
        public static int CADJPY_OCO4_EO2_DOWN_S2_ID ;
        public static int CADJPY_OCO4_EO3_DOWN_S2_ID ;
        public static int CADJPY_OCO4_EO4_DOWN_S2_ID ;
        public static int CADJPY_OCO4_EO5_DOWN_S2_ID ;
        public static int CADJPY_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool CADJPY_OCO4_EO1_DOWN_S2 ;
        public static bool CADJPY_OCO4_EO2_DOWN_S2 ;
        public static bool CADJPY_OCO4_EO3_DOWN_S2 ;
        public static bool CADJPY_OCO4_EO4_DOWN_S2 ;
        public static bool CADJPY_OCO4_EO5_DOWN_S2 ;
        public static bool CADJPY_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_DOWN_S2> CADJPY_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_DOWN_S2> CADJPY_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_DOWN_S2> CADJPY_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_DOWN_S2> CADJPY_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_DOWN_S2> CADJPY_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, CADJPY_OCO4_DOWN_S2> CADJPY_OOFE_OCO4_DOWN_S2_6 ;
        
        public static CADJPY_OCO4_DOWN_S2 CADJPY_PFO_OCO4_DOWN_S2_1 ;
        public static CADJPY_OCO4_DOWN_S2 CADJPY_PFO_OCO4_DOWN_S2_2 ;
        public static CADJPY_OCO4_DOWN_S2 CADJPY_PFO_OCO4_DOWN_S2_3 ;
        public static CADJPY_OCO4_DOWN_S2 CADJPY_PFO_OCO4_DOWN_S2_4 ;
        public static CADJPY_OCO4_DOWN_S2 CADJPY_PFO_OCO4_DOWN_S2_5 ;
        public static CADJPY_OCO4_DOWN_S2 CADJPY_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<CADJPY_OCO4_DOWN_S2> CADJPY_DOWN_S2_OCO4Sets1 = new List<CADJPY_OCO4_DOWN_S2>();
        public static List<CADJPY_OCO4_DOWN_S2> CADJPY_DOWN_S2_OCO4Sets2 = new List<CADJPY_OCO4_DOWN_S2>();
        public static List<CADJPY_OCO4_DOWN_S2> CADJPY_DOWN_S2_OCO4Sets3 = new List<CADJPY_OCO4_DOWN_S2>();
        public static List<CADJPY_OCO4_DOWN_S2> CADJPY_DOWN_S2_OCO4Sets4 = new List<CADJPY_OCO4_DOWN_S2>();
        public static List<CADJPY_OCO4_DOWN_S2> CADJPY_DOWN_S2_OCO4Sets5 = new List<CADJPY_OCO4_DOWN_S2>();
        public static List<CADJPY_OCO4_DOWN_S2> CADJPY_DOWN_S2_OCO4Sets6 = new List<CADJPY_OCO4_DOWN_S2>();
        
        public static bool CADJPY_OCO4_DOWN_S2_IsReady = true;
        public static bool CADJPY_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal CADJPY_UP_S2_SL {get; set;}
		public static decimal CADJPY_UP_S2_TP1 {get; set;}
		public static decimal CADJPY_UP_S2_TP2 {get; set;}
		public static decimal CADJPY_UP_S2_TP3 {get; set;}
		public static decimal CADJPY_UP_S2_TP4 {get; set;}
		public static decimal CADJPY_UP_S2_TP5 {get; set;}
		public static decimal CADJPY_UP_S2_TP6 {get; set;}
		
		public static decimal CADJPY_DOWN_S2_SL {get; set;}
		public static decimal CADJPY_DOWN_S2_TP1 {get; set;}
		public static decimal CADJPY_DOWN_S2_TP2 {get; set;}
		public static decimal CADJPY_DOWN_S2_TP3 {get; set;}
		public static decimal CADJPY_DOWN_S2_TP4 {get; set;}
		public static decimal CADJPY_DOWN_S2_TP5 {get; set;}
		public static decimal CADJPY_DOWN_S2_TP6 {get; set;}

        public static bool CADJPY_Signal_Condition_UP_1 ;
        public static bool CADJPY_Signal_Condition_UP_2 ;        
        public static bool CADJPY_Signal_Condition_UP_3 ;
        
        public static bool CADJPY_Signal_Condition_DOWN_1 ;
        public static bool CADJPY_Signal_Condition_DOWN_2 ;
        public static bool CADJPY_Signal_Condition_DOWN_3 ;
        
        public static int CADJPY_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int CADJPY_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int CADJPY_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int CADJPY_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int CADJPY_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int CADJPY_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int CADJPY_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int CADJPY_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int CADJPY_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int CADJPY_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_CADJPY_UP_S2 ;
        public static bool DOWM_CADJPY_UP_S2 ;
        public static bool DOWT_CADJPY_UP_S2 ;
        public static bool DOWW_CADJPY_UP_S2 ;
        public static bool DOWTH_CADJPY_UP_S2 ;
        
		public static bool DOWR_CADJPY_DOWN_S2 ;
        public static bool DOWM_CADJPY_DOWN_S2 ;
        public static bool DOWT_CADJPY_DOWN_S2 ;
        public static bool DOWW_CADJPY_DOWN_S2 ;
        public static bool DOWTH_CADJPY_DOWN_S2 ;
        
        
		public static int CADJPY_quantity_UP_S2 ;
		public static int CADJPY_quantity_SL_UP_S2 ;
		public static int CADJPY_quantity_TP1_UP_S2 ;
		public static int CADJPY_quantity_TP2_UP_S2 ;
		public static int CADJPY_quantity_TP3_UP_S2 ;
		public static int CADJPY_quantity_TP4_UP_S2 ;
		public static int CADJPY_quantity_TP5_UP_S2;
		public static int CADJPY_quantity_TP6_UP_S2 ;
		
		public static int CADJPY_quantity_DOWN_S2 ;
		public static int CADJPY_quantity_SL_DOWN_S2 ;
		public static int CADJPY_quantity_TP1_DOWN_S2 ;
		public static int CADJPY_quantity_TP2_DOWN_S2 ;
		public static int CADJPY_quantity_TP3_DOWN_S2 ;
		public static int CADJPY_quantity_TP4_DOWN_S2 ;
		public static int CADJPY_quantity_TP5_DOWN_S2;
		public static int CADJPY_quantity_TP6_DOWN_S2 ;
    }
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct GBPNZD_OCO1_DOWN_S2
    {
        public GBPNZD_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 =="TP1_GBPNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD 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 =="TP1_GBPNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD 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 GBPNZD_OCO1_UP_S2
    {
        public GBPNZD_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 =="TP1_GBPNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD 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 =="TP1_GBPNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPNZD 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 GBPNZD_OCO2_DOWN_S2
    {
        public GBPNZD_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 =="TP1_GBPNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD 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 =="TP1_GBPNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD 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 GBPNZD_OCO2_UP_S2
    {
        public GBPNZD_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 =="TP1_GBPNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD 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 =="TP1_GBPNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPNZD 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 GBPNZD_OCO3_DOWN_S2
    {
        public GBPNZD_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 =="TP1_GBPNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD 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 =="TP1_GBPNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD 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 GBPNZD_OCO3_UP_S2
    {
        public GBPNZD_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 =="TP1_GBPNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD 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 =="TP1_GBPNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPNZD 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 GBPNZD_OCO4_DOWN_S2
    {
        public GBPNZD_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 =="TP1_GBPNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD 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 =="TP1_GBPNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD 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 GBPNZD_OCO4_UP_S2
    {
        public GBPNZD_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 =="TP1_GBPNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD 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 =="TP1_GBPNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPNZD 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;

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;
    }
}
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 GBPAUD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPAUD_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("GBPAUD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPAUD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPAUD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPAUD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPAUD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPAUD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPAUD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        }
		        
				if (Base.GBPAUD_OCO1_EO1_UP_S2)
	                Base.GBPAUD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPAUD_OCO1_EO2_UP_S2)
	                Base.GBPAUD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO1_EO3_UP_S2)
	                Base.GBPAUD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO1_EO4_UP_S2)
	                Base.GBPAUD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO1_EO5_UP_S2)
	                Base.GBPAUD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO1_EO6_UP_S2)
	                Base.GBPAUD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.GBPAUD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP1,"TP1_GBPAUD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP1_GBPAUD_UP_S2_OCO1"));
		                 };
		                Base.GBPAUD_UP_S2_OCO1Sets1.Add( Base.GBPAUD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP2,"TP2_GBPAUD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP2_GBPAUD_UP_S2_OCO1"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO1Sets2.Add( Base.GBPAUD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP3,"TP3_GBPAUD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP3_GBPAUD_UP_S2_OCO1"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO1Sets3.Add( Base.GBPAUD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP4,"TP4_GBPAUD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP4_GBPAUD_UP_S2_OCO1"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO1Sets4.Add( Base.GBPAUD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP5,"TP5_GBPAUD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP5_GBPAUD_UP_S2_OCO1"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO1Sets5.Add( Base.GBPAUD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP6,"TP6_GBPAUD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP6_GBPAUD_UP_S2_OCO1"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO1Sets6.Add( Base.GBPAUD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPAUD_OCO1S1_UP_S2 = 0;
	                for (; GBPAUD_OCO1S1_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets1.Count; GBPAUD_OCO1S1_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO1Sets1[GBPAUD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO1Sets1[GBPAUD_OCO1S1_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO1Sets1.RemoveAt(GBPAUD_OCO1S1_UP_S2);
	                        GBPAUD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPAUD_OCO1S2_UP_S2 = 0;
	                for (; GBPAUD_OCO1S2_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets2.Count; GBPAUD_OCO1S2_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO1Sets2[GBPAUD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO1Sets2[GBPAUD_OCO1S2_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO1Sets2.RemoveAt(GBPAUD_OCO1S2_UP_S2);
	                        GBPAUD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO1S3_UP_S2 = 0;
	                for (; GBPAUD_OCO1S3_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets3.Count; GBPAUD_OCO1S3_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO1Sets3[GBPAUD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO1Sets3[GBPAUD_OCO1S3_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO1Sets3.RemoveAt(GBPAUD_OCO1S3_UP_S2);
	                        GBPAUD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO1S4_UP_S2 = 0;
	                for (; GBPAUD_OCO1S4_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets4.Count; GBPAUD_OCO1S4_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO1Sets4[GBPAUD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO1Sets4[GBPAUD_OCO1S4_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO1Sets4.RemoveAt(GBPAUD_OCO1S4_UP_S2);
	                        GBPAUD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPAUD_OCO1S5_UP_S2 = 0;
	                for (; GBPAUD_OCO1S5_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets5.Count; GBPAUD_OCO1S5_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO1Sets5[GBPAUD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO1Sets5[GBPAUD_OCO1S5_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO1Sets5.RemoveAt(GBPAUD_OCO1S5_UP_S2);
	                        GBPAUD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPAUD_OCO1S6_UP_S2 = 0;
	                for (; GBPAUD_OCO1S6_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets6.Count; GBPAUD_OCO1S6_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO1Sets6[GBPAUD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO1Sets6[GBPAUD_OCO1S6_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO1Sets6.RemoveAt(GBPAUD_OCO1S6_UP_S2);
	                        GBPAUD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.GBPAUD_OCO2_EO1_UP_S2)
	                Base.GBPAUD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPAUD_OCO2_EO2_UP_S2)
	                Base.GBPAUD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO2_EO3_UP_S2)
	                Base.GBPAUD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO2_EO4_UP_S2)
	                Base.GBPAUD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO2_EO5_UP_S2)
	                Base.GBPAUD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO2_EO6_UP_S2)
	                Base.GBPAUD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.GBPAUD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP1,"TP1_GBPAUD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP1_GBPAUD_UP_S2_OCO2"));
		                 };
		                Base.GBPAUD_UP_S2_OCO2Sets1.Add( Base.GBPAUD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP2,"TP2_GBPAUD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP2_GBPAUD_UP_S2_OCO2"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO2Sets2.Add( Base.GBPAUD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP3,"TP3_GBPAUD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP3_GBPAUD_UP_S2_OCO2"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO2Sets3.Add( Base.GBPAUD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP4,"TP4_GBPAUD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP4_GBPAUD_UP_S2_OCO2"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO2Sets4.Add( Base.GBPAUD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP5,"TP5_GBPAUD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP5_GBPAUD_UP_S2_OCO2"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO2Sets5.Add( Base.GBPAUD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP6,"TP6_GBPAUD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP6_GBPAUD_UP_S2_OCO2"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO2Sets6.Add( Base.GBPAUD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPAUD_OCO2S1_UP_S2 = 0;
	                for (; GBPAUD_OCO2S1_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets1.Count; GBPAUD_OCO2S1_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO2Sets1[GBPAUD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO2Sets1[GBPAUD_OCO2S1_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO2Sets1.RemoveAt(GBPAUD_OCO2S1_UP_S2);
	                        GBPAUD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPAUD_OCO2S2_UP_S2 = 0;
	                for (; GBPAUD_OCO2S2_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets2.Count; GBPAUD_OCO2S2_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO2Sets2[GBPAUD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO2Sets2[GBPAUD_OCO2S2_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO2Sets2.RemoveAt(GBPAUD_OCO2S2_UP_S2);
	                        GBPAUD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO2S3_UP_S2 = 0;
	                for (; GBPAUD_OCO2S3_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets3.Count; GBPAUD_OCO2S3_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO2Sets3[GBPAUD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO2Sets3[GBPAUD_OCO2S3_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO2Sets3.RemoveAt(GBPAUD_OCO2S3_UP_S2);
	                        GBPAUD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO2S4_UP_S2 = 0;
	                for (; GBPAUD_OCO2S4_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets4.Count; GBPAUD_OCO2S4_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO2Sets4[GBPAUD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO2Sets4[GBPAUD_OCO2S4_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO2Sets4.RemoveAt(GBPAUD_OCO2S4_UP_S2);
	                        GBPAUD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPAUD_OCO2S5_UP_S2 = 0;
	                for (; GBPAUD_OCO2S5_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets5.Count; GBPAUD_OCO2S5_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO2Sets5[GBPAUD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO2Sets5[GBPAUD_OCO2S5_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO2Sets5.RemoveAt(GBPAUD_OCO2S5_UP_S2);
	                        GBPAUD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPAUD_OCO2S6_UP_S2 = 0;
	                for (; GBPAUD_OCO2S6_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets6.Count; GBPAUD_OCO2S6_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO2Sets6[GBPAUD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO2Sets6[GBPAUD_OCO2S6_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO2Sets6.RemoveAt(GBPAUD_OCO2S6_UP_S2);
	                        GBPAUD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPAUD_OCO3_EO1_UP_S2)
	                Base.GBPAUD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPAUD_OCO3_EO2_UP_S2)
	                Base.GBPAUD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO3_EO3_UP_S2)
	                Base.GBPAUD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO3_EO4_UP_S2)
	                Base.GBPAUD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO3_EO5_UP_S2)
	                Base.GBPAUD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO3_EO6_UP_S2)
	                Base.GBPAUD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.GBPAUD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP1,"TP1_GBPAUD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP1_GBPAUD_UP_S2_OCO3"));
		                 };
		                Base.GBPAUD_UP_S2_OCO3Sets1.Add( Base.GBPAUD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP2,"TP2_GBPAUD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP2_GBPAUD_UP_S2_OCO3"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO3Sets2.Add( Base.GBPAUD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP3,"TP3_GBPAUD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP3_GBPAUD_UP_S2_OCO3"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO3Sets3.Add( Base.GBPAUD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP4,"TP4_GBPAUD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP4_GBPAUD_UP_S2_OCO3"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO3Sets4.Add( Base.GBPAUD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP5,"TP5_GBPAUD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP5_GBPAUD_UP_S2_OCO3"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO3Sets5.Add( Base.GBPAUD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP6,"TP6_GBPAUD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP6_GBPAUD_UP_S2_OCO3"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO3Sets6.Add( Base.GBPAUD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPAUD_OCO3S1_UP_S2 = 0;
	                for (; GBPAUD_OCO3S1_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets1.Count; GBPAUD_OCO3S1_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO3Sets1[GBPAUD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO3Sets1[GBPAUD_OCO3S1_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO3Sets1.RemoveAt(GBPAUD_OCO3S1_UP_S2);
	                        GBPAUD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPAUD_OCO3S2_UP_S2 = 0;
	                for (; GBPAUD_OCO3S2_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets2.Count; GBPAUD_OCO3S2_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO3Sets2[GBPAUD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO3Sets2[GBPAUD_OCO3S2_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO3Sets2.RemoveAt(GBPAUD_OCO3S2_UP_S2);
	                        GBPAUD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO3S3_UP_S2 = 0;
	                for (; GBPAUD_OCO3S3_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets3.Count; GBPAUD_OCO3S3_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO3Sets3[GBPAUD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO3Sets3[GBPAUD_OCO3S3_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO3Sets3.RemoveAt(GBPAUD_OCO3S3_UP_S2);
	                        GBPAUD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO3S4_UP_S2 = 0;
	                for (; GBPAUD_OCO3S4_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets4.Count; GBPAUD_OCO3S4_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO3Sets4[GBPAUD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO3Sets4[GBPAUD_OCO3S4_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO3Sets4.RemoveAt(GBPAUD_OCO3S4_UP_S2);
	                        GBPAUD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPAUD_OCO3S5_UP_S2 = 0;
	                for (; GBPAUD_OCO3S5_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets5.Count; GBPAUD_OCO3S5_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO3Sets5[GBPAUD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO3Sets5[GBPAUD_OCO3S5_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO3Sets5.RemoveAt(GBPAUD_OCO3S5_UP_S2);
	                        GBPAUD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPAUD_OCO3S6_UP_S2 = 0;
	                for (; GBPAUD_OCO3S6_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets6.Count; GBPAUD_OCO3S6_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO3Sets6[GBPAUD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO3Sets6[GBPAUD_OCO3S6_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO3Sets6.RemoveAt(GBPAUD_OCO3S6_UP_S2);
	                        GBPAUD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPAUD_OCO4_EO1_UP_S2)
	                Base.GBPAUD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPAUD_OCO4_EO2_UP_S2)
	                Base.GBPAUD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO4_EO3_UP_S2)
	                Base.GBPAUD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO4_EO4_UP_S2)
	                Base.GBPAUD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO4_EO5_UP_S2)
	                Base.GBPAUD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO4_EO6_UP_S2)
	                Base.GBPAUD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.GBPAUD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP1,"TP1_GBPAUD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP1_GBPAUD_UP_S2_OCO4"));
		                 };
		                Base.GBPAUD_UP_S2_OCO4Sets1.Add( Base.GBPAUD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP2,"TP2_GBPAUD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP2_GBPAUD_UP_S2_OCO4"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO4Sets2.Add( Base.GBPAUD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP3,"TP3_GBPAUD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP3_GBPAUD_UP_S2_OCO4"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO4Sets3.Add( Base.GBPAUD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP4,"TP4_GBPAUD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP4_GBPAUD_UP_S2_OCO4"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO4Sets4.Add( Base.GBPAUD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP5,"TP5_GBPAUD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP5_GBPAUD_UP_S2_OCO4"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO4Sets5.Add( Base.GBPAUD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_UP_S2_TP6,"TP6_GBPAUD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_UP_S2_SL,"SL_TP6_GBPAUD_UP_S2_OCO4"));
		                 };
	                    Base.GBPAUD_UP_S2_OCO4Sets6.Add( Base.GBPAUD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPAUD_OCO4S1_UP_S2 = 0;
	                for (; GBPAUD_OCO4S1_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets1.Count; GBPAUD_OCO4S1_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO4Sets1[GBPAUD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO4Sets1[GBPAUD_OCO4S1_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO4Sets1.RemoveAt(GBPAUD_OCO4S1_UP_S2);
	                        GBPAUD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPAUD_OCO4S2_UP_S2 = 0;
	                for (; GBPAUD_OCO4S2_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets2.Count; GBPAUD_OCO4S2_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO4Sets2[GBPAUD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO4Sets2[GBPAUD_OCO4S2_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO4Sets2.RemoveAt(GBPAUD_OCO4S2_UP_S2);
	                        GBPAUD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO4S3_UP_S2 = 0;
	                for (; GBPAUD_OCO4S3_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets3.Count; GBPAUD_OCO4S3_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO4Sets3[GBPAUD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO4Sets3[GBPAUD_OCO4S3_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO4Sets3.RemoveAt(GBPAUD_OCO4S3_UP_S2);
	                        GBPAUD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO4S4_UP_S2 = 0;
	                for (; GBPAUD_OCO4S4_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets4.Count; GBPAUD_OCO4S4_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO4Sets4[GBPAUD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO4Sets4[GBPAUD_OCO4S4_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO4Sets4.RemoveAt(GBPAUD_OCO4S4_UP_S2);
	                        GBPAUD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPAUD_OCO4S5_UP_S2 = 0;
	                for (; GBPAUD_OCO4S5_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets5.Count; GBPAUD_OCO4S5_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO4Sets5[GBPAUD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO4Sets5[GBPAUD_OCO4S5_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO4Sets5.RemoveAt(GBPAUD_OCO4S5_UP_S2);
	                        GBPAUD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPAUD_OCO4S6_UP_S2 = 0;
	                for (; GBPAUD_OCO4S6_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets6.Count; GBPAUD_OCO4S6_UP_S2++)
	                    if (Base.GBPAUD_UP_S2_OCO4Sets6[GBPAUD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_UP_S2_OCO4Sets6[GBPAUD_OCO4S6_UP_S2].Filled();
	                        Base.GBPAUD_UP_S2_OCO4Sets6.RemoveAt(GBPAUD_OCO4S6_UP_S2);
	                        GBPAUD_OCO4S6_UP_S2 = 0;
	                        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.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 GBPAUD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPAUD_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("GBPAUD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPAUD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPAUD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPAUD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPAUD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPAUD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPAUD S2");
		        	}
		        }
		        
				if (Base.GBPAUD_OCO1_EO1_DOWN_S2)
	                Base.GBPAUD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPAUD_OCO1_EO2_DOWN_S2)
	                Base.GBPAUD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO1_EO3_DOWN_S2)
	                Base.GBPAUD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO1_EO4_DOWN_S2)
	                Base.GBPAUD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPAUD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP1_GBPAUD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP1,"TP1_GBPAUD_DOWN_S2_OCO1"));
		                 };
		                Base.GBPAUD_DOWN_S2_OCO1Sets1.Add( Base.GBPAUD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP2_GBPAUD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP2,"TP2_GBPAUD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO1Sets2.Add( Base.GBPAUD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP3_GBPAUD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP3,"TP3_GBPAUD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO1Sets3.Add( Base.GBPAUD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP4_GBPAUD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP4,"TP4_GBPAUD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO1Sets4.Add( Base.GBPAUD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPAUD_OCO1S1_DOWN_S2 = 0;
	                for (; GBPAUD_OCO1S1_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets1.Count; GBPAUD_OCO1S1_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO1Sets1[GBPAUD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO1Sets1[GBPAUD_OCO1S1_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO1Sets1.RemoveAt(GBPAUD_OCO1S1_DOWN_S2);
	                        GBPAUD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPAUD_OCO1S2_DOWN_S2 = 0;
	                for (; GBPAUD_OCO1S2_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets2.Count; GBPAUD_OCO1S2_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO1Sets2[GBPAUD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO1Sets2[GBPAUD_OCO1S2_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO1Sets2.RemoveAt(GBPAUD_OCO1S2_DOWN_S2);
	                        GBPAUD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO1S3_DOWN_S2 = 0;
	                for (; GBPAUD_OCO1S3_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets3.Count; GBPAUD_OCO1S3_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO1Sets3[GBPAUD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO1Sets3[GBPAUD_OCO1S3_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO1Sets3.RemoveAt(GBPAUD_OCO1S3_DOWN_S2);
	                        GBPAUD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO1S4_DOWN_S2 = 0;
	                for (; GBPAUD_OCO1S4_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets4.Count; GBPAUD_OCO1S4_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO1Sets4[GBPAUD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO1Sets4[GBPAUD_OCO1S4_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO1Sets4.RemoveAt(GBPAUD_OCO1S4_DOWN_S2);
	                        GBPAUD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPAUD_OCO2_EO1_DOWN_S2)
	                Base.GBPAUD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPAUD_OCO2_EO2_DOWN_S2)
	                Base.GBPAUD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO2_EO3_DOWN_S2)
	                Base.GBPAUD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO2_EO4_DOWN_S2)
	                Base.GBPAUD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPAUD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP1_GBPAUD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP1,"TP1_GBPAUD_DOWN_S2_OCO2"));
		                 };
		                Base.GBPAUD_DOWN_S2_OCO2Sets1.Add( Base.GBPAUD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP2_GBPAUD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP2,"TP2_GBPAUD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO2Sets2.Add( Base.GBPAUD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP3_GBPAUD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP3,"TP3_GBPAUD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO2Sets3.Add( Base.GBPAUD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP4_GBPAUD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP4,"TP4_GBPAUD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO2Sets4.Add( Base.GBPAUD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPAUD_OCO2S1_DOWN_S2 = 0;
	                for (; GBPAUD_OCO2S1_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets1.Count; GBPAUD_OCO2S1_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO2Sets1[GBPAUD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO2Sets1[GBPAUD_OCO2S1_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO2Sets1.RemoveAt(GBPAUD_OCO2S1_DOWN_S2);
	                        GBPAUD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPAUD_OCO2S2_DOWN_S2 = 0;
	                for (; GBPAUD_OCO2S2_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets2.Count; GBPAUD_OCO2S2_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO2Sets2[GBPAUD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO2Sets2[GBPAUD_OCO2S2_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO2Sets2.RemoveAt(GBPAUD_OCO2S2_DOWN_S2);
	                        GBPAUD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO2S3_DOWN_S2 = 0;
	                for (; GBPAUD_OCO2S3_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets3.Count; GBPAUD_OCO2S3_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO2Sets3[GBPAUD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO2Sets3[GBPAUD_OCO2S3_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO2Sets3.RemoveAt(GBPAUD_OCO2S3_DOWN_S2);
	                        GBPAUD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO2S4_DOWN_S2 = 0;
	                for (; GBPAUD_OCO2S4_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets4.Count; GBPAUD_OCO2S4_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO2Sets4[GBPAUD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO2Sets4[GBPAUD_OCO2S4_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO2Sets4.RemoveAt(GBPAUD_OCO2S4_DOWN_S2);
	                        GBPAUD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPAUD_OCO3_EO1_DOWN_S2)
	                Base.GBPAUD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPAUD_OCO3_EO2_DOWN_S2)
	                Base.GBPAUD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO3_EO3_DOWN_S2)
	                Base.GBPAUD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO3_EO4_DOWN_S2)
	                Base.GBPAUD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPAUD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP1_GBPAUD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP1,"TP1_GBPAUD_DOWN_S2_OCO3"));
		                 };
		                Base.GBPAUD_DOWN_S2_OCO3Sets1.Add( Base.GBPAUD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP2_GBPAUD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP2,"TP2_GBPAUD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO3Sets2.Add( Base.GBPAUD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP3_GBPAUD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP3,"TP3_GBPAUD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO3Sets3.Add( Base.GBPAUD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP4_GBPAUD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP4,"TP4_GBPAUD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO3Sets4.Add( Base.GBPAUD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPAUD_OCO3S1_DOWN_S2 = 0;
	                for (; GBPAUD_OCO3S1_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets1.Count; GBPAUD_OCO3S1_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO3Sets1[GBPAUD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO3Sets1[GBPAUD_OCO3S1_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO3Sets1.RemoveAt(GBPAUD_OCO3S1_DOWN_S2);
	                        GBPAUD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPAUD_OCO3S2_DOWN_S2 = 0;
	                for (; GBPAUD_OCO3S2_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets2.Count; GBPAUD_OCO3S2_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO3Sets2[GBPAUD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO3Sets2[GBPAUD_OCO3S2_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO3Sets2.RemoveAt(GBPAUD_OCO3S2_DOWN_S2);
	                        GBPAUD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO3S3_DOWN_S2 = 0;
	                for (; GBPAUD_OCO3S3_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets3.Count; GBPAUD_OCO3S3_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO3Sets3[GBPAUD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO3Sets3[GBPAUD_OCO3S3_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO3Sets3.RemoveAt(GBPAUD_OCO3S3_DOWN_S2);
	                        GBPAUD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO3S4_DOWN_S2 = 0;
	                for (; GBPAUD_OCO3S4_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets4.Count; GBPAUD_OCO3S4_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO3Sets4[GBPAUD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO3Sets4[GBPAUD_OCO3S4_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO3Sets4.RemoveAt(GBPAUD_OCO3S4_DOWN_S2);
	                        GBPAUD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPAUD_OCO4_EO1_DOWN_S2)
	                Base.GBPAUD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPAUD_OCO4_EO2_DOWN_S2)
	                Base.GBPAUD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO4_EO3_DOWN_S2)
	                Base.GBPAUD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPAUD_OCO4_EO4_DOWN_S2)
	                Base.GBPAUD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPAUD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP1_GBPAUD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP1,"TP1_GBPAUD_DOWN_S2_OCO4"));
		                 };
		                Base.GBPAUD_DOWN_S2_OCO4Sets1.Add( Base.GBPAUD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP2_GBPAUD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP2,"TP2_GBPAUD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO4Sets2.Add( Base.GBPAUD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP3_GBPAUD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP3,"TP3_GBPAUD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO4Sets3.Add( Base.GBPAUD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPAUD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPAUD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPAUD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPAUD_DOWN_S2_SL,"SL_TP4_GBPAUD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPAUD_DOWN_S2_TP4,"TP4_GBPAUD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPAUD_DOWN_S2_OCO4Sets4.Add( Base.GBPAUD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPAUD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPAUD_OCO4S1_DOWN_S2 = 0;
	                for (; GBPAUD_OCO4S1_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets1.Count; GBPAUD_OCO4S1_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO4Sets1[GBPAUD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO4Sets1[GBPAUD_OCO4S1_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO4Sets1.RemoveAt(GBPAUD_OCO4S1_DOWN_S2);
	                        GBPAUD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPAUD_OCO4S2_DOWN_S2 = 0;
	                for (; GBPAUD_OCO4S2_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets2.Count; GBPAUD_OCO4S2_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO4Sets2[GBPAUD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO4Sets2[GBPAUD_OCO4S2_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO4Sets2.RemoveAt(GBPAUD_OCO4S2_DOWN_S2);
	                        GBPAUD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO4S3_DOWN_S2 = 0;
	                for (; GBPAUD_OCO4S3_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets3.Count; GBPAUD_OCO4S3_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO4Sets3[GBPAUD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO4Sets3[GBPAUD_OCO4S3_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO4Sets3.RemoveAt(GBPAUD_OCO4S3_DOWN_S2);
	                        GBPAUD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPAUD_OCO4S4_DOWN_S2 = 0;
	                for (; GBPAUD_OCO4S4_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets4.Count; GBPAUD_OCO4S4_DOWN_S2++)
	                    if (Base.GBPAUD_DOWN_S2_OCO4Sets4[GBPAUD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPAUD_DOWN_S2_OCO4Sets4[GBPAUD_OCO4S4_DOWN_S2].Filled();
	                        Base.GBPAUD_DOWN_S2_OCO4Sets4.RemoveAt(GBPAUD_OCO4S4_DOWN_S2);
	                        GBPAUD_OCO4S4_DOWN_S2 = 0;
	                        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.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 GBPJPY_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPJPY_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("GBPJPY OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPJPY OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPJPY OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPJPY OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPJPY OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPJPY OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPJPY OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        }
		        
				if (Base.GBPJPY_OCO1_EO1_UP_S2)
	                Base.GBPJPY_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPJPY_OCO1_EO2_UP_S2)
	                Base.GBPJPY_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO1_EO3_UP_S2)
	                Base.GBPJPY_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO1_EO4_UP_S2)
	                Base.GBPJPY_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO1_EO5_UP_S2)
	                Base.GBPJPY_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO1_EO6_UP_S2)
	                Base.GBPJPY_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.GBPJPY_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP1,"TP1_GBPJPY_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP1_GBPJPY_UP_S2_OCO1"));
		                 };
		                Base.GBPJPY_UP_S2_OCO1Sets1.Add( Base.GBPJPY_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP2,"TP2_GBPJPY_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP2_GBPJPY_UP_S2_OCO1"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO1Sets2.Add( Base.GBPJPY_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP3,"TP3_GBPJPY_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP3_GBPJPY_UP_S2_OCO1"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO1Sets3.Add( Base.GBPJPY_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP4,"TP4_GBPJPY_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP4_GBPJPY_UP_S2_OCO1"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO1Sets4.Add( Base.GBPJPY_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP5,"TP5_GBPJPY_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP5_GBPJPY_UP_S2_OCO1"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO1Sets5.Add( Base.GBPJPY_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP6,"TP6_GBPJPY_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP6_GBPJPY_UP_S2_OCO1"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO1Sets6.Add( Base.GBPJPY_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPJPY_OCO1S1_UP_S2 = 0;
	                for (; GBPJPY_OCO1S1_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets1.Count; GBPJPY_OCO1S1_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO1Sets1[GBPJPY_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO1Sets1[GBPJPY_OCO1S1_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO1Sets1.RemoveAt(GBPJPY_OCO1S1_UP_S2);
	                        GBPJPY_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPJPY_OCO1S2_UP_S2 = 0;
	                for (; GBPJPY_OCO1S2_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets2.Count; GBPJPY_OCO1S2_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO1Sets2[GBPJPY_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO1Sets2[GBPJPY_OCO1S2_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO1Sets2.RemoveAt(GBPJPY_OCO1S2_UP_S2);
	                        GBPJPY_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO1S3_UP_S2 = 0;
	                for (; GBPJPY_OCO1S3_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets3.Count; GBPJPY_OCO1S3_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO1Sets3[GBPJPY_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO1Sets3[GBPJPY_OCO1S3_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO1Sets3.RemoveAt(GBPJPY_OCO1S3_UP_S2);
	                        GBPJPY_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO1S4_UP_S2 = 0;
	                for (; GBPJPY_OCO1S4_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets4.Count; GBPJPY_OCO1S4_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO1Sets4[GBPJPY_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO1Sets4[GBPJPY_OCO1S4_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO1Sets4.RemoveAt(GBPJPY_OCO1S4_UP_S2);
	                        GBPJPY_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPJPY_OCO1S5_UP_S2 = 0;
	                for (; GBPJPY_OCO1S5_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets5.Count; GBPJPY_OCO1S5_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO1Sets5[GBPJPY_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO1Sets5[GBPJPY_OCO1S5_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO1Sets5.RemoveAt(GBPJPY_OCO1S5_UP_S2);
	                        GBPJPY_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPJPY_OCO1S6_UP_S2 = 0;
	                for (; GBPJPY_OCO1S6_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets6.Count; GBPJPY_OCO1S6_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO1Sets6[GBPJPY_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO1Sets6[GBPJPY_OCO1S6_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO1Sets6.RemoveAt(GBPJPY_OCO1S6_UP_S2);
	                        GBPJPY_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.GBPJPY_OCO2_EO1_UP_S2)
	                Base.GBPJPY_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPJPY_OCO2_EO2_UP_S2)
	                Base.GBPJPY_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO2_EO3_UP_S2)
	                Base.GBPJPY_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO2_EO4_UP_S2)
	                Base.GBPJPY_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO2_EO5_UP_S2)
	                Base.GBPJPY_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO2_EO6_UP_S2)
	                Base.GBPJPY_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.GBPJPY_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP1,"TP1_GBPJPY_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP1_GBPJPY_UP_S2_OCO2"));
		                 };
		                Base.GBPJPY_UP_S2_OCO2Sets1.Add( Base.GBPJPY_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP2,"TP2_GBPJPY_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP2_GBPJPY_UP_S2_OCO2"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO2Sets2.Add( Base.GBPJPY_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP3,"TP3_GBPJPY_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP3_GBPJPY_UP_S2_OCO2"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO2Sets3.Add( Base.GBPJPY_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP4,"TP4_GBPJPY_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP4_GBPJPY_UP_S2_OCO2"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO2Sets4.Add( Base.GBPJPY_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP5,"TP5_GBPJPY_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP5_GBPJPY_UP_S2_OCO2"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO2Sets5.Add( Base.GBPJPY_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP6,"TP6_GBPJPY_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP6_GBPJPY_UP_S2_OCO2"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO2Sets6.Add( Base.GBPJPY_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPJPY_OCO2S1_UP_S2 = 0;
	                for (; GBPJPY_OCO2S1_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets1.Count; GBPJPY_OCO2S1_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO2Sets1[GBPJPY_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO2Sets1[GBPJPY_OCO2S1_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO2Sets1.RemoveAt(GBPJPY_OCO2S1_UP_S2);
	                        GBPJPY_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPJPY_OCO2S2_UP_S2 = 0;
	                for (; GBPJPY_OCO2S2_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets2.Count; GBPJPY_OCO2S2_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO2Sets2[GBPJPY_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO2Sets2[GBPJPY_OCO2S2_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO2Sets2.RemoveAt(GBPJPY_OCO2S2_UP_S2);
	                        GBPJPY_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO2S3_UP_S2 = 0;
	                for (; GBPJPY_OCO2S3_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets3.Count; GBPJPY_OCO2S3_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO2Sets3[GBPJPY_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO2Sets3[GBPJPY_OCO2S3_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO2Sets3.RemoveAt(GBPJPY_OCO2S3_UP_S2);
	                        GBPJPY_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO2S4_UP_S2 = 0;
	                for (; GBPJPY_OCO2S4_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets4.Count; GBPJPY_OCO2S4_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO2Sets4[GBPJPY_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO2Sets4[GBPJPY_OCO2S4_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO2Sets4.RemoveAt(GBPJPY_OCO2S4_UP_S2);
	                        GBPJPY_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPJPY_OCO2S5_UP_S2 = 0;
	                for (; GBPJPY_OCO2S5_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets5.Count; GBPJPY_OCO2S5_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO2Sets5[GBPJPY_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO2Sets5[GBPJPY_OCO2S5_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO2Sets5.RemoveAt(GBPJPY_OCO2S5_UP_S2);
	                        GBPJPY_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPJPY_OCO2S6_UP_S2 = 0;
	                for (; GBPJPY_OCO2S6_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets6.Count; GBPJPY_OCO2S6_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO2Sets6[GBPJPY_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO2Sets6[GBPJPY_OCO2S6_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO2Sets6.RemoveAt(GBPJPY_OCO2S6_UP_S2);
	                        GBPJPY_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPJPY_OCO3_EO1_UP_S2)
	                Base.GBPJPY_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPJPY_OCO3_EO2_UP_S2)
	                Base.GBPJPY_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO3_EO3_UP_S2)
	                Base.GBPJPY_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO3_EO4_UP_S2)
	                Base.GBPJPY_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO3_EO5_UP_S2)
	                Base.GBPJPY_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO3_EO6_UP_S2)
	                Base.GBPJPY_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.GBPJPY_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP1,"TP1_GBPJPY_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP1_GBPJPY_UP_S2_OCO3"));
		                 };
		                Base.GBPJPY_UP_S2_OCO3Sets1.Add( Base.GBPJPY_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP2,"TP2_GBPJPY_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP2_GBPJPY_UP_S2_OCO3"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO3Sets2.Add( Base.GBPJPY_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP3,"TP3_GBPJPY_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP3_GBPJPY_UP_S2_OCO3"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO3Sets3.Add( Base.GBPJPY_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP4,"TP4_GBPJPY_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP4_GBPJPY_UP_S2_OCO3"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO3Sets4.Add( Base.GBPJPY_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP5,"TP5_GBPJPY_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP5_GBPJPY_UP_S2_OCO3"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO3Sets5.Add( Base.GBPJPY_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP6,"TP6_GBPJPY_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP6_GBPJPY_UP_S2_OCO3"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO3Sets6.Add( Base.GBPJPY_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPJPY_OCO3S1_UP_S2 = 0;
	                for (; GBPJPY_OCO3S1_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets1.Count; GBPJPY_OCO3S1_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO3Sets1[GBPJPY_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO3Sets1[GBPJPY_OCO3S1_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO3Sets1.RemoveAt(GBPJPY_OCO3S1_UP_S2);
	                        GBPJPY_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPJPY_OCO3S2_UP_S2 = 0;
	                for (; GBPJPY_OCO3S2_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets2.Count; GBPJPY_OCO3S2_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO3Sets2[GBPJPY_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO3Sets2[GBPJPY_OCO3S2_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO3Sets2.RemoveAt(GBPJPY_OCO3S2_UP_S2);
	                        GBPJPY_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO3S3_UP_S2 = 0;
	                for (; GBPJPY_OCO3S3_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets3.Count; GBPJPY_OCO3S3_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO3Sets3[GBPJPY_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO3Sets3[GBPJPY_OCO3S3_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO3Sets3.RemoveAt(GBPJPY_OCO3S3_UP_S2);
	                        GBPJPY_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO3S4_UP_S2 = 0;
	                for (; GBPJPY_OCO3S4_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets4.Count; GBPJPY_OCO3S4_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO3Sets4[GBPJPY_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO3Sets4[GBPJPY_OCO3S4_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO3Sets4.RemoveAt(GBPJPY_OCO3S4_UP_S2);
	                        GBPJPY_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPJPY_OCO3S5_UP_S2 = 0;
	                for (; GBPJPY_OCO3S5_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets5.Count; GBPJPY_OCO3S5_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO3Sets5[GBPJPY_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO3Sets5[GBPJPY_OCO3S5_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO3Sets5.RemoveAt(GBPJPY_OCO3S5_UP_S2);
	                        GBPJPY_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPJPY_OCO3S6_UP_S2 = 0;
	                for (; GBPJPY_OCO3S6_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets6.Count; GBPJPY_OCO3S6_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO3Sets6[GBPJPY_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO3Sets6[GBPJPY_OCO3S6_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO3Sets6.RemoveAt(GBPJPY_OCO3S6_UP_S2);
	                        GBPJPY_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPJPY_OCO4_EO1_UP_S2)
	                Base.GBPJPY_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPJPY_OCO4_EO2_UP_S2)
	                Base.GBPJPY_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO4_EO3_UP_S2)
	                Base.GBPJPY_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO4_EO4_UP_S2)
	                Base.GBPJPY_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO4_EO5_UP_S2)
	                Base.GBPJPY_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO4_EO6_UP_S2)
	                Base.GBPJPY_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.GBPJPY_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP1,"TP1_GBPJPY_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP1_GBPJPY_UP_S2_OCO4"));
		                 };
		                Base.GBPJPY_UP_S2_OCO4Sets1.Add( Base.GBPJPY_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP2,"TP2_GBPJPY_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP2_GBPJPY_UP_S2_OCO4"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO4Sets2.Add( Base.GBPJPY_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP3,"TP3_GBPJPY_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP3_GBPJPY_UP_S2_OCO4"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO4Sets3.Add( Base.GBPJPY_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP4,"TP4_GBPJPY_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP4_GBPJPY_UP_S2_OCO4"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO4Sets4.Add( Base.GBPJPY_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP5,"TP5_GBPJPY_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP5_GBPJPY_UP_S2_OCO4"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO4Sets5.Add( Base.GBPJPY_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_UP_S2_TP6,"TP6_GBPJPY_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_UP_S2_SL,"SL_TP6_GBPJPY_UP_S2_OCO4"));
		                 };
	                    Base.GBPJPY_UP_S2_OCO4Sets6.Add( Base.GBPJPY_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPJPY_OCO4S1_UP_S2 = 0;
	                for (; GBPJPY_OCO4S1_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets1.Count; GBPJPY_OCO4S1_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO4Sets1[GBPJPY_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO4Sets1[GBPJPY_OCO4S1_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO4Sets1.RemoveAt(GBPJPY_OCO4S1_UP_S2);
	                        GBPJPY_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPJPY_OCO4S2_UP_S2 = 0;
	                for (; GBPJPY_OCO4S2_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets2.Count; GBPJPY_OCO4S2_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO4Sets2[GBPJPY_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO4Sets2[GBPJPY_OCO4S2_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO4Sets2.RemoveAt(GBPJPY_OCO4S2_UP_S2);
	                        GBPJPY_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO4S3_UP_S2 = 0;
	                for (; GBPJPY_OCO4S3_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets3.Count; GBPJPY_OCO4S3_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO4Sets3[GBPJPY_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO4Sets3[GBPJPY_OCO4S3_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO4Sets3.RemoveAt(GBPJPY_OCO4S3_UP_S2);
	                        GBPJPY_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO4S4_UP_S2 = 0;
	                for (; GBPJPY_OCO4S4_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets4.Count; GBPJPY_OCO4S4_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO4Sets4[GBPJPY_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO4Sets4[GBPJPY_OCO4S4_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO4Sets4.RemoveAt(GBPJPY_OCO4S4_UP_S2);
	                        GBPJPY_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPJPY_OCO4S5_UP_S2 = 0;
	                for (; GBPJPY_OCO4S5_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets5.Count; GBPJPY_OCO4S5_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO4Sets5[GBPJPY_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO4Sets5[GBPJPY_OCO4S5_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO4Sets5.RemoveAt(GBPJPY_OCO4S5_UP_S2);
	                        GBPJPY_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPJPY_OCO4S6_UP_S2 = 0;
	                for (; GBPJPY_OCO4S6_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets6.Count; GBPJPY_OCO4S6_UP_S2++)
	                    if (Base.GBPJPY_UP_S2_OCO4Sets6[GBPJPY_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_UP_S2_OCO4Sets6[GBPJPY_OCO4S6_UP_S2].Filled();
	                        Base.GBPJPY_UP_S2_OCO4Sets6.RemoveAt(GBPJPY_OCO4S6_UP_S2);
	                        GBPJPY_OCO4S6_UP_S2 = 0;
	                        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.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 GBPJPY_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPJPY_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("GBPJPY OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPJPY OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPJPY OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPJPY OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPJPY OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPJPY OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPJPY S2");
		        	}
		        }
		        
				if (Base.GBPJPY_OCO1_EO1_DOWN_S2)
	                Base.GBPJPY_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPJPY_OCO1_EO2_DOWN_S2)
	                Base.GBPJPY_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO1_EO3_DOWN_S2)
	                Base.GBPJPY_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO1_EO4_DOWN_S2)
	                Base.GBPJPY_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPJPY_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP1_GBPJPY_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP1,"TP1_GBPJPY_DOWN_S2_OCO1"));
		                 };
		                Base.GBPJPY_DOWN_S2_OCO1Sets1.Add( Base.GBPJPY_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP2_GBPJPY_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP2,"TP2_GBPJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO1Sets2.Add( Base.GBPJPY_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP3_GBPJPY_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP3,"TP3_GBPJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO1Sets3.Add( Base.GBPJPY_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP4_GBPJPY_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP4,"TP4_GBPJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO1Sets4.Add( Base.GBPJPY_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPJPY_OCO1S1_DOWN_S2 = 0;
	                for (; GBPJPY_OCO1S1_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets1.Count; GBPJPY_OCO1S1_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO1Sets1[GBPJPY_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO1Sets1[GBPJPY_OCO1S1_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO1Sets1.RemoveAt(GBPJPY_OCO1S1_DOWN_S2);
	                        GBPJPY_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPJPY_OCO1S2_DOWN_S2 = 0;
	                for (; GBPJPY_OCO1S2_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets2.Count; GBPJPY_OCO1S2_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO1Sets2[GBPJPY_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO1Sets2[GBPJPY_OCO1S2_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO1Sets2.RemoveAt(GBPJPY_OCO1S2_DOWN_S2);
	                        GBPJPY_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO1S3_DOWN_S2 = 0;
	                for (; GBPJPY_OCO1S3_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets3.Count; GBPJPY_OCO1S3_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO1Sets3[GBPJPY_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO1Sets3[GBPJPY_OCO1S3_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO1Sets3.RemoveAt(GBPJPY_OCO1S3_DOWN_S2);
	                        GBPJPY_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO1S4_DOWN_S2 = 0;
	                for (; GBPJPY_OCO1S4_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets4.Count; GBPJPY_OCO1S4_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO1Sets4[GBPJPY_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO1Sets4[GBPJPY_OCO1S4_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO1Sets4.RemoveAt(GBPJPY_OCO1S4_DOWN_S2);
	                        GBPJPY_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPJPY_OCO2_EO1_DOWN_S2)
	                Base.GBPJPY_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPJPY_OCO2_EO2_DOWN_S2)
	                Base.GBPJPY_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO2_EO3_DOWN_S2)
	                Base.GBPJPY_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO2_EO4_DOWN_S2)
	                Base.GBPJPY_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPJPY_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP1_GBPJPY_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP1,"TP1_GBPJPY_DOWN_S2_OCO2"));
		                 };
		                Base.GBPJPY_DOWN_S2_OCO2Sets1.Add( Base.GBPJPY_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP2_GBPJPY_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP2,"TP2_GBPJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO2Sets2.Add( Base.GBPJPY_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP3_GBPJPY_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP3,"TP3_GBPJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO2Sets3.Add( Base.GBPJPY_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP4_GBPJPY_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP4,"TP4_GBPJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO2Sets4.Add( Base.GBPJPY_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPJPY_OCO2S1_DOWN_S2 = 0;
	                for (; GBPJPY_OCO2S1_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets1.Count; GBPJPY_OCO2S1_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO2Sets1[GBPJPY_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO2Sets1[GBPJPY_OCO2S1_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO2Sets1.RemoveAt(GBPJPY_OCO2S1_DOWN_S2);
	                        GBPJPY_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPJPY_OCO2S2_DOWN_S2 = 0;
	                for (; GBPJPY_OCO2S2_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets2.Count; GBPJPY_OCO2S2_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO2Sets2[GBPJPY_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO2Sets2[GBPJPY_OCO2S2_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO2Sets2.RemoveAt(GBPJPY_OCO2S2_DOWN_S2);
	                        GBPJPY_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO2S3_DOWN_S2 = 0;
	                for (; GBPJPY_OCO2S3_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets3.Count; GBPJPY_OCO2S3_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO2Sets3[GBPJPY_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO2Sets3[GBPJPY_OCO2S3_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO2Sets3.RemoveAt(GBPJPY_OCO2S3_DOWN_S2);
	                        GBPJPY_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO2S4_DOWN_S2 = 0;
	                for (; GBPJPY_OCO2S4_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets4.Count; GBPJPY_OCO2S4_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO2Sets4[GBPJPY_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO2Sets4[GBPJPY_OCO2S4_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO2Sets4.RemoveAt(GBPJPY_OCO2S4_DOWN_S2);
	                        GBPJPY_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPJPY_OCO3_EO1_DOWN_S2)
	                Base.GBPJPY_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPJPY_OCO3_EO2_DOWN_S2)
	                Base.GBPJPY_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO3_EO3_DOWN_S2)
	                Base.GBPJPY_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO3_EO4_DOWN_S2)
	                Base.GBPJPY_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPJPY_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP1_GBPJPY_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP1,"TP1_GBPJPY_DOWN_S2_OCO3"));
		                 };
		                Base.GBPJPY_DOWN_S2_OCO3Sets1.Add( Base.GBPJPY_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP2_GBPJPY_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP2,"TP2_GBPJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO3Sets2.Add( Base.GBPJPY_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP3_GBPJPY_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP3,"TP3_GBPJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO3Sets3.Add( Base.GBPJPY_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP4_GBPJPY_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP4,"TP4_GBPJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO3Sets4.Add( Base.GBPJPY_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPJPY_OCO3S1_DOWN_S2 = 0;
	                for (; GBPJPY_OCO3S1_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets1.Count; GBPJPY_OCO3S1_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO3Sets1[GBPJPY_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO3Sets1[GBPJPY_OCO3S1_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO3Sets1.RemoveAt(GBPJPY_OCO3S1_DOWN_S2);
	                        GBPJPY_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPJPY_OCO3S2_DOWN_S2 = 0;
	                for (; GBPJPY_OCO3S2_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets2.Count; GBPJPY_OCO3S2_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO3Sets2[GBPJPY_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO3Sets2[GBPJPY_OCO3S2_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO3Sets2.RemoveAt(GBPJPY_OCO3S2_DOWN_S2);
	                        GBPJPY_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO3S3_DOWN_S2 = 0;
	                for (; GBPJPY_OCO3S3_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets3.Count; GBPJPY_OCO3S3_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO3Sets3[GBPJPY_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO3Sets3[GBPJPY_OCO3S3_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO3Sets3.RemoveAt(GBPJPY_OCO3S3_DOWN_S2);
	                        GBPJPY_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO3S4_DOWN_S2 = 0;
	                for (; GBPJPY_OCO3S4_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets4.Count; GBPJPY_OCO3S4_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO3Sets4[GBPJPY_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO3Sets4[GBPJPY_OCO3S4_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO3Sets4.RemoveAt(GBPJPY_OCO3S4_DOWN_S2);
	                        GBPJPY_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPJPY_OCO4_EO1_DOWN_S2)
	                Base.GBPJPY_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPJPY_OCO4_EO2_DOWN_S2)
	                Base.GBPJPY_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO4_EO3_DOWN_S2)
	                Base.GBPJPY_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPJPY_OCO4_EO4_DOWN_S2)
	                Base.GBPJPY_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPJPY_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP1_GBPJPY_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP1,"TP1_GBPJPY_DOWN_S2_OCO4"));
		                 };
		                Base.GBPJPY_DOWN_S2_OCO4Sets1.Add( Base.GBPJPY_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP2_GBPJPY_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP2,"TP2_GBPJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO4Sets2.Add( Base.GBPJPY_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP3_GBPJPY_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP3,"TP3_GBPJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO4Sets3.Add( Base.GBPJPY_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPJPY_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPJPY_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPJPY_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPJPY_DOWN_S2_SL,"SL_TP4_GBPJPY_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPJPY_DOWN_S2_TP4,"TP4_GBPJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPJPY_DOWN_S2_OCO4Sets4.Add( Base.GBPJPY_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPJPY_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPJPY_OCO4S1_DOWN_S2 = 0;
	                for (; GBPJPY_OCO4S1_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets1.Count; GBPJPY_OCO4S1_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO4Sets1[GBPJPY_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO4Sets1[GBPJPY_OCO4S1_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO4Sets1.RemoveAt(GBPJPY_OCO4S1_DOWN_S2);
	                        GBPJPY_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPJPY_OCO4S2_DOWN_S2 = 0;
	                for (; GBPJPY_OCO4S2_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets2.Count; GBPJPY_OCO4S2_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO4Sets2[GBPJPY_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO4Sets2[GBPJPY_OCO4S2_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO4Sets2.RemoveAt(GBPJPY_OCO4S2_DOWN_S2);
	                        GBPJPY_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO4S3_DOWN_S2 = 0;
	                for (; GBPJPY_OCO4S3_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets3.Count; GBPJPY_OCO4S3_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO4Sets3[GBPJPY_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO4Sets3[GBPJPY_OCO4S3_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO4Sets3.RemoveAt(GBPJPY_OCO4S3_DOWN_S2);
	                        GBPJPY_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPJPY_OCO4S4_DOWN_S2 = 0;
	                for (; GBPJPY_OCO4S4_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets4.Count; GBPJPY_OCO4S4_DOWN_S2++)
	                    if (Base.GBPJPY_DOWN_S2_OCO4Sets4[GBPJPY_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPJPY_DOWN_S2_OCO4Sets4[GBPJPY_OCO4S4_DOWN_S2].Filled();
	                        Base.GBPJPY_DOWN_S2_OCO4Sets4.RemoveAt(GBPJPY_OCO4S4_DOWN_S2);
	                        GBPJPY_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPUSD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPUSD_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("GBPUSD_DOWN_S2_OCO1")))
			{
				Base.GBPUSD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPUSD_DOWN_S2_OCO2")))
			{
				Base.GBPUSD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPUSD_DOWN_S2_OCO3")))
			{
				Base.GBPUSD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPUSD_DOWN_S2_OCO4")))
			{
				Base.GBPUSD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPUSD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.GBPUSD_OCO1_EO1_DOWN_S2)
	                Base.GBPUSD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPUSD_OCO1_EO2_DOWN_S2)
	                Base.GBPUSD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO1_EO3_DOWN_S2)
	                Base.GBPUSD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO1_EO4_DOWN_S2)
	                Base.GBPUSD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO1_EO5_DOWN_S2)
	                Base.GBPUSD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO1_EO6_DOWN_S2)
	                Base.GBPUSD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPUSD_OCO1S1_DOWN_S2 = 0;
		                for (; GBPUSD_OCO1S1_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets1.Count; GBPUSD_OCO1S1_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO1Sets1[GBPUSD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO1Sets1[GBPUSD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.GBPUSD_DOWN_S2_OCO1Sets1.Clear();
		                        GBPUSD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPUSD_OCO1S2_DOWN_S2 = 0;
		                for (; GBPUSD_OCO1S2_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets2.Count; GBPUSD_OCO1S2_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO1Sets2[GBPUSD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO1Sets2[GBPUSD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.GBPUSD_DOWN_S2_OCO1Sets2.Clear();
		                        GBPUSD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO1S3_DOWN_S2 = 0;
		                for (; GBPUSD_OCO1S3_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets3.Count; GBPUSD_OCO1S3_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO1Sets3[GBPUSD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO1Sets3[GBPUSD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.GBPUSD_DOWN_S2_OCO1Sets3.Clear();
		                        GBPUSD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO1S4_DOWN_S2 = 0;
		                for (; GBPUSD_OCO1S4_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets4.Count; GBPUSD_OCO1S4_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO1Sets4[GBPUSD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO1Sets4[GBPUSD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.GBPUSD_DOWN_S2_OCO1Sets4.Clear();
		                        GBPUSD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO1S5_DOWN_S2 = 0;
		                for (; GBPUSD_OCO1S5_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets5.Count; GBPUSD_OCO1S5_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO1Sets5[GBPUSD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO1Sets5[GBPUSD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.GBPUSD_DOWN_S2_OCO1Sets5.Clear();
		                        GBPUSD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO1S6_DOWN_S2 = 0;
		                for (; GBPUSD_OCO1S6_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO1Sets6.Count; GBPUSD_OCO1S6_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO1Sets6[GBPUSD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO1Sets6[GBPUSD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.GBPUSD_DOWN_S2_OCO1Sets6.Clear();
		                        GBPUSD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPUSD_OCO2_EO1_DOWN_S2)
	                Base.GBPUSD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPUSD_OCO2_EO2_DOWN_S2)
	                Base.GBPUSD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO2_EO3_DOWN_S2)
	                Base.GBPUSD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO2_EO4_DOWN_S2)
	                Base.GBPUSD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO2_EO5_DOWN_S2)
	                Base.GBPUSD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO2_EO6_DOWN_S2)
	                Base.GBPUSD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPUSD_OCO2S1_DOWN_S2 = 0;
		                for (; GBPUSD_OCO2S1_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets1.Count; GBPUSD_OCO2S1_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO2Sets1[GBPUSD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO2Sets1[GBPUSD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.GBPUSD_DOWN_S2_OCO2Sets1.Clear();
		                        GBPUSD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPUSD_OCO2S2_DOWN_S2 = 0;
		                for (; GBPUSD_OCO2S2_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets2.Count; GBPUSD_OCO2S2_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO2Sets2[GBPUSD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO2Sets2[GBPUSD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.GBPUSD_DOWN_S2_OCO2Sets2.Clear();
		                        GBPUSD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO2S3_DOWN_S2 = 0;
		                for (; GBPUSD_OCO2S3_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets3.Count; GBPUSD_OCO2S3_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO2Sets3[GBPUSD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO2Sets3[GBPUSD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.GBPUSD_DOWN_S2_OCO2Sets3.Clear();
		                        GBPUSD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO2S4_DOWN_S2 = 0;
		                for (; GBPUSD_OCO2S4_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets4.Count; GBPUSD_OCO2S4_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO2Sets4[GBPUSD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO2Sets4[GBPUSD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.GBPUSD_DOWN_S2_OCO2Sets4.Clear();
		                        GBPUSD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO2S5_DOWN_S2 = 0;
		                for (; GBPUSD_OCO2S5_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets5.Count; GBPUSD_OCO2S5_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO2Sets5[GBPUSD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO2Sets5[GBPUSD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.GBPUSD_DOWN_S2_OCO2Sets5.Clear();
		                        GBPUSD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO2S6_DOWN_S2 = 0;
		                for (; GBPUSD_OCO2S6_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO2Sets6.Count; GBPUSD_OCO2S6_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO2Sets6[GBPUSD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO2Sets6[GBPUSD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.GBPUSD_DOWN_S2_OCO2Sets6.Clear();
		                        GBPUSD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPUSD_OCO3_EO1_DOWN_S2)
	                Base.GBPUSD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPUSD_OCO3_EO2_DOWN_S2)
	                Base.GBPUSD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO3_EO3_DOWN_S2)
	                Base.GBPUSD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO3_EO4_DOWN_S2)
	                Base.GBPUSD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO3_EO5_DOWN_S2)
	                Base.GBPUSD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO3_EO6_DOWN_S2)
	                Base.GBPUSD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPUSD_OCO3S1_DOWN_S2 = 0;
		                for (; GBPUSD_OCO3S1_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets1.Count; GBPUSD_OCO3S1_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO3Sets1[GBPUSD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO3Sets1[GBPUSD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.GBPUSD_DOWN_S2_OCO3Sets1.Clear();
		                        GBPUSD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPUSD_OCO3S2_DOWN_S2 = 0;
		                for (; GBPUSD_OCO3S2_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets2.Count; GBPUSD_OCO3S2_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO3Sets2[GBPUSD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO3Sets2[GBPUSD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.GBPUSD_DOWN_S2_OCO3Sets2.Clear();
		                        GBPUSD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO3S3_DOWN_S2 = 0;
		                for (; GBPUSD_OCO3S3_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets3.Count; GBPUSD_OCO3S3_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO3Sets3[GBPUSD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO3Sets3[GBPUSD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.GBPUSD_DOWN_S2_OCO3Sets3.Clear();
		                        GBPUSD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO3S4_DOWN_S2 = 0;
		                for (; GBPUSD_OCO3S4_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets4.Count; GBPUSD_OCO3S4_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO3Sets4[GBPUSD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO3Sets4[GBPUSD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.GBPUSD_DOWN_S2_OCO3Sets4.Clear();
		                        GBPUSD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO3S5_DOWN_S2 = 0;
		                for (; GBPUSD_OCO3S5_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets5.Count; GBPUSD_OCO3S5_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO3Sets5[GBPUSD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO3Sets5[GBPUSD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.GBPUSD_DOWN_S2_OCO3Sets5.Clear();
		                        GBPUSD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO3S6_DOWN_S2 = 0;
		                for (; GBPUSD_OCO3S6_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO3Sets6.Count; GBPUSD_OCO3S6_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO3Sets6[GBPUSD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO3Sets6[GBPUSD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.GBPUSD_DOWN_S2_OCO3Sets6.Clear();
		                        GBPUSD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPUSD_OCO4_EO1_DOWN_S2)
	                Base.GBPUSD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPUSD_OCO4_EO2_DOWN_S2)
	                Base.GBPUSD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO4_EO3_DOWN_S2)
	                Base.GBPUSD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO4_EO4_DOWN_S2)
	                Base.GBPUSD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO4_EO5_DOWN_S2)
	                Base.GBPUSD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO4_EO6_DOWN_S2)
	                Base.GBPUSD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPUSD_OCO4S1_DOWN_S2 = 0;
		                for (; GBPUSD_OCO4S1_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets1.Count; GBPUSD_OCO4S1_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO4Sets1[GBPUSD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO4Sets1[GBPUSD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.GBPUSD_DOWN_S2_OCO4Sets1.Clear();
		                        GBPUSD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPUSD_OCO4S2_DOWN_S2 = 0;
		                for (; GBPUSD_OCO4S2_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets2.Count; GBPUSD_OCO4S2_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO4Sets2[GBPUSD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO4Sets2[GBPUSD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.GBPUSD_DOWN_S2_OCO4Sets2.Clear();
		                        GBPUSD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO4S3_DOWN_S2 = 0;
		                for (; GBPUSD_OCO4S3_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets3.Count; GBPUSD_OCO4S3_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO4Sets3[GBPUSD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO4Sets3[GBPUSD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.GBPUSD_DOWN_S2_OCO4Sets3.Clear();
		                        GBPUSD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO4S4_DOWN_S2 = 0;
		                for (; GBPUSD_OCO4S4_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets4.Count; GBPUSD_OCO4S4_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO4Sets4[GBPUSD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO4Sets4[GBPUSD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.GBPUSD_DOWN_S2_OCO4Sets4.Clear();
		                        GBPUSD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO4S5_DOWN_S2 = 0;
		                for (; GBPUSD_OCO4S5_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets5.Count; GBPUSD_OCO4S5_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO4Sets5[GBPUSD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO4Sets5[GBPUSD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.GBPUSD_DOWN_S2_OCO4Sets5.Clear();
		                        GBPUSD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO4S6_DOWN_S2 = 0;
		                for (; GBPUSD_OCO4S6_DOWN_S2 < Base.GBPUSD_DOWN_S2_OCO4Sets6.Count; GBPUSD_OCO4S6_DOWN_S2++)
		                    if (Base.GBPUSD_DOWN_S2_OCO4Sets6[GBPUSD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_DOWN_S2_OCO4Sets6[GBPUSD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.GBPUSD_DOWN_S2_OCO4Sets6.Clear();
		                        GBPUSD_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();
	            	}
	            	
					DOWM_GBPUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPUSD_DOWN_S2 = DOWM_GBPUSD_DOWN_S2 || DOWT_GBPUSD_DOWN_S2 || DOWW_GBPUSD_DOWN_S2 || DOWTH_GBPUSD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPUSD"))
	            	{
	            		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.GBPUSD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.GBPUSD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.GBPUSD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.GBPUSD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.GBPUSD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPUSD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPUSD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPUSD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPUSD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPUSD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPUSD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPUSD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	GBPUSD_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
	                									);
	                									
	                	GBPUSD_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
	                									);
	                									
	                									
	                	GBPUSD_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 (GBPUSD_Signal_Condition_DOWN_1)
	                	{
	                    	GBPUSD_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (GBPUSD_Signal_Condition_DOWN_2)
	                	{
	                    	GBPUSD_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (GBPUSD_Signal_Condition_DOWN_3)
	                	{
	                    	GBPUSD_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	
	                	if (GBPUSD_Signal_Condition_DOWN_1)
	                	{
	                    	GBPUSD_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.05m ;
	                	}
	                	
	                	if (GBPUSD_Signal_Condition_DOWN_2)
	                	{
	                    	GBPUSD_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.1m ;
	                	}
	                	
	                	if (GBPUSD_Signal_Condition_DOWN_3)
	                	{
	                    	GBPUSD_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.2m ;
	                	}
	                	
	                    GBPUSD_DOWN_S2_TP2 =  GBPUSD_DOWN_S2_SL * 0;
	                    GBPUSD_DOWN_S2_TP3 =  GBPUSD_DOWN_S2_SL * 0;
	                    GBPUSD_DOWN_S2_TP4 =  GBPUSD_DOWN_S2_SL * 0;
	                    GBPUSD_DOWN_S2_TP5 =  GBPUSD_DOWN_S2_SL * 0;
	                    GBPUSD_DOWN_S2_TP6 =  GBPUSD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0 && GBPUSD_DOWN_S2_SL !=  0)
	                    {
	                    GBPUSD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)*0.015m);
	                    GBPUSD_quantity_SL_DOWN_S2 = GBPUSD_quantity_DOWN_S2;
	                    GBPUSD_quantity_TP1_DOWN_S2 = (GBPUSD_quantity_DOWN_S2 );
	                    GBPUSD_quantity_TP2_DOWN_S2 = (GBPUSD_quantity_TP1_DOWN_S2 * 0);
	                    GBPUSD_quantity_TP3_DOWN_S2 = (GBPUSD_quantity_TP2_DOWN_S2 * 0);
	                    GBPUSD_quantity_TP4_DOWN_S2 = (GBPUSD_quantity_TP3_DOWN_S2 * 0);
	                    GBPUSD_quantity_TP5_DOWN_S2 = (GBPUSD_quantity_TP4_DOWN_S2 * 0);
	                    GBPUSD_quantity_TP6_DOWN_S2 = (GBPUSD_quantity_TP5_DOWN_S2 * 0);
	                    }
	                    
	                    oco1:
	                    if ((GBPUSD_Signal_Condition_DOWN_1 || GBPUSD_Signal_Condition_DOWN_2 || GBPUSD_Signal_Condition_DOWN_3)  && 
	                    DOWR_GBPUSD_DOWN_S2 && 
	                    Base.GBPUSD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.GBPUSD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPUSD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP1_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.GBPUSD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPUSD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP2_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.GBPUSD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.GBPUSD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP3_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.GBPUSD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPUSD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP4_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.GBPUSD_OCO1_EO4_DOWN_S2 = false;

							Base.GBPUSD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.GBPUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((GBPUSD_Signal_Condition_DOWN_1 || GBPUSD_Signal_Condition_DOWN_2 || GBPUSD_Signal_Condition_DOWN_3)  && 
	                    DOWR_GBPUSD_DOWN_S2 && 
	                    Base.GBPUSD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.GBPUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPUSD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPUSD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP1_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.GBPUSD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPUSD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP2_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.GBPUSD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.GBPUSD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP3_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.GBPUSD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPUSD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP4_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.GBPUSD_OCO2_EO4_DOWN_S2 = false;

							Base.GBPUSD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.GBPUSD_OCO2_DOWN_S2_IsReady == false && Base.GBPUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((GBPUSD_Signal_Condition_DOWN_1 || GBPUSD_Signal_Condition_DOWN_2 || GBPUSD_Signal_Condition_DOWN_3)  && 
	                    DOWR_GBPUSD_DOWN_S2 &&
	                    Base.GBPUSD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.GBPUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPUSD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPUSD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPUSD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP1_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.GBPUSD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPUSD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP2_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.GBPUSD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.GBPUSD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP3_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.GBPUSD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPUSD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP4_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.GBPUSD_OCO3_EO4_DOWN_S2 = false;

							Base.GBPUSD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.GBPUSD_OCO3_DOWN_S2_IsReady == false && Base.GBPUSD_OCO2_DOWN_S2_IsReady == false && Base.GBPUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((GBPUSD_Signal_Condition_DOWN_1 || GBPUSD_Signal_Condition_DOWN_2 || GBPUSD_Signal_Condition_DOWN_3)  && 
	                    DOWR_GBPUSD_DOWN_S2 && 
	                    Base.GBPUSD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.GBPUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPUSD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPUSD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.GBPUSD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPUSD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP1_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.GBPUSD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPUSD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP2_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.GBPUSD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.GBPUSD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP3_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.GBPUSD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPUSD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPUSD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP4_DOWN_S2, false,"GBPUSD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.GBPUSD_OCO4_EO4_DOWN_S2 = false;

							Base.GBPUSD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.GBPUSD_OCO4_DOWN_S2_IsReady == false && Base.GBPUSD_OCO3_DOWN_S2_IsReady == false && Base.GBPUSD_OCO2_DOWN_S2_IsReady == false && Base.GBPUSD_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct USDCAD_OCO1_DOWN_S2
    {
        public USDCAD_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 =="TP1_USDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD 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 =="TP1_USDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD 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 USDCAD_OCO1_UP_S2
    {
        public USDCAD_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 =="TP1_USDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD 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 =="TP1_USDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCAD 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 USDCAD_OCO2_DOWN_S2
    {
        public USDCAD_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 =="TP1_USDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD 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 =="TP1_USDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD 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 USDCAD_OCO2_UP_S2
    {
        public USDCAD_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 =="TP1_USDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD 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 =="TP1_USDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCAD 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 USDCAD_OCO3_DOWN_S2
    {
        public USDCAD_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 =="TP1_USDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD 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 =="TP1_USDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD 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 USDCAD_OCO3_UP_S2
    {
        public USDCAD_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 =="TP1_USDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD 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 =="TP1_USDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCAD 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 USDCAD_OCO4_DOWN_S2
    {
        public USDCAD_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 =="TP1_USDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD 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 =="TP1_USDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD 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 USDCAD_OCO4_UP_S2
    {
        public USDCAD_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 =="TP1_USDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD 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 =="TP1_USDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCAD 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPUSD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPUSD_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(x=>x.Tag.Contains("GBPUSD_UP_S2_OCO1")))
			{
				Base.GBPUSD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPUSD_UP_S2_OCO2")))
			{
				Base.GBPUSD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPUSD_UP_S2_OCO3")))
			{
				Base.GBPUSD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPUSD_UP_S2_OCO4")))
			{
				Base.GBPUSD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPUSD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.GBPUSD_OCO1_EO1_UP_S2)
	                Base.GBPUSD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPUSD_OCO1_EO2_UP_S2)
	                Base.GBPUSD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO1_EO3_UP_S2)
	                Base.GBPUSD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO1_EO4_UP_S2)
	                Base.GBPUSD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO1_EO5_UP_S2)
	                Base.GBPUSD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO1_EO6_UP_S2)
	                Base.GBPUSD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPUSD_OCO1S1_UP_S2 = 0;
		                for (; GBPUSD_OCO1S1_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets1.Count; GBPUSD_OCO1S1_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO1Sets1[GBPUSD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO1Sets1[GBPUSD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.GBPUSD_UP_S2_OCO1Sets1.Clear();
		                        GBPUSD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPUSD_OCO1S2_UP_S2 = 0;
		                for (; GBPUSD_OCO1S2_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets2.Count; GBPUSD_OCO1S2_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO1Sets2[GBPUSD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO1Sets2[GBPUSD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.GBPUSD_UP_S2_OCO1Sets2.Clear();
		                        GBPUSD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO1S3_UP_S2 = 0;
		                for (; GBPUSD_OCO1S3_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets3.Count; GBPUSD_OCO1S3_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO1Sets3[GBPUSD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO1Sets3[GBPUSD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.GBPUSD_UP_S2_OCO1Sets3.Clear();
		                        GBPUSD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO1S4_UP_S2 = 0;
		                for (; GBPUSD_OCO1S4_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets4.Count; GBPUSD_OCO1S4_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO1Sets4[GBPUSD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO1Sets4[GBPUSD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.GBPUSD_UP_S2_OCO1Sets4.Clear();
		                        GBPUSD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO1S5_UP_S2 = 0;
		                for (; GBPUSD_OCO1S5_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets5.Count; GBPUSD_OCO1S5_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO1Sets5[GBPUSD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO1Sets5[GBPUSD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.GBPUSD_UP_S2_OCO1Sets5.Clear();
		                        GBPUSD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO1S6_UP_S2 = 0;
		                for (; GBPUSD_OCO1S6_UP_S2 < Base.GBPUSD_UP_S2_OCO1Sets6.Count; GBPUSD_OCO1S6_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO1Sets6[GBPUSD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO1Sets6[GBPUSD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.GBPUSD_UP_S2_OCO1Sets6.Clear();
		                        GBPUSD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPUSD_OCO2_EO1_UP_S2)
                	Base.GBPUSD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPUSD_OCO2_EO2_UP_S2)
	                Base.GBPUSD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO2_EO3_UP_S2)
	                Base.GBPUSD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO2_EO4_UP_S2)
	                Base.GBPUSD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO2_EO5_UP_S2)
	                Base.GBPUSD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO2_EO6_UP_S2)
	                Base.GBPUSD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPUSD_OCO2S1_UP_S2 = 0;
		                for (; GBPUSD_OCO2S1_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets1.Count; GBPUSD_OCO2S1_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO2Sets1[GBPUSD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO2Sets1[GBPUSD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.GBPUSD_UP_S2_OCO2Sets1.Clear();
		                        GBPUSD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPUSD_OCO2S2_UP_S2 = 0;
		                for (; GBPUSD_OCO2S2_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets2.Count; GBPUSD_OCO2S2_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO2Sets2[GBPUSD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO2Sets2[GBPUSD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.GBPUSD_UP_S2_OCO2Sets2.Clear();
		                        GBPUSD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO2S3_UP_S2 = 0;
		                for (; GBPUSD_OCO2S3_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets3.Count; GBPUSD_OCO2S3_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO2Sets3[GBPUSD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO2Sets3[GBPUSD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.GBPUSD_UP_S2_OCO2Sets3.Clear();
		                        GBPUSD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO2S4_UP_S2 = 0;
		                for (; GBPUSD_OCO2S4_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets4.Count; GBPUSD_OCO2S4_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO2Sets4[GBPUSD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO2Sets4[GBPUSD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.GBPUSD_UP_S2_OCO2Sets4.Clear();
		                        GBPUSD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO2S5_UP_S2 = 0;
		                for (; GBPUSD_OCO2S5_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets5.Count; GBPUSD_OCO2S5_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO2Sets5[GBPUSD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO2Sets5[GBPUSD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.GBPUSD_UP_S2_OCO2Sets5.Clear();
		                        GBPUSD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO2S6_UP_S2 = 0;
		                for (; GBPUSD_OCO2S6_UP_S2 < Base.GBPUSD_UP_S2_OCO2Sets6.Count; GBPUSD_OCO2S6_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO2Sets6[GBPUSD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO2Sets6[GBPUSD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.GBPUSD_UP_S2_OCO2Sets6.Clear();
		                        GBPUSD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPUSD_OCO3_EO1_UP_S2)
            		Base.GBPUSD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPUSD_OCO3_EO2_UP_S2)
	                Base.GBPUSD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO3_EO3_UP_S2)
	                Base.GBPUSD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO3_EO4_UP_S2)
	                Base.GBPUSD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO3_EO5_UP_S2)
	                Base.GBPUSD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO3_EO6_UP_S2)
	                Base.GBPUSD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPUSD_OCO3S1_UP_S2 = 0;
		                for (; GBPUSD_OCO3S1_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets1.Count; GBPUSD_OCO3S1_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO3Sets1[GBPUSD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO3Sets1[GBPUSD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.GBPUSD_UP_S2_OCO3Sets1.Clear();
		                        GBPUSD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPUSD_OCO3S2_UP_S2 = 0;
		                for (; GBPUSD_OCO3S2_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets2.Count; GBPUSD_OCO3S2_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO3Sets2[GBPUSD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO3Sets2[GBPUSD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.GBPUSD_UP_S2_OCO3Sets2.Clear();
		                        GBPUSD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO3S3_UP_S2 = 0;
		                for (; GBPUSD_OCO3S3_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets3.Count; GBPUSD_OCO3S3_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO3Sets3[GBPUSD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO3Sets3[GBPUSD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.GBPUSD_UP_S2_OCO3Sets3.Clear();
		                        GBPUSD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO3S4_UP_S2 = 0;
		                for (; GBPUSD_OCO3S4_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets4.Count; GBPUSD_OCO3S4_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO3Sets4[GBPUSD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO3Sets4[GBPUSD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.GBPUSD_UP_S2_OCO3Sets4.Clear();
		                        GBPUSD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO3S5_UP_S2 = 0;
		                for (; GBPUSD_OCO3S5_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets5.Count; GBPUSD_OCO3S5_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO3Sets5[GBPUSD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO3Sets5[GBPUSD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.GBPUSD_UP_S2_OCO3Sets5.Clear();
		                        GBPUSD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO3S6_UP_S2 = 0;
		                for (; GBPUSD_OCO3S6_UP_S2 < Base.GBPUSD_UP_S2_OCO3Sets6.Count; GBPUSD_OCO3S6_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO3Sets6[GBPUSD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO3Sets6[GBPUSD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.GBPUSD_UP_S2_OCO3Sets6.Clear();
		                        GBPUSD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPUSD_OCO4_EO1_UP_S2)
            		Base.GBPUSD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPUSD_OCO4_EO2_UP_S2)
	                Base.GBPUSD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO4_EO3_UP_S2)
	                Base.GBPUSD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO4_EO4_UP_S2)
	                Base.GBPUSD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO4_EO5_UP_S2)
	                Base.GBPUSD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPUSD_OCO4_EO6_UP_S2)
	                Base.GBPUSD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPUSD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPUSD_OCO4S1_UP_S2 = 0;
		                for (; GBPUSD_OCO4S1_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets1.Count; GBPUSD_OCO4S1_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO4Sets1[GBPUSD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO4Sets1[GBPUSD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.GBPUSD_UP_S2_OCO4Sets1.Clear();
		                        GBPUSD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPUSD_OCO4S2_UP_S2 = 0;
		                for (; GBPUSD_OCO4S2_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets2.Count; GBPUSD_OCO4S2_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO4Sets2[GBPUSD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO4Sets2[GBPUSD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.GBPUSD_UP_S2_OCO4Sets2.Clear();
		                        GBPUSD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO4S3_UP_S2 = 0;
		                for (; GBPUSD_OCO4S3_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets3.Count; GBPUSD_OCO4S3_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO4Sets3[GBPUSD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO4Sets3[GBPUSD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.GBPUSD_UP_S2_OCO4Sets3.Clear();
		                        GBPUSD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPUSD_OCO4S4_UP_S2 = 0;
		                for (; GBPUSD_OCO4S4_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets4.Count; GBPUSD_OCO4S4_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO4Sets4[GBPUSD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO4Sets4[GBPUSD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.GBPUSD_UP_S2_OCO4Sets4.Clear();
		                        GBPUSD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO4S5_UP_S2 = 0;
		                for (; GBPUSD_OCO4S5_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets5.Count; GBPUSD_OCO4S5_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO4Sets5[GBPUSD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO4Sets5[GBPUSD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.GBPUSD_UP_S2_OCO4Sets5.Clear();
		                        GBPUSD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPUSD_OCO4S6_UP_S2 = 0;
		                for (; GBPUSD_OCO4S6_UP_S2 < Base.GBPUSD_UP_S2_OCO4Sets6.Count; GBPUSD_OCO4S6_UP_S2++)
		                    if (Base.GBPUSD_UP_S2_OCO4Sets6[GBPUSD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPUSD_UP_S2_OCO4Sets6[GBPUSD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPUSD", order.Quantity, false, "GBPUSD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.GBPUSD_UP_S2_OCO4Sets6.Clear();
		                        GBPUSD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_GBPUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPUSD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPUSD_UP_S2 = DOWM_GBPUSD_UP_S2 || DOWT_GBPUSD_UP_S2 || DOWW_GBPUSD_UP_S2 || DOWTH_GBPUSD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPUSD"))
	            	{
	            		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.GBPUSD_OCO1_UP_S2_IsReady == false ||
	                    	Base.GBPUSD_OCO2_UP_S2_IsReady == false ||
	                    	Base.GBPUSD_OCO3_UP_S2_IsReady == false ||
	                    	Base.GBPUSD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.GBPUSD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPUSD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPUSD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPUSD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPUSD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.GBPUSD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.GBPUSD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.GBPUSD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	GBPUSD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                							
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	GBPUSD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	GBPUSD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
		
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (GBPUSD_Signal_Condition_UP_1)
	                	{
	                    	GBPUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPUSD_Signal_Condition_UP_2)
	                	{
	                    	GBPUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPUSD_Signal_Condition_UP_3)
	                	{
	                    	GBPUSD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (GBPUSD_Signal_Condition_UP_1)
	                	{
	                    	GBPUSD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (GBPUSD_Signal_Condition_UP_2)
	                	{
	                    	GBPUSD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (GBPUSD_Signal_Condition_UP_3)
	                	{
	                    	GBPUSD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    GBPUSD_UP_S2_TP2 =  GBPUSD_UP_S2_SL * 0;
	                    GBPUSD_UP_S2_TP3 =  GBPUSD_UP_S2_SL * 0;
	                    GBPUSD_UP_S2_TP4 =  GBPUSD_UP_S2_SL * 0;
	                    GBPUSD_UP_S2_TP5 =  GBPUSD_UP_S2_SL * 0;
	                    GBPUSD_UP_S2_TP6 =  GBPUSD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPUSD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPUSD_quantity_SL_UP_S2 = GBPUSD_quantity_UP_S2;
	                    GBPUSD_quantity_TP1_UP_S2 = (int)Math.Floor(GBPUSD_quantity_UP_S2 * 1m);
	                    GBPUSD_quantity_TP2_UP_S2 = (int)Math.Floor(GBPUSD_quantity_TP1_UP_S2 * 0m);
	                    GBPUSD_quantity_TP3_UP_S2 = (int)Math.Floor(GBPUSD_quantity_TP2_UP_S2 * 0m);
	                    GBPUSD_quantity_TP4_UP_S2 = (int)Math.Floor(GBPUSD_quantity_TP3_UP_S2 * 0m);
	                    GBPUSD_quantity_TP5_UP_S2 = (int)Math.Floor(GBPUSD_quantity_TP4_UP_S2 * 0m);
	                    GBPUSD_quantity_TP6_UP_S2 = (int)Math.Floor(GBPUSD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((GBPUSD_Signal_Condition_UP_1 || GBPUSD_Signal_Condition_UP_2 || GBPUSD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPUSD_UP_S2 && 
	                    Base.GBPUSD_OCO1_UP_S2_IsReady == true &&
	                    Base.GBPUSD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPUSD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP1_UP_S2, false,"GBPUSD_UP_S2_Entry_TP1_OCO1");
	                         Base.GBPUSD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.GBPUSD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP2_UP_S2, false,"GBPUSD_UP_S2_Entry_TP2_OCO1");
	                         Base.GBPUSD_OCO1_EO2_UP_S2 = false;
	
	                         Base.GBPUSD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP3_UP_S2, false,"GBPUSD_UP_S2_Entry_TP3_OCO1");
	                         Base.GBPUSD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.GBPUSD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP4_UP_S2, false,"GBPUSD_UP_S2_Entry_TP4_OCO1");
	                         Base.GBPUSD_OCO1_EO4_UP_S2 = false;

							Base.GBPUSD_OCO1_UP_S2_IsReady = false;
							
							if (Base.GBPUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((GBPUSD_Signal_Condition_UP_1 || GBPUSD_Signal_Condition_UP_2 || GBPUSD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPUSD_UP_S2 && 
	                    Base.GBPUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPUSD_OCO2_UP_S2_IsReady == true &&
	                    Base.GBPUSD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPUSD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP1_UP_S2, false,"GBPUSD_UP_S2_Entry_TP1_OCO2");
	                         Base.GBPUSD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.GBPUSD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP2_UP_S2, false,"GBPUSD_UP_S2_Entry_TP2_OCO2");
	                         Base.GBPUSD_OCO2_EO2_UP_S2 = false;
	
	                         Base.GBPUSD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP3_UP_S2, false,"GBPUSD_UP_S2_Entry_TP3_OCO2");
	                         Base.GBPUSD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.GBPUSD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP4_UP_S2, false,"GBPUSD_UP_S2_Entry_TP4_OCO2");
	                         Base.GBPUSD_OCO2_EO4_UP_S2 = false;

							Base.GBPUSD_OCO2_UP_S2_IsReady = false;
							
							if (Base.GBPUSD_OCO2_UP_S2_IsReady == false && Base.GBPUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((GBPUSD_Signal_Condition_UP_1 || GBPUSD_Signal_Condition_UP_2 || GBPUSD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPUSD_UP_S2 &&
	                    Base.GBPUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPUSD_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPUSD_OCO3_UP_S2_IsReady == true &&
	                    Base.GBPUSD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPUSD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP1_UP_S2, false,"GBPUSD_UP_S2_Entry_TP1_OCO3");
	                         Base.GBPUSD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.GBPUSD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP2_UP_S2, false,"GBPUSD_UP_S2_Entry_TP2_OCO3");
	                         Base.GBPUSD_OCO3_EO2_UP_S2 = false;
	
	                         Base.GBPUSD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP3_UP_S2, false,"GBPUSD_UP_S2_Entry_TP3_OCO3");
	                         Base.GBPUSD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.GBPUSD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP4_UP_S2, false,"GBPUSD_UP_S2_Entry_TP4_OCO3");
	                         Base.GBPUSD_OCO3_EO4_UP_S2 = false;

							Base.GBPUSD_OCO3_UP_S2_IsReady = false;
							
							if (Base.GBPUSD_OCO3_UP_S2_IsReady == false && Base.GBPUSD_OCO2_UP_S2_IsReady == false && Base.GBPUSD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((GBPUSD_Signal_Condition_UP_1 || GBPUSD_Signal_Condition_UP_2 || GBPUSD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPUSD_UP_S2 && 
	                    Base.GBPUSD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPUSD_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPUSD_OCO3_UP_S2_IsReady == false &&
	                    Base.GBPUSD_OCO4_UP_S2_IsReady == true &&
	                    Base.GBPUSD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPUSD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP1_UP_S2, false,"GBPUSD_UP_S2_Entry_TP1_OCO4");
	                         Base.GBPUSD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.GBPUSD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP2_UP_S2, false,"GBPUSD_UP_S2_Entry_TP2_OCO4");
	                         Base.GBPUSD_OCO4_EO2_UP_S2 = false;
	
	                         Base.GBPUSD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP3_UP_S2, false,"GBPUSD_UP_S2_Entry_TP3_OCO4");
	                         Base.GBPUSD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.GBPUSD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPUSD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPUSD_quantity_TP4_UP_S2, false,"GBPUSD_UP_S2_Entry_TP4_OCO4");
	                         Base.GBPUSD_OCO4_EO4_UP_S2 = false;

							Base.GBPUSD_OCO4_UP_S2_IsReady = false;
							
							if (Base.GBPUSD_OCO4_UP_S2_IsReady == false && Base.GBPUSD_OCO3_UP_S2_IsReady == false && Base.GBPUSD_OCO2_UP_S2_IsReady == false && Base.GBPUSD_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_CADJPY_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_CADJPY_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("CADJPY_DOWN_S2_OCO1")))
			{
				Base.CADJPY_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CADJPY_DOWN_S2_OCO2")))
			{
				Base.CADJPY_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CADJPY_DOWN_S2_OCO3")))
			{
				Base.CADJPY_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CADJPY_DOWN_S2_OCO4")))
			{
				Base.CADJPY_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("CADJPY_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.CADJPY_OCO1_EO1_DOWN_S2)
	                Base.CADJPY_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.CADJPY_OCO1_EO2_DOWN_S2)
	                Base.CADJPY_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO1_EO3_DOWN_S2)
	                Base.CADJPY_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO1_EO4_DOWN_S2)
	                Base.CADJPY_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO1_EO5_DOWN_S2)
	                Base.CADJPY_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO1_EO6_DOWN_S2)
	                Base.CADJPY_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CADJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int CADJPY_OCO1S1_DOWN_S2 = 0;
		                for (; CADJPY_OCO1S1_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets1.Count; CADJPY_OCO1S1_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO1Sets1[CADJPY_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO1Sets1[CADJPY_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.CADJPY_DOWN_S2_OCO1Sets1.Clear();
		                        CADJPY_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int CADJPY_OCO1S2_DOWN_S2 = 0;
		                for (; CADJPY_OCO1S2_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets2.Count; CADJPY_OCO1S2_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO1Sets2[CADJPY_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO1Sets2[CADJPY_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.CADJPY_DOWN_S2_OCO1Sets2.Clear();
		                        CADJPY_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO1S3_DOWN_S2 = 0;
		                for (; CADJPY_OCO1S3_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets3.Count; CADJPY_OCO1S3_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO1Sets3[CADJPY_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO1Sets3[CADJPY_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.CADJPY_DOWN_S2_OCO1Sets3.Clear();
		                        CADJPY_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO1S4_DOWN_S2 = 0;
		                for (; CADJPY_OCO1S4_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets4.Count; CADJPY_OCO1S4_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO1Sets4[CADJPY_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO1Sets4[CADJPY_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.CADJPY_DOWN_S2_OCO1Sets4.Clear();
		                        CADJPY_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO1S5_DOWN_S2 = 0;
		                for (; CADJPY_OCO1S5_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets5.Count; CADJPY_OCO1S5_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO1Sets5[CADJPY_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO1Sets5[CADJPY_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.CADJPY_DOWN_S2_OCO1Sets5.Clear();
		                        CADJPY_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO1S6_DOWN_S2 = 0;
		                for (; CADJPY_OCO1S6_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO1Sets6.Count; CADJPY_OCO1S6_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO1Sets6[CADJPY_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO1Sets6[CADJPY_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.CADJPY_DOWN_S2_OCO1Sets6.Clear();
		                        CADJPY_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.CADJPY_OCO2_EO1_DOWN_S2)
	                Base.CADJPY_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.CADJPY_OCO2_EO2_DOWN_S2)
	                Base.CADJPY_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO2_EO3_DOWN_S2)
	                Base.CADJPY_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO2_EO4_DOWN_S2)
	                Base.CADJPY_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO2_EO5_DOWN_S2)
	                Base.CADJPY_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO2_EO6_DOWN_S2)
	                Base.CADJPY_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CADJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int CADJPY_OCO2S1_DOWN_S2 = 0;
		                for (; CADJPY_OCO2S1_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets1.Count; CADJPY_OCO2S1_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO2Sets1[CADJPY_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO2Sets1[CADJPY_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.CADJPY_DOWN_S2_OCO2Sets1.Clear();
		                        CADJPY_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int CADJPY_OCO2S2_DOWN_S2 = 0;
		                for (; CADJPY_OCO2S2_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets2.Count; CADJPY_OCO2S2_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO2Sets2[CADJPY_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO2Sets2[CADJPY_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.CADJPY_DOWN_S2_OCO2Sets2.Clear();
		                        CADJPY_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO2S3_DOWN_S2 = 0;
		                for (; CADJPY_OCO2S3_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets3.Count; CADJPY_OCO2S3_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO2Sets3[CADJPY_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO2Sets3[CADJPY_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.CADJPY_DOWN_S2_OCO2Sets3.Clear();
		                        CADJPY_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO2S4_DOWN_S2 = 0;
		                for (; CADJPY_OCO2S4_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets4.Count; CADJPY_OCO2S4_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO2Sets4[CADJPY_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO2Sets4[CADJPY_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.CADJPY_DOWN_S2_OCO2Sets4.Clear();
		                        CADJPY_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO2S5_DOWN_S2 = 0;
		                for (; CADJPY_OCO2S5_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets5.Count; CADJPY_OCO2S5_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO2Sets5[CADJPY_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO2Sets5[CADJPY_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.CADJPY_DOWN_S2_OCO2Sets5.Clear();
		                        CADJPY_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO2S6_DOWN_S2 = 0;
		                for (; CADJPY_OCO2S6_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO2Sets6.Count; CADJPY_OCO2S6_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO2Sets6[CADJPY_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO2Sets6[CADJPY_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.CADJPY_DOWN_S2_OCO2Sets6.Clear();
		                        CADJPY_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.CADJPY_OCO3_EO1_DOWN_S2)
	                Base.CADJPY_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.CADJPY_OCO3_EO2_DOWN_S2)
	                Base.CADJPY_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO3_EO3_DOWN_S2)
	                Base.CADJPY_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO3_EO4_DOWN_S2)
	                Base.CADJPY_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO3_EO5_DOWN_S2)
	                Base.CADJPY_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO3_EO6_DOWN_S2)
	                Base.CADJPY_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CADJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int CADJPY_OCO3S1_DOWN_S2 = 0;
		                for (; CADJPY_OCO3S1_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets1.Count; CADJPY_OCO3S1_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO3Sets1[CADJPY_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO3Sets1[CADJPY_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.CADJPY_DOWN_S2_OCO3Sets1.Clear();
		                        CADJPY_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int CADJPY_OCO3S2_DOWN_S2 = 0;
		                for (; CADJPY_OCO3S2_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets2.Count; CADJPY_OCO3S2_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO3Sets2[CADJPY_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO3Sets2[CADJPY_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.CADJPY_DOWN_S2_OCO3Sets2.Clear();
		                        CADJPY_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO3S3_DOWN_S2 = 0;
		                for (; CADJPY_OCO3S3_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets3.Count; CADJPY_OCO3S3_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO3Sets3[CADJPY_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO3Sets3[CADJPY_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.CADJPY_DOWN_S2_OCO3Sets3.Clear();
		                        CADJPY_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO3S4_DOWN_S2 = 0;
		                for (; CADJPY_OCO3S4_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets4.Count; CADJPY_OCO3S4_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO3Sets4[CADJPY_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO3Sets4[CADJPY_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.CADJPY_DOWN_S2_OCO3Sets4.Clear();
		                        CADJPY_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO3S5_DOWN_S2 = 0;
		                for (; CADJPY_OCO3S5_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets5.Count; CADJPY_OCO3S5_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO3Sets5[CADJPY_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO3Sets5[CADJPY_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.CADJPY_DOWN_S2_OCO3Sets5.Clear();
		                        CADJPY_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO3S6_DOWN_S2 = 0;
		                for (; CADJPY_OCO3S6_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO3Sets6.Count; CADJPY_OCO3S6_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO3Sets6[CADJPY_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO3Sets6[CADJPY_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.CADJPY_DOWN_S2_OCO3Sets6.Clear();
		                        CADJPY_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.CADJPY_OCO4_EO1_DOWN_S2)
	                Base.CADJPY_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.CADJPY_OCO4_EO2_DOWN_S2)
	                Base.CADJPY_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO4_EO3_DOWN_S2)
	                Base.CADJPY_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO4_EO4_DOWN_S2)
	                Base.CADJPY_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO4_EO5_DOWN_S2)
	                Base.CADJPY_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO4_EO6_DOWN_S2)
	                Base.CADJPY_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CADJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int CADJPY_OCO4S1_DOWN_S2 = 0;
		                for (; CADJPY_OCO4S1_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets1.Count; CADJPY_OCO4S1_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO4Sets1[CADJPY_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO4Sets1[CADJPY_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.CADJPY_DOWN_S2_OCO4Sets1.Clear();
		                        CADJPY_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int CADJPY_OCO4S2_DOWN_S2 = 0;
		                for (; CADJPY_OCO4S2_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets2.Count; CADJPY_OCO4S2_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO4Sets2[CADJPY_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO4Sets2[CADJPY_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.CADJPY_DOWN_S2_OCO4Sets2.Clear();
		                        CADJPY_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO4S3_DOWN_S2 = 0;
		                for (; CADJPY_OCO4S3_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets3.Count; CADJPY_OCO4S3_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO4Sets3[CADJPY_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO4Sets3[CADJPY_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.CADJPY_DOWN_S2_OCO4Sets3.Clear();
		                        CADJPY_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO4S4_DOWN_S2 = 0;
		                for (; CADJPY_OCO4S4_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets4.Count; CADJPY_OCO4S4_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO4Sets4[CADJPY_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO4Sets4[CADJPY_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.CADJPY_DOWN_S2_OCO4Sets4.Clear();
		                        CADJPY_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO4S5_DOWN_S2 = 0;
		                for (; CADJPY_OCO4S5_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets5.Count; CADJPY_OCO4S5_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO4Sets5[CADJPY_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO4Sets5[CADJPY_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.CADJPY_DOWN_S2_OCO4Sets5.Clear();
		                        CADJPY_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO4S6_DOWN_S2 = 0;
		                for (; CADJPY_OCO4S6_DOWN_S2 < Base.CADJPY_DOWN_S2_OCO4Sets6.Count; CADJPY_OCO4S6_DOWN_S2++)
		                    if (Base.CADJPY_DOWN_S2_OCO4Sets6[CADJPY_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_DOWN_S2_OCO4Sets6[CADJPY_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.CADJPY_DOWN_S2_OCO4Sets6.Clear();
		                        CADJPY_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();
	            	}
	            	
					DOWM_CADJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_CADJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_CADJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_CADJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_CADJPY_DOWN_S2 = DOWM_CADJPY_DOWN_S2 || DOWT_CADJPY_DOWN_S2 || DOWW_CADJPY_DOWN_S2 || DOWTH_CADJPY_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("CADJPY"))
	            	{
	            		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.CADJPY_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.CADJPY_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.CADJPY_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.CADJPY_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.CADJPY_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.CADJPY_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.CADJPY_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.CADJPY_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.CADJPY_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.CADJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.CADJPY_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.CADJPY_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	CADJPY_Signal_Condition_DOWN_1 =	
	                									(
		                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > Base.Yen_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.Yen_Min_SPRD
	                									);
	                									
	                	CADJPY_Signal_Condition_DOWN_2 =	
	                									(
		                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > Base.Yen_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.Yen_Min_SPRD
	                									);
	                									
	                									
	                	CADJPY_Signal_Condition_DOWN_3 =	
	                									(
		                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > Base.Yen_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.Yen_Min_SPRD
	                									);
	                									
	                	if (CADJPY_Signal_Condition_DOWN_1)
	                	{
	                    	CADJPY_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (CADJPY_Signal_Condition_DOWN_2)
	                	{
	                    	CADJPY_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (CADJPY_Signal_Condition_DOWN_3)
	                	{
	                    	CADJPY_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	
	                	if (CADJPY_Signal_Condition_DOWN_1)
	                	{
	                    	CADJPY_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Static_Yen_TP_1 ;
	                	}
	                	
	                	if (CADJPY_Signal_Condition_DOWN_2)
	                	{
	                    	CADJPY_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Static_Yen_TP_1 ;
	                	}
	                	
	                	if (CADJPY_Signal_Condition_DOWN_3)
	                	{
	                    	CADJPY_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Static_Yen_TP_1 ;
	                	}
	                	
	                    CADJPY_DOWN_S2_TP2 =  CADJPY_DOWN_S2_SL * 0;
	                    CADJPY_DOWN_S2_TP3 =  CADJPY_DOWN_S2_SL * 0;
	                    CADJPY_DOWN_S2_TP4 =  CADJPY_DOWN_S2_SL * 0;
	                    CADJPY_DOWN_S2_TP5 =  CADJPY_DOWN_S2_SL * 0;
	                    CADJPY_DOWN_S2_TP6 =  CADJPY_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0 && CADJPY_DOWN_S2_SL !=  0)
	                    {
	                    CADJPY_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)*0.015m);
	                    CADJPY_quantity_SL_DOWN_S2 = CADJPY_quantity_DOWN_S2;
	                    CADJPY_quantity_TP1_DOWN_S2 = (CADJPY_quantity_DOWN_S2 );
	                    CADJPY_quantity_TP2_DOWN_S2 = (CADJPY_quantity_TP1_DOWN_S2 * 0);
	                    CADJPY_quantity_TP3_DOWN_S2 = (CADJPY_quantity_TP2_DOWN_S2 * 0);
	                    CADJPY_quantity_TP4_DOWN_S2 = (CADJPY_quantity_TP3_DOWN_S2 * 0);
	                    CADJPY_quantity_TP5_DOWN_S2 = (CADJPY_quantity_TP4_DOWN_S2 * 0);
	                    CADJPY_quantity_TP6_DOWN_S2 = (CADJPY_quantity_TP5_DOWN_S2 * 0);
	                    }
	                    
	                    oco1:
	                    if ((CADJPY_Signal_Condition_DOWN_1 || CADJPY_Signal_Condition_DOWN_2 || CADJPY_Signal_Condition_DOWN_3)  && 
	                    DOWR_CADJPY_DOWN_S2 && 
	                    Base.CADJPY_OCO1_DOWN_S2_IsReady == true &&
	                    Base.CADJPY_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.CADJPY_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP1_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP1_OCO1");
	                         Base.CADJPY_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.CADJPY_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP2_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP2_OCO1");
	                         Base.CADJPY_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.CADJPY_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP3_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP3_OCO1");
	                         Base.CADJPY_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.CADJPY_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP4_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP4_OCO1");
	                         Base.CADJPY_OCO1_EO4_DOWN_S2 = false;

							Base.CADJPY_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.CADJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((CADJPY_Signal_Condition_DOWN_1 || CADJPY_Signal_Condition_DOWN_2 || CADJPY_Signal_Condition_DOWN_3)  && 
	                    DOWR_CADJPY_DOWN_S2 && 
	                    Base.CADJPY_OCO2_DOWN_S2_IsReady == true &&
	                    Base.CADJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.CADJPY_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.CADJPY_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP1_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP1_OCO2");
	                         Base.CADJPY_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.CADJPY_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP2_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP2_OCO2");
	                         Base.CADJPY_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.CADJPY_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP3_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP3_OCO2");
	                         Base.CADJPY_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.CADJPY_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP4_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP4_OCO2");
	                         Base.CADJPY_OCO2_EO4_DOWN_S2 = false;

							Base.CADJPY_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.CADJPY_OCO2_DOWN_S2_IsReady == false && Base.CADJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((CADJPY_Signal_Condition_DOWN_1 || CADJPY_Signal_Condition_DOWN_2 || CADJPY_Signal_Condition_DOWN_3)  && 
	                    DOWR_CADJPY_DOWN_S2 &&
	                    Base.CADJPY_OCO3_DOWN_S2_IsReady == true &&
	                    Base.CADJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.CADJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.CADJPY_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.CADJPY_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP1_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP1_OCO3");
	                         Base.CADJPY_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.CADJPY_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP2_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP2_OCO3");
	                         Base.CADJPY_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.CADJPY_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP3_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP3_OCO3");
	                         Base.CADJPY_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.CADJPY_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP4_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP4_OCO3");
	                         Base.CADJPY_OCO3_EO4_DOWN_S2 = false;

							Base.CADJPY_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.CADJPY_OCO3_DOWN_S2_IsReady == false && Base.CADJPY_OCO2_DOWN_S2_IsReady == false && Base.CADJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((CADJPY_Signal_Condition_DOWN_1 || CADJPY_Signal_Condition_DOWN_2 || CADJPY_Signal_Condition_DOWN_3)  && 
	                    DOWR_CADJPY_DOWN_S2 && 
	                    Base.CADJPY_OCO4_DOWN_S2_IsReady == true &&
	                    Base.CADJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.CADJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.CADJPY_OCO3_DOWN_S2_IsReady == false &&
	                    Base.CADJPY_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.CADJPY_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP1_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP1_OCO4");
	                         Base.CADJPY_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.CADJPY_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP2_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP2_OCO4");
	                         Base.CADJPY_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.CADJPY_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP3_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP3_OCO4");
	                         Base.CADJPY_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.CADJPY_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         CADJPY_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP4_DOWN_S2, false,"CADJPY_DOWN_S2_Entry_TP4_OCO4");
	                         Base.CADJPY_OCO4_EO4_DOWN_S2 = false;

							Base.CADJPY_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.CADJPY_OCO4_DOWN_S2_IsReady == false && Base.CADJPY_OCO3_DOWN_S2_IsReady == false && Base.CADJPY_OCO2_DOWN_S2_IsReady == false && Base.CADJPY_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct AUDUSD_OCO1_DOWN_S2
    {
        public AUDUSD_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 =="TP1_AUDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD 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 =="TP1_AUDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD 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 AUDUSD_OCO1_UP_S2
    {
        public AUDUSD_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 =="TP1_AUDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD 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 =="TP1_AUDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDUSD 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 AUDUSD_OCO2_DOWN_S2
    {
        public AUDUSD_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 =="TP1_AUDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD 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 =="TP1_AUDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD 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 AUDUSD_OCO2_UP_S2
    {
        public AUDUSD_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 =="TP1_AUDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD 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 =="TP1_AUDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDUSD 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 AUDUSD_OCO3_DOWN_S2
    {
        public AUDUSD_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 =="TP1_AUDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD 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 =="TP1_AUDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD 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 AUDUSD_OCO3_UP_S2
    {
        public AUDUSD_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 =="TP1_AUDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD 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 =="TP1_AUDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDUSD 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 AUDUSD_OCO4_DOWN_S2
    {
        public AUDUSD_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 =="TP1_AUDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD 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 =="TP1_AUDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD 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 AUDUSD_OCO4_UP_S2
    {
        public AUDUSD_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 =="TP1_AUDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD 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 =="TP1_AUDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDUSD 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 NZDCAD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public NZDCAD_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("NZDCAD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCAD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCAD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCAD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCAD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCAD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCAD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        }
		        
				if (Base.NZDCAD_OCO1_EO1_UP_S2)
	                Base.NZDCAD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCAD_OCO1_EO2_UP_S2)
	                Base.NZDCAD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO1_EO3_UP_S2)
	                Base.NZDCAD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO1_EO4_UP_S2)
	                Base.NZDCAD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO1_EO5_UP_S2)
	                Base.NZDCAD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO1_EO6_UP_S2)
	                Base.NZDCAD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.NZDCAD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP1,"TP1_NZDCAD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP1_NZDCAD_UP_S2_OCO1"));
		                 };
		                Base.NZDCAD_UP_S2_OCO1Sets1.Add( Base.NZDCAD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP2,"TP2_NZDCAD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP2_NZDCAD_UP_S2_OCO1"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO1Sets2.Add( Base.NZDCAD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP3,"TP3_NZDCAD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP3_NZDCAD_UP_S2_OCO1"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO1Sets3.Add( Base.NZDCAD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP4,"TP4_NZDCAD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP4_NZDCAD_UP_S2_OCO1"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO1Sets4.Add( Base.NZDCAD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP5,"TP5_NZDCAD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP5_NZDCAD_UP_S2_OCO1"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO1Sets5.Add( Base.NZDCAD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP6,"TP6_NZDCAD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP6_NZDCAD_UP_S2_OCO1"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO1Sets6.Add( Base.NZDCAD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDCAD_OCO1S1_UP_S2 = 0;
	                for (; NZDCAD_OCO1S1_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets1.Count; NZDCAD_OCO1S1_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO1Sets1[NZDCAD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO1Sets1[NZDCAD_OCO1S1_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO1Sets1.RemoveAt(NZDCAD_OCO1S1_UP_S2);
	                        NZDCAD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCAD_OCO1S2_UP_S2 = 0;
	                for (; NZDCAD_OCO1S2_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets2.Count; NZDCAD_OCO1S2_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO1Sets2[NZDCAD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO1Sets2[NZDCAD_OCO1S2_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO1Sets2.RemoveAt(NZDCAD_OCO1S2_UP_S2);
	                        NZDCAD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO1S3_UP_S2 = 0;
	                for (; NZDCAD_OCO1S3_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets3.Count; NZDCAD_OCO1S3_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO1Sets3[NZDCAD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO1Sets3[NZDCAD_OCO1S3_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO1Sets3.RemoveAt(NZDCAD_OCO1S3_UP_S2);
	                        NZDCAD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO1S4_UP_S2 = 0;
	                for (; NZDCAD_OCO1S4_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets4.Count; NZDCAD_OCO1S4_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO1Sets4[NZDCAD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO1Sets4[NZDCAD_OCO1S4_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO1Sets4.RemoveAt(NZDCAD_OCO1S4_UP_S2);
	                        NZDCAD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCAD_OCO1S5_UP_S2 = 0;
	                for (; NZDCAD_OCO1S5_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets5.Count; NZDCAD_OCO1S5_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO1Sets5[NZDCAD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO1Sets5[NZDCAD_OCO1S5_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO1Sets5.RemoveAt(NZDCAD_OCO1S5_UP_S2);
	                        NZDCAD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCAD_OCO1S6_UP_S2 = 0;
	                for (; NZDCAD_OCO1S6_UP_S2 < Base.NZDCAD_UP_S2_OCO1Sets6.Count; NZDCAD_OCO1S6_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO1Sets6[NZDCAD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO1Sets6[NZDCAD_OCO1S6_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO1Sets6.RemoveAt(NZDCAD_OCO1S6_UP_S2);
	                        NZDCAD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.NZDCAD_OCO2_EO1_UP_S2)
	                Base.NZDCAD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCAD_OCO2_EO2_UP_S2)
	                Base.NZDCAD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO2_EO3_UP_S2)
	                Base.NZDCAD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO2_EO4_UP_S2)
	                Base.NZDCAD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO2_EO5_UP_S2)
	                Base.NZDCAD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO2_EO6_UP_S2)
	                Base.NZDCAD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.NZDCAD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP1,"TP1_NZDCAD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP1_NZDCAD_UP_S2_OCO2"));
		                 };
		                Base.NZDCAD_UP_S2_OCO2Sets1.Add( Base.NZDCAD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP2,"TP2_NZDCAD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP2_NZDCAD_UP_S2_OCO2"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO2Sets2.Add( Base.NZDCAD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP3,"TP3_NZDCAD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP3_NZDCAD_UP_S2_OCO2"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO2Sets3.Add( Base.NZDCAD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP4,"TP4_NZDCAD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP4_NZDCAD_UP_S2_OCO2"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO2Sets4.Add( Base.NZDCAD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP5,"TP5_NZDCAD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP5_NZDCAD_UP_S2_OCO2"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO2Sets5.Add( Base.NZDCAD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP6,"TP6_NZDCAD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP6_NZDCAD_UP_S2_OCO2"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO2Sets6.Add( Base.NZDCAD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDCAD_OCO2S1_UP_S2 = 0;
	                for (; NZDCAD_OCO2S1_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets1.Count; NZDCAD_OCO2S1_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO2Sets1[NZDCAD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO2Sets1[NZDCAD_OCO2S1_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO2Sets1.RemoveAt(NZDCAD_OCO2S1_UP_S2);
	                        NZDCAD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCAD_OCO2S2_UP_S2 = 0;
	                for (; NZDCAD_OCO2S2_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets2.Count; NZDCAD_OCO2S2_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO2Sets2[NZDCAD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO2Sets2[NZDCAD_OCO2S2_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO2Sets2.RemoveAt(NZDCAD_OCO2S2_UP_S2);
	                        NZDCAD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO2S3_UP_S2 = 0;
	                for (; NZDCAD_OCO2S3_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets3.Count; NZDCAD_OCO2S3_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO2Sets3[NZDCAD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO2Sets3[NZDCAD_OCO2S3_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO2Sets3.RemoveAt(NZDCAD_OCO2S3_UP_S2);
	                        NZDCAD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO2S4_UP_S2 = 0;
	                for (; NZDCAD_OCO2S4_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets4.Count; NZDCAD_OCO2S4_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO2Sets4[NZDCAD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO2Sets4[NZDCAD_OCO2S4_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO2Sets4.RemoveAt(NZDCAD_OCO2S4_UP_S2);
	                        NZDCAD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCAD_OCO2S5_UP_S2 = 0;
	                for (; NZDCAD_OCO2S5_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets5.Count; NZDCAD_OCO2S5_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO2Sets5[NZDCAD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO2Sets5[NZDCAD_OCO2S5_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO2Sets5.RemoveAt(NZDCAD_OCO2S5_UP_S2);
	                        NZDCAD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCAD_OCO2S6_UP_S2 = 0;
	                for (; NZDCAD_OCO2S6_UP_S2 < Base.NZDCAD_UP_S2_OCO2Sets6.Count; NZDCAD_OCO2S6_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO2Sets6[NZDCAD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO2Sets6[NZDCAD_OCO2S6_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO2Sets6.RemoveAt(NZDCAD_OCO2S6_UP_S2);
	                        NZDCAD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCAD_OCO3_EO1_UP_S2)
	                Base.NZDCAD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCAD_OCO3_EO2_UP_S2)
	                Base.NZDCAD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO3_EO3_UP_S2)
	                Base.NZDCAD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO3_EO4_UP_S2)
	                Base.NZDCAD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO3_EO5_UP_S2)
	                Base.NZDCAD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO3_EO6_UP_S2)
	                Base.NZDCAD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.NZDCAD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP1,"TP1_NZDCAD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP1_NZDCAD_UP_S2_OCO3"));
		                 };
		                Base.NZDCAD_UP_S2_OCO3Sets1.Add( Base.NZDCAD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP2,"TP2_NZDCAD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP2_NZDCAD_UP_S2_OCO3"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO3Sets2.Add( Base.NZDCAD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP3,"TP3_NZDCAD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP3_NZDCAD_UP_S2_OCO3"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO3Sets3.Add( Base.NZDCAD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP4,"TP4_NZDCAD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP4_NZDCAD_UP_S2_OCO3"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO3Sets4.Add( Base.NZDCAD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP5,"TP5_NZDCAD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP5_NZDCAD_UP_S2_OCO3"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO3Sets5.Add( Base.NZDCAD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP6,"TP6_NZDCAD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP6_NZDCAD_UP_S2_OCO3"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO3Sets6.Add( Base.NZDCAD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDCAD_OCO3S1_UP_S2 = 0;
	                for (; NZDCAD_OCO3S1_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets1.Count; NZDCAD_OCO3S1_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO3Sets1[NZDCAD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO3Sets1[NZDCAD_OCO3S1_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO3Sets1.RemoveAt(NZDCAD_OCO3S1_UP_S2);
	                        NZDCAD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCAD_OCO3S2_UP_S2 = 0;
	                for (; NZDCAD_OCO3S2_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets2.Count; NZDCAD_OCO3S2_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO3Sets2[NZDCAD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO3Sets2[NZDCAD_OCO3S2_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO3Sets2.RemoveAt(NZDCAD_OCO3S2_UP_S2);
	                        NZDCAD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO3S3_UP_S2 = 0;
	                for (; NZDCAD_OCO3S3_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets3.Count; NZDCAD_OCO3S3_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO3Sets3[NZDCAD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO3Sets3[NZDCAD_OCO3S3_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO3Sets3.RemoveAt(NZDCAD_OCO3S3_UP_S2);
	                        NZDCAD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO3S4_UP_S2 = 0;
	                for (; NZDCAD_OCO3S4_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets4.Count; NZDCAD_OCO3S4_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO3Sets4[NZDCAD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO3Sets4[NZDCAD_OCO3S4_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO3Sets4.RemoveAt(NZDCAD_OCO3S4_UP_S2);
	                        NZDCAD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCAD_OCO3S5_UP_S2 = 0;
	                for (; NZDCAD_OCO3S5_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets5.Count; NZDCAD_OCO3S5_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO3Sets5[NZDCAD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO3Sets5[NZDCAD_OCO3S5_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO3Sets5.RemoveAt(NZDCAD_OCO3S5_UP_S2);
	                        NZDCAD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCAD_OCO3S6_UP_S2 = 0;
	                for (; NZDCAD_OCO3S6_UP_S2 < Base.NZDCAD_UP_S2_OCO3Sets6.Count; NZDCAD_OCO3S6_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO3Sets6[NZDCAD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO3Sets6[NZDCAD_OCO3S6_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO3Sets6.RemoveAt(NZDCAD_OCO3S6_UP_S2);
	                        NZDCAD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCAD_OCO4_EO1_UP_S2)
	                Base.NZDCAD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCAD_OCO4_EO2_UP_S2)
	                Base.NZDCAD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO4_EO3_UP_S2)
	                Base.NZDCAD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO4_EO4_UP_S2)
	                Base.NZDCAD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO4_EO5_UP_S2)
	                Base.NZDCAD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO4_EO6_UP_S2)
	                Base.NZDCAD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.NZDCAD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP1,"TP1_NZDCAD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP1_NZDCAD_UP_S2_OCO4"));
		                 };
		                Base.NZDCAD_UP_S2_OCO4Sets1.Add( Base.NZDCAD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP2,"TP2_NZDCAD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP2_NZDCAD_UP_S2_OCO4"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO4Sets2.Add( Base.NZDCAD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP3,"TP3_NZDCAD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP3_NZDCAD_UP_S2_OCO4"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO4Sets3.Add( Base.NZDCAD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP4,"TP4_NZDCAD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP4_NZDCAD_UP_S2_OCO4"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO4Sets4.Add( Base.NZDCAD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP5,"TP5_NZDCAD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP5_NZDCAD_UP_S2_OCO4"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO4Sets5.Add( Base.NZDCAD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_UP_S2_TP6,"TP6_NZDCAD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_UP_S2_SL,"SL_TP6_NZDCAD_UP_S2_OCO4"));
		                 };
	                    Base.NZDCAD_UP_S2_OCO4Sets6.Add( Base.NZDCAD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDCAD_OCO4S1_UP_S2 = 0;
	                for (; NZDCAD_OCO4S1_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets1.Count; NZDCAD_OCO4S1_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO4Sets1[NZDCAD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO4Sets1[NZDCAD_OCO4S1_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO4Sets1.RemoveAt(NZDCAD_OCO4S1_UP_S2);
	                        NZDCAD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCAD_OCO4S2_UP_S2 = 0;
	                for (; NZDCAD_OCO4S2_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets2.Count; NZDCAD_OCO4S2_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO4Sets2[NZDCAD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO4Sets2[NZDCAD_OCO4S2_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO4Sets2.RemoveAt(NZDCAD_OCO4S2_UP_S2);
	                        NZDCAD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO4S3_UP_S2 = 0;
	                for (; NZDCAD_OCO4S3_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets3.Count; NZDCAD_OCO4S3_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO4Sets3[NZDCAD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO4Sets3[NZDCAD_OCO4S3_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO4Sets3.RemoveAt(NZDCAD_OCO4S3_UP_S2);
	                        NZDCAD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO4S4_UP_S2 = 0;
	                for (; NZDCAD_OCO4S4_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets4.Count; NZDCAD_OCO4S4_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO4Sets4[NZDCAD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO4Sets4[NZDCAD_OCO4S4_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO4Sets4.RemoveAt(NZDCAD_OCO4S4_UP_S2);
	                        NZDCAD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCAD_OCO4S5_UP_S2 = 0;
	                for (; NZDCAD_OCO4S5_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets5.Count; NZDCAD_OCO4S5_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO4Sets5[NZDCAD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO4Sets5[NZDCAD_OCO4S5_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO4Sets5.RemoveAt(NZDCAD_OCO4S5_UP_S2);
	                        NZDCAD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCAD_OCO4S6_UP_S2 = 0;
	                for (; NZDCAD_OCO4S6_UP_S2 < Base.NZDCAD_UP_S2_OCO4Sets6.Count; NZDCAD_OCO4S6_UP_S2++)
	                    if (Base.NZDCAD_UP_S2_OCO4Sets6[NZDCAD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_UP_S2_OCO4Sets6[NZDCAD_OCO4S6_UP_S2].Filled();
	                        Base.NZDCAD_UP_S2_OCO4Sets6.RemoveAt(NZDCAD_OCO4S6_UP_S2);
	                        NZDCAD_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct USDCHF_OCO1_DOWN_S2
    {
        public USDCHF_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 =="TP1_USDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF 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 =="TP1_USDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF 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 USDCHF_OCO1_UP_S2
    {
        public USDCHF_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 =="TP1_USDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF 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 =="TP1_USDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDCHF 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 USDCHF_OCO2_DOWN_S2
    {
        public USDCHF_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 =="TP1_USDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF 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 =="TP1_USDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF 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 USDCHF_OCO2_UP_S2
    {
        public USDCHF_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 =="TP1_USDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF 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 =="TP1_USDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDCHF 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 USDCHF_OCO3_DOWN_S2
    {
        public USDCHF_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 =="TP1_USDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF 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 =="TP1_USDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF 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 USDCHF_OCO3_UP_S2
    {
        public USDCHF_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 =="TP1_USDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF 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 =="TP1_USDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDCHF 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 USDCHF_OCO4_DOWN_S2
    {
        public USDCHF_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 =="TP1_USDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF 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 =="TP1_USDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF 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 USDCHF_OCO4_UP_S2
    {
        public USDCHF_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 =="TP1_USDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF 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 =="TP1_USDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDCHF 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_CADJPY_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_CADJPY_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(x=>x.Tag.Contains("CADJPY_UP_S2_OCO1")))
			{
				Base.CADJPY_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CADJPY_UP_S2_OCO2")))
			{
				Base.CADJPY_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CADJPY_UP_S2_OCO3")))
			{
				Base.CADJPY_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CADJPY_UP_S2_OCO4")))
			{
				Base.CADJPY_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("CADJPY_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.CADJPY_OCO1_EO1_UP_S2)
	                Base.CADJPY_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.CADJPY_OCO1_EO2_UP_S2)
	                Base.CADJPY_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO1_EO3_UP_S2)
	                Base.CADJPY_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO1_EO4_UP_S2)
	                Base.CADJPY_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO1_EO5_UP_S2)
	                Base.CADJPY_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO1_EO6_UP_S2)
	                Base.CADJPY_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CADJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int CADJPY_OCO1S1_UP_S2 = 0;
		                for (; CADJPY_OCO1S1_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets1.Count; CADJPY_OCO1S1_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO1Sets1[CADJPY_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO1Sets1[CADJPY_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_1__Time out_OCO1");
		                        Base.CADJPY_UP_S2_OCO1Sets1.Clear();
		                        CADJPY_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int CADJPY_OCO1S2_UP_S2 = 0;
		                for (; CADJPY_OCO1S2_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets2.Count; CADJPY_OCO1S2_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO1Sets2[CADJPY_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO1Sets2[CADJPY_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_2__Time out_OCO1");
		                        Base.CADJPY_UP_S2_OCO1Sets2.Clear();
		                        CADJPY_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO1S3_UP_S2 = 0;
		                for (; CADJPY_OCO1S3_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets3.Count; CADJPY_OCO1S3_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO1Sets3[CADJPY_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO1Sets3[CADJPY_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_3__Time out_OCO1");
		                        Base.CADJPY_UP_S2_OCO1Sets3.Clear();
		                        CADJPY_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO1S4_UP_S2 = 0;
		                for (; CADJPY_OCO1S4_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets4.Count; CADJPY_OCO1S4_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO1Sets4[CADJPY_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO1Sets4[CADJPY_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_4__Time out_OCO1");
		                        Base.CADJPY_UP_S2_OCO1Sets4.Clear();
		                        CADJPY_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO1S5_UP_S2 = 0;
		                for (; CADJPY_OCO1S5_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets5.Count; CADJPY_OCO1S5_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO1Sets5[CADJPY_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO1Sets5[CADJPY_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_5__Time out_OCO1");
		                        Base.CADJPY_UP_S2_OCO1Sets5.Clear();
		                        CADJPY_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO1S6_UP_S2 = 0;
		                for (; CADJPY_OCO1S6_UP_S2 < Base.CADJPY_UP_S2_OCO1Sets6.Count; CADJPY_OCO1S6_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO1Sets6[CADJPY_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO1Sets6[CADJPY_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_6__Time out_OCO1");
		                        Base.CADJPY_UP_S2_OCO1Sets6.Clear();
		                        CADJPY_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.CADJPY_OCO2_EO1_UP_S2)
                	Base.CADJPY_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.CADJPY_OCO2_EO2_UP_S2)
	                Base.CADJPY_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO2_EO3_UP_S2)
	                Base.CADJPY_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO2_EO4_UP_S2)
	                Base.CADJPY_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO2_EO5_UP_S2)
	                Base.CADJPY_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO2_EO6_UP_S2)
	                Base.CADJPY_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CADJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int CADJPY_OCO2S1_UP_S2 = 0;
		                for (; CADJPY_OCO2S1_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets1.Count; CADJPY_OCO2S1_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO2Sets1[CADJPY_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO2Sets1[CADJPY_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_1__Time out_OCO2");
		                        Base.CADJPY_UP_S2_OCO2Sets1.Clear();
		                        CADJPY_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int CADJPY_OCO2S2_UP_S2 = 0;
		                for (; CADJPY_OCO2S2_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets2.Count; CADJPY_OCO2S2_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO2Sets2[CADJPY_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO2Sets2[CADJPY_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_2__Time out_OCO2");
		                        Base.CADJPY_UP_S2_OCO2Sets2.Clear();
		                        CADJPY_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO2S3_UP_S2 = 0;
		                for (; CADJPY_OCO2S3_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets3.Count; CADJPY_OCO2S3_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO2Sets3[CADJPY_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO2Sets3[CADJPY_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_3__Time out_OCO2");
		                        Base.CADJPY_UP_S2_OCO2Sets3.Clear();
		                        CADJPY_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO2S4_UP_S2 = 0;
		                for (; CADJPY_OCO2S4_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets4.Count; CADJPY_OCO2S4_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO2Sets4[CADJPY_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO2Sets4[CADJPY_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_4__Time out_OCO2");
		                        Base.CADJPY_UP_S2_OCO2Sets4.Clear();
		                        CADJPY_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO2S5_UP_S2 = 0;
		                for (; CADJPY_OCO2S5_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets5.Count; CADJPY_OCO2S5_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO2Sets5[CADJPY_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO2Sets5[CADJPY_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_5__Time out_OCO2");
		                        Base.CADJPY_UP_S2_OCO2Sets5.Clear();
		                        CADJPY_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO2S6_UP_S2 = 0;
		                for (; CADJPY_OCO2S6_UP_S2 < Base.CADJPY_UP_S2_OCO2Sets6.Count; CADJPY_OCO2S6_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO2Sets6[CADJPY_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO2Sets6[CADJPY_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_6__Time out_OCO2");
		                        Base.CADJPY_UP_S2_OCO2Sets6.Clear();
		                        CADJPY_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.CADJPY_OCO3_EO1_UP_S2)
            		Base.CADJPY_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.CADJPY_OCO3_EO2_UP_S2)
	                Base.CADJPY_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO3_EO3_UP_S2)
	                Base.CADJPY_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO3_EO4_UP_S2)
	                Base.CADJPY_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO3_EO5_UP_S2)
	                Base.CADJPY_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO3_EO6_UP_S2)
	                Base.CADJPY_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CADJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int CADJPY_OCO3S1_UP_S2 = 0;
		                for (; CADJPY_OCO3S1_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets1.Count; CADJPY_OCO3S1_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO3Sets1[CADJPY_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO3Sets1[CADJPY_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_1__Time out_OCO3");
		                        Base.CADJPY_UP_S2_OCO3Sets1.Clear();
		                        CADJPY_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int CADJPY_OCO3S2_UP_S2 = 0;
		                for (; CADJPY_OCO3S2_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets2.Count; CADJPY_OCO3S2_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO3Sets2[CADJPY_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO3Sets2[CADJPY_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_2__Time out_OCO3");
		                        Base.CADJPY_UP_S2_OCO3Sets2.Clear();
		                        CADJPY_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO3S3_UP_S2 = 0;
		                for (; CADJPY_OCO3S3_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets3.Count; CADJPY_OCO3S3_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO3Sets3[CADJPY_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO3Sets3[CADJPY_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_3__Time out_OCO3");
		                        Base.CADJPY_UP_S2_OCO3Sets3.Clear();
		                        CADJPY_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO3S4_UP_S2 = 0;
		                for (; CADJPY_OCO3S4_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets4.Count; CADJPY_OCO3S4_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO3Sets4[CADJPY_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO3Sets4[CADJPY_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_4__Time out_OCO3");
		                        Base.CADJPY_UP_S2_OCO3Sets4.Clear();
		                        CADJPY_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO3S5_UP_S2 = 0;
		                for (; CADJPY_OCO3S5_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets5.Count; CADJPY_OCO3S5_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO3Sets5[CADJPY_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO3Sets5[CADJPY_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_5__Time out_OCO3");
		                        Base.CADJPY_UP_S2_OCO3Sets5.Clear();
		                        CADJPY_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO3S6_UP_S2 = 0;
		                for (; CADJPY_OCO3S6_UP_S2 < Base.CADJPY_UP_S2_OCO3Sets6.Count; CADJPY_OCO3S6_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO3Sets6[CADJPY_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO3Sets6[CADJPY_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_6__Time out_OCO3");
		                        Base.CADJPY_UP_S2_OCO3Sets6.Clear();
		                        CADJPY_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.CADJPY_OCO4_EO1_UP_S2)
            		Base.CADJPY_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.CADJPY_OCO4_EO2_UP_S2)
	                Base.CADJPY_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO4_EO3_UP_S2)
	                Base.CADJPY_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO4_EO4_UP_S2)
	                Base.CADJPY_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO4_EO5_UP_S2)
	                Base.CADJPY_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.CADJPY_OCO4_EO6_UP_S2)
	                Base.CADJPY_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CADJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int CADJPY_OCO4S1_UP_S2 = 0;
		                for (; CADJPY_OCO4S1_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets1.Count; CADJPY_OCO4S1_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO4Sets1[CADJPY_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO4Sets1[CADJPY_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_1__Time out_OCO4");
		                        Base.CADJPY_UP_S2_OCO4Sets1.Clear();
		                        CADJPY_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int CADJPY_OCO4S2_UP_S2 = 0;
		                for (; CADJPY_OCO4S2_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets2.Count; CADJPY_OCO4S2_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO4Sets2[CADJPY_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO4Sets2[CADJPY_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_2__Time out_OCO4");
		                        Base.CADJPY_UP_S2_OCO4Sets2.Clear();
		                        CADJPY_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO4S3_UP_S2 = 0;
		                for (; CADJPY_OCO4S3_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets3.Count; CADJPY_OCO4S3_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO4Sets3[CADJPY_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO4Sets3[CADJPY_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_3__Time out_OCO4");
		                        Base.CADJPY_UP_S2_OCO4Sets3.Clear();
		                        CADJPY_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CADJPY_OCO4S4_UP_S2 = 0;
		                for (; CADJPY_OCO4S4_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets4.Count; CADJPY_OCO4S4_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO4Sets4[CADJPY_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO4Sets4[CADJPY_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_4__Time out_OCO4");
		                        Base.CADJPY_UP_S2_OCO4Sets4.Clear();
		                        CADJPY_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO4S5_UP_S2 = 0;
		                for (; CADJPY_OCO4S5_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets5.Count; CADJPY_OCO4S5_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO4Sets5[CADJPY_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO4Sets5[CADJPY_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_5__Time out_OCO4");
		                        Base.CADJPY_UP_S2_OCO4Sets5.Clear();
		                        CADJPY_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CADJPY_OCO4S6_UP_S2 = 0;
		                for (; CADJPY_OCO4S6_UP_S2 < Base.CADJPY_UP_S2_OCO4Sets6.Count; CADJPY_OCO4S6_UP_S2++)
		                    if (Base.CADJPY_UP_S2_OCO4Sets6[CADJPY_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CADJPY_UP_S2_OCO4Sets6[CADJPY_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("CADJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CADJPY", order.Quantity, false, "CADJPY_UP_S2_Entry_6__Time out_OCO4");
		                        Base.CADJPY_UP_S2_OCO4Sets6.Clear();
		                        CADJPY_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_CADJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_CADJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_CADJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_CADJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_CADJPY_UP_S2 = DOWM_CADJPY_UP_S2 || DOWT_CADJPY_UP_S2 || DOWW_CADJPY_UP_S2 || DOWTH_CADJPY_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("CADJPY") && SY1D.Symbol.ID.Market == Market.FXCM)
	            	{
	            		if(SY1D.BQ[0].Open != 0)
	            		{
	            			algorithm.Debug("ID : " + SY1D.Symbol.ID.Market);
	            		}
	            		
	            		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.CADJPY_OCO1_UP_S2_IsReady == false ||
	                    	Base.CADJPY_OCO2_UP_S2_IsReady == false ||
	                    	Base.CADJPY_OCO3_UP_S2_IsReady == false ||
	                    	Base.CADJPY_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.CADJPY_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.CADJPY_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.CADJPY_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.CADJPY_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.CADJPY_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.CADJPY_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.CADJPY_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.CADJPY_OCO4_UP_S2_Monthly_IsReady = true;
                    	}

	                	CADJPY_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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.Yen_Min_SPRD
	                									);
	                									
	                	CADJPY_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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.Yen_Min_SPRD
	                									);
	                									
	                									
	                	CADJPY_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[0] < pricesM_BID_Low[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.Yen_Min_SPRD
	                									);
	                									
	                	if (CADJPY_Signal_Condition_UP_1)
	                	{
	                    	CADJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (CADJPY_Signal_Condition_UP_2)
	                	{
	                    	CADJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (CADJPY_Signal_Condition_UP_3)
	                	{
	                    	CADJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (CADJPY_Signal_Condition_UP_1)
	                	{
	                    	CADJPY_UP_S2_TP1  =  Base.Yen_TP_1 ;
	                	}
	                	
	                	if (CADJPY_Signal_Condition_UP_2)
	                	{
	                    	CADJPY_UP_S2_TP1  =  Base.Yen_TP_2 ;
	                	}
	                	
	                	if (CADJPY_Signal_Condition_UP_3)
	                	{
	                    	CADJPY_UP_S2_TP1  =  Base.Yen_TP_3 ;
	                	}

	                    CADJPY_UP_S2_TP2 =  CADJPY_UP_S2_SL * 0;
	                    CADJPY_UP_S2_TP3 =  CADJPY_UP_S2_SL * 0;
	                    CADJPY_UP_S2_TP4 =  CADJPY_UP_S2_SL * 0;
	                    CADJPY_UP_S2_TP5 =  CADJPY_UP_S2_SL * 0;
	                    CADJPY_UP_S2_TP6 =  CADJPY_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    CADJPY_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    CADJPY_quantity_SL_UP_S2 = CADJPY_quantity_UP_S2;
	                    CADJPY_quantity_TP1_UP_S2 = (int)Math.Floor(CADJPY_quantity_UP_S2 * 1m);
	                    CADJPY_quantity_TP2_UP_S2 = (int)Math.Floor(CADJPY_quantity_TP1_UP_S2 * 0m);
	                    CADJPY_quantity_TP3_UP_S2 = (int)Math.Floor(CADJPY_quantity_TP2_UP_S2 * 0m);
	                    CADJPY_quantity_TP4_UP_S2 = (int)Math.Floor(CADJPY_quantity_TP3_UP_S2 * 0m);
	                    CADJPY_quantity_TP5_UP_S2 = (int)Math.Floor(CADJPY_quantity_TP4_UP_S2 * 0m);
	                    CADJPY_quantity_TP6_UP_S2 = (int)Math.Floor(CADJPY_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((CADJPY_Signal_Condition_UP_1 || CADJPY_Signal_Condition_UP_2 || CADJPY_Signal_Condition_UP_3)  && 
	                    DOWR_CADJPY_UP_S2 && 
	                    Base.CADJPY_OCO1_UP_S2_IsReady == true &&
	                    Base.CADJPY_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.CADJPY_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP1_UP_S2, false,"CADJPY_UP_S2_Entry_TP1_OCO1");
	                         Base.CADJPY_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.CADJPY_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP2_UP_S2, false,"CADJPY_UP_S2_Entry_TP2_OCO1");
	                         Base.CADJPY_OCO1_EO2_UP_S2 = false;
	
	                         Base.CADJPY_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP3_UP_S2, false,"CADJPY_UP_S2_Entry_TP3_OCO1");
	                         Base.CADJPY_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.CADJPY_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP4_UP_S2, false,"CADJPY_UP_S2_Entry_TP4_OCO1");
	                         Base.CADJPY_OCO1_EO4_UP_S2 = false;

							Base.CADJPY_OCO1_UP_S2_IsReady = false;
							
							if (Base.CADJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco2:
	                    if ((CADJPY_Signal_Condition_UP_1 || CADJPY_Signal_Condition_UP_2 || CADJPY_Signal_Condition_UP_3)  && 
	                    DOWR_CADJPY_UP_S2 && 
	                    Base.CADJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.CADJPY_OCO2_UP_S2_IsReady == true &&
	                    Base.CADJPY_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.CADJPY_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP1_UP_S2, false,"CADJPY_UP_S2_Entry_TP1_OCO2");
	                         Base.CADJPY_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.CADJPY_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP2_UP_S2, false,"CADJPY_UP_S2_Entry_TP2_OCO2");
	                         Base.CADJPY_OCO2_EO2_UP_S2 = false;
	
	                         Base.CADJPY_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP3_UP_S2, false,"CADJPY_UP_S2_Entry_TP3_OCO2");
	                         Base.CADJPY_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.CADJPY_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP4_UP_S2, false,"CADJPY_UP_S2_Entry_TP4_OCO2");
	                         Base.CADJPY_OCO2_EO4_UP_S2 = false;

							Base.CADJPY_OCO2_UP_S2_IsReady = false;
							
							if (Base.CADJPY_OCO2_UP_S2_IsReady == false && Base.CADJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco3:
	                    if ((CADJPY_Signal_Condition_UP_1 || CADJPY_Signal_Condition_UP_2 || CADJPY_Signal_Condition_UP_3)  && 
	                    DOWR_CADJPY_UP_S2 &&
	                    Base.CADJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.CADJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.CADJPY_OCO3_UP_S2_IsReady == true &&
	                    Base.CADJPY_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.CADJPY_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP1_UP_S2, false,"CADJPY_UP_S2_Entry_TP1_OCO3");
	                         Base.CADJPY_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.CADJPY_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP2_UP_S2, false,"CADJPY_UP_S2_Entry_TP2_OCO3");
	                         Base.CADJPY_OCO3_EO2_UP_S2 = false;
	
	                         Base.CADJPY_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP3_UP_S2, false,"CADJPY_UP_S2_Entry_TP3_OCO3");
	                         Base.CADJPY_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.CADJPY_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP4_UP_S2, false,"CADJPY_UP_S2_Entry_TP4_OCO3");
	                         Base.CADJPY_OCO3_EO4_UP_S2 = false;

							Base.CADJPY_OCO3_UP_S2_IsReady = false;
							
							if (Base.CADJPY_OCO3_UP_S2_IsReady == false && Base.CADJPY_OCO2_UP_S2_IsReady == false && Base.CADJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco4:
	                    if ((CADJPY_Signal_Condition_UP_1 || CADJPY_Signal_Condition_UP_2 || CADJPY_Signal_Condition_UP_3)  && 
	                    DOWR_CADJPY_UP_S2 && 
	                    Base.CADJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.CADJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.CADJPY_OCO3_UP_S2_IsReady == false &&
	                    Base.CADJPY_OCO4_UP_S2_IsReady == true &&
	                    Base.CADJPY_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.CADJPY_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP1_UP_S2, false,"CADJPY_UP_S2_Entry_TP1_OCO4");
	                         Base.CADJPY_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.CADJPY_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP2_UP_S2, false,"CADJPY_UP_S2_Entry_TP2_OCO4");
	                         Base.CADJPY_OCO4_EO2_UP_S2 = false;
	
	                         Base.CADJPY_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP3_UP_S2, false,"CADJPY_UP_S2_Entry_TP3_OCO4");
	                         Base.CADJPY_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.CADJPY_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CADJPY_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CADJPY_quantity_TP4_UP_S2, false,"CADJPY_UP_S2_Entry_TP4_OCO4");
	                         Base.CADJPY_OCO4_EO4_UP_S2 = false;

							Base.CADJPY_OCO4_UP_S2_IsReady = false;
							
							if (Base.CADJPY_OCO4_UP_S2_IsReady == false && Base.CADJPY_OCO3_UP_S2_IsReady == false && Base.CADJPY_OCO2_UP_S2_IsReady == false && Base.CADJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct AUDNZD_OCO1_DOWN_S2
    {
        public AUDNZD_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 =="TP1_AUDNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD 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 =="TP1_AUDNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD 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 AUDNZD_OCO1_UP_S2
    {
        public AUDNZD_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 =="TP1_AUDNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD 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 =="TP1_AUDNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDNZD 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 AUDNZD_OCO2_DOWN_S2
    {
        public AUDNZD_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 =="TP1_AUDNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD 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 =="TP1_AUDNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD 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 AUDNZD_OCO2_UP_S2
    {
        public AUDNZD_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 =="TP1_AUDNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD 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 =="TP1_AUDNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDNZD 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 AUDNZD_OCO3_DOWN_S2
    {
        public AUDNZD_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 =="TP1_AUDNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD 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 =="TP1_AUDNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD 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 AUDNZD_OCO3_UP_S2
    {
        public AUDNZD_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 =="TP1_AUDNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD 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 =="TP1_AUDNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDNZD 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 AUDNZD_OCO4_DOWN_S2
    {
        public AUDNZD_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 =="TP1_AUDNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD 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 =="TP1_AUDNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD 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 AUDNZD_OCO4_UP_S2
    {
        public AUDNZD_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 =="TP1_AUDNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD 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 =="TP1_AUDNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDNZD 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 GBPCHF_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPCHF_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("GBPCHF OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCHF OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCHF OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCHF OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        }
		        
				if (Base.GBPCHF_OCO1_EO1_DOWN_S2)
	                Base.GBPCHF_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCHF_OCO1_EO2_DOWN_S2)
	                Base.GBPCHF_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO1_EO3_DOWN_S2)
	                Base.GBPCHF_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO1_EO4_DOWN_S2)
	                Base.GBPCHF_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPCHF_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP1_GBPCHF_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP1,"TP1_GBPCHF_DOWN_S2_OCO1"));
		                 };
		                Base.GBPCHF_DOWN_S2_OCO1Sets1.Add( Base.GBPCHF_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP2_GBPCHF_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP2,"TP2_GBPCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO1Sets2.Add( Base.GBPCHF_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP3_GBPCHF_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP3,"TP3_GBPCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO1Sets3.Add( Base.GBPCHF_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP4_GBPCHF_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP4,"TP4_GBPCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO1Sets4.Add( Base.GBPCHF_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPCHF_OCO1S1_DOWN_S2 = 0;
	                for (; GBPCHF_OCO1S1_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets1.Count; GBPCHF_OCO1S1_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO1Sets1[GBPCHF_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO1Sets1[GBPCHF_OCO1S1_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO1Sets1.RemoveAt(GBPCHF_OCO1S1_DOWN_S2);
	                        GBPCHF_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCHF_OCO1S2_DOWN_S2 = 0;
	                for (; GBPCHF_OCO1S2_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets2.Count; GBPCHF_OCO1S2_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO1Sets2[GBPCHF_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO1Sets2[GBPCHF_OCO1S2_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO1Sets2.RemoveAt(GBPCHF_OCO1S2_DOWN_S2);
	                        GBPCHF_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO1S3_DOWN_S2 = 0;
	                for (; GBPCHF_OCO1S3_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets3.Count; GBPCHF_OCO1S3_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO1Sets3[GBPCHF_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO1Sets3[GBPCHF_OCO1S3_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO1Sets3.RemoveAt(GBPCHF_OCO1S3_DOWN_S2);
	                        GBPCHF_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO1S4_DOWN_S2 = 0;
	                for (; GBPCHF_OCO1S4_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets4.Count; GBPCHF_OCO1S4_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO1Sets4[GBPCHF_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO1Sets4[GBPCHF_OCO1S4_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO1Sets4.RemoveAt(GBPCHF_OCO1S4_DOWN_S2);
	                        GBPCHF_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCHF_OCO2_EO1_DOWN_S2)
	                Base.GBPCHF_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCHF_OCO2_EO2_DOWN_S2)
	                Base.GBPCHF_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO2_EO3_DOWN_S2)
	                Base.GBPCHF_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO2_EO4_DOWN_S2)
	                Base.GBPCHF_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPCHF_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP1_GBPCHF_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP1,"TP1_GBPCHF_DOWN_S2_OCO2"));
		                 };
		                Base.GBPCHF_DOWN_S2_OCO2Sets1.Add( Base.GBPCHF_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP2_GBPCHF_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP2,"TP2_GBPCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO2Sets2.Add( Base.GBPCHF_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP3_GBPCHF_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP3,"TP3_GBPCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO2Sets3.Add( Base.GBPCHF_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP4_GBPCHF_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP4,"TP4_GBPCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO2Sets4.Add( Base.GBPCHF_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPCHF_OCO2S1_DOWN_S2 = 0;
	                for (; GBPCHF_OCO2S1_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets1.Count; GBPCHF_OCO2S1_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO2Sets1[GBPCHF_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO2Sets1[GBPCHF_OCO2S1_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO2Sets1.RemoveAt(GBPCHF_OCO2S1_DOWN_S2);
	                        GBPCHF_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCHF_OCO2S2_DOWN_S2 = 0;
	                for (; GBPCHF_OCO2S2_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets2.Count; GBPCHF_OCO2S2_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO2Sets2[GBPCHF_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO2Sets2[GBPCHF_OCO2S2_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO2Sets2.RemoveAt(GBPCHF_OCO2S2_DOWN_S2);
	                        GBPCHF_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO2S3_DOWN_S2 = 0;
	                for (; GBPCHF_OCO2S3_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets3.Count; GBPCHF_OCO2S3_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO2Sets3[GBPCHF_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO2Sets3[GBPCHF_OCO2S3_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO2Sets3.RemoveAt(GBPCHF_OCO2S3_DOWN_S2);
	                        GBPCHF_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO2S4_DOWN_S2 = 0;
	                for (; GBPCHF_OCO2S4_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets4.Count; GBPCHF_OCO2S4_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO2Sets4[GBPCHF_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO2Sets4[GBPCHF_OCO2S4_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO2Sets4.RemoveAt(GBPCHF_OCO2S4_DOWN_S2);
	                        GBPCHF_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCHF_OCO3_EO1_DOWN_S2)
	                Base.GBPCHF_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCHF_OCO3_EO2_DOWN_S2)
	                Base.GBPCHF_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO3_EO3_DOWN_S2)
	                Base.GBPCHF_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO3_EO4_DOWN_S2)
	                Base.GBPCHF_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPCHF_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP1_GBPCHF_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP1,"TP1_GBPCHF_DOWN_S2_OCO3"));
		                 };
		                Base.GBPCHF_DOWN_S2_OCO3Sets1.Add( Base.GBPCHF_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP2_GBPCHF_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP2,"TP2_GBPCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO3Sets2.Add( Base.GBPCHF_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP3_GBPCHF_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP3,"TP3_GBPCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO3Sets3.Add( Base.GBPCHF_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP4_GBPCHF_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP4,"TP4_GBPCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO3Sets4.Add( Base.GBPCHF_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPCHF_OCO3S1_DOWN_S2 = 0;
	                for (; GBPCHF_OCO3S1_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets1.Count; GBPCHF_OCO3S1_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO3Sets1[GBPCHF_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO3Sets1[GBPCHF_OCO3S1_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO3Sets1.RemoveAt(GBPCHF_OCO3S1_DOWN_S2);
	                        GBPCHF_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCHF_OCO3S2_DOWN_S2 = 0;
	                for (; GBPCHF_OCO3S2_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets2.Count; GBPCHF_OCO3S2_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO3Sets2[GBPCHF_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO3Sets2[GBPCHF_OCO3S2_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO3Sets2.RemoveAt(GBPCHF_OCO3S2_DOWN_S2);
	                        GBPCHF_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO3S3_DOWN_S2 = 0;
	                for (; GBPCHF_OCO3S3_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets3.Count; GBPCHF_OCO3S3_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO3Sets3[GBPCHF_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO3Sets3[GBPCHF_OCO3S3_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO3Sets3.RemoveAt(GBPCHF_OCO3S3_DOWN_S2);
	                        GBPCHF_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO3S4_DOWN_S2 = 0;
	                for (; GBPCHF_OCO3S4_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets4.Count; GBPCHF_OCO3S4_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO3Sets4[GBPCHF_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO3Sets4[GBPCHF_OCO3S4_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO3Sets4.RemoveAt(GBPCHF_OCO3S4_DOWN_S2);
	                        GBPCHF_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCHF_OCO4_EO1_DOWN_S2)
	                Base.GBPCHF_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCHF_OCO4_EO2_DOWN_S2)
	                Base.GBPCHF_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO4_EO3_DOWN_S2)
	                Base.GBPCHF_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO4_EO4_DOWN_S2)
	                Base.GBPCHF_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPCHF_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP1_GBPCHF_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP1,"TP1_GBPCHF_DOWN_S2_OCO4"));
		                 };
		                Base.GBPCHF_DOWN_S2_OCO4Sets1.Add( Base.GBPCHF_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP2_GBPCHF_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP2,"TP2_GBPCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO4Sets2.Add( Base.GBPCHF_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP3_GBPCHF_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP3,"TP3_GBPCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO4Sets3.Add( Base.GBPCHF_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_DOWN_S2_SL,"SL_TP4_GBPCHF_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_DOWN_S2_TP4,"TP4_GBPCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPCHF_DOWN_S2_OCO4Sets4.Add( Base.GBPCHF_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPCHF_OCO4S1_DOWN_S2 = 0;
	                for (; GBPCHF_OCO4S1_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets1.Count; GBPCHF_OCO4S1_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO4Sets1[GBPCHF_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO4Sets1[GBPCHF_OCO4S1_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO4Sets1.RemoveAt(GBPCHF_OCO4S1_DOWN_S2);
	                        GBPCHF_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCHF_OCO4S2_DOWN_S2 = 0;
	                for (; GBPCHF_OCO4S2_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets2.Count; GBPCHF_OCO4S2_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO4Sets2[GBPCHF_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO4Sets2[GBPCHF_OCO4S2_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO4Sets2.RemoveAt(GBPCHF_OCO4S2_DOWN_S2);
	                        GBPCHF_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO4S3_DOWN_S2 = 0;
	                for (; GBPCHF_OCO4S3_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets3.Count; GBPCHF_OCO4S3_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO4Sets3[GBPCHF_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO4Sets3[GBPCHF_OCO4S3_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO4Sets3.RemoveAt(GBPCHF_OCO4S3_DOWN_S2);
	                        GBPCHF_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO4S4_DOWN_S2 = 0;
	                for (; GBPCHF_OCO4S4_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets4.Count; GBPCHF_OCO4S4_DOWN_S2++)
	                    if (Base.GBPCHF_DOWN_S2_OCO4Sets4[GBPCHF_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_DOWN_S2_OCO4Sets4[GBPCHF_OCO4S4_DOWN_S2].Filled();
	                        Base.GBPCHF_DOWN_S2_OCO4Sets4.RemoveAt(GBPCHF_OCO4S4_DOWN_S2);
	                        GBPCHF_OCO4S4_DOWN_S2 = 0;
	                        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.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 NZDCAD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public NZDCAD_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("NZDCAD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCAD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCAD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCAD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDCAD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCAD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCAD S2");
		        	}
		        }
		        
				if (Base.NZDCAD_OCO1_EO1_DOWN_S2)
	                Base.NZDCAD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCAD_OCO1_EO2_DOWN_S2)
	                Base.NZDCAD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO1_EO3_DOWN_S2)
	                Base.NZDCAD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO1_EO4_DOWN_S2)
	                Base.NZDCAD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDCAD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP1_NZDCAD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP1,"TP1_NZDCAD_DOWN_S2_OCO1"));
		                 };
		                Base.NZDCAD_DOWN_S2_OCO1Sets1.Add( Base.NZDCAD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP2_NZDCAD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP2,"TP2_NZDCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO1Sets2.Add( Base.NZDCAD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP3_NZDCAD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP3,"TP3_NZDCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO1Sets3.Add( Base.NZDCAD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP4_NZDCAD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP4,"TP4_NZDCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO1Sets4.Add( Base.NZDCAD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int NZDCAD_OCO1S1_DOWN_S2 = 0;
	                for (; NZDCAD_OCO1S1_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets1.Count; NZDCAD_OCO1S1_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO1Sets1[NZDCAD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO1Sets1[NZDCAD_OCO1S1_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO1Sets1.RemoveAt(NZDCAD_OCO1S1_DOWN_S2);
	                        NZDCAD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCAD_OCO1S2_DOWN_S2 = 0;
	                for (; NZDCAD_OCO1S2_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets2.Count; NZDCAD_OCO1S2_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO1Sets2[NZDCAD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO1Sets2[NZDCAD_OCO1S2_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO1Sets2.RemoveAt(NZDCAD_OCO1S2_DOWN_S2);
	                        NZDCAD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO1S3_DOWN_S2 = 0;
	                for (; NZDCAD_OCO1S3_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets3.Count; NZDCAD_OCO1S3_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO1Sets3[NZDCAD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO1Sets3[NZDCAD_OCO1S3_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO1Sets3.RemoveAt(NZDCAD_OCO1S3_DOWN_S2);
	                        NZDCAD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO1S4_DOWN_S2 = 0;
	                for (; NZDCAD_OCO1S4_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO1Sets4.Count; NZDCAD_OCO1S4_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO1Sets4[NZDCAD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO1Sets4[NZDCAD_OCO1S4_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO1Sets4.RemoveAt(NZDCAD_OCO1S4_DOWN_S2);
	                        NZDCAD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCAD_OCO2_EO1_DOWN_S2)
	                Base.NZDCAD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCAD_OCO2_EO2_DOWN_S2)
	                Base.NZDCAD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO2_EO3_DOWN_S2)
	                Base.NZDCAD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO2_EO4_DOWN_S2)
	                Base.NZDCAD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDCAD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP1_NZDCAD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP1,"TP1_NZDCAD_DOWN_S2_OCO2"));
		                 };
		                Base.NZDCAD_DOWN_S2_OCO2Sets1.Add( Base.NZDCAD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP2_NZDCAD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP2,"TP2_NZDCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO2Sets2.Add( Base.NZDCAD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP3_NZDCAD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP3,"TP3_NZDCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO2Sets3.Add( Base.NZDCAD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP4_NZDCAD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP4,"TP4_NZDCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO2Sets4.Add( Base.NZDCAD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int NZDCAD_OCO2S1_DOWN_S2 = 0;
	                for (; NZDCAD_OCO2S1_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets1.Count; NZDCAD_OCO2S1_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO2Sets1[NZDCAD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO2Sets1[NZDCAD_OCO2S1_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO2Sets1.RemoveAt(NZDCAD_OCO2S1_DOWN_S2);
	                        NZDCAD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCAD_OCO2S2_DOWN_S2 = 0;
	                for (; NZDCAD_OCO2S2_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets2.Count; NZDCAD_OCO2S2_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO2Sets2[NZDCAD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO2Sets2[NZDCAD_OCO2S2_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO2Sets2.RemoveAt(NZDCAD_OCO2S2_DOWN_S2);
	                        NZDCAD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO2S3_DOWN_S2 = 0;
	                for (; NZDCAD_OCO2S3_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets3.Count; NZDCAD_OCO2S3_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO2Sets3[NZDCAD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO2Sets3[NZDCAD_OCO2S3_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO2Sets3.RemoveAt(NZDCAD_OCO2S3_DOWN_S2);
	                        NZDCAD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO2S4_DOWN_S2 = 0;
	                for (; NZDCAD_OCO2S4_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO2Sets4.Count; NZDCAD_OCO2S4_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO2Sets4[NZDCAD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO2Sets4[NZDCAD_OCO2S4_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO2Sets4.RemoveAt(NZDCAD_OCO2S4_DOWN_S2);
	                        NZDCAD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCAD_OCO3_EO1_DOWN_S2)
	                Base.NZDCAD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCAD_OCO3_EO2_DOWN_S2)
	                Base.NZDCAD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO3_EO3_DOWN_S2)
	                Base.NZDCAD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO3_EO4_DOWN_S2)
	                Base.NZDCAD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDCAD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP1_NZDCAD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP1,"TP1_NZDCAD_DOWN_S2_OCO3"));
		                 };
		                Base.NZDCAD_DOWN_S2_OCO3Sets1.Add( Base.NZDCAD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP2_NZDCAD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP2,"TP2_NZDCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO3Sets2.Add( Base.NZDCAD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP3_NZDCAD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP3,"TP3_NZDCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO3Sets3.Add( Base.NZDCAD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP4_NZDCAD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP4,"TP4_NZDCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO3Sets4.Add( Base.NZDCAD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int NZDCAD_OCO3S1_DOWN_S2 = 0;
	                for (; NZDCAD_OCO3S1_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets1.Count; NZDCAD_OCO3S1_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO3Sets1[NZDCAD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO3Sets1[NZDCAD_OCO3S1_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO3Sets1.RemoveAt(NZDCAD_OCO3S1_DOWN_S2);
	                        NZDCAD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCAD_OCO3S2_DOWN_S2 = 0;
	                for (; NZDCAD_OCO3S2_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets2.Count; NZDCAD_OCO3S2_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO3Sets2[NZDCAD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO3Sets2[NZDCAD_OCO3S2_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO3Sets2.RemoveAt(NZDCAD_OCO3S2_DOWN_S2);
	                        NZDCAD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO3S3_DOWN_S2 = 0;
	                for (; NZDCAD_OCO3S3_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets3.Count; NZDCAD_OCO3S3_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO3Sets3[NZDCAD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO3Sets3[NZDCAD_OCO3S3_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO3Sets3.RemoveAt(NZDCAD_OCO3S3_DOWN_S2);
	                        NZDCAD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO3S4_DOWN_S2 = 0;
	                for (; NZDCAD_OCO3S4_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO3Sets4.Count; NZDCAD_OCO3S4_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO3Sets4[NZDCAD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO3Sets4[NZDCAD_OCO3S4_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO3Sets4.RemoveAt(NZDCAD_OCO3S4_DOWN_S2);
	                        NZDCAD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCAD_OCO4_EO1_DOWN_S2)
	                Base.NZDCAD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCAD_OCO4_EO2_DOWN_S2)
	                Base.NZDCAD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO4_EO3_DOWN_S2)
	                Base.NZDCAD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCAD_OCO4_EO4_DOWN_S2)
	                Base.NZDCAD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDCAD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP1_NZDCAD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP1,"TP1_NZDCAD_DOWN_S2_OCO4"));
		                 };
		                Base.NZDCAD_DOWN_S2_OCO4Sets1.Add( Base.NZDCAD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP2_NZDCAD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP2,"TP2_NZDCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO4Sets2.Add( Base.NZDCAD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP3_NZDCAD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP3,"TP3_NZDCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO4Sets3.Add( Base.NZDCAD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCAD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDCAD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCAD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCAD_DOWN_S2_SL,"SL_TP4_NZDCAD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCAD_DOWN_S2_TP4,"TP4_NZDCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDCAD_DOWN_S2_OCO4Sets4.Add( Base.NZDCAD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCAD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int NZDCAD_OCO4S1_DOWN_S2 = 0;
	                for (; NZDCAD_OCO4S1_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets1.Count; NZDCAD_OCO4S1_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO4Sets1[NZDCAD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO4Sets1[NZDCAD_OCO4S1_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO4Sets1.RemoveAt(NZDCAD_OCO4S1_DOWN_S2);
	                        NZDCAD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCAD_OCO4S2_DOWN_S2 = 0;
	                for (; NZDCAD_OCO4S2_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets2.Count; NZDCAD_OCO4S2_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO4Sets2[NZDCAD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO4Sets2[NZDCAD_OCO4S2_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO4Sets2.RemoveAt(NZDCAD_OCO4S2_DOWN_S2);
	                        NZDCAD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO4S3_DOWN_S2 = 0;
	                for (; NZDCAD_OCO4S3_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets3.Count; NZDCAD_OCO4S3_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO4Sets3[NZDCAD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO4Sets3[NZDCAD_OCO4S3_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO4Sets3.RemoveAt(NZDCAD_OCO4S3_DOWN_S2);
	                        NZDCAD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCAD_OCO4S4_DOWN_S2 = 0;
	                for (; NZDCAD_OCO4S4_DOWN_S2 < Base.NZDCAD_DOWN_S2_OCO4Sets4.Count; NZDCAD_OCO4S4_DOWN_S2++)
	                    if (Base.NZDCAD_DOWN_S2_OCO4Sets4[NZDCAD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCAD_DOWN_S2_OCO4Sets4[NZDCAD_OCO4S4_DOWN_S2].Filled();
	                        Base.NZDCAD_DOWN_S2_OCO4Sets4.RemoveAt(NZDCAD_OCO4S4_DOWN_S2);
	                        NZDCAD_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct AUDCHF_OCO1_DOWN_S2
    {
        public AUDCHF_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 =="TP1_AUDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF 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 =="TP1_AUDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF 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 AUDCHF_OCO1_UP_S2
    {
        public AUDCHF_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 =="TP1_AUDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF 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 =="TP1_AUDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCHF 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 AUDCHF_OCO2_DOWN_S2
    {
        public AUDCHF_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 =="TP1_AUDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF 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 =="TP1_AUDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF 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 AUDCHF_OCO2_UP_S2
    {
        public AUDCHF_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 =="TP1_AUDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF 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 =="TP1_AUDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCHF 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 AUDCHF_OCO3_DOWN_S2
    {
        public AUDCHF_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 =="TP1_AUDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF 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 =="TP1_AUDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF 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 AUDCHF_OCO3_UP_S2
    {
        public AUDCHF_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 =="TP1_AUDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF 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 =="TP1_AUDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCHF 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 AUDCHF_OCO4_DOWN_S2
    {
        public AUDCHF_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 =="TP1_AUDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF 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 =="TP1_AUDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF 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 AUDCHF_OCO4_UP_S2
    {
        public AUDCHF_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 =="TP1_AUDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF 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 =="TP1_AUDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCHF 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPNZD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPNZD_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())
			{
				algorithm.Liquidate();
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPNZD_DOWN_S2_OCO1")))
			{
				Base.GBPNZD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPNZD_DOWN_S2_OCO2")))
			{
				Base.GBPNZD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPNZD_DOWN_S2_OCO3")))
			{
				Base.GBPNZD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPNZD_DOWN_S2_OCO4")))
			{
				Base.GBPNZD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPNZD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.GBPNZD_OCO1_EO1_DOWN_S2)
	                Base.GBPNZD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPNZD_OCO1_EO2_DOWN_S2)
	                Base.GBPNZD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO1_EO3_DOWN_S2)
	                Base.GBPNZD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO1_EO4_DOWN_S2)
	                Base.GBPNZD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO1_EO5_DOWN_S2)
	                Base.GBPNZD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO1_EO6_DOWN_S2)
	                Base.GBPNZD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPNZD_OCO1S1_DOWN_S2 = 0;
		                for (; GBPNZD_OCO1S1_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets1.Count; GBPNZD_OCO1S1_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO1Sets1[GBPNZD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO1Sets1[GBPNZD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.GBPNZD_DOWN_S2_OCO1Sets1.Clear();
		                        GBPNZD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPNZD_OCO1S2_DOWN_S2 = 0;
		                for (; GBPNZD_OCO1S2_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets2.Count; GBPNZD_OCO1S2_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO1Sets2[GBPNZD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO1Sets2[GBPNZD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.GBPNZD_DOWN_S2_OCO1Sets2.Clear();
		                        GBPNZD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO1S3_DOWN_S2 = 0;
		                for (; GBPNZD_OCO1S3_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets3.Count; GBPNZD_OCO1S3_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO1Sets3[GBPNZD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO1Sets3[GBPNZD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.GBPNZD_DOWN_S2_OCO1Sets3.Clear();
		                        GBPNZD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO1S4_DOWN_S2 = 0;
		                for (; GBPNZD_OCO1S4_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets4.Count; GBPNZD_OCO1S4_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO1Sets4[GBPNZD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO1Sets4[GBPNZD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.GBPNZD_DOWN_S2_OCO1Sets4.Clear();
		                        GBPNZD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO1S5_DOWN_S2 = 0;
		                for (; GBPNZD_OCO1S5_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets5.Count; GBPNZD_OCO1S5_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO1Sets5[GBPNZD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO1Sets5[GBPNZD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.GBPNZD_DOWN_S2_OCO1Sets5.Clear();
		                        GBPNZD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO1S6_DOWN_S2 = 0;
		                for (; GBPNZD_OCO1S6_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO1Sets6.Count; GBPNZD_OCO1S6_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO1Sets6[GBPNZD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO1Sets6[GBPNZD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.GBPNZD_DOWN_S2_OCO1Sets6.Clear();
		                        GBPNZD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPNZD_OCO2_EO1_DOWN_S2)
	                Base.GBPNZD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPNZD_OCO2_EO2_DOWN_S2)
	                Base.GBPNZD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO2_EO3_DOWN_S2)
	                Base.GBPNZD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO2_EO4_DOWN_S2)
	                Base.GBPNZD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO2_EO5_DOWN_S2)
	                Base.GBPNZD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO2_EO6_DOWN_S2)
	                Base.GBPNZD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPNZD_OCO2S1_DOWN_S2 = 0;
		                for (; GBPNZD_OCO2S1_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets1.Count; GBPNZD_OCO2S1_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO2Sets1[GBPNZD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO2Sets1[GBPNZD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.GBPNZD_DOWN_S2_OCO2Sets1.Clear();
		                        GBPNZD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPNZD_OCO2S2_DOWN_S2 = 0;
		                for (; GBPNZD_OCO2S2_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets2.Count; GBPNZD_OCO2S2_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO2Sets2[GBPNZD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO2Sets2[GBPNZD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.GBPNZD_DOWN_S2_OCO2Sets2.Clear();
		                        GBPNZD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO2S3_DOWN_S2 = 0;
		                for (; GBPNZD_OCO2S3_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets3.Count; GBPNZD_OCO2S3_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO2Sets3[GBPNZD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO2Sets3[GBPNZD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.GBPNZD_DOWN_S2_OCO2Sets3.Clear();
		                        GBPNZD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO2S4_DOWN_S2 = 0;
		                for (; GBPNZD_OCO2S4_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets4.Count; GBPNZD_OCO2S4_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO2Sets4[GBPNZD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO2Sets4[GBPNZD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.GBPNZD_DOWN_S2_OCO2Sets4.Clear();
		                        GBPNZD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO2S5_DOWN_S2 = 0;
		                for (; GBPNZD_OCO2S5_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets5.Count; GBPNZD_OCO2S5_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO2Sets5[GBPNZD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO2Sets5[GBPNZD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.GBPNZD_DOWN_S2_OCO2Sets5.Clear();
		                        GBPNZD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO2S6_DOWN_S2 = 0;
		                for (; GBPNZD_OCO2S6_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO2Sets6.Count; GBPNZD_OCO2S6_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO2Sets6[GBPNZD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO2Sets6[GBPNZD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.GBPNZD_DOWN_S2_OCO2Sets6.Clear();
		                        GBPNZD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPNZD_OCO3_EO1_DOWN_S2)
	                Base.GBPNZD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPNZD_OCO3_EO2_DOWN_S2)
	                Base.GBPNZD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO3_EO3_DOWN_S2)
	                Base.GBPNZD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO3_EO4_DOWN_S2)
	                Base.GBPNZD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO3_EO5_DOWN_S2)
	                Base.GBPNZD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO3_EO6_DOWN_S2)
	                Base.GBPNZD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPNZD_OCO3S1_DOWN_S2 = 0;
		                for (; GBPNZD_OCO3S1_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets1.Count; GBPNZD_OCO3S1_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO3Sets1[GBPNZD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO3Sets1[GBPNZD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.GBPNZD_DOWN_S2_OCO3Sets1.Clear();
		                        GBPNZD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPNZD_OCO3S2_DOWN_S2 = 0;
		                for (; GBPNZD_OCO3S2_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets2.Count; GBPNZD_OCO3S2_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO3Sets2[GBPNZD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO3Sets2[GBPNZD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.GBPNZD_DOWN_S2_OCO3Sets2.Clear();
		                        GBPNZD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO3S3_DOWN_S2 = 0;
		                for (; GBPNZD_OCO3S3_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets3.Count; GBPNZD_OCO3S3_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO3Sets3[GBPNZD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO3Sets3[GBPNZD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.GBPNZD_DOWN_S2_OCO3Sets3.Clear();
		                        GBPNZD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO3S4_DOWN_S2 = 0;
		                for (; GBPNZD_OCO3S4_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets4.Count; GBPNZD_OCO3S4_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO3Sets4[GBPNZD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO3Sets4[GBPNZD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.GBPNZD_DOWN_S2_OCO3Sets4.Clear();
		                        GBPNZD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO3S5_DOWN_S2 = 0;
		                for (; GBPNZD_OCO3S5_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets5.Count; GBPNZD_OCO3S5_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO3Sets5[GBPNZD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO3Sets5[GBPNZD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.GBPNZD_DOWN_S2_OCO3Sets5.Clear();
		                        GBPNZD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO3S6_DOWN_S2 = 0;
		                for (; GBPNZD_OCO3S6_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO3Sets6.Count; GBPNZD_OCO3S6_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO3Sets6[GBPNZD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO3Sets6[GBPNZD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.GBPNZD_DOWN_S2_OCO3Sets6.Clear();
		                        GBPNZD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPNZD_OCO4_EO1_DOWN_S2)
	                Base.GBPNZD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPNZD_OCO4_EO2_DOWN_S2)
	                Base.GBPNZD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO4_EO3_DOWN_S2)
	                Base.GBPNZD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO4_EO4_DOWN_S2)
	                Base.GBPNZD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO4_EO5_DOWN_S2)
	                Base.GBPNZD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO4_EO6_DOWN_S2)
	                Base.GBPNZD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPNZD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPNZD_OCO4S1_DOWN_S2 = 0;
		                for (; GBPNZD_OCO4S1_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets1.Count; GBPNZD_OCO4S1_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO4Sets1[GBPNZD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO4Sets1[GBPNZD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.GBPNZD_DOWN_S2_OCO4Sets1.Clear();
		                        GBPNZD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPNZD_OCO4S2_DOWN_S2 = 0;
		                for (; GBPNZD_OCO4S2_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets2.Count; GBPNZD_OCO4S2_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO4Sets2[GBPNZD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO4Sets2[GBPNZD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.GBPNZD_DOWN_S2_OCO4Sets2.Clear();
		                        GBPNZD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO4S3_DOWN_S2 = 0;
		                for (; GBPNZD_OCO4S3_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets3.Count; GBPNZD_OCO4S3_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO4Sets3[GBPNZD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO4Sets3[GBPNZD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.GBPNZD_DOWN_S2_OCO4Sets3.Clear();
		                        GBPNZD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO4S4_DOWN_S2 = 0;
		                for (; GBPNZD_OCO4S4_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets4.Count; GBPNZD_OCO4S4_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO4Sets4[GBPNZD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO4Sets4[GBPNZD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.GBPNZD_DOWN_S2_OCO4Sets4.Clear();
		                        GBPNZD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO4S5_DOWN_S2 = 0;
		                for (; GBPNZD_OCO4S5_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets5.Count; GBPNZD_OCO4S5_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO4Sets5[GBPNZD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO4Sets5[GBPNZD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.GBPNZD_DOWN_S2_OCO4Sets5.Clear();
		                        GBPNZD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO4S6_DOWN_S2 = 0;
		                for (; GBPNZD_OCO4S6_DOWN_S2 < Base.GBPNZD_DOWN_S2_OCO4Sets6.Count; GBPNZD_OCO4S6_DOWN_S2++)
		                    if (Base.GBPNZD_DOWN_S2_OCO4Sets6[GBPNZD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_DOWN_S2_OCO4Sets6[GBPNZD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.GBPNZD_DOWN_S2_OCO4Sets6.Clear();
		                        GBPNZD_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();
	            	}

					DOWM_GBPNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPNZD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPNZD_DOWN_S2 = DOWM_GBPNZD_DOWN_S2 || DOWT_GBPNZD_DOWN_S2 || DOWW_GBPNZD_DOWN_S2 || DOWTH_GBPNZD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPNZD"))
	            	{
	            		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.GBPNZD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.GBPNZD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.GBPNZD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.GBPNZD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.GBPNZD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPNZD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPNZD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPNZD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPNZD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPNZD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPNZD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPNZD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	GBPNZD_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
	                									);
	                									
	                	GBPNZD_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
	                									);
	                									
	                									
	                	GBPNZD_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 (GBPNZD_Signal_Condition_DOWN_1)
	                	{
	                    	GBPNZD_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (GBPNZD_Signal_Condition_DOWN_2)
	                	{
	                    	GBPNZD_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	if (GBPNZD_Signal_Condition_DOWN_3)
	                	{
	                    	GBPNZD_DOWN_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m);
	                	}
	                	
	                	
	                	if (GBPNZD_Signal_Condition_DOWN_1)
	                	{
	                    	GBPNZD_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.05m ;
	                	}
	                	
	                	if (GBPNZD_Signal_Condition_DOWN_2)
	                	{
	                    	GBPNZD_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.1m ;
	                	}
	                	
	                	if (GBPNZD_Signal_Condition_DOWN_3)
	                	{
	                    	GBPNZD_DOWN_S2_TP1  =  (pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.2m ;
	                	}
	                	
	                    GBPNZD_DOWN_S2_TP2 =  GBPNZD_DOWN_S2_SL * 0;
	                    GBPNZD_DOWN_S2_TP3 =  GBPNZD_DOWN_S2_SL * 0;
	                    GBPNZD_DOWN_S2_TP4 =  GBPNZD_DOWN_S2_SL * 0;
	                    GBPNZD_DOWN_S2_TP5 =  GBPNZD_DOWN_S2_SL * 0;
	                    GBPNZD_DOWN_S2_TP6 =  GBPNZD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0 && GBPNZD_DOWN_S2_SL !=  0)
	                    {
	                    GBPNZD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)*0.015m);
	                    GBPNZD_quantity_SL_DOWN_S2 = GBPNZD_quantity_DOWN_S2;
	                    GBPNZD_quantity_TP1_DOWN_S2 = (GBPNZD_quantity_DOWN_S2 );
	                    GBPNZD_quantity_TP2_DOWN_S2 = (GBPNZD_quantity_TP1_DOWN_S2 * 0);
	                    GBPNZD_quantity_TP3_DOWN_S2 = (GBPNZD_quantity_TP2_DOWN_S2 * 0);
	                    GBPNZD_quantity_TP4_DOWN_S2 = (GBPNZD_quantity_TP3_DOWN_S2 * 0);
	                    GBPNZD_quantity_TP5_DOWN_S2 = (GBPNZD_quantity_TP4_DOWN_S2 * 0);
	                    GBPNZD_quantity_TP6_DOWN_S2 = (GBPNZD_quantity_TP5_DOWN_S2 * 0);
	                    }
	                    
	                    oco1:
	                    if ((GBPNZD_Signal_Condition_DOWN_1 || GBPNZD_Signal_Condition_DOWN_2 || GBPNZD_Signal_Condition_DOWN_3)  && 
	                    DOWR_GBPNZD_DOWN_S2 && 
	                    Base.GBPNZD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.GBPNZD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPNZD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP1_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.GBPNZD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPNZD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP2_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.GBPNZD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.GBPNZD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP3_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.GBPNZD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPNZD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP4_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.GBPNZD_OCO1_EO4_DOWN_S2 = false;

							Base.GBPNZD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.GBPNZD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((GBPNZD_Signal_Condition_DOWN_1 || GBPNZD_Signal_Condition_DOWN_2 || GBPNZD_Signal_Condition_DOWN_3)  && 
	                    DOWR_GBPNZD_DOWN_S2 && 
	                    Base.GBPNZD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.GBPNZD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPNZD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPNZD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP1_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.GBPNZD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPNZD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP2_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.GBPNZD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.GBPNZD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP3_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.GBPNZD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPNZD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP4_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.GBPNZD_OCO2_EO4_DOWN_S2 = false;

							Base.GBPNZD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.GBPNZD_OCO2_DOWN_S2_IsReady == false && Base.GBPNZD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((GBPNZD_Signal_Condition_DOWN_1 || GBPNZD_Signal_Condition_DOWN_2 || GBPNZD_Signal_Condition_DOWN_3)  && 
	                    DOWR_GBPNZD_DOWN_S2 &&
	                    Base.GBPNZD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.GBPNZD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPNZD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPNZD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPNZD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP1_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.GBPNZD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPNZD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP2_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.GBPNZD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.GBPNZD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP3_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.GBPNZD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPNZD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP4_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.GBPNZD_OCO3_EO4_DOWN_S2 = false;

							Base.GBPNZD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.GBPNZD_OCO3_DOWN_S2_IsReady == false && Base.GBPNZD_OCO2_DOWN_S2_IsReady == false && Base.GBPNZD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((GBPNZD_Signal_Condition_DOWN_1 || GBPNZD_Signal_Condition_DOWN_2 || GBPNZD_Signal_Condition_DOWN_3)  && 
	                    DOWR_GBPNZD_DOWN_S2 && 
	                    Base.GBPNZD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.GBPNZD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPNZD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPNZD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.GBPNZD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPNZD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP1_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.GBPNZD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPNZD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP2_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.GBPNZD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.GBPNZD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP3_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.GBPNZD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPNZD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPNZD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP4_DOWN_S2, false,"GBPNZD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.GBPNZD_OCO4_EO4_DOWN_S2 = false;

							Base.GBPNZD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.GBPNZD_OCO4_DOWN_S2_IsReady == false && Base.GBPNZD_OCO3_DOWN_S2_IsReady == false && Base.GBPNZD_OCO2_DOWN_S2_IsReady == false && Base.GBPNZD_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPNZD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPNZD_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(x=>x.Tag.Contains("GBPNZD_UP_S2_OCO1")))
			{
				Base.GBPNZD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPNZD_UP_S2_OCO2")))
			{
				Base.GBPNZD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPNZD_UP_S2_OCO3")))
			{
				Base.GBPNZD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPNZD_UP_S2_OCO4")))
			{
				Base.GBPNZD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPNZD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.GBPNZD_OCO1_EO1_UP_S2)
	                Base.GBPNZD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPNZD_OCO1_EO2_UP_S2)
	                Base.GBPNZD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO1_EO3_UP_S2)
	                Base.GBPNZD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO1_EO4_UP_S2)
	                Base.GBPNZD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO1_EO5_UP_S2)
	                Base.GBPNZD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO1_EO6_UP_S2)
	                Base.GBPNZD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPNZD_OCO1S1_UP_S2 = 0;
		                for (; GBPNZD_OCO1S1_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets1.Count; GBPNZD_OCO1S1_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO1Sets1[GBPNZD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO1Sets1[GBPNZD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.GBPNZD_UP_S2_OCO1Sets1.Clear();
		                        GBPNZD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPNZD_OCO1S2_UP_S2 = 0;
		                for (; GBPNZD_OCO1S2_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets2.Count; GBPNZD_OCO1S2_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO1Sets2[GBPNZD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO1Sets2[GBPNZD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.GBPNZD_UP_S2_OCO1Sets2.Clear();
		                        GBPNZD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO1S3_UP_S2 = 0;
		                for (; GBPNZD_OCO1S3_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets3.Count; GBPNZD_OCO1S3_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO1Sets3[GBPNZD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO1Sets3[GBPNZD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.GBPNZD_UP_S2_OCO1Sets3.Clear();
		                        GBPNZD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO1S4_UP_S2 = 0;
		                for (; GBPNZD_OCO1S4_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets4.Count; GBPNZD_OCO1S4_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO1Sets4[GBPNZD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO1Sets4[GBPNZD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.GBPNZD_UP_S2_OCO1Sets4.Clear();
		                        GBPNZD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO1S5_UP_S2 = 0;
		                for (; GBPNZD_OCO1S5_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets5.Count; GBPNZD_OCO1S5_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO1Sets5[GBPNZD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO1Sets5[GBPNZD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.GBPNZD_UP_S2_OCO1Sets5.Clear();
		                        GBPNZD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO1S6_UP_S2 = 0;
		                for (; GBPNZD_OCO1S6_UP_S2 < Base.GBPNZD_UP_S2_OCO1Sets6.Count; GBPNZD_OCO1S6_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO1Sets6[GBPNZD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO1Sets6[GBPNZD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.GBPNZD_UP_S2_OCO1Sets6.Clear();
		                        GBPNZD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPNZD_OCO2_EO1_UP_S2)
                	Base.GBPNZD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPNZD_OCO2_EO2_UP_S2)
	                Base.GBPNZD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO2_EO3_UP_S2)
	                Base.GBPNZD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO2_EO4_UP_S2)
	                Base.GBPNZD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO2_EO5_UP_S2)
	                Base.GBPNZD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO2_EO6_UP_S2)
	                Base.GBPNZD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPNZD_OCO2S1_UP_S2 = 0;
		                for (; GBPNZD_OCO2S1_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets1.Count; GBPNZD_OCO2S1_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO2Sets1[GBPNZD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO2Sets1[GBPNZD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.GBPNZD_UP_S2_OCO2Sets1.Clear();
		                        GBPNZD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPNZD_OCO2S2_UP_S2 = 0;
		                for (; GBPNZD_OCO2S2_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets2.Count; GBPNZD_OCO2S2_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO2Sets2[GBPNZD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO2Sets2[GBPNZD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.GBPNZD_UP_S2_OCO2Sets2.Clear();
		                        GBPNZD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO2S3_UP_S2 = 0;
		                for (; GBPNZD_OCO2S3_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets3.Count; GBPNZD_OCO2S3_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO2Sets3[GBPNZD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO2Sets3[GBPNZD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.GBPNZD_UP_S2_OCO2Sets3.Clear();
		                        GBPNZD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO2S4_UP_S2 = 0;
		                for (; GBPNZD_OCO2S4_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets4.Count; GBPNZD_OCO2S4_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO2Sets4[GBPNZD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO2Sets4[GBPNZD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.GBPNZD_UP_S2_OCO2Sets4.Clear();
		                        GBPNZD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO2S5_UP_S2 = 0;
		                for (; GBPNZD_OCO2S5_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets5.Count; GBPNZD_OCO2S5_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO2Sets5[GBPNZD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO2Sets5[GBPNZD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.GBPNZD_UP_S2_OCO2Sets5.Clear();
		                        GBPNZD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO2S6_UP_S2 = 0;
		                for (; GBPNZD_OCO2S6_UP_S2 < Base.GBPNZD_UP_S2_OCO2Sets6.Count; GBPNZD_OCO2S6_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO2Sets6[GBPNZD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO2Sets6[GBPNZD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.GBPNZD_UP_S2_OCO2Sets6.Clear();
		                        GBPNZD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPNZD_OCO3_EO1_UP_S2)
            		Base.GBPNZD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPNZD_OCO3_EO2_UP_S2)
	                Base.GBPNZD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO3_EO3_UP_S2)
	                Base.GBPNZD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO3_EO4_UP_S2)
	                Base.GBPNZD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO3_EO5_UP_S2)
	                Base.GBPNZD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO3_EO6_UP_S2)
	                Base.GBPNZD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPNZD_OCO3S1_UP_S2 = 0;
		                for (; GBPNZD_OCO3S1_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets1.Count; GBPNZD_OCO3S1_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO3Sets1[GBPNZD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO3Sets1[GBPNZD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.GBPNZD_UP_S2_OCO3Sets1.Clear();
		                        GBPNZD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPNZD_OCO3S2_UP_S2 = 0;
		                for (; GBPNZD_OCO3S2_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets2.Count; GBPNZD_OCO3S2_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO3Sets2[GBPNZD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO3Sets2[GBPNZD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.GBPNZD_UP_S2_OCO3Sets2.Clear();
		                        GBPNZD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO3S3_UP_S2 = 0;
		                for (; GBPNZD_OCO3S3_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets3.Count; GBPNZD_OCO3S3_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO3Sets3[GBPNZD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO3Sets3[GBPNZD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.GBPNZD_UP_S2_OCO3Sets3.Clear();
		                        GBPNZD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO3S4_UP_S2 = 0;
		                for (; GBPNZD_OCO3S4_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets4.Count; GBPNZD_OCO3S4_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO3Sets4[GBPNZD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO3Sets4[GBPNZD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.GBPNZD_UP_S2_OCO3Sets4.Clear();
		                        GBPNZD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO3S5_UP_S2 = 0;
		                for (; GBPNZD_OCO3S5_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets5.Count; GBPNZD_OCO3S5_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO3Sets5[GBPNZD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO3Sets5[GBPNZD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.GBPNZD_UP_S2_OCO3Sets5.Clear();
		                        GBPNZD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO3S6_UP_S2 = 0;
		                for (; GBPNZD_OCO3S6_UP_S2 < Base.GBPNZD_UP_S2_OCO3Sets6.Count; GBPNZD_OCO3S6_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO3Sets6[GBPNZD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO3Sets6[GBPNZD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.GBPNZD_UP_S2_OCO3Sets6.Clear();
		                        GBPNZD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPNZD_OCO4_EO1_UP_S2)
            		Base.GBPNZD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPNZD_OCO4_EO2_UP_S2)
	                Base.GBPNZD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO4_EO3_UP_S2)
	                Base.GBPNZD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO4_EO4_UP_S2)
	                Base.GBPNZD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO4_EO5_UP_S2)
	                Base.GBPNZD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPNZD_OCO4_EO6_UP_S2)
	                Base.GBPNZD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPNZD_OCO4S1_UP_S2 = 0;
		                for (; GBPNZD_OCO4S1_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets1.Count; GBPNZD_OCO4S1_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO4Sets1[GBPNZD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO4Sets1[GBPNZD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.GBPNZD_UP_S2_OCO4Sets1.Clear();
		                        GBPNZD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPNZD_OCO4S2_UP_S2 = 0;
		                for (; GBPNZD_OCO4S2_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets2.Count; GBPNZD_OCO4S2_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO4Sets2[GBPNZD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO4Sets2[GBPNZD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.GBPNZD_UP_S2_OCO4Sets2.Clear();
		                        GBPNZD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO4S3_UP_S2 = 0;
		                for (; GBPNZD_OCO4S3_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets3.Count; GBPNZD_OCO4S3_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO4Sets3[GBPNZD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO4Sets3[GBPNZD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.GBPNZD_UP_S2_OCO4Sets3.Clear();
		                        GBPNZD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPNZD_OCO4S4_UP_S2 = 0;
		                for (; GBPNZD_OCO4S4_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets4.Count; GBPNZD_OCO4S4_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO4Sets4[GBPNZD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO4Sets4[GBPNZD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.GBPNZD_UP_S2_OCO4Sets4.Clear();
		                        GBPNZD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO4S5_UP_S2 = 0;
		                for (; GBPNZD_OCO4S5_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets5.Count; GBPNZD_OCO4S5_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO4Sets5[GBPNZD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO4Sets5[GBPNZD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.GBPNZD_UP_S2_OCO4Sets5.Clear();
		                        GBPNZD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPNZD_OCO4S6_UP_S2 = 0;
		                for (; GBPNZD_OCO4S6_UP_S2 < Base.GBPNZD_UP_S2_OCO4Sets6.Count; GBPNZD_OCO4S6_UP_S2++)
		                    if (Base.GBPNZD_UP_S2_OCO4Sets6[GBPNZD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPNZD_UP_S2_OCO4Sets6[GBPNZD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPNZD", order.Quantity, false, "GBPNZD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.GBPNZD_UP_S2_OCO4Sets6.Clear();
		                        GBPNZD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_GBPNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPNZD_UP_S2 = DOWM_GBPNZD_UP_S2 || DOWT_GBPNZD_UP_S2 || DOWW_GBPNZD_UP_S2 || DOWTH_GBPNZD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPNZD"))
	            	{
	            		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.GBPNZD_OCO1_UP_S2_IsReady == false ||
	                    	Base.GBPNZD_OCO2_UP_S2_IsReady == false ||
	                    	Base.GBPNZD_OCO3_UP_S2_IsReady == false ||
	                    	Base.GBPNZD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.GBPNZD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPNZD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPNZD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPNZD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPNZD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.GBPNZD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.GBPNZD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.GBPNZD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	GBPNZD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											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.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*3
				                										
				                										)
			                							
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	GBPNZD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*3
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	GBPNZD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
		
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*3
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	if (GBPNZD_Signal_Condition_UP_1)
	                	{
	                    	GBPNZD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPNZD_Signal_Condition_UP_2)
	                	{
	                    	GBPNZD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPNZD_Signal_Condition_UP_3)
	                	{
	                    	GBPNZD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (GBPNZD_Signal_Condition_UP_1)
	                	{
	                    	GBPNZD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (GBPNZD_Signal_Condition_UP_2)
	                	{
	                    	GBPNZD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (GBPNZD_Signal_Condition_UP_3)
	                	{
	                    	GBPNZD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    GBPNZD_UP_S2_TP2 =  GBPNZD_UP_S2_SL * 0;
	                    GBPNZD_UP_S2_TP3 =  GBPNZD_UP_S2_SL * 0;
	                    GBPNZD_UP_S2_TP4 =  GBPNZD_UP_S2_SL * 0;
	                    GBPNZD_UP_S2_TP5 =  GBPNZD_UP_S2_SL * 0;
	                    GBPNZD_UP_S2_TP6 =  GBPNZD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPNZD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPNZD_quantity_SL_UP_S2 = GBPNZD_quantity_UP_S2;
	                    GBPNZD_quantity_TP1_UP_S2 = (int)Math.Floor(GBPNZD_quantity_UP_S2 * 1m);
	                    GBPNZD_quantity_TP2_UP_S2 = (int)Math.Floor(GBPNZD_quantity_TP1_UP_S2 * 0m);
	                    GBPNZD_quantity_TP3_UP_S2 = (int)Math.Floor(GBPNZD_quantity_TP2_UP_S2 * 0m);
	                    GBPNZD_quantity_TP4_UP_S2 = (int)Math.Floor(GBPNZD_quantity_TP3_UP_S2 * 0m);
	                    GBPNZD_quantity_TP5_UP_S2 = (int)Math.Floor(GBPNZD_quantity_TP4_UP_S2 * 0m);
	                    GBPNZD_quantity_TP6_UP_S2 = (int)Math.Floor(GBPNZD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((GBPNZD_Signal_Condition_UP_1 || GBPNZD_Signal_Condition_UP_2 || GBPNZD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPNZD_UP_S2 && 
	                    Base.GBPNZD_OCO1_UP_S2_IsReady == true &&
	                    Base.GBPNZD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPNZD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP1_UP_S2, false,"GBPNZD_UP_S2_Entry_TP1_OCO1");
	                         Base.GBPNZD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.GBPNZD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP2_UP_S2, false,"GBPNZD_UP_S2_Entry_TP2_OCO1");
	                         Base.GBPNZD_OCO1_EO2_UP_S2 = false;
	
	                         Base.GBPNZD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP3_UP_S2, false,"GBPNZD_UP_S2_Entry_TP3_OCO1");
	                         Base.GBPNZD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.GBPNZD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP4_UP_S2, false,"GBPNZD_UP_S2_Entry_TP4_OCO1");
	                         Base.GBPNZD_OCO1_EO4_UP_S2 = false;

							Base.GBPNZD_OCO1_UP_S2_IsReady = false;
							
							if (Base.GBPNZD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((GBPNZD_Signal_Condition_UP_1 || GBPNZD_Signal_Condition_UP_2 || GBPNZD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPNZD_UP_S2 && 
	                    Base.GBPNZD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPNZD_OCO2_UP_S2_IsReady == true &&
	                    Base.GBPNZD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPNZD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP1_UP_S2, false,"GBPNZD_UP_S2_Entry_TP1_OCO2");
	                         Base.GBPNZD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.GBPNZD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP2_UP_S2, false,"GBPNZD_UP_S2_Entry_TP2_OCO2");
	                         Base.GBPNZD_OCO2_EO2_UP_S2 = false;
	
	                         Base.GBPNZD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP3_UP_S2, false,"GBPNZD_UP_S2_Entry_TP3_OCO2");
	                         Base.GBPNZD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.GBPNZD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP4_UP_S2, false,"GBPNZD_UP_S2_Entry_TP4_OCO2");
	                         Base.GBPNZD_OCO2_EO4_UP_S2 = false;

							Base.GBPNZD_OCO2_UP_S2_IsReady = false;
							
							if (Base.GBPNZD_OCO2_UP_S2_IsReady == false && Base.GBPNZD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((GBPNZD_Signal_Condition_UP_1 || GBPNZD_Signal_Condition_UP_2 || GBPNZD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPNZD_UP_S2 &&
	                    Base.GBPNZD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPNZD_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPNZD_OCO3_UP_S2_IsReady == true &&
	                    Base.GBPNZD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPNZD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP1_UP_S2, false,"GBPNZD_UP_S2_Entry_TP1_OCO3");
	                         Base.GBPNZD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.GBPNZD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP2_UP_S2, false,"GBPNZD_UP_S2_Entry_TP2_OCO3");
	                         Base.GBPNZD_OCO3_EO2_UP_S2 = false;
	
	                         Base.GBPNZD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP3_UP_S2, false,"GBPNZD_UP_S2_Entry_TP3_OCO3");
	                         Base.GBPNZD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.GBPNZD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP4_UP_S2, false,"GBPNZD_UP_S2_Entry_TP4_OCO3");
	                         Base.GBPNZD_OCO3_EO4_UP_S2 = false;

							Base.GBPNZD_OCO3_UP_S2_IsReady = false;
							
							if (Base.GBPNZD_OCO3_UP_S2_IsReady == false && Base.GBPNZD_OCO2_UP_S2_IsReady == false && Base.GBPNZD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((GBPNZD_Signal_Condition_UP_1 || GBPNZD_Signal_Condition_UP_2 || GBPNZD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPNZD_UP_S2 && 
	                    Base.GBPNZD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPNZD_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPNZD_OCO3_UP_S2_IsReady == false &&
	                    Base.GBPNZD_OCO4_UP_S2_IsReady == true &&
	                    Base.GBPNZD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPNZD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP1_UP_S2, false,"GBPNZD_UP_S2_Entry_TP1_OCO4");
	                         Base.GBPNZD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.GBPNZD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP2_UP_S2, false,"GBPNZD_UP_S2_Entry_TP2_OCO4");
	                         Base.GBPNZD_OCO4_EO2_UP_S2 = false;
	
	                         Base.GBPNZD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP3_UP_S2, false,"GBPNZD_UP_S2_Entry_TP3_OCO4");
	                         Base.GBPNZD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.GBPNZD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPNZD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPNZD_quantity_TP4_UP_S2, false,"GBPNZD_UP_S2_Entry_TP4_OCO4");
	                         Base.GBPNZD_OCO4_EO4_UP_S2 = false;

							Base.GBPNZD_OCO4_UP_S2_IsReady = false;
							
							if (Base.GBPNZD_OCO4_UP_S2_IsReady == false && Base.GBPNZD_OCO3_UP_S2_IsReady == false && Base.GBPNZD_OCO2_UP_S2_IsReady == false && Base.GBPNZD_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.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 GBPCHF_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPCHF_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("GBPCHF OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCHF OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCHF OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCHF OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCHF OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCHF OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCHF OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCHF OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCHF OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCHF S2");
		        	}
		        }
		        
				if (Base.GBPCHF_OCO1_EO1_UP_S2)
	                Base.GBPCHF_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCHF_OCO1_EO2_UP_S2)
	                Base.GBPCHF_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO1_EO3_UP_S2)
	                Base.GBPCHF_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO1_EO4_UP_S2)
	                Base.GBPCHF_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO1_EO5_UP_S2)
	                Base.GBPCHF_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO1_EO6_UP_S2)
	                Base.GBPCHF_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.GBPCHF_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP1,"TP1_GBPCHF_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP1_GBPCHF_UP_S2_OCO1"));
		                 };
		                Base.GBPCHF_UP_S2_OCO1Sets1.Add( Base.GBPCHF_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP2,"TP2_GBPCHF_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP2_GBPCHF_UP_S2_OCO1"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO1Sets2.Add( Base.GBPCHF_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP3,"TP3_GBPCHF_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP3_GBPCHF_UP_S2_OCO1"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO1Sets3.Add( Base.GBPCHF_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP4,"TP4_GBPCHF_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP4_GBPCHF_UP_S2_OCO1"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO1Sets4.Add( Base.GBPCHF_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP5,"TP5_GBPCHF_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP5_GBPCHF_UP_S2_OCO1"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO1Sets5.Add( Base.GBPCHF_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP6,"TP6_GBPCHF_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP6_GBPCHF_UP_S2_OCO1"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO1Sets6.Add( Base.GBPCHF_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPCHF_OCO1S1_UP_S2 = 0;
	                for (; GBPCHF_OCO1S1_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets1.Count; GBPCHF_OCO1S1_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO1Sets1[GBPCHF_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO1Sets1[GBPCHF_OCO1S1_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO1Sets1.RemoveAt(GBPCHF_OCO1S1_UP_S2);
	                        GBPCHF_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCHF_OCO1S2_UP_S2 = 0;
	                for (; GBPCHF_OCO1S2_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets2.Count; GBPCHF_OCO1S2_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO1Sets2[GBPCHF_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO1Sets2[GBPCHF_OCO1S2_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO1Sets2.RemoveAt(GBPCHF_OCO1S2_UP_S2);
	                        GBPCHF_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO1S3_UP_S2 = 0;
	                for (; GBPCHF_OCO1S3_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets3.Count; GBPCHF_OCO1S3_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO1Sets3[GBPCHF_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO1Sets3[GBPCHF_OCO1S3_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO1Sets3.RemoveAt(GBPCHF_OCO1S3_UP_S2);
	                        GBPCHF_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO1S4_UP_S2 = 0;
	                for (; GBPCHF_OCO1S4_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets4.Count; GBPCHF_OCO1S4_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO1Sets4[GBPCHF_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO1Sets4[GBPCHF_OCO1S4_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO1Sets4.RemoveAt(GBPCHF_OCO1S4_UP_S2);
	                        GBPCHF_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCHF_OCO1S5_UP_S2 = 0;
	                for (; GBPCHF_OCO1S5_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets5.Count; GBPCHF_OCO1S5_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO1Sets5[GBPCHF_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO1Sets5[GBPCHF_OCO1S5_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO1Sets5.RemoveAt(GBPCHF_OCO1S5_UP_S2);
	                        GBPCHF_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCHF_OCO1S6_UP_S2 = 0;
	                for (; GBPCHF_OCO1S6_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets6.Count; GBPCHF_OCO1S6_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO1Sets6[GBPCHF_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO1Sets6[GBPCHF_OCO1S6_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO1Sets6.RemoveAt(GBPCHF_OCO1S6_UP_S2);
	                        GBPCHF_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.GBPCHF_OCO2_EO1_UP_S2)
	                Base.GBPCHF_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCHF_OCO2_EO2_UP_S2)
	                Base.GBPCHF_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO2_EO3_UP_S2)
	                Base.GBPCHF_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO2_EO4_UP_S2)
	                Base.GBPCHF_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO2_EO5_UP_S2)
	                Base.GBPCHF_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO2_EO6_UP_S2)
	                Base.GBPCHF_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.GBPCHF_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP1,"TP1_GBPCHF_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP1_GBPCHF_UP_S2_OCO2"));
		                 };
		                Base.GBPCHF_UP_S2_OCO2Sets1.Add( Base.GBPCHF_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP2,"TP2_GBPCHF_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP2_GBPCHF_UP_S2_OCO2"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO2Sets2.Add( Base.GBPCHF_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP3,"TP3_GBPCHF_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP3_GBPCHF_UP_S2_OCO2"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO2Sets3.Add( Base.GBPCHF_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP4,"TP4_GBPCHF_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP4_GBPCHF_UP_S2_OCO2"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO2Sets4.Add( Base.GBPCHF_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP5,"TP5_GBPCHF_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP5_GBPCHF_UP_S2_OCO2"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO2Sets5.Add( Base.GBPCHF_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP6,"TP6_GBPCHF_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP6_GBPCHF_UP_S2_OCO2"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO2Sets6.Add( Base.GBPCHF_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPCHF_OCO2S1_UP_S2 = 0;
	                for (; GBPCHF_OCO2S1_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets1.Count; GBPCHF_OCO2S1_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO2Sets1[GBPCHF_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO2Sets1[GBPCHF_OCO2S1_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO2Sets1.RemoveAt(GBPCHF_OCO2S1_UP_S2);
	                        GBPCHF_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCHF_OCO2S2_UP_S2 = 0;
	                for (; GBPCHF_OCO2S2_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets2.Count; GBPCHF_OCO2S2_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO2Sets2[GBPCHF_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO2Sets2[GBPCHF_OCO2S2_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO2Sets2.RemoveAt(GBPCHF_OCO2S2_UP_S2);
	                        GBPCHF_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO2S3_UP_S2 = 0;
	                for (; GBPCHF_OCO2S3_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets3.Count; GBPCHF_OCO2S3_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO2Sets3[GBPCHF_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO2Sets3[GBPCHF_OCO2S3_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO2Sets3.RemoveAt(GBPCHF_OCO2S3_UP_S2);
	                        GBPCHF_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO2S4_UP_S2 = 0;
	                for (; GBPCHF_OCO2S4_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets4.Count; GBPCHF_OCO2S4_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO2Sets4[GBPCHF_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO2Sets4[GBPCHF_OCO2S4_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO2Sets4.RemoveAt(GBPCHF_OCO2S4_UP_S2);
	                        GBPCHF_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCHF_OCO2S5_UP_S2 = 0;
	                for (; GBPCHF_OCO2S5_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets5.Count; GBPCHF_OCO2S5_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO2Sets5[GBPCHF_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO2Sets5[GBPCHF_OCO2S5_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO2Sets5.RemoveAt(GBPCHF_OCO2S5_UP_S2);
	                        GBPCHF_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCHF_OCO2S6_UP_S2 = 0;
	                for (; GBPCHF_OCO2S6_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets6.Count; GBPCHF_OCO2S6_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO2Sets6[GBPCHF_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO2Sets6[GBPCHF_OCO2S6_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO2Sets6.RemoveAt(GBPCHF_OCO2S6_UP_S2);
	                        GBPCHF_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCHF_OCO3_EO1_UP_S2)
	                Base.GBPCHF_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCHF_OCO3_EO2_UP_S2)
	                Base.GBPCHF_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO3_EO3_UP_S2)
	                Base.GBPCHF_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO3_EO4_UP_S2)
	                Base.GBPCHF_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO3_EO5_UP_S2)
	                Base.GBPCHF_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO3_EO6_UP_S2)
	                Base.GBPCHF_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.GBPCHF_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP1,"TP1_GBPCHF_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP1_GBPCHF_UP_S2_OCO3"));
		                 };
		                Base.GBPCHF_UP_S2_OCO3Sets1.Add( Base.GBPCHF_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP2,"TP2_GBPCHF_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP2_GBPCHF_UP_S2_OCO3"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO3Sets2.Add( Base.GBPCHF_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP3,"TP3_GBPCHF_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP3_GBPCHF_UP_S2_OCO3"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO3Sets3.Add( Base.GBPCHF_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP4,"TP4_GBPCHF_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP4_GBPCHF_UP_S2_OCO3"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO3Sets4.Add( Base.GBPCHF_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP5,"TP5_GBPCHF_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP5_GBPCHF_UP_S2_OCO3"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO3Sets5.Add( Base.GBPCHF_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP6,"TP6_GBPCHF_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP6_GBPCHF_UP_S2_OCO3"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO3Sets6.Add( Base.GBPCHF_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPCHF_OCO3S1_UP_S2 = 0;
	                for (; GBPCHF_OCO3S1_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets1.Count; GBPCHF_OCO3S1_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO3Sets1[GBPCHF_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO3Sets1[GBPCHF_OCO3S1_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO3Sets1.RemoveAt(GBPCHF_OCO3S1_UP_S2);
	                        GBPCHF_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCHF_OCO3S2_UP_S2 = 0;
	                for (; GBPCHF_OCO3S2_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets2.Count; GBPCHF_OCO3S2_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO3Sets2[GBPCHF_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO3Sets2[GBPCHF_OCO3S2_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO3Sets2.RemoveAt(GBPCHF_OCO3S2_UP_S2);
	                        GBPCHF_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO3S3_UP_S2 = 0;
	                for (; GBPCHF_OCO3S3_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets3.Count; GBPCHF_OCO3S3_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO3Sets3[GBPCHF_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO3Sets3[GBPCHF_OCO3S3_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO3Sets3.RemoveAt(GBPCHF_OCO3S3_UP_S2);
	                        GBPCHF_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO3S4_UP_S2 = 0;
	                for (; GBPCHF_OCO3S4_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets4.Count; GBPCHF_OCO3S4_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO3Sets4[GBPCHF_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO3Sets4[GBPCHF_OCO3S4_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO3Sets4.RemoveAt(GBPCHF_OCO3S4_UP_S2);
	                        GBPCHF_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCHF_OCO3S5_UP_S2 = 0;
	                for (; GBPCHF_OCO3S5_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets5.Count; GBPCHF_OCO3S5_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO3Sets5[GBPCHF_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO3Sets5[GBPCHF_OCO3S5_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO3Sets5.RemoveAt(GBPCHF_OCO3S5_UP_S2);
	                        GBPCHF_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCHF_OCO3S6_UP_S2 = 0;
	                for (; GBPCHF_OCO3S6_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets6.Count; GBPCHF_OCO3S6_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO3Sets6[GBPCHF_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO3Sets6[GBPCHF_OCO3S6_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO3Sets6.RemoveAt(GBPCHF_OCO3S6_UP_S2);
	                        GBPCHF_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCHF_OCO4_EO1_UP_S2)
	                Base.GBPCHF_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCHF_OCO4_EO2_UP_S2)
	                Base.GBPCHF_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO4_EO3_UP_S2)
	                Base.GBPCHF_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO4_EO4_UP_S2)
	                Base.GBPCHF_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO4_EO5_UP_S2)
	                Base.GBPCHF_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCHF_OCO4_EO6_UP_S2)
	                Base.GBPCHF_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.GBPCHF_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP1,"TP1_GBPCHF_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP1_GBPCHF_UP_S2_OCO4"));
		                 };
		                Base.GBPCHF_UP_S2_OCO4Sets1.Add( Base.GBPCHF_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP2,"TP2_GBPCHF_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP2_GBPCHF_UP_S2_OCO4"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO4Sets2.Add( Base.GBPCHF_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP3,"TP3_GBPCHF_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP3_GBPCHF_UP_S2_OCO4"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO4Sets3.Add( Base.GBPCHF_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP4,"TP4_GBPCHF_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP4_GBPCHF_UP_S2_OCO4"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO4Sets4.Add( Base.GBPCHF_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP5,"TP5_GBPCHF_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP5_GBPCHF_UP_S2_OCO4"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO4Sets5.Add( Base.GBPCHF_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCHF_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.GBPCHF_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCHF_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCHF_UP_S2_TP6,"TP6_GBPCHF_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCHF_UP_S2_SL,"SL_TP6_GBPCHF_UP_S2_OCO4"));
		                 };
	                    Base.GBPCHF_UP_S2_OCO4Sets6.Add( Base.GBPCHF_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCHF_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPCHF_OCO4S1_UP_S2 = 0;
	                for (; GBPCHF_OCO4S1_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets1.Count; GBPCHF_OCO4S1_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO4Sets1[GBPCHF_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO4Sets1[GBPCHF_OCO4S1_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO4Sets1.RemoveAt(GBPCHF_OCO4S1_UP_S2);
	                        GBPCHF_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCHF_OCO4S2_UP_S2 = 0;
	                for (; GBPCHF_OCO4S2_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets2.Count; GBPCHF_OCO4S2_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO4Sets2[GBPCHF_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO4Sets2[GBPCHF_OCO4S2_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO4Sets2.RemoveAt(GBPCHF_OCO4S2_UP_S2);
	                        GBPCHF_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO4S3_UP_S2 = 0;
	                for (; GBPCHF_OCO4S3_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets3.Count; GBPCHF_OCO4S3_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO4Sets3[GBPCHF_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO4Sets3[GBPCHF_OCO4S3_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO4Sets3.RemoveAt(GBPCHF_OCO4S3_UP_S2);
	                        GBPCHF_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCHF_OCO4S4_UP_S2 = 0;
	                for (; GBPCHF_OCO4S4_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets4.Count; GBPCHF_OCO4S4_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO4Sets4[GBPCHF_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO4Sets4[GBPCHF_OCO4S4_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO4Sets4.RemoveAt(GBPCHF_OCO4S4_UP_S2);
	                        GBPCHF_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCHF_OCO4S5_UP_S2 = 0;
	                for (; GBPCHF_OCO4S5_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets5.Count; GBPCHF_OCO4S5_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO4Sets5[GBPCHF_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO4Sets5[GBPCHF_OCO4S5_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO4Sets5.RemoveAt(GBPCHF_OCO4S5_UP_S2);
	                        GBPCHF_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCHF_OCO4S6_UP_S2 = 0;
	                for (; GBPCHF_OCO4S6_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets6.Count; GBPCHF_OCO4S6_UP_S2++)
	                    if (Base.GBPCHF_UP_S2_OCO4Sets6[GBPCHF_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCHF_UP_S2_OCO4Sets6[GBPCHF_OCO4S6_UP_S2].Filled();
	                        Base.GBPCHF_UP_S2_OCO4Sets6.RemoveAt(GBPCHF_OCO4S6_UP_S2);
	                        GBPCHF_OCO4S6_UP_S2 = 0;
	                        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.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 GBPCAD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPCAD_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("GBPCAD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCAD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCAD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCAD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        }
		        
				if (Base.GBPCAD_OCO1_EO1_DOWN_S2)
	                Base.GBPCAD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCAD_OCO1_EO2_DOWN_S2)
	                Base.GBPCAD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO1_EO3_DOWN_S2)
	                Base.GBPCAD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO1_EO4_DOWN_S2)
	                Base.GBPCAD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPCAD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP1_GBPCAD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP1,"TP1_GBPCAD_DOWN_S2_OCO1"));
		                 };
		                Base.GBPCAD_DOWN_S2_OCO1Sets1.Add( Base.GBPCAD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP2_GBPCAD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP2,"TP2_GBPCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO1Sets2.Add( Base.GBPCAD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP3_GBPCAD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP3,"TP3_GBPCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO1Sets3.Add( Base.GBPCAD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP4_GBPCAD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP4,"TP4_GBPCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO1Sets4.Add( Base.GBPCAD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPCAD_OCO1S1_DOWN_S2 = 0;
	                for (; GBPCAD_OCO1S1_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets1.Count; GBPCAD_OCO1S1_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO1Sets1[GBPCAD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO1Sets1[GBPCAD_OCO1S1_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO1Sets1.RemoveAt(GBPCAD_OCO1S1_DOWN_S2);
	                        GBPCAD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCAD_OCO1S2_DOWN_S2 = 0;
	                for (; GBPCAD_OCO1S2_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets2.Count; GBPCAD_OCO1S2_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO1Sets2[GBPCAD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO1Sets2[GBPCAD_OCO1S2_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO1Sets2.RemoveAt(GBPCAD_OCO1S2_DOWN_S2);
	                        GBPCAD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO1S3_DOWN_S2 = 0;
	                for (; GBPCAD_OCO1S3_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets3.Count; GBPCAD_OCO1S3_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO1Sets3[GBPCAD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO1Sets3[GBPCAD_OCO1S3_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO1Sets3.RemoveAt(GBPCAD_OCO1S3_DOWN_S2);
	                        GBPCAD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO1S4_DOWN_S2 = 0;
	                for (; GBPCAD_OCO1S4_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets4.Count; GBPCAD_OCO1S4_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO1Sets4[GBPCAD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO1Sets4[GBPCAD_OCO1S4_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO1Sets4.RemoveAt(GBPCAD_OCO1S4_DOWN_S2);
	                        GBPCAD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCAD_OCO2_EO1_DOWN_S2)
	                Base.GBPCAD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCAD_OCO2_EO2_DOWN_S2)
	                Base.GBPCAD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO2_EO3_DOWN_S2)
	                Base.GBPCAD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO2_EO4_DOWN_S2)
	                Base.GBPCAD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPCAD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP1_GBPCAD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP1,"TP1_GBPCAD_DOWN_S2_OCO2"));
		                 };
		                Base.GBPCAD_DOWN_S2_OCO2Sets1.Add( Base.GBPCAD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP2_GBPCAD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP2,"TP2_GBPCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO2Sets2.Add( Base.GBPCAD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP3_GBPCAD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP3,"TP3_GBPCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO2Sets3.Add( Base.GBPCAD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP4_GBPCAD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP4,"TP4_GBPCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO2Sets4.Add( Base.GBPCAD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int GBPCAD_OCO2S1_DOWN_S2 = 0;
	                for (; GBPCAD_OCO2S1_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets1.Count; GBPCAD_OCO2S1_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO2Sets1[GBPCAD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO2Sets1[GBPCAD_OCO2S1_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO2Sets1.RemoveAt(GBPCAD_OCO2S1_DOWN_S2);
	                        GBPCAD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCAD_OCO2S2_DOWN_S2 = 0;
	                for (; GBPCAD_OCO2S2_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets2.Count; GBPCAD_OCO2S2_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO2Sets2[GBPCAD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO2Sets2[GBPCAD_OCO2S2_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO2Sets2.RemoveAt(GBPCAD_OCO2S2_DOWN_S2);
	                        GBPCAD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO2S3_DOWN_S2 = 0;
	                for (; GBPCAD_OCO2S3_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets3.Count; GBPCAD_OCO2S3_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO2Sets3[GBPCAD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO2Sets3[GBPCAD_OCO2S3_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO2Sets3.RemoveAt(GBPCAD_OCO2S3_DOWN_S2);
	                        GBPCAD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO2S4_DOWN_S2 = 0;
	                for (; GBPCAD_OCO2S4_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets4.Count; GBPCAD_OCO2S4_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO2Sets4[GBPCAD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO2Sets4[GBPCAD_OCO2S4_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO2Sets4.RemoveAt(GBPCAD_OCO2S4_DOWN_S2);
	                        GBPCAD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCAD_OCO3_EO1_DOWN_S2)
	                Base.GBPCAD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCAD_OCO3_EO2_DOWN_S2)
	                Base.GBPCAD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO3_EO3_DOWN_S2)
	                Base.GBPCAD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO3_EO4_DOWN_S2)
	                Base.GBPCAD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPCAD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP1_GBPCAD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP1,"TP1_GBPCAD_DOWN_S2_OCO3"));
		                 };
		                Base.GBPCAD_DOWN_S2_OCO3Sets1.Add( Base.GBPCAD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP2_GBPCAD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP2,"TP2_GBPCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO3Sets2.Add( Base.GBPCAD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP3_GBPCAD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP3,"TP3_GBPCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO3Sets3.Add( Base.GBPCAD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP4_GBPCAD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP4,"TP4_GBPCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO3Sets4.Add( Base.GBPCAD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPCAD_OCO3S1_DOWN_S2 = 0;
	                for (; GBPCAD_OCO3S1_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets1.Count; GBPCAD_OCO3S1_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO3Sets1[GBPCAD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO3Sets1[GBPCAD_OCO3S1_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO3Sets1.RemoveAt(GBPCAD_OCO3S1_DOWN_S2);
	                        GBPCAD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCAD_OCO3S2_DOWN_S2 = 0;
	                for (; GBPCAD_OCO3S2_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets2.Count; GBPCAD_OCO3S2_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO3Sets2[GBPCAD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO3Sets2[GBPCAD_OCO3S2_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO3Sets2.RemoveAt(GBPCAD_OCO3S2_DOWN_S2);
	                        GBPCAD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO3S3_DOWN_S2 = 0;
	                for (; GBPCAD_OCO3S3_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets3.Count; GBPCAD_OCO3S3_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO3Sets3[GBPCAD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO3Sets3[GBPCAD_OCO3S3_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO3Sets3.RemoveAt(GBPCAD_OCO3S3_DOWN_S2);
	                        GBPCAD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO3S4_DOWN_S2 = 0;
	                for (; GBPCAD_OCO3S4_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets4.Count; GBPCAD_OCO3S4_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO3Sets4[GBPCAD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO3Sets4[GBPCAD_OCO3S4_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO3Sets4.RemoveAt(GBPCAD_OCO3S4_DOWN_S2);
	                        GBPCAD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCAD_OCO4_EO1_DOWN_S2)
	                Base.GBPCAD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCAD_OCO4_EO2_DOWN_S2)
	                Base.GBPCAD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO4_EO3_DOWN_S2)
	                Base.GBPCAD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO4_EO4_DOWN_S2)
	                Base.GBPCAD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.GBPCAD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP1_GBPCAD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP1,"TP1_GBPCAD_DOWN_S2_OCO4"));
		                 };
		                Base.GBPCAD_DOWN_S2_OCO4Sets1.Add( Base.GBPCAD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP2_GBPCAD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP2,"TP2_GBPCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO4Sets2.Add( Base.GBPCAD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP3_GBPCAD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP3,"TP3_GBPCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO4Sets3.Add( Base.GBPCAD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_DOWN_S2_SL,"SL_TP4_GBPCAD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_DOWN_S2_TP4,"TP4_GBPCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.GBPCAD_DOWN_S2_OCO4Sets4.Add( Base.GBPCAD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int GBPCAD_OCO4S1_DOWN_S2 = 0;
	                for (; GBPCAD_OCO4S1_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets1.Count; GBPCAD_OCO4S1_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO4Sets1[GBPCAD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO4Sets1[GBPCAD_OCO4S1_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO4Sets1.RemoveAt(GBPCAD_OCO4S1_DOWN_S2);
	                        GBPCAD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCAD_OCO4S2_DOWN_S2 = 0;
	                for (; GBPCAD_OCO4S2_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets2.Count; GBPCAD_OCO4S2_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO4Sets2[GBPCAD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO4Sets2[GBPCAD_OCO4S2_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO4Sets2.RemoveAt(GBPCAD_OCO4S2_DOWN_S2);
	                        GBPCAD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO4S3_DOWN_S2 = 0;
	                for (; GBPCAD_OCO4S3_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets3.Count; GBPCAD_OCO4S3_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO4Sets3[GBPCAD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO4Sets3[GBPCAD_OCO4S3_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO4Sets3.RemoveAt(GBPCAD_OCO4S3_DOWN_S2);
	                        GBPCAD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO4S4_DOWN_S2 = 0;
	                for (; GBPCAD_OCO4S4_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets4.Count; GBPCAD_OCO4S4_DOWN_S2++)
	                    if (Base.GBPCAD_DOWN_S2_OCO4Sets4[GBPCAD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_DOWN_S2_OCO4Sets4[GBPCAD_OCO4S4_DOWN_S2].Filled();
	                        Base.GBPCAD_DOWN_S2_OCO4Sets4.RemoveAt(GBPCAD_OCO4S4_DOWN_S2);
	                        GBPCAD_OCO4S4_DOWN_S2 = 0;
	                        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.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 GBPCAD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public GBPCAD_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("GBPCAD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCAD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCAD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCAD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCAD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCAD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("GBPCAD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("GBPCAD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("GBPCAD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue GBPCAD S2");
		        	}
		        }
		        
				if (Base.GBPCAD_OCO1_EO1_UP_S2)
	                Base.GBPCAD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCAD_OCO1_EO2_UP_S2)
	                Base.GBPCAD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO1_EO3_UP_S2)
	                Base.GBPCAD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO1_EO4_UP_S2)
	                Base.GBPCAD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO1_EO5_UP_S2)
	                Base.GBPCAD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO1_EO6_UP_S2)
	                Base.GBPCAD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.GBPCAD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP1,"TP1_GBPCAD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP1_GBPCAD_UP_S2_OCO1"));
		                 };
		                Base.GBPCAD_UP_S2_OCO1Sets1.Add( Base.GBPCAD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP2,"TP2_GBPCAD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP2_GBPCAD_UP_S2_OCO1"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO1Sets2.Add( Base.GBPCAD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP3,"TP3_GBPCAD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP3_GBPCAD_UP_S2_OCO1"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO1Sets3.Add( Base.GBPCAD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP4,"TP4_GBPCAD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP4_GBPCAD_UP_S2_OCO1"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO1Sets4.Add( Base.GBPCAD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP5,"TP5_GBPCAD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP5_GBPCAD_UP_S2_OCO1"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO1Sets5.Add( Base.GBPCAD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP6,"TP6_GBPCAD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP6_GBPCAD_UP_S2_OCO1"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO1Sets6.Add( Base.GBPCAD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPCAD_OCO1S1_UP_S2 = 0;
	                for (; GBPCAD_OCO1S1_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets1.Count; GBPCAD_OCO1S1_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO1Sets1[GBPCAD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO1Sets1[GBPCAD_OCO1S1_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO1Sets1.RemoveAt(GBPCAD_OCO1S1_UP_S2);
	                        GBPCAD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCAD_OCO1S2_UP_S2 = 0;
	                for (; GBPCAD_OCO1S2_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets2.Count; GBPCAD_OCO1S2_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO1Sets2[GBPCAD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO1Sets2[GBPCAD_OCO1S2_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO1Sets2.RemoveAt(GBPCAD_OCO1S2_UP_S2);
	                        GBPCAD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO1S3_UP_S2 = 0;
	                for (; GBPCAD_OCO1S3_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets3.Count; GBPCAD_OCO1S3_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO1Sets3[GBPCAD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO1Sets3[GBPCAD_OCO1S3_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO1Sets3.RemoveAt(GBPCAD_OCO1S3_UP_S2);
	                        GBPCAD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO1S4_UP_S2 = 0;
	                for (; GBPCAD_OCO1S4_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets4.Count; GBPCAD_OCO1S4_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO1Sets4[GBPCAD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO1Sets4[GBPCAD_OCO1S4_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO1Sets4.RemoveAt(GBPCAD_OCO1S4_UP_S2);
	                        GBPCAD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCAD_OCO1S5_UP_S2 = 0;
	                for (; GBPCAD_OCO1S5_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets5.Count; GBPCAD_OCO1S5_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO1Sets5[GBPCAD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO1Sets5[GBPCAD_OCO1S5_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO1Sets5.RemoveAt(GBPCAD_OCO1S5_UP_S2);
	                        GBPCAD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCAD_OCO1S6_UP_S2 = 0;
	                for (; GBPCAD_OCO1S6_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets6.Count; GBPCAD_OCO1S6_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO1Sets6[GBPCAD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO1Sets6[GBPCAD_OCO1S6_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO1Sets6.RemoveAt(GBPCAD_OCO1S6_UP_S2);
	                        GBPCAD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.GBPCAD_OCO2_EO1_UP_S2)
	                Base.GBPCAD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCAD_OCO2_EO2_UP_S2)
	                Base.GBPCAD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO2_EO3_UP_S2)
	                Base.GBPCAD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO2_EO4_UP_S2)
	                Base.GBPCAD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO2_EO5_UP_S2)
	                Base.GBPCAD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO2_EO6_UP_S2)
	                Base.GBPCAD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.GBPCAD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP1,"TP1_GBPCAD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP1_GBPCAD_UP_S2_OCO2"));
		                 };
		                Base.GBPCAD_UP_S2_OCO2Sets1.Add( Base.GBPCAD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP2,"TP2_GBPCAD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP2_GBPCAD_UP_S2_OCO2"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO2Sets2.Add( Base.GBPCAD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP3,"TP3_GBPCAD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP3_GBPCAD_UP_S2_OCO2"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO2Sets3.Add( Base.GBPCAD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP4,"TP4_GBPCAD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP4_GBPCAD_UP_S2_OCO2"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO2Sets4.Add( Base.GBPCAD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP5,"TP5_GBPCAD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP5_GBPCAD_UP_S2_OCO2"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO2Sets5.Add( Base.GBPCAD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP6,"TP6_GBPCAD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP6_GBPCAD_UP_S2_OCO2"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO2Sets6.Add( Base.GBPCAD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPCAD_OCO2S1_UP_S2 = 0;
	                for (; GBPCAD_OCO2S1_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets1.Count; GBPCAD_OCO2S1_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO2Sets1[GBPCAD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO2Sets1[GBPCAD_OCO2S1_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO2Sets1.RemoveAt(GBPCAD_OCO2S1_UP_S2);
	                        GBPCAD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCAD_OCO2S2_UP_S2 = 0;
	                for (; GBPCAD_OCO2S2_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets2.Count; GBPCAD_OCO2S2_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO2Sets2[GBPCAD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO2Sets2[GBPCAD_OCO2S2_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO2Sets2.RemoveAt(GBPCAD_OCO2S2_UP_S2);
	                        GBPCAD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO2S3_UP_S2 = 0;
	                for (; GBPCAD_OCO2S3_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets3.Count; GBPCAD_OCO2S3_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO2Sets3[GBPCAD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO2Sets3[GBPCAD_OCO2S3_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO2Sets3.RemoveAt(GBPCAD_OCO2S3_UP_S2);
	                        GBPCAD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO2S4_UP_S2 = 0;
	                for (; GBPCAD_OCO2S4_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets4.Count; GBPCAD_OCO2S4_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO2Sets4[GBPCAD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO2Sets4[GBPCAD_OCO2S4_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO2Sets4.RemoveAt(GBPCAD_OCO2S4_UP_S2);
	                        GBPCAD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCAD_OCO2S5_UP_S2 = 0;
	                for (; GBPCAD_OCO2S5_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets5.Count; GBPCAD_OCO2S5_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO2Sets5[GBPCAD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO2Sets5[GBPCAD_OCO2S5_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO2Sets5.RemoveAt(GBPCAD_OCO2S5_UP_S2);
	                        GBPCAD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCAD_OCO2S6_UP_S2 = 0;
	                for (; GBPCAD_OCO2S6_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets6.Count; GBPCAD_OCO2S6_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO2Sets6[GBPCAD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO2Sets6[GBPCAD_OCO2S6_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO2Sets6.RemoveAt(GBPCAD_OCO2S6_UP_S2);
	                        GBPCAD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCAD_OCO3_EO1_UP_S2)
	                Base.GBPCAD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCAD_OCO3_EO2_UP_S2)
	                Base.GBPCAD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO3_EO3_UP_S2)
	                Base.GBPCAD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO3_EO4_UP_S2)
	                Base.GBPCAD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO3_EO5_UP_S2)
	                Base.GBPCAD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO3_EO6_UP_S2)
	                Base.GBPCAD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.GBPCAD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP1,"TP1_GBPCAD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP1_GBPCAD_UP_S2_OCO3"));
		                 };
		                Base.GBPCAD_UP_S2_OCO3Sets1.Add( Base.GBPCAD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP2,"TP2_GBPCAD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP2_GBPCAD_UP_S2_OCO3"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO3Sets2.Add( Base.GBPCAD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP3,"TP3_GBPCAD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP3_GBPCAD_UP_S2_OCO3"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO3Sets3.Add( Base.GBPCAD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP4,"TP4_GBPCAD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP4_GBPCAD_UP_S2_OCO3"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO3Sets4.Add( Base.GBPCAD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP5,"TP5_GBPCAD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP5_GBPCAD_UP_S2_OCO3"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO3Sets5.Add( Base.GBPCAD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP6,"TP6_GBPCAD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP6_GBPCAD_UP_S2_OCO3"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO3Sets6.Add( Base.GBPCAD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPCAD_OCO3S1_UP_S2 = 0;
	                for (; GBPCAD_OCO3S1_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets1.Count; GBPCAD_OCO3S1_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO3Sets1[GBPCAD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO3Sets1[GBPCAD_OCO3S1_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO3Sets1.RemoveAt(GBPCAD_OCO3S1_UP_S2);
	                        GBPCAD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCAD_OCO3S2_UP_S2 = 0;
	                for (; GBPCAD_OCO3S2_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets2.Count; GBPCAD_OCO3S2_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO3Sets2[GBPCAD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO3Sets2[GBPCAD_OCO3S2_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO3Sets2.RemoveAt(GBPCAD_OCO3S2_UP_S2);
	                        GBPCAD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO3S3_UP_S2 = 0;
	                for (; GBPCAD_OCO3S3_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets3.Count; GBPCAD_OCO3S3_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO3Sets3[GBPCAD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO3Sets3[GBPCAD_OCO3S3_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO3Sets3.RemoveAt(GBPCAD_OCO3S3_UP_S2);
	                        GBPCAD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO3S4_UP_S2 = 0;
	                for (; GBPCAD_OCO3S4_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets4.Count; GBPCAD_OCO3S4_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO3Sets4[GBPCAD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO3Sets4[GBPCAD_OCO3S4_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO3Sets4.RemoveAt(GBPCAD_OCO3S4_UP_S2);
	                        GBPCAD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCAD_OCO3S5_UP_S2 = 0;
	                for (; GBPCAD_OCO3S5_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets5.Count; GBPCAD_OCO3S5_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO3Sets5[GBPCAD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO3Sets5[GBPCAD_OCO3S5_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO3Sets5.RemoveAt(GBPCAD_OCO3S5_UP_S2);
	                        GBPCAD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCAD_OCO3S6_UP_S2 = 0;
	                for (; GBPCAD_OCO3S6_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets6.Count; GBPCAD_OCO3S6_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO3Sets6[GBPCAD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO3Sets6[GBPCAD_OCO3S6_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO3Sets6.RemoveAt(GBPCAD_OCO3S6_UP_S2);
	                        GBPCAD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.GBPCAD_OCO4_EO1_UP_S2)
	                Base.GBPCAD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.GBPCAD_OCO4_EO2_UP_S2)
	                Base.GBPCAD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO4_EO3_UP_S2)
	                Base.GBPCAD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO4_EO4_UP_S2)
	                Base.GBPCAD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO4_EO5_UP_S2)
	                Base.GBPCAD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.GBPCAD_OCO4_EO6_UP_S2)
	                Base.GBPCAD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.GBPCAD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP1,"TP1_GBPCAD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP1_GBPCAD_UP_S2_OCO4"));
		                 };
		                Base.GBPCAD_UP_S2_OCO4Sets1.Add( Base.GBPCAD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP2,"TP2_GBPCAD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP2_GBPCAD_UP_S2_OCO4"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO4Sets2.Add( Base.GBPCAD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP3,"TP3_GBPCAD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP3_GBPCAD_UP_S2_OCO4"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO4Sets3.Add( Base.GBPCAD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP4,"TP4_GBPCAD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP4_GBPCAD_UP_S2_OCO4"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO4Sets4.Add( Base.GBPCAD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP5,"TP5_GBPCAD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP5_GBPCAD_UP_S2_OCO4"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO4Sets5.Add( Base.GBPCAD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.GBPCAD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.GBPCAD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new GBPCAD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.GBPCAD_UP_S2_TP6,"TP6_GBPCAD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.GBPCAD_UP_S2_SL,"SL_TP6_GBPCAD_UP_S2_OCO4"));
		                 };
	                    Base.GBPCAD_UP_S2_OCO4Sets6.Add( Base.GBPCAD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.GBPCAD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int GBPCAD_OCO4S1_UP_S2 = 0;
	                for (; GBPCAD_OCO4S1_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets1.Count; GBPCAD_OCO4S1_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO4Sets1[GBPCAD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO4Sets1[GBPCAD_OCO4S1_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO4Sets1.RemoveAt(GBPCAD_OCO4S1_UP_S2);
	                        GBPCAD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int GBPCAD_OCO4S2_UP_S2 = 0;
	                for (; GBPCAD_OCO4S2_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets2.Count; GBPCAD_OCO4S2_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO4Sets2[GBPCAD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO4Sets2[GBPCAD_OCO4S2_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO4Sets2.RemoveAt(GBPCAD_OCO4S2_UP_S2);
	                        GBPCAD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO4S3_UP_S2 = 0;
	                for (; GBPCAD_OCO4S3_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets3.Count; GBPCAD_OCO4S3_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO4Sets3[GBPCAD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO4Sets3[GBPCAD_OCO4S3_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO4Sets3.RemoveAt(GBPCAD_OCO4S3_UP_S2);
	                        GBPCAD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int GBPCAD_OCO4S4_UP_S2 = 0;
	                for (; GBPCAD_OCO4S4_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets4.Count; GBPCAD_OCO4S4_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO4Sets4[GBPCAD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO4Sets4[GBPCAD_OCO4S4_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO4Sets4.RemoveAt(GBPCAD_OCO4S4_UP_S2);
	                        GBPCAD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCAD_OCO4S5_UP_S2 = 0;
	                for (; GBPCAD_OCO4S5_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets5.Count; GBPCAD_OCO4S5_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO4Sets5[GBPCAD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO4Sets5[GBPCAD_OCO4S5_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO4Sets5.RemoveAt(GBPCAD_OCO4S5_UP_S2);
	                        GBPCAD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int GBPCAD_OCO4S6_UP_S2 = 0;
	                for (; GBPCAD_OCO4S6_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets6.Count; GBPCAD_OCO4S6_UP_S2++)
	                    if (Base.GBPCAD_UP_S2_OCO4Sets6[GBPCAD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.GBPCAD_UP_S2_OCO4Sets6[GBPCAD_OCO4S6_UP_S2].Filled();
	                        Base.GBPCAD_UP_S2_OCO4Sets6.RemoveAt(GBPCAD_OCO4S6_UP_S2);
	                        GBPCAD_OCO4S6_UP_S2 = 0;
	                        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.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 NZDCHF_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public NZDCHF_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("NZDCHF OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCHF OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCHF OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCHF OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCHF OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCHF OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCHF OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        }
		        
				if (Base.NZDCHF_OCO1_EO1_UP_S2)
	                Base.NZDCHF_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCHF_OCO1_EO2_UP_S2)
	                Base.NZDCHF_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO1_EO3_UP_S2)
	                Base.NZDCHF_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO1_EO4_UP_S2)
	                Base.NZDCHF_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO1_EO5_UP_S2)
	                Base.NZDCHF_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO1_EO6_UP_S2)
	                Base.NZDCHF_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.NZDCHF_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP1,"TP1_NZDCHF_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP1_NZDCHF_UP_S2_OCO1"));
		                 };
		                Base.NZDCHF_UP_S2_OCO1Sets1.Add( Base.NZDCHF_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP2,"TP2_NZDCHF_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP2_NZDCHF_UP_S2_OCO1"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO1Sets2.Add( Base.NZDCHF_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP3,"TP3_NZDCHF_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP3_NZDCHF_UP_S2_OCO1"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO1Sets3.Add( Base.NZDCHF_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP4,"TP4_NZDCHF_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP4_NZDCHF_UP_S2_OCO1"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO1Sets4.Add( Base.NZDCHF_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP5,"TP5_NZDCHF_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP5_NZDCHF_UP_S2_OCO1"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO1Sets5.Add( Base.NZDCHF_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP6,"TP6_NZDCHF_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP6_NZDCHF_UP_S2_OCO1"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO1Sets6.Add( Base.NZDCHF_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDCHF_OCO1S1_UP_S2 = 0;
	                for (; NZDCHF_OCO1S1_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets1.Count; NZDCHF_OCO1S1_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO1Sets1[NZDCHF_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO1Sets1[NZDCHF_OCO1S1_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO1Sets1.RemoveAt(NZDCHF_OCO1S1_UP_S2);
	                        NZDCHF_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCHF_OCO1S2_UP_S2 = 0;
	                for (; NZDCHF_OCO1S2_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets2.Count; NZDCHF_OCO1S2_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO1Sets2[NZDCHF_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO1Sets2[NZDCHF_OCO1S2_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO1Sets2.RemoveAt(NZDCHF_OCO1S2_UP_S2);
	                        NZDCHF_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO1S3_UP_S2 = 0;
	                for (; NZDCHF_OCO1S3_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets3.Count; NZDCHF_OCO1S3_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO1Sets3[NZDCHF_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO1Sets3[NZDCHF_OCO1S3_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO1Sets3.RemoveAt(NZDCHF_OCO1S3_UP_S2);
	                        NZDCHF_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO1S4_UP_S2 = 0;
	                for (; NZDCHF_OCO1S4_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets4.Count; NZDCHF_OCO1S4_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO1Sets4[NZDCHF_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO1Sets4[NZDCHF_OCO1S4_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO1Sets4.RemoveAt(NZDCHF_OCO1S4_UP_S2);
	                        NZDCHF_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCHF_OCO1S5_UP_S2 = 0;
	                for (; NZDCHF_OCO1S5_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets5.Count; NZDCHF_OCO1S5_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO1Sets5[NZDCHF_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO1Sets5[NZDCHF_OCO1S5_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO1Sets5.RemoveAt(NZDCHF_OCO1S5_UP_S2);
	                        NZDCHF_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCHF_OCO1S6_UP_S2 = 0;
	                for (; NZDCHF_OCO1S6_UP_S2 < Base.NZDCHF_UP_S2_OCO1Sets6.Count; NZDCHF_OCO1S6_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO1Sets6[NZDCHF_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO1Sets6[NZDCHF_OCO1S6_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO1Sets6.RemoveAt(NZDCHF_OCO1S6_UP_S2);
	                        NZDCHF_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.NZDCHF_OCO2_EO1_UP_S2)
	                Base.NZDCHF_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCHF_OCO2_EO2_UP_S2)
	                Base.NZDCHF_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO2_EO3_UP_S2)
	                Base.NZDCHF_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO2_EO4_UP_S2)
	                Base.NZDCHF_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO2_EO5_UP_S2)
	                Base.NZDCHF_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO2_EO6_UP_S2)
	                Base.NZDCHF_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.NZDCHF_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP1,"TP1_NZDCHF_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP1_NZDCHF_UP_S2_OCO2"));
		                 };
		                Base.NZDCHF_UP_S2_OCO2Sets1.Add( Base.NZDCHF_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP2,"TP2_NZDCHF_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP2_NZDCHF_UP_S2_OCO2"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO2Sets2.Add( Base.NZDCHF_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP3,"TP3_NZDCHF_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP3_NZDCHF_UP_S2_OCO2"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO2Sets3.Add( Base.NZDCHF_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP4,"TP4_NZDCHF_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP4_NZDCHF_UP_S2_OCO2"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO2Sets4.Add( Base.NZDCHF_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP5,"TP5_NZDCHF_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP5_NZDCHF_UP_S2_OCO2"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO2Sets5.Add( Base.NZDCHF_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP6,"TP6_NZDCHF_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP6_NZDCHF_UP_S2_OCO2"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO2Sets6.Add( Base.NZDCHF_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDCHF_OCO2S1_UP_S2 = 0;
	                for (; NZDCHF_OCO2S1_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets1.Count; NZDCHF_OCO2S1_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO2Sets1[NZDCHF_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO2Sets1[NZDCHF_OCO2S1_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO2Sets1.RemoveAt(NZDCHF_OCO2S1_UP_S2);
	                        NZDCHF_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCHF_OCO2S2_UP_S2 = 0;
	                for (; NZDCHF_OCO2S2_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets2.Count; NZDCHF_OCO2S2_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO2Sets2[NZDCHF_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO2Sets2[NZDCHF_OCO2S2_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO2Sets2.RemoveAt(NZDCHF_OCO2S2_UP_S2);
	                        NZDCHF_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO2S3_UP_S2 = 0;
	                for (; NZDCHF_OCO2S3_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets3.Count; NZDCHF_OCO2S3_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO2Sets3[NZDCHF_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO2Sets3[NZDCHF_OCO2S3_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO2Sets3.RemoveAt(NZDCHF_OCO2S3_UP_S2);
	                        NZDCHF_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO2S4_UP_S2 = 0;
	                for (; NZDCHF_OCO2S4_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets4.Count; NZDCHF_OCO2S4_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO2Sets4[NZDCHF_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO2Sets4[NZDCHF_OCO2S4_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO2Sets4.RemoveAt(NZDCHF_OCO2S4_UP_S2);
	                        NZDCHF_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCHF_OCO2S5_UP_S2 = 0;
	                for (; NZDCHF_OCO2S5_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets5.Count; NZDCHF_OCO2S5_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO2Sets5[NZDCHF_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO2Sets5[NZDCHF_OCO2S5_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO2Sets5.RemoveAt(NZDCHF_OCO2S5_UP_S2);
	                        NZDCHF_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCHF_OCO2S6_UP_S2 = 0;
	                for (; NZDCHF_OCO2S6_UP_S2 < Base.NZDCHF_UP_S2_OCO2Sets6.Count; NZDCHF_OCO2S6_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO2Sets6[NZDCHF_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO2Sets6[NZDCHF_OCO2S6_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO2Sets6.RemoveAt(NZDCHF_OCO2S6_UP_S2);
	                        NZDCHF_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCHF_OCO3_EO1_UP_S2)
	                Base.NZDCHF_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCHF_OCO3_EO2_UP_S2)
	                Base.NZDCHF_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO3_EO3_UP_S2)
	                Base.NZDCHF_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO3_EO4_UP_S2)
	                Base.NZDCHF_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO3_EO5_UP_S2)
	                Base.NZDCHF_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO3_EO6_UP_S2)
	                Base.NZDCHF_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.NZDCHF_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP1,"TP1_NZDCHF_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP1_NZDCHF_UP_S2_OCO3"));
		                 };
		                Base.NZDCHF_UP_S2_OCO3Sets1.Add( Base.NZDCHF_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP2,"TP2_NZDCHF_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP2_NZDCHF_UP_S2_OCO3"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO3Sets2.Add( Base.NZDCHF_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP3,"TP3_NZDCHF_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP3_NZDCHF_UP_S2_OCO3"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO3Sets3.Add( Base.NZDCHF_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP4,"TP4_NZDCHF_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP4_NZDCHF_UP_S2_OCO3"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO3Sets4.Add( Base.NZDCHF_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP5,"TP5_NZDCHF_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP5_NZDCHF_UP_S2_OCO3"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO3Sets5.Add( Base.NZDCHF_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP6,"TP6_NZDCHF_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP6_NZDCHF_UP_S2_OCO3"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO3Sets6.Add( Base.NZDCHF_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDCHF_OCO3S1_UP_S2 = 0;
	                for (; NZDCHF_OCO3S1_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets1.Count; NZDCHF_OCO3S1_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO3Sets1[NZDCHF_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO3Sets1[NZDCHF_OCO3S1_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO3Sets1.RemoveAt(NZDCHF_OCO3S1_UP_S2);
	                        NZDCHF_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCHF_OCO3S2_UP_S2 = 0;
	                for (; NZDCHF_OCO3S2_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets2.Count; NZDCHF_OCO3S2_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO3Sets2[NZDCHF_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO3Sets2[NZDCHF_OCO3S2_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO3Sets2.RemoveAt(NZDCHF_OCO3S2_UP_S2);
	                        NZDCHF_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO3S3_UP_S2 = 0;
	                for (; NZDCHF_OCO3S3_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets3.Count; NZDCHF_OCO3S3_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO3Sets3[NZDCHF_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO3Sets3[NZDCHF_OCO3S3_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO3Sets3.RemoveAt(NZDCHF_OCO3S3_UP_S2);
	                        NZDCHF_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO3S4_UP_S2 = 0;
	                for (; NZDCHF_OCO3S4_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets4.Count; NZDCHF_OCO3S4_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO3Sets4[NZDCHF_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO3Sets4[NZDCHF_OCO3S4_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO3Sets4.RemoveAt(NZDCHF_OCO3S4_UP_S2);
	                        NZDCHF_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCHF_OCO3S5_UP_S2 = 0;
	                for (; NZDCHF_OCO3S5_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets5.Count; NZDCHF_OCO3S5_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO3Sets5[NZDCHF_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO3Sets5[NZDCHF_OCO3S5_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO3Sets5.RemoveAt(NZDCHF_OCO3S5_UP_S2);
	                        NZDCHF_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCHF_OCO3S6_UP_S2 = 0;
	                for (; NZDCHF_OCO3S6_UP_S2 < Base.NZDCHF_UP_S2_OCO3Sets6.Count; NZDCHF_OCO3S6_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO3Sets6[NZDCHF_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO3Sets6[NZDCHF_OCO3S6_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO3Sets6.RemoveAt(NZDCHF_OCO3S6_UP_S2);
	                        NZDCHF_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCHF_OCO4_EO1_UP_S2)
	                Base.NZDCHF_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCHF_OCO4_EO2_UP_S2)
	                Base.NZDCHF_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO4_EO3_UP_S2)
	                Base.NZDCHF_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO4_EO4_UP_S2)
	                Base.NZDCHF_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO4_EO5_UP_S2)
	                Base.NZDCHF_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO4_EO6_UP_S2)
	                Base.NZDCHF_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.NZDCHF_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP1,"TP1_NZDCHF_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP1_NZDCHF_UP_S2_OCO4"));
		                 };
		                Base.NZDCHF_UP_S2_OCO4Sets1.Add( Base.NZDCHF_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP2,"TP2_NZDCHF_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP2_NZDCHF_UP_S2_OCO4"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO4Sets2.Add( Base.NZDCHF_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP3,"TP3_NZDCHF_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP3_NZDCHF_UP_S2_OCO4"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO4Sets3.Add( Base.NZDCHF_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP4,"TP4_NZDCHF_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP4_NZDCHF_UP_S2_OCO4"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO4Sets4.Add( Base.NZDCHF_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP5,"TP5_NZDCHF_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP5_NZDCHF_UP_S2_OCO4"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO4Sets5.Add( Base.NZDCHF_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_UP_S2_TP6,"TP6_NZDCHF_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_UP_S2_SL,"SL_TP6_NZDCHF_UP_S2_OCO4"));
		                 };
	                    Base.NZDCHF_UP_S2_OCO4Sets6.Add( Base.NZDCHF_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDCHF_OCO4S1_UP_S2 = 0;
	                for (; NZDCHF_OCO4S1_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets1.Count; NZDCHF_OCO4S1_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO4Sets1[NZDCHF_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO4Sets1[NZDCHF_OCO4S1_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO4Sets1.RemoveAt(NZDCHF_OCO4S1_UP_S2);
	                        NZDCHF_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCHF_OCO4S2_UP_S2 = 0;
	                for (; NZDCHF_OCO4S2_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets2.Count; NZDCHF_OCO4S2_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO4Sets2[NZDCHF_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO4Sets2[NZDCHF_OCO4S2_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO4Sets2.RemoveAt(NZDCHF_OCO4S2_UP_S2);
	                        NZDCHF_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO4S3_UP_S2 = 0;
	                for (; NZDCHF_OCO4S3_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets3.Count; NZDCHF_OCO4S3_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO4Sets3[NZDCHF_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO4Sets3[NZDCHF_OCO4S3_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO4Sets3.RemoveAt(NZDCHF_OCO4S3_UP_S2);
	                        NZDCHF_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO4S4_UP_S2 = 0;
	                for (; NZDCHF_OCO4S4_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets4.Count; NZDCHF_OCO4S4_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO4Sets4[NZDCHF_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO4Sets4[NZDCHF_OCO4S4_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO4Sets4.RemoveAt(NZDCHF_OCO4S4_UP_S2);
	                        NZDCHF_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCHF_OCO4S5_UP_S2 = 0;
	                for (; NZDCHF_OCO4S5_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets5.Count; NZDCHF_OCO4S5_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO4Sets5[NZDCHF_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO4Sets5[NZDCHF_OCO4S5_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO4Sets5.RemoveAt(NZDCHF_OCO4S5_UP_S2);
	                        NZDCHF_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDCHF_OCO4S6_UP_S2 = 0;
	                for (; NZDCHF_OCO4S6_UP_S2 < Base.NZDCHF_UP_S2_OCO4Sets6.Count; NZDCHF_OCO4S6_UP_S2++)
	                    if (Base.NZDCHF_UP_S2_OCO4Sets6[NZDCHF_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_UP_S2_OCO4Sets6[NZDCHF_OCO4S6_UP_S2].Filled();
	                        Base.NZDCHF_UP_S2_OCO4Sets6.RemoveAt(NZDCHF_OCO4S6_UP_S2);
	                        NZDCHF_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPJPY_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPJPY_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("GBPJPY_DOWN_S2_OCO1")))
			{
				Base.GBPJPY_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPJPY_DOWN_S2_OCO2")))
			{
				Base.GBPJPY_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPJPY_DOWN_S2_OCO3")))
			{
				Base.GBPJPY_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPJPY_DOWN_S2_OCO4")))
			{
				Base.GBPJPY_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPJPY_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.GBPJPY_OCO1_EO1_DOWN_S2)
	                Base.GBPJPY_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPJPY_OCO1_EO2_DOWN_S2)
	                Base.GBPJPY_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO1_EO3_DOWN_S2)
	                Base.GBPJPY_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO1_EO4_DOWN_S2)
	                Base.GBPJPY_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO1_EO5_DOWN_S2)
	                Base.GBPJPY_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO1_EO6_DOWN_S2)
	                Base.GBPJPY_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPJPY_OCO1S1_DOWN_S2 = 0;
		                for (; GBPJPY_OCO1S1_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets1.Count; GBPJPY_OCO1S1_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO1Sets1[GBPJPY_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO1Sets1[GBPJPY_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.GBPJPY_DOWN_S2_OCO1Sets1.Clear();
		                        GBPJPY_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPJPY_OCO1S2_DOWN_S2 = 0;
		                for (; GBPJPY_OCO1S2_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets2.Count; GBPJPY_OCO1S2_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO1Sets2[GBPJPY_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO1Sets2[GBPJPY_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.GBPJPY_DOWN_S2_OCO1Sets2.Clear();
		                        GBPJPY_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO1S3_DOWN_S2 = 0;
		                for (; GBPJPY_OCO1S3_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets3.Count; GBPJPY_OCO1S3_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO1Sets3[GBPJPY_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO1Sets3[GBPJPY_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.GBPJPY_DOWN_S2_OCO1Sets3.Clear();
		                        GBPJPY_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO1S4_DOWN_S2 = 0;
		                for (; GBPJPY_OCO1S4_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets4.Count; GBPJPY_OCO1S4_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO1Sets4[GBPJPY_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO1Sets4[GBPJPY_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.GBPJPY_DOWN_S2_OCO1Sets4.Clear();
		                        GBPJPY_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO1S5_DOWN_S2 = 0;
		                for (; GBPJPY_OCO1S5_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets5.Count; GBPJPY_OCO1S5_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO1Sets5[GBPJPY_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO1Sets5[GBPJPY_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.GBPJPY_DOWN_S2_OCO1Sets5.Clear();
		                        GBPJPY_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO1S6_DOWN_S2 = 0;
		                for (; GBPJPY_OCO1S6_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO1Sets6.Count; GBPJPY_OCO1S6_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO1Sets6[GBPJPY_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO1Sets6[GBPJPY_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.GBPJPY_DOWN_S2_OCO1Sets6.Clear();
		                        GBPJPY_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPJPY_OCO2_EO1_DOWN_S2)
	                Base.GBPJPY_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPJPY_OCO2_EO2_DOWN_S2)
	                Base.GBPJPY_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO2_EO3_DOWN_S2)
	                Base.GBPJPY_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO2_EO4_DOWN_S2)
	                Base.GBPJPY_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO2_EO5_DOWN_S2)
	                Base.GBPJPY_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO2_EO6_DOWN_S2)
	                Base.GBPJPY_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPJPY_OCO2S1_DOWN_S2 = 0;
		                for (; GBPJPY_OCO2S1_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets1.Count; GBPJPY_OCO2S1_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO2Sets1[GBPJPY_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO2Sets1[GBPJPY_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.GBPJPY_DOWN_S2_OCO2Sets1.Clear();
		                        GBPJPY_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPJPY_OCO2S2_DOWN_S2 = 0;
		                for (; GBPJPY_OCO2S2_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets2.Count; GBPJPY_OCO2S2_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO2Sets2[GBPJPY_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO2Sets2[GBPJPY_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.GBPJPY_DOWN_S2_OCO2Sets2.Clear();
		                        GBPJPY_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO2S3_DOWN_S2 = 0;
		                for (; GBPJPY_OCO2S3_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets3.Count; GBPJPY_OCO2S3_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO2Sets3[GBPJPY_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO2Sets3[GBPJPY_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.GBPJPY_DOWN_S2_OCO2Sets3.Clear();
		                        GBPJPY_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO2S4_DOWN_S2 = 0;
		                for (; GBPJPY_OCO2S4_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets4.Count; GBPJPY_OCO2S4_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO2Sets4[GBPJPY_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO2Sets4[GBPJPY_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.GBPJPY_DOWN_S2_OCO2Sets4.Clear();
		                        GBPJPY_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO2S5_DOWN_S2 = 0;
		                for (; GBPJPY_OCO2S5_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets5.Count; GBPJPY_OCO2S5_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO2Sets5[GBPJPY_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO2Sets5[GBPJPY_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.GBPJPY_DOWN_S2_OCO2Sets5.Clear();
		                        GBPJPY_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO2S6_DOWN_S2 = 0;
		                for (; GBPJPY_OCO2S6_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO2Sets6.Count; GBPJPY_OCO2S6_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO2Sets6[GBPJPY_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO2Sets6[GBPJPY_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.GBPJPY_DOWN_S2_OCO2Sets6.Clear();
		                        GBPJPY_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPJPY_OCO3_EO1_DOWN_S2)
	                Base.GBPJPY_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPJPY_OCO3_EO2_DOWN_S2)
	                Base.GBPJPY_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO3_EO3_DOWN_S2)
	                Base.GBPJPY_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO3_EO4_DOWN_S2)
	                Base.GBPJPY_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO3_EO5_DOWN_S2)
	                Base.GBPJPY_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO3_EO6_DOWN_S2)
	                Base.GBPJPY_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPJPY_OCO3S1_DOWN_S2 = 0;
		                for (; GBPJPY_OCO3S1_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets1.Count; GBPJPY_OCO3S1_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO3Sets1[GBPJPY_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO3Sets1[GBPJPY_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.GBPJPY_DOWN_S2_OCO3Sets1.Clear();
		                        GBPJPY_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPJPY_OCO3S2_DOWN_S2 = 0;
		                for (; GBPJPY_OCO3S2_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets2.Count; GBPJPY_OCO3S2_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO3Sets2[GBPJPY_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO3Sets2[GBPJPY_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.GBPJPY_DOWN_S2_OCO3Sets2.Clear();
		                        GBPJPY_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO3S3_DOWN_S2 = 0;
		                for (; GBPJPY_OCO3S3_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets3.Count; GBPJPY_OCO3S3_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO3Sets3[GBPJPY_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO3Sets3[GBPJPY_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.GBPJPY_DOWN_S2_OCO3Sets3.Clear();
		                        GBPJPY_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO3S4_DOWN_S2 = 0;
		                for (; GBPJPY_OCO3S4_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets4.Count; GBPJPY_OCO3S4_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO3Sets4[GBPJPY_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO3Sets4[GBPJPY_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.GBPJPY_DOWN_S2_OCO3Sets4.Clear();
		                        GBPJPY_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO3S5_DOWN_S2 = 0;
		                for (; GBPJPY_OCO3S5_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets5.Count; GBPJPY_OCO3S5_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO3Sets5[GBPJPY_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO3Sets5[GBPJPY_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.GBPJPY_DOWN_S2_OCO3Sets5.Clear();
		                        GBPJPY_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO3S6_DOWN_S2 = 0;
		                for (; GBPJPY_OCO3S6_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO3Sets6.Count; GBPJPY_OCO3S6_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO3Sets6[GBPJPY_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO3Sets6[GBPJPY_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.GBPJPY_DOWN_S2_OCO3Sets6.Clear();
		                        GBPJPY_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPJPY_OCO4_EO1_DOWN_S2)
	                Base.GBPJPY_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPJPY_OCO4_EO2_DOWN_S2)
	                Base.GBPJPY_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO4_EO3_DOWN_S2)
	                Base.GBPJPY_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO4_EO4_DOWN_S2)
	                Base.GBPJPY_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO4_EO5_DOWN_S2)
	                Base.GBPJPY_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO4_EO6_DOWN_S2)
	                Base.GBPJPY_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPJPY_OCO4S1_DOWN_S2 = 0;
		                for (; GBPJPY_OCO4S1_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets1.Count; GBPJPY_OCO4S1_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO4Sets1[GBPJPY_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO4Sets1[GBPJPY_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.GBPJPY_DOWN_S2_OCO4Sets1.Clear();
		                        GBPJPY_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPJPY_OCO4S2_DOWN_S2 = 0;
		                for (; GBPJPY_OCO4S2_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets2.Count; GBPJPY_OCO4S2_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO4Sets2[GBPJPY_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO4Sets2[GBPJPY_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.GBPJPY_DOWN_S2_OCO4Sets2.Clear();
		                        GBPJPY_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO4S3_DOWN_S2 = 0;
		                for (; GBPJPY_OCO4S3_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets3.Count; GBPJPY_OCO4S3_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO4Sets3[GBPJPY_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO4Sets3[GBPJPY_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.GBPJPY_DOWN_S2_OCO4Sets3.Clear();
		                        GBPJPY_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO4S4_DOWN_S2 = 0;
		                for (; GBPJPY_OCO4S4_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets4.Count; GBPJPY_OCO4S4_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO4Sets4[GBPJPY_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO4Sets4[GBPJPY_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.GBPJPY_DOWN_S2_OCO4Sets4.Clear();
		                        GBPJPY_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO4S5_DOWN_S2 = 0;
		                for (; GBPJPY_OCO4S5_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets5.Count; GBPJPY_OCO4S5_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO4Sets5[GBPJPY_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO4Sets5[GBPJPY_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.GBPJPY_DOWN_S2_OCO4Sets5.Clear();
		                        GBPJPY_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO4S6_DOWN_S2 = 0;
		                for (; GBPJPY_OCO4S6_DOWN_S2 < Base.GBPJPY_DOWN_S2_OCO4Sets6.Count; GBPJPY_OCO4S6_DOWN_S2++)
		                    if (Base.GBPJPY_DOWN_S2_OCO4Sets6[GBPJPY_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_DOWN_S2_OCO4Sets6[GBPJPY_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.GBPJPY_DOWN_S2_OCO4Sets6.Clear();
		                        GBPJPY_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();
	            	}
	            	
					DOWM_GBPJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPJPY_DOWN_S2 = DOWM_GBPJPY_DOWN_S2 || DOWT_GBPJPY_DOWN_S2 || DOWW_GBPJPY_DOWN_S2 || DOWTH_GBPJPY_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPJPY"))
	            	{
	            		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.GBPJPY_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.GBPJPY_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.GBPJPY_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.GBPJPY_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.GBPJPY_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPJPY_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPJPY_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPJPY_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPJPY_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPJPY_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPJPY_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	GBPJPY_Signal_Condition_DOWN_S2 =  
	                									(
															pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.004m &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.02m 
	                									);
	                									
	                    GBPJPY_DOWN_S2_SL  =  1m;
	                    GBPJPY_DOWN_S2_TP1 =  0.05m;
	                    GBPJPY_DOWN_S2_TP2 =  GBPJPY_DOWN_S2_SL * 0;
	                    GBPJPY_DOWN_S2_TP3 =  GBPJPY_DOWN_S2_SL * 0;
	                    GBPJPY_DOWN_S2_TP4 =  GBPJPY_DOWN_S2_SL * 0;
	                    GBPJPY_DOWN_S2_TP5 =  GBPJPY_DOWN_S2_SL * 0;
	                    GBPJPY_DOWN_S2_TP6 =  GBPJPY_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPJPY_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPJPY_quantity_SL_DOWN_S2 = GBPJPY_quantity_DOWN_S2;
	                    GBPJPY_quantity_TP1_DOWN_S2 = (int)Math.Floor(GBPJPY_quantity_DOWN_S2 * 1m);
	                    GBPJPY_quantity_TP2_DOWN_S2 = (int)Math.Floor(GBPJPY_quantity_TP1_DOWN_S2 * 0m);
	                    GBPJPY_quantity_TP3_DOWN_S2 = (int)Math.Floor(GBPJPY_quantity_TP2_DOWN_S2 * 0m);
	                    GBPJPY_quantity_TP4_DOWN_S2 = (int)Math.Floor(GBPJPY_quantity_TP3_DOWN_S2 * 0m);
	                    GBPJPY_quantity_TP5_DOWN_S2 = (int)Math.Floor(GBPJPY_quantity_TP4_DOWN_S2 * 0m);
	                    GBPJPY_quantity_TP6_DOWN_S2 = (int)Math.Floor(GBPJPY_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (GBPJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPJPY_DOWN_S2 && 
	                    Base.GBPJPY_OCO1_DOWN_S2_IsReady == true &&
	                    Base.GBPJPY_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPJPY_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP1_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP1_OCO1");
	                         Base.GBPJPY_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPJPY_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP2_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP2_OCO1");
	                         Base.GBPJPY_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.GBPJPY_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP3_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP3_OCO1");
	                         Base.GBPJPY_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPJPY_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP4_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP4_OCO1");
	                         Base.GBPJPY_OCO1_EO4_DOWN_S2 = false;

							Base.GBPJPY_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.GBPJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (GBPJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPJPY_DOWN_S2 && 
	                    Base.GBPJPY_OCO2_DOWN_S2_IsReady == true &&
	                    Base.GBPJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPJPY_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPJPY_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP1_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP1_OCO2");
	                         Base.GBPJPY_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPJPY_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP2_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP2_OCO2");
	                         Base.GBPJPY_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.GBPJPY_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP3_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP3_OCO2");
	                         Base.GBPJPY_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPJPY_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP4_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP4_OCO2");
	                         Base.GBPJPY_OCO2_EO4_DOWN_S2 = false;

							Base.GBPJPY_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.GBPJPY_OCO2_DOWN_S2_IsReady == false && Base.GBPJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (GBPJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPJPY_DOWN_S2 &&
	                    Base.GBPJPY_OCO3_DOWN_S2_IsReady == true &&
	                    Base.GBPJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPJPY_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPJPY_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP1_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP1_OCO3");
	                         Base.GBPJPY_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPJPY_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP2_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP2_OCO3");
	                         Base.GBPJPY_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.GBPJPY_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP3_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP3_OCO3");
	                         Base.GBPJPY_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPJPY_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP4_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP4_OCO3");
	                         Base.GBPJPY_OCO3_EO4_DOWN_S2 = false;

							Base.GBPJPY_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.GBPJPY_OCO3_DOWN_S2_IsReady == false && Base.GBPJPY_OCO2_DOWN_S2_IsReady == false && Base.GBPJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (GBPJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPJPY_DOWN_S2 && 
	                    Base.GBPJPY_OCO4_DOWN_S2_IsReady == true &&
	                    Base.GBPJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPJPY_OCO3_DOWN_S2_IsReady == false &&
	                    Base.GBPJPY_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPJPY_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP1_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP1_OCO4");
	                         Base.GBPJPY_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPJPY_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP2_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP2_OCO4");
	                         Base.GBPJPY_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.GBPJPY_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP3_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP3_OCO4");
	                         Base.GBPJPY_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPJPY_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPJPY_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP4_DOWN_S2, false,"GBPJPY_DOWN_S2_Entry_TP4_OCO4");
	                         Base.GBPJPY_OCO4_EO4_DOWN_S2 = false;

							Base.GBPJPY_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.GBPJPY_OCO4_DOWN_S2_IsReady == false && Base.GBPJPY_OCO3_DOWN_S2_IsReady == false && Base.GBPJPY_OCO2_DOWN_S2_IsReady == false && Base.GBPJPY_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.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 USDJPY_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public USDJPY_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("USDJPY OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDJPY OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDJPY OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDJPY OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        }
		        
				if (Base.USDJPY_OCO1_EO1_DOWN_S2)
	                Base.USDJPY_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDJPY_OCO1_EO2_DOWN_S2)
	                Base.USDJPY_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO1_EO3_DOWN_S2)
	                Base.USDJPY_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO1_EO4_DOWN_S2)
	                Base.USDJPY_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDJPY_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.USDJPY_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP1_USDJPY_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP1,"TP1_USDJPY_DOWN_S2_OCO1"));
		                 };
		                Base.USDJPY_DOWN_S2_OCO1Sets1.Add( Base.USDJPY_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDJPY_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP2_USDJPY_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP2,"TP2_USDJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO1Sets2.Add( Base.USDJPY_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP3_USDJPY_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP3,"TP3_USDJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO1Sets3.Add( Base.USDJPY_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP4_USDJPY_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP4,"TP4_USDJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO1Sets4.Add( Base.USDJPY_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int USDJPY_OCO1S1_DOWN_S2 = 0;
	                for (; USDJPY_OCO1S1_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets1.Count; USDJPY_OCO1S1_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO1Sets1[USDJPY_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO1Sets1[USDJPY_OCO1S1_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO1Sets1.RemoveAt(USDJPY_OCO1S1_DOWN_S2);
	                        USDJPY_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDJPY_OCO1S2_DOWN_S2 = 0;
	                for (; USDJPY_OCO1S2_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets2.Count; USDJPY_OCO1S2_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO1Sets2[USDJPY_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO1Sets2[USDJPY_OCO1S2_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO1Sets2.RemoveAt(USDJPY_OCO1S2_DOWN_S2);
	                        USDJPY_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO1S3_DOWN_S2 = 0;
	                for (; USDJPY_OCO1S3_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets3.Count; USDJPY_OCO1S3_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO1Sets3[USDJPY_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO1Sets3[USDJPY_OCO1S3_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO1Sets3.RemoveAt(USDJPY_OCO1S3_DOWN_S2);
	                        USDJPY_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO1S4_DOWN_S2 = 0;
	                for (; USDJPY_OCO1S4_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets4.Count; USDJPY_OCO1S4_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO1Sets4[USDJPY_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO1Sets4[USDJPY_OCO1S4_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO1Sets4.RemoveAt(USDJPY_OCO1S4_DOWN_S2);
	                        USDJPY_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDJPY_OCO2_EO1_DOWN_S2)
	                Base.USDJPY_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDJPY_OCO2_EO2_DOWN_S2)
	                Base.USDJPY_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO2_EO3_DOWN_S2)
	                Base.USDJPY_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO2_EO4_DOWN_S2)
	                Base.USDJPY_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDJPY_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.USDJPY_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP1_USDJPY_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP1,"TP1_USDJPY_DOWN_S2_OCO2"));
		                 };
		                Base.USDJPY_DOWN_S2_OCO2Sets1.Add( Base.USDJPY_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDJPY_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP2_USDJPY_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP2,"TP2_USDJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO2Sets2.Add( Base.USDJPY_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP3_USDJPY_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP3,"TP3_USDJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO2Sets3.Add( Base.USDJPY_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP4_USDJPY_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP4,"TP4_USDJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO2Sets4.Add( Base.USDJPY_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int USDJPY_OCO2S1_DOWN_S2 = 0;
	                for (; USDJPY_OCO2S1_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets1.Count; USDJPY_OCO2S1_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO2Sets1[USDJPY_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO2Sets1[USDJPY_OCO2S1_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO2Sets1.RemoveAt(USDJPY_OCO2S1_DOWN_S2);
	                        USDJPY_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDJPY_OCO2S2_DOWN_S2 = 0;
	                for (; USDJPY_OCO2S2_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets2.Count; USDJPY_OCO2S2_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO2Sets2[USDJPY_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO2Sets2[USDJPY_OCO2S2_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO2Sets2.RemoveAt(USDJPY_OCO2S2_DOWN_S2);
	                        USDJPY_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO2S3_DOWN_S2 = 0;
	                for (; USDJPY_OCO2S3_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets3.Count; USDJPY_OCO2S3_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO2Sets3[USDJPY_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO2Sets3[USDJPY_OCO2S3_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO2Sets3.RemoveAt(USDJPY_OCO2S3_DOWN_S2);
	                        USDJPY_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO2S4_DOWN_S2 = 0;
	                for (; USDJPY_OCO2S4_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets4.Count; USDJPY_OCO2S4_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO2Sets4[USDJPY_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO2Sets4[USDJPY_OCO2S4_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO2Sets4.RemoveAt(USDJPY_OCO2S4_DOWN_S2);
	                        USDJPY_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDJPY_OCO3_EO1_DOWN_S2)
	                Base.USDJPY_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDJPY_OCO3_EO2_DOWN_S2)
	                Base.USDJPY_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO3_EO3_DOWN_S2)
	                Base.USDJPY_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO3_EO4_DOWN_S2)
	                Base.USDJPY_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDJPY_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.USDJPY_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP1_USDJPY_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP1,"TP1_USDJPY_DOWN_S2_OCO3"));
		                 };
		                Base.USDJPY_DOWN_S2_OCO3Sets1.Add( Base.USDJPY_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDJPY_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP2_USDJPY_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP2,"TP2_USDJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO3Sets2.Add( Base.USDJPY_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP3_USDJPY_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP3,"TP3_USDJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO3Sets3.Add( Base.USDJPY_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP4_USDJPY_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP4,"TP4_USDJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO3Sets4.Add( Base.USDJPY_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int USDJPY_OCO3S1_DOWN_S2 = 0;
	                for (; USDJPY_OCO3S1_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets1.Count; USDJPY_OCO3S1_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO3Sets1[USDJPY_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO3Sets1[USDJPY_OCO3S1_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO3Sets1.RemoveAt(USDJPY_OCO3S1_DOWN_S2);
	                        USDJPY_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDJPY_OCO3S2_DOWN_S2 = 0;
	                for (; USDJPY_OCO3S2_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets2.Count; USDJPY_OCO3S2_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO3Sets2[USDJPY_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO3Sets2[USDJPY_OCO3S2_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO3Sets2.RemoveAt(USDJPY_OCO3S2_DOWN_S2);
	                        USDJPY_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO3S3_DOWN_S2 = 0;
	                for (; USDJPY_OCO3S3_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets3.Count; USDJPY_OCO3S3_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO3Sets3[USDJPY_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO3Sets3[USDJPY_OCO3S3_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO3Sets3.RemoveAt(USDJPY_OCO3S3_DOWN_S2);
	                        USDJPY_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO3S4_DOWN_S2 = 0;
	                for (; USDJPY_OCO3S4_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets4.Count; USDJPY_OCO3S4_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO3Sets4[USDJPY_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO3Sets4[USDJPY_OCO3S4_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO3Sets4.RemoveAt(USDJPY_OCO3S4_DOWN_S2);
	                        USDJPY_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDJPY_OCO4_EO1_DOWN_S2)
	                Base.USDJPY_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDJPY_OCO4_EO2_DOWN_S2)
	                Base.USDJPY_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO4_EO3_DOWN_S2)
	                Base.USDJPY_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO4_EO4_DOWN_S2)
	                Base.USDJPY_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDJPY_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.USDJPY_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP1_USDJPY_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP1,"TP1_USDJPY_DOWN_S2_OCO4"));
		                 };
		                Base.USDJPY_DOWN_S2_OCO4Sets1.Add( Base.USDJPY_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDJPY_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP2_USDJPY_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP2,"TP2_USDJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO4Sets2.Add( Base.USDJPY_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP3_USDJPY_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP3,"TP3_USDJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO4Sets3.Add( Base.USDJPY_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_DOWN_S2_SL,"SL_TP4_USDJPY_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_DOWN_S2_TP4,"TP4_USDJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.USDJPY_DOWN_S2_OCO4Sets4.Add( Base.USDJPY_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int USDJPY_OCO4S1_DOWN_S2 = 0;
	                for (; USDJPY_OCO4S1_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets1.Count; USDJPY_OCO4S1_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO4Sets1[USDJPY_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO4Sets1[USDJPY_OCO4S1_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO4Sets1.RemoveAt(USDJPY_OCO4S1_DOWN_S2);
	                        USDJPY_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDJPY_OCO4S2_DOWN_S2 = 0;
	                for (; USDJPY_OCO4S2_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets2.Count; USDJPY_OCO4S2_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO4Sets2[USDJPY_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO4Sets2[USDJPY_OCO4S2_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO4Sets2.RemoveAt(USDJPY_OCO4S2_DOWN_S2);
	                        USDJPY_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO4S3_DOWN_S2 = 0;
	                for (; USDJPY_OCO4S3_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets3.Count; USDJPY_OCO4S3_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO4Sets3[USDJPY_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO4Sets3[USDJPY_OCO4S3_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO4Sets3.RemoveAt(USDJPY_OCO4S3_DOWN_S2);
	                        USDJPY_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO4S4_DOWN_S2 = 0;
	                for (; USDJPY_OCO4S4_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets4.Count; USDJPY_OCO4S4_DOWN_S2++)
	                    if (Base.USDJPY_DOWN_S2_OCO4Sets4[USDJPY_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_DOWN_S2_OCO4Sets4[USDJPY_OCO4S4_DOWN_S2].Filled();
	                        Base.USDJPY_DOWN_S2_OCO4Sets4.RemoveAt(USDJPY_OCO4S4_DOWN_S2);
	                        USDJPY_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct AUDCAD_OCO1_DOWN_S2
    {
        public AUDCAD_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 =="TP1_AUDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD 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 =="TP1_AUDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD 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 AUDCAD_OCO1_UP_S2
    {
        public AUDCAD_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 =="TP1_AUDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD 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 =="TP1_AUDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_AUDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_AUDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_AUDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_AUDCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("AUDCAD 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 AUDCAD_OCO2_DOWN_S2
    {
        public AUDCAD_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 =="TP1_AUDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD 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 =="TP1_AUDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD 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 AUDCAD_OCO2_UP_S2
    {
        public AUDCAD_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 =="TP1_AUDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD 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 =="TP1_AUDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_AUDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_AUDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_AUDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_AUDCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("AUDCAD 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 AUDCAD_OCO3_DOWN_S2
    {
        public AUDCAD_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 =="TP1_AUDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD 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 =="TP1_AUDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD 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 AUDCAD_OCO3_UP_S2
    {
        public AUDCAD_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 =="TP1_AUDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD 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 =="TP1_AUDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_AUDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_AUDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_AUDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_AUDCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("AUDCAD 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 AUDCAD_OCO4_DOWN_S2
    {
        public AUDCAD_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 =="TP1_AUDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD 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 =="TP1_AUDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD 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 AUDCAD_OCO4_UP_S2
    {
        public AUDCAD_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 =="TP1_AUDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD 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 =="TP1_AUDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_AUDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_AUDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_AUDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_AUDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_AUDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_AUDCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_AUDCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("AUDCAD 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_USDCHF_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_USDCHF_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("USDCHF_DOWN_S2_OCO1")))
			{
				Base.USDCHF_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCHF_DOWN_S2_OCO2")))
			{
				Base.USDCHF_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCHF_DOWN_S2_OCO3")))
			{
				Base.USDCHF_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCHF_DOWN_S2_OCO4")))
			{
				Base.USDCHF_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("USDCHF_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.USDCHF_OCO1_EO1_DOWN_S2)
	                Base.USDCHF_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDCHF_OCO1_EO2_DOWN_S2)
	                Base.USDCHF_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO1_EO3_DOWN_S2)
	                Base.USDCHF_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO1_EO4_DOWN_S2)
	                Base.USDCHF_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO1_EO5_DOWN_S2)
	                Base.USDCHF_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO1_EO6_DOWN_S2)
	                Base.USDCHF_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCHF_OCO1S1_DOWN_S2 = 0;
		                for (; USDCHF_OCO1S1_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets1.Count; USDCHF_OCO1S1_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO1Sets1[USDCHF_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO1Sets1[USDCHF_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.USDCHF_DOWN_S2_OCO1Sets1.Clear();
		                        USDCHF_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDCHF_OCO1S2_DOWN_S2 = 0;
		                for (; USDCHF_OCO1S2_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets2.Count; USDCHF_OCO1S2_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO1Sets2[USDCHF_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO1Sets2[USDCHF_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.USDCHF_DOWN_S2_OCO1Sets2.Clear();
		                        USDCHF_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO1S3_DOWN_S2 = 0;
		                for (; USDCHF_OCO1S3_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets3.Count; USDCHF_OCO1S3_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO1Sets3[USDCHF_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO1Sets3[USDCHF_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.USDCHF_DOWN_S2_OCO1Sets3.Clear();
		                        USDCHF_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO1S4_DOWN_S2 = 0;
		                for (; USDCHF_OCO1S4_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets4.Count; USDCHF_OCO1S4_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO1Sets4[USDCHF_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO1Sets4[USDCHF_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.USDCHF_DOWN_S2_OCO1Sets4.Clear();
		                        USDCHF_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO1S5_DOWN_S2 = 0;
		                for (; USDCHF_OCO1S5_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets5.Count; USDCHF_OCO1S5_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO1Sets5[USDCHF_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO1Sets5[USDCHF_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.USDCHF_DOWN_S2_OCO1Sets5.Clear();
		                        USDCHF_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO1S6_DOWN_S2 = 0;
		                for (; USDCHF_OCO1S6_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO1Sets6.Count; USDCHF_OCO1S6_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO1Sets6[USDCHF_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO1Sets6[USDCHF_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.USDCHF_DOWN_S2_OCO1Sets6.Clear();
		                        USDCHF_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDCHF_OCO2_EO1_DOWN_S2)
	                Base.USDCHF_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDCHF_OCO2_EO2_DOWN_S2)
	                Base.USDCHF_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO2_EO3_DOWN_S2)
	                Base.USDCHF_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO2_EO4_DOWN_S2)
	                Base.USDCHF_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO2_EO5_DOWN_S2)
	                Base.USDCHF_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO2_EO6_DOWN_S2)
	                Base.USDCHF_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCHF_OCO2S1_DOWN_S2 = 0;
		                for (; USDCHF_OCO2S1_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets1.Count; USDCHF_OCO2S1_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO2Sets1[USDCHF_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO2Sets1[USDCHF_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.USDCHF_DOWN_S2_OCO2Sets1.Clear();
		                        USDCHF_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDCHF_OCO2S2_DOWN_S2 = 0;
		                for (; USDCHF_OCO2S2_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets2.Count; USDCHF_OCO2S2_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO2Sets2[USDCHF_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO2Sets2[USDCHF_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.USDCHF_DOWN_S2_OCO2Sets2.Clear();
		                        USDCHF_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO2S3_DOWN_S2 = 0;
		                for (; USDCHF_OCO2S3_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets3.Count; USDCHF_OCO2S3_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO2Sets3[USDCHF_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO2Sets3[USDCHF_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.USDCHF_DOWN_S2_OCO2Sets3.Clear();
		                        USDCHF_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO2S4_DOWN_S2 = 0;
		                for (; USDCHF_OCO2S4_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets4.Count; USDCHF_OCO2S4_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO2Sets4[USDCHF_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO2Sets4[USDCHF_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.USDCHF_DOWN_S2_OCO2Sets4.Clear();
		                        USDCHF_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO2S5_DOWN_S2 = 0;
		                for (; USDCHF_OCO2S5_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets5.Count; USDCHF_OCO2S5_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO2Sets5[USDCHF_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO2Sets5[USDCHF_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.USDCHF_DOWN_S2_OCO2Sets5.Clear();
		                        USDCHF_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO2S6_DOWN_S2 = 0;
		                for (; USDCHF_OCO2S6_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO2Sets6.Count; USDCHF_OCO2S6_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO2Sets6[USDCHF_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO2Sets6[USDCHF_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.USDCHF_DOWN_S2_OCO2Sets6.Clear();
		                        USDCHF_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDCHF_OCO3_EO1_DOWN_S2)
	                Base.USDCHF_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDCHF_OCO3_EO2_DOWN_S2)
	                Base.USDCHF_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO3_EO3_DOWN_S2)
	                Base.USDCHF_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO3_EO4_DOWN_S2)
	                Base.USDCHF_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO3_EO5_DOWN_S2)
	                Base.USDCHF_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO3_EO6_DOWN_S2)
	                Base.USDCHF_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCHF_OCO3S1_DOWN_S2 = 0;
		                for (; USDCHF_OCO3S1_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets1.Count; USDCHF_OCO3S1_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO3Sets1[USDCHF_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO3Sets1[USDCHF_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.USDCHF_DOWN_S2_OCO3Sets1.Clear();
		                        USDCHF_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDCHF_OCO3S2_DOWN_S2 = 0;
		                for (; USDCHF_OCO3S2_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets2.Count; USDCHF_OCO3S2_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO3Sets2[USDCHF_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO3Sets2[USDCHF_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.USDCHF_DOWN_S2_OCO3Sets2.Clear();
		                        USDCHF_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO3S3_DOWN_S2 = 0;
		                for (; USDCHF_OCO3S3_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets3.Count; USDCHF_OCO3S3_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO3Sets3[USDCHF_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO3Sets3[USDCHF_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.USDCHF_DOWN_S2_OCO3Sets3.Clear();
		                        USDCHF_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO3S4_DOWN_S2 = 0;
		                for (; USDCHF_OCO3S4_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets4.Count; USDCHF_OCO3S4_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO3Sets4[USDCHF_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO3Sets4[USDCHF_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.USDCHF_DOWN_S2_OCO3Sets4.Clear();
		                        USDCHF_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO3S5_DOWN_S2 = 0;
		                for (; USDCHF_OCO3S5_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets5.Count; USDCHF_OCO3S5_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO3Sets5[USDCHF_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO3Sets5[USDCHF_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.USDCHF_DOWN_S2_OCO3Sets5.Clear();
		                        USDCHF_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO3S6_DOWN_S2 = 0;
		                for (; USDCHF_OCO3S6_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO3Sets6.Count; USDCHF_OCO3S6_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO3Sets6[USDCHF_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO3Sets6[USDCHF_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.USDCHF_DOWN_S2_OCO3Sets6.Clear();
		                        USDCHF_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDCHF_OCO4_EO1_DOWN_S2)
	                Base.USDCHF_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDCHF_OCO4_EO2_DOWN_S2)
	                Base.USDCHF_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO4_EO3_DOWN_S2)
	                Base.USDCHF_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO4_EO4_DOWN_S2)
	                Base.USDCHF_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO4_EO5_DOWN_S2)
	                Base.USDCHF_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO4_EO6_DOWN_S2)
	                Base.USDCHF_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCHF_OCO4S1_DOWN_S2 = 0;
		                for (; USDCHF_OCO4S1_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets1.Count; USDCHF_OCO4S1_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO4Sets1[USDCHF_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO4Sets1[USDCHF_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.USDCHF_DOWN_S2_OCO4Sets1.Clear();
		                        USDCHF_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDCHF_OCO4S2_DOWN_S2 = 0;
		                for (; USDCHF_OCO4S2_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets2.Count; USDCHF_OCO4S2_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO4Sets2[USDCHF_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO4Sets2[USDCHF_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.USDCHF_DOWN_S2_OCO4Sets2.Clear();
		                        USDCHF_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO4S3_DOWN_S2 = 0;
		                for (; USDCHF_OCO4S3_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets3.Count; USDCHF_OCO4S3_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO4Sets3[USDCHF_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO4Sets3[USDCHF_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.USDCHF_DOWN_S2_OCO4Sets3.Clear();
		                        USDCHF_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO4S4_DOWN_S2 = 0;
		                for (; USDCHF_OCO4S4_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets4.Count; USDCHF_OCO4S4_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO4Sets4[USDCHF_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO4Sets4[USDCHF_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.USDCHF_DOWN_S2_OCO4Sets4.Clear();
		                        USDCHF_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO4S5_DOWN_S2 = 0;
		                for (; USDCHF_OCO4S5_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets5.Count; USDCHF_OCO4S5_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO4Sets5[USDCHF_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO4Sets5[USDCHF_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.USDCHF_DOWN_S2_OCO4Sets5.Clear();
		                        USDCHF_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO4S6_DOWN_S2 = 0;
		                for (; USDCHF_OCO4S6_DOWN_S2 < Base.USDCHF_DOWN_S2_OCO4Sets6.Count; USDCHF_OCO4S6_DOWN_S2++)
		                    if (Base.USDCHF_DOWN_S2_OCO4Sets6[USDCHF_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_DOWN_S2_OCO4Sets6[USDCHF_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.USDCHF_DOWN_S2_OCO4Sets6.Clear();
		                        USDCHF_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();
	            	}
	            	
					DOWM_USDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_USDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_USDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_USDCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_USDCHF_DOWN_S2 = DOWM_USDCHF_DOWN_S2 || DOWT_USDCHF_DOWN_S2 || DOWW_USDCHF_DOWN_S2 || DOWTH_USDCHF_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("USDCHF"))
	            	{
	            		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.USDCHF_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.USDCHF_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.USDCHF_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.USDCHF_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.USDCHF_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.USDCHF_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.USDCHF_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.USDCHF_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.USDCHF_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.USDCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.USDCHF_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.USDCHF_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	USDCHF_Signal_Condition_DOWN_S2 =  
	                									(
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.04m &&
	                										
	                										//prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//prices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[0] > prices_ASK_Close[0] * 0.001m &&
	                										
	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										
	                										prices_ASK_High[0] > pricesM_ASK_High[0] &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.0002m
	                									);
	                									
	                    USDCHF_DOWN_S2_SL  =  0.01m;
	                    USDCHF_DOWN_S2_TP1 =  0.01m;
	                    USDCHF_DOWN_S2_TP2 =  USDCHF_DOWN_S2_SL * 0;
	                    USDCHF_DOWN_S2_TP3 =  USDCHF_DOWN_S2_SL * 0;
	                    USDCHF_DOWN_S2_TP4 =  USDCHF_DOWN_S2_SL * 0;
	                    USDCHF_DOWN_S2_TP5 =  USDCHF_DOWN_S2_SL * 0;
	                    USDCHF_DOWN_S2_TP6 =  USDCHF_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    USDCHF_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    USDCHF_quantity_SL_DOWN_S2 = USDCHF_quantity_DOWN_S2;
	                    USDCHF_quantity_TP1_DOWN_S2 = (int)Math.Floor(USDCHF_quantity_DOWN_S2 * 1m);
	                    USDCHF_quantity_TP2_DOWN_S2 = (int)Math.Floor(USDCHF_quantity_TP1_DOWN_S2 * 0m);
	                    USDCHF_quantity_TP3_DOWN_S2 = (int)Math.Floor(USDCHF_quantity_TP2_DOWN_S2 * 0m);
	                    USDCHF_quantity_TP4_DOWN_S2 = (int)Math.Floor(USDCHF_quantity_TP3_DOWN_S2 * 0m);
	                    USDCHF_quantity_TP5_DOWN_S2 = (int)Math.Floor(USDCHF_quantity_TP4_DOWN_S2 * 0m);
	                    USDCHF_quantity_TP6_DOWN_S2 = (int)Math.Floor(USDCHF_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (USDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_USDCHF_DOWN_S2 && 
	                    Base.USDCHF_OCO1_DOWN_S2_IsReady == true &&
	                    Base.USDCHF_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCHF_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP1_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP1_OCO1");
	                         Base.USDCHF_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.USDCHF_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP2_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP2_OCO1");
	                         Base.USDCHF_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.USDCHF_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP3_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP3_OCO1");
	                         Base.USDCHF_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.USDCHF_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP4_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP4_OCO1");
	                         Base.USDCHF_OCO1_EO4_DOWN_S2 = false;

							Base.USDCHF_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.USDCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (USDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_USDCHF_DOWN_S2 && 
	                    Base.USDCHF_OCO2_DOWN_S2_IsReady == true &&
	                    Base.USDCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.USDCHF_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCHF_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP1_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP1_OCO2");
	                         Base.USDCHF_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.USDCHF_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP2_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP2_OCO2");
	                         Base.USDCHF_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.USDCHF_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP3_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP3_OCO2");
	                         Base.USDCHF_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.USDCHF_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP4_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP4_OCO2");
	                         Base.USDCHF_OCO2_EO4_DOWN_S2 = false;

							Base.USDCHF_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.USDCHF_OCO2_DOWN_S2_IsReady == false && Base.USDCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (USDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_USDCHF_DOWN_S2 &&
	                    Base.USDCHF_OCO3_DOWN_S2_IsReady == true &&
	                    Base.USDCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.USDCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.USDCHF_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCHF_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP1_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP1_OCO3");
	                         Base.USDCHF_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.USDCHF_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP2_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP2_OCO3");
	                         Base.USDCHF_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.USDCHF_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP3_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP3_OCO3");
	                         Base.USDCHF_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.USDCHF_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP4_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP4_OCO3");
	                         Base.USDCHF_OCO3_EO4_DOWN_S2 = false;

							Base.USDCHF_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.USDCHF_OCO3_DOWN_S2_IsReady == false && Base.USDCHF_OCO2_DOWN_S2_IsReady == false && Base.USDCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (USDCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_USDCHF_DOWN_S2 && 
	                    Base.USDCHF_OCO4_DOWN_S2_IsReady == true &&
	                    Base.USDCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.USDCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.USDCHF_OCO3_DOWN_S2_IsReady == false &&
	                    Base.USDCHF_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCHF_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP1_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP1_OCO4");
	                         Base.USDCHF_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.USDCHF_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP2_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP2_OCO4");
	                         Base.USDCHF_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.USDCHF_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP3_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP3_OCO4");
	                         Base.USDCHF_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.USDCHF_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDCHF_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP4_DOWN_S2, false,"USDCHF_DOWN_S2_Entry_TP4_OCO4");
	                         Base.USDCHF_OCO4_EO4_DOWN_S2 = false;

							Base.USDCHF_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.USDCHF_OCO4_DOWN_S2_IsReady == false && Base.USDCHF_OCO3_DOWN_S2_IsReady == false && Base.USDCHF_OCO2_DOWN_S2_IsReady == false && Base.USDCHF_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.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 NZDCHF_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public NZDCHF_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("NZDCHF OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCHF OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCHF OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDCHF OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDCHF OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDCHF OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDCHF S2");
		        	}
		        }
		        
				if (Base.NZDCHF_OCO1_EO1_DOWN_S2)
	                Base.NZDCHF_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCHF_OCO1_EO2_DOWN_S2)
	                Base.NZDCHF_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO1_EO3_DOWN_S2)
	                Base.NZDCHF_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO1_EO4_DOWN_S2)
	                Base.NZDCHF_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDCHF_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP1_NZDCHF_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP1,"TP1_NZDCHF_DOWN_S2_OCO1"));
		                 };
		                Base.NZDCHF_DOWN_S2_OCO1Sets1.Add( Base.NZDCHF_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP2_NZDCHF_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP2,"TP2_NZDCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO1Sets2.Add( Base.NZDCHF_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP3_NZDCHF_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP3,"TP3_NZDCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO1Sets3.Add( Base.NZDCHF_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP4_NZDCHF_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP4,"TP4_NZDCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO1Sets4.Add( Base.NZDCHF_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int NZDCHF_OCO1S1_DOWN_S2 = 0;
	                for (; NZDCHF_OCO1S1_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets1.Count; NZDCHF_OCO1S1_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO1Sets1[NZDCHF_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO1Sets1[NZDCHF_OCO1S1_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO1Sets1.RemoveAt(NZDCHF_OCO1S1_DOWN_S2);
	                        NZDCHF_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCHF_OCO1S2_DOWN_S2 = 0;
	                for (; NZDCHF_OCO1S2_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets2.Count; NZDCHF_OCO1S2_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO1Sets2[NZDCHF_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO1Sets2[NZDCHF_OCO1S2_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO1Sets2.RemoveAt(NZDCHF_OCO1S2_DOWN_S2);
	                        NZDCHF_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO1S3_DOWN_S2 = 0;
	                for (; NZDCHF_OCO1S3_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets3.Count; NZDCHF_OCO1S3_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO1Sets3[NZDCHF_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO1Sets3[NZDCHF_OCO1S3_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO1Sets3.RemoveAt(NZDCHF_OCO1S3_DOWN_S2);
	                        NZDCHF_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO1S4_DOWN_S2 = 0;
	                for (; NZDCHF_OCO1S4_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO1Sets4.Count; NZDCHF_OCO1S4_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO1Sets4[NZDCHF_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO1Sets4[NZDCHF_OCO1S4_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO1Sets4.RemoveAt(NZDCHF_OCO1S4_DOWN_S2);
	                        NZDCHF_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCHF_OCO2_EO1_DOWN_S2)
	                Base.NZDCHF_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCHF_OCO2_EO2_DOWN_S2)
	                Base.NZDCHF_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO2_EO3_DOWN_S2)
	                Base.NZDCHF_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO2_EO4_DOWN_S2)
	                Base.NZDCHF_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDCHF_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP1_NZDCHF_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP1,"TP1_NZDCHF_DOWN_S2_OCO2"));
		                 };
		                Base.NZDCHF_DOWN_S2_OCO2Sets1.Add( Base.NZDCHF_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP2_NZDCHF_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP2,"TP2_NZDCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO2Sets2.Add( Base.NZDCHF_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP3_NZDCHF_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP3,"TP3_NZDCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO2Sets3.Add( Base.NZDCHF_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP4_NZDCHF_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP4,"TP4_NZDCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO2Sets4.Add( Base.NZDCHF_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int NZDCHF_OCO2S1_DOWN_S2 = 0;
	                for (; NZDCHF_OCO2S1_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets1.Count; NZDCHF_OCO2S1_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO2Sets1[NZDCHF_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO2Sets1[NZDCHF_OCO2S1_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO2Sets1.RemoveAt(NZDCHF_OCO2S1_DOWN_S2);
	                        NZDCHF_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCHF_OCO2S2_DOWN_S2 = 0;
	                for (; NZDCHF_OCO2S2_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets2.Count; NZDCHF_OCO2S2_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO2Sets2[NZDCHF_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO2Sets2[NZDCHF_OCO2S2_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO2Sets2.RemoveAt(NZDCHF_OCO2S2_DOWN_S2);
	                        NZDCHF_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO2S3_DOWN_S2 = 0;
	                for (; NZDCHF_OCO2S3_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets3.Count; NZDCHF_OCO2S3_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO2Sets3[NZDCHF_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO2Sets3[NZDCHF_OCO2S3_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO2Sets3.RemoveAt(NZDCHF_OCO2S3_DOWN_S2);
	                        NZDCHF_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO2S4_DOWN_S2 = 0;
	                for (; NZDCHF_OCO2S4_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO2Sets4.Count; NZDCHF_OCO2S4_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO2Sets4[NZDCHF_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO2Sets4[NZDCHF_OCO2S4_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO2Sets4.RemoveAt(NZDCHF_OCO2S4_DOWN_S2);
	                        NZDCHF_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCHF_OCO3_EO1_DOWN_S2)
	                Base.NZDCHF_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCHF_OCO3_EO2_DOWN_S2)
	                Base.NZDCHF_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO3_EO3_DOWN_S2)
	                Base.NZDCHF_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO3_EO4_DOWN_S2)
	                Base.NZDCHF_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDCHF_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP1_NZDCHF_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP1,"TP1_NZDCHF_DOWN_S2_OCO3"));
		                 };
		                Base.NZDCHF_DOWN_S2_OCO3Sets1.Add( Base.NZDCHF_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP2_NZDCHF_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP2,"TP2_NZDCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO3Sets2.Add( Base.NZDCHF_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP3_NZDCHF_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP3,"TP3_NZDCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO3Sets3.Add( Base.NZDCHF_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP4_NZDCHF_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP4,"TP4_NZDCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO3Sets4.Add( Base.NZDCHF_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int NZDCHF_OCO3S1_DOWN_S2 = 0;
	                for (; NZDCHF_OCO3S1_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets1.Count; NZDCHF_OCO3S1_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO3Sets1[NZDCHF_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO3Sets1[NZDCHF_OCO3S1_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO3Sets1.RemoveAt(NZDCHF_OCO3S1_DOWN_S2);
	                        NZDCHF_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCHF_OCO3S2_DOWN_S2 = 0;
	                for (; NZDCHF_OCO3S2_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets2.Count; NZDCHF_OCO3S2_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO3Sets2[NZDCHF_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO3Sets2[NZDCHF_OCO3S2_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO3Sets2.RemoveAt(NZDCHF_OCO3S2_DOWN_S2);
	                        NZDCHF_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO3S3_DOWN_S2 = 0;
	                for (; NZDCHF_OCO3S3_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets3.Count; NZDCHF_OCO3S3_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO3Sets3[NZDCHF_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO3Sets3[NZDCHF_OCO3S3_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO3Sets3.RemoveAt(NZDCHF_OCO3S3_DOWN_S2);
	                        NZDCHF_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO3S4_DOWN_S2 = 0;
	                for (; NZDCHF_OCO3S4_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO3Sets4.Count; NZDCHF_OCO3S4_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO3Sets4[NZDCHF_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO3Sets4[NZDCHF_OCO3S4_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO3Sets4.RemoveAt(NZDCHF_OCO3S4_DOWN_S2);
	                        NZDCHF_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDCHF_OCO4_EO1_DOWN_S2)
	                Base.NZDCHF_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDCHF_OCO4_EO2_DOWN_S2)
	                Base.NZDCHF_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO4_EO3_DOWN_S2)
	                Base.NZDCHF_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDCHF_OCO4_EO4_DOWN_S2)
	                Base.NZDCHF_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDCHF_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP1_NZDCHF_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP1,"TP1_NZDCHF_DOWN_S2_OCO4"));
		                 };
		                Base.NZDCHF_DOWN_S2_OCO4Sets1.Add( Base.NZDCHF_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP2_NZDCHF_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP2,"TP2_NZDCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO4Sets2.Add( Base.NZDCHF_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP3_NZDCHF_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP3,"TP3_NZDCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO4Sets3.Add( Base.NZDCHF_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDCHF_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDCHF_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDCHF_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDCHF_DOWN_S2_SL,"SL_TP4_NZDCHF_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDCHF_DOWN_S2_TP4,"TP4_NZDCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDCHF_DOWN_S2_OCO4Sets4.Add( Base.NZDCHF_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDCHF_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int NZDCHF_OCO4S1_DOWN_S2 = 0;
	                for (; NZDCHF_OCO4S1_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets1.Count; NZDCHF_OCO4S1_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO4Sets1[NZDCHF_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO4Sets1[NZDCHF_OCO4S1_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO4Sets1.RemoveAt(NZDCHF_OCO4S1_DOWN_S2);
	                        NZDCHF_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDCHF_OCO4S2_DOWN_S2 = 0;
	                for (; NZDCHF_OCO4S2_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets2.Count; NZDCHF_OCO4S2_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO4Sets2[NZDCHF_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO4Sets2[NZDCHF_OCO4S2_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO4Sets2.RemoveAt(NZDCHF_OCO4S2_DOWN_S2);
	                        NZDCHF_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO4S3_DOWN_S2 = 0;
	                for (; NZDCHF_OCO4S3_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets3.Count; NZDCHF_OCO4S3_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO4Sets3[NZDCHF_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO4Sets3[NZDCHF_OCO4S3_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO4Sets3.RemoveAt(NZDCHF_OCO4S3_DOWN_S2);
	                        NZDCHF_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDCHF_OCO4S4_DOWN_S2 = 0;
	                for (; NZDCHF_OCO4S4_DOWN_S2 < Base.NZDCHF_DOWN_S2_OCO4Sets4.Count; NZDCHF_OCO4S4_DOWN_S2++)
	                    if (Base.NZDCHF_DOWN_S2_OCO4Sets4[NZDCHF_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDCHF_DOWN_S2_OCO4Sets4[NZDCHF_OCO4S4_DOWN_S2].Filled();
	                        Base.NZDCHF_DOWN_S2_OCO4Sets4.RemoveAt(NZDCHF_OCO4S4_DOWN_S2);
	                        NZDCHF_OCO4S4_DOWN_S2 = 0;
	                        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 _EURCAD;
		
    	///oco1 up
    	public static OrderTicket EURCAD_OCO1_MO1_UP_S2;
    	public static OrderTicket EURCAD_OCO1_MO2_UP_S2;
    	public static OrderTicket EURCAD_OCO1_MO3_UP_S2;
    	public static OrderTicket EURCAD_OCO1_MO4_UP_S2;
    	public static OrderTicket EURCAD_OCO1_MO5_UP_S2;
    	public static OrderTicket EURCAD_OCO1_MO6_UP_S2;
    	
    	public static int EURCAD_OCO1_EO1_UP_S2_ID ;
        public static int EURCAD_OCO1_EO2_UP_S2_ID ;
        public static int EURCAD_OCO1_EO3_UP_S2_ID ;
        public static int EURCAD_OCO1_EO4_UP_S2_ID ;
        public static int EURCAD_OCO1_EO5_UP_S2_ID ;
        public static int EURCAD_OCO1_EO6_UP_S2_ID ;
        
        public static bool EURCAD_OCO1_EO1_UP_S2 ;
        public static bool EURCAD_OCO1_EO2_UP_S2 ;
        public static bool EURCAD_OCO1_EO3_UP_S2 ;
        public static bool EURCAD_OCO1_EO4_UP_S2 ;
        public static bool EURCAD_OCO1_EO5_UP_S2 ;
        public static bool EURCAD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_UP_S2> EURCAD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_UP_S2> EURCAD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_UP_S2> EURCAD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_UP_S2> EURCAD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_UP_S2> EURCAD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_UP_S2> EURCAD_OOFE_OCO1_UP_S2_6 ;
        
        public static EURCAD_OCO1_UP_S2 EURCAD_PFO_OCO1_UP_S2_1 ;
        public static EURCAD_OCO1_UP_S2 EURCAD_PFO_OCO1_UP_S2_2 ;
        public static EURCAD_OCO1_UP_S2 EURCAD_PFO_OCO1_UP_S2_3 ;
        public static EURCAD_OCO1_UP_S2 EURCAD_PFO_OCO1_UP_S2_4 ;
        public static EURCAD_OCO1_UP_S2 EURCAD_PFO_OCO1_UP_S2_5 ;
        public static EURCAD_OCO1_UP_S2 EURCAD_PFO_OCO1_UP_S2_6 ;
        
        public static List<EURCAD_OCO1_UP_S2> EURCAD_UP_S2_OCO1Sets1 = new List<EURCAD_OCO1_UP_S2>();
        public static List<EURCAD_OCO1_UP_S2> EURCAD_UP_S2_OCO1Sets2 = new List<EURCAD_OCO1_UP_S2>();
        public static List<EURCAD_OCO1_UP_S2> EURCAD_UP_S2_OCO1Sets3 = new List<EURCAD_OCO1_UP_S2>();
        public static List<EURCAD_OCO1_UP_S2> EURCAD_UP_S2_OCO1Sets4 = new List<EURCAD_OCO1_UP_S2>();
        public static List<EURCAD_OCO1_UP_S2> EURCAD_UP_S2_OCO1Sets5 = new List<EURCAD_OCO1_UP_S2>();
        public static List<EURCAD_OCO1_UP_S2> EURCAD_UP_S2_OCO1Sets6 = new List<EURCAD_OCO1_UP_S2>();
        
        public static bool EURCAD_OCO1_UP_S2_IsReady = true;
        public static bool EURCAD_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket EURCAD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int EURCAD_OCO1_EO1_DOWN_S2_ID ;
        public static int EURCAD_OCO1_EO2_DOWN_S2_ID ;
        public static int EURCAD_OCO1_EO3_DOWN_S2_ID ;
        public static int EURCAD_OCO1_EO4_DOWN_S2_ID ;
        public static int EURCAD_OCO1_EO5_DOWN_S2_ID ;
        public static int EURCAD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool EURCAD_OCO1_EO1_DOWN_S2 ;
        public static bool EURCAD_OCO1_EO2_DOWN_S2 ;
        public static bool EURCAD_OCO1_EO3_DOWN_S2 ;
        public static bool EURCAD_OCO1_EO4_DOWN_S2 ;
        public static bool EURCAD_OCO1_EO5_DOWN_S2 ;
        public static bool EURCAD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_DOWN_S2> EURCAD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_DOWN_S2> EURCAD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_DOWN_S2> EURCAD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_DOWN_S2> EURCAD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_DOWN_S2> EURCAD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO1_DOWN_S2> EURCAD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static EURCAD_OCO1_DOWN_S2 EURCAD_PFO_OCO1_DOWN_S2_1 ;
        public static EURCAD_OCO1_DOWN_S2 EURCAD_PFO_OCO1_DOWN_S2_2 ;
        public static EURCAD_OCO1_DOWN_S2 EURCAD_PFO_OCO1_DOWN_S2_3 ;
        public static EURCAD_OCO1_DOWN_S2 EURCAD_PFO_OCO1_DOWN_S2_4 ;
        public static EURCAD_OCO1_DOWN_S2 EURCAD_PFO_OCO1_DOWN_S2_5 ;
        public static EURCAD_OCO1_DOWN_S2 EURCAD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<EURCAD_OCO1_DOWN_S2> EURCAD_DOWN_S2_OCO1Sets1 = new List<EURCAD_OCO1_DOWN_S2>();
        public static List<EURCAD_OCO1_DOWN_S2> EURCAD_DOWN_S2_OCO1Sets2 = new List<EURCAD_OCO1_DOWN_S2>();
        public static List<EURCAD_OCO1_DOWN_S2> EURCAD_DOWN_S2_OCO1Sets3 = new List<EURCAD_OCO1_DOWN_S2>();
        public static List<EURCAD_OCO1_DOWN_S2> EURCAD_DOWN_S2_OCO1Sets4 = new List<EURCAD_OCO1_DOWN_S2>();
        public static List<EURCAD_OCO1_DOWN_S2> EURCAD_DOWN_S2_OCO1Sets5 = new List<EURCAD_OCO1_DOWN_S2>();
        public static List<EURCAD_OCO1_DOWN_S2> EURCAD_DOWN_S2_OCO1Sets6 = new List<EURCAD_OCO1_DOWN_S2>();
        
        public static bool EURCAD_OCO1_DOWN_S2_IsReady = true;
        public static bool EURCAD_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket EURCAD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO6_UP_S2 ;
    	
    	public static int EURCAD_OCO2_EO1_UP_S2_ID ;
        public static int EURCAD_OCO2_EO2_UP_S2_ID ;
        public static int EURCAD_OCO2_EO3_UP_S2_ID ;
        public static int EURCAD_OCO2_EO4_UP_S2_ID ;
        public static int EURCAD_OCO2_EO5_UP_S2_ID ;
        public static int EURCAD_OCO2_EO6_UP_S2_ID ;
        
        public static bool EURCAD_OCO2_EO1_UP_S2 ;
        public static bool EURCAD_OCO2_EO2_UP_S2 ;
        public static bool EURCAD_OCO2_EO3_UP_S2 ;
        public static bool EURCAD_OCO2_EO4_UP_S2 ;
        public static bool EURCAD_OCO2_EO5_UP_S2 ;
        public static bool EURCAD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_UP_S2> EURCAD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_UP_S2> EURCAD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_UP_S2> EURCAD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_UP_S2> EURCAD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_UP_S2> EURCAD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_UP_S2> EURCAD_OOFE_OCO2_UP_S2_6 ;
        
        public static EURCAD_OCO2_UP_S2 EURCAD_PFO_OCO2_UP_S2_1 ;
        public static EURCAD_OCO2_UP_S2 EURCAD_PFO_OCO2_UP_S2_2 ;
        public static EURCAD_OCO2_UP_S2 EURCAD_PFO_OCO2_UP_S2_3 ;
        public static EURCAD_OCO2_UP_S2 EURCAD_PFO_OCO2_UP_S2_4 ;
        public static EURCAD_OCO2_UP_S2 EURCAD_PFO_OCO2_UP_S2_5 ;
        public static EURCAD_OCO2_UP_S2 EURCAD_PFO_OCO2_UP_S2_6 ;
        
        public static List<EURCAD_OCO2_UP_S2> EURCAD_UP_S2_OCO2Sets1 = new List<EURCAD_OCO2_UP_S2>();
        public static List<EURCAD_OCO2_UP_S2> EURCAD_UP_S2_OCO2Sets2 = new List<EURCAD_OCO2_UP_S2>();
        public static List<EURCAD_OCO2_UP_S2> EURCAD_UP_S2_OCO2Sets3 = new List<EURCAD_OCO2_UP_S2>();
        public static List<EURCAD_OCO2_UP_S2> EURCAD_UP_S2_OCO2Sets4 = new List<EURCAD_OCO2_UP_S2>();
        public static List<EURCAD_OCO2_UP_S2> EURCAD_UP_S2_OCO2Sets5 = new List<EURCAD_OCO2_UP_S2>();
        public static List<EURCAD_OCO2_UP_S2> EURCAD_UP_S2_OCO2Sets6 = new List<EURCAD_OCO2_UP_S2>();
        
        public static bool EURCAD_OCO2_UP_S2_IsReady = true;
        public static bool EURCAD_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket EURCAD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int EURCAD_OCO2_EO1_DOWN_S2_ID ;
        public static int EURCAD_OCO2_EO2_DOWN_S2_ID ;
        public static int EURCAD_OCO2_EO3_DOWN_S2_ID ;
        public static int EURCAD_OCO2_EO4_DOWN_S2_ID ;
        public static int EURCAD_OCO2_EO5_DOWN_S2_ID ;
        public static int EURCAD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool EURCAD_OCO2_EO1_DOWN_S2 ;
        public static bool EURCAD_OCO2_EO2_DOWN_S2 ;
        public static bool EURCAD_OCO2_EO3_DOWN_S2 ;
        public static bool EURCAD_OCO2_EO4_DOWN_S2 ;
        public static bool EURCAD_OCO2_EO5_DOWN_S2 ;
        public static bool EURCAD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_DOWN_S2> EURCAD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_DOWN_S2> EURCAD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_DOWN_S2> EURCAD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_DOWN_S2> EURCAD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_DOWN_S2> EURCAD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO2_DOWN_S2> EURCAD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static EURCAD_OCO2_DOWN_S2 EURCAD_PFO_OCO2_DOWN_S2_1 ;
        public static EURCAD_OCO2_DOWN_S2 EURCAD_PFO_OCO2_DOWN_S2_2 ;
        public static EURCAD_OCO2_DOWN_S2 EURCAD_PFO_OCO2_DOWN_S2_3 ;
        public static EURCAD_OCO2_DOWN_S2 EURCAD_PFO_OCO2_DOWN_S2_4 ;
        public static EURCAD_OCO2_DOWN_S2 EURCAD_PFO_OCO2_DOWN_S2_5 ;
        public static EURCAD_OCO2_DOWN_S2 EURCAD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<EURCAD_OCO2_DOWN_S2> EURCAD_DOWN_S2_OCO2Sets1 = new List<EURCAD_OCO2_DOWN_S2>();
        public static List<EURCAD_OCO2_DOWN_S2> EURCAD_DOWN_S2_OCO2Sets2 = new List<EURCAD_OCO2_DOWN_S2>();
        public static List<EURCAD_OCO2_DOWN_S2> EURCAD_DOWN_S2_OCO2Sets3 = new List<EURCAD_OCO2_DOWN_S2>();
        public static List<EURCAD_OCO2_DOWN_S2> EURCAD_DOWN_S2_OCO2Sets4 = new List<EURCAD_OCO2_DOWN_S2>();
        public static List<EURCAD_OCO2_DOWN_S2> EURCAD_DOWN_S2_OCO2Sets5 = new List<EURCAD_OCO2_DOWN_S2>();
        public static List<EURCAD_OCO2_DOWN_S2> EURCAD_DOWN_S2_OCO2Sets6 = new List<EURCAD_OCO2_DOWN_S2>();
        
        public static bool EURCAD_OCO2_DOWN_S2_IsReady = true;
        public static bool EURCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket EURCAD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO6_UP_S2 ;
    	
    	public static int EURCAD_OCO3_EO1_UP_S2_ID ;
        public static int EURCAD_OCO3_EO2_UP_S2_ID ;
        public static int EURCAD_OCO3_EO3_UP_S2_ID ;
        public static int EURCAD_OCO3_EO4_UP_S2_ID ;
        public static int EURCAD_OCO3_EO5_UP_S2_ID ;
        public static int EURCAD_OCO3_EO6_UP_S2_ID ;
        
        public static bool EURCAD_OCO3_EO1_UP_S2 ;
        public static bool EURCAD_OCO3_EO2_UP_S2 ;
        public static bool EURCAD_OCO3_EO3_UP_S2 ;
        public static bool EURCAD_OCO3_EO4_UP_S2 ;
        public static bool EURCAD_OCO3_EO5_UP_S2 ;
        public static bool EURCAD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_UP_S2> EURCAD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_UP_S2> EURCAD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_UP_S2> EURCAD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_UP_S2> EURCAD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_UP_S2> EURCAD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_UP_S2> EURCAD_OOFE_OCO3_UP_S2_6 ;
        
        public static EURCAD_OCO3_UP_S2 EURCAD_PFO_OCO3_UP_S2_1 ;
        public static EURCAD_OCO3_UP_S2 EURCAD_PFO_OCO3_UP_S2_2 ;
        public static EURCAD_OCO3_UP_S2 EURCAD_PFO_OCO3_UP_S2_3 ;
        public static EURCAD_OCO3_UP_S2 EURCAD_PFO_OCO3_UP_S2_4 ;
        public static EURCAD_OCO3_UP_S2 EURCAD_PFO_OCO3_UP_S2_5 ;
        public static EURCAD_OCO3_UP_S2 EURCAD_PFO_OCO3_UP_S2_6 ;
        
        public static List<EURCAD_OCO3_UP_S2> EURCAD_UP_S2_OCO3Sets1 = new List<EURCAD_OCO3_UP_S2>();
        public static List<EURCAD_OCO3_UP_S2> EURCAD_UP_S2_OCO3Sets2 = new List<EURCAD_OCO3_UP_S2>();
        public static List<EURCAD_OCO3_UP_S2> EURCAD_UP_S2_OCO3Sets3 = new List<EURCAD_OCO3_UP_S2>();
        public static List<EURCAD_OCO3_UP_S2> EURCAD_UP_S2_OCO3Sets4 = new List<EURCAD_OCO3_UP_S2>();
        public static List<EURCAD_OCO3_UP_S2> EURCAD_UP_S2_OCO3Sets5 = new List<EURCAD_OCO3_UP_S2>();
        public static List<EURCAD_OCO3_UP_S2> EURCAD_UP_S2_OCO3Sets6 = new List<EURCAD_OCO3_UP_S2>();
        
        public static bool EURCAD_OCO3_UP_S2_IsReady = true;
        public static bool EURCAD_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket EURCAD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int EURCAD_OCO3_EO1_DOWN_S2_ID ;
        public static int EURCAD_OCO3_EO2_DOWN_S2_ID ;
        public static int EURCAD_OCO3_EO3_DOWN_S2_ID ;
        public static int EURCAD_OCO3_EO4_DOWN_S2_ID ;
        public static int EURCAD_OCO3_EO5_DOWN_S2_ID ;
        public static int EURCAD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool EURCAD_OCO3_EO1_DOWN_S2 ;
        public static bool EURCAD_OCO3_EO2_DOWN_S2 ;
        public static bool EURCAD_OCO3_EO3_DOWN_S2 ;
        public static bool EURCAD_OCO3_EO4_DOWN_S2 ;
        public static bool EURCAD_OCO3_EO5_DOWN_S2 ;
        public static bool EURCAD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_DOWN_S2> EURCAD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_DOWN_S2> EURCAD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_DOWN_S2> EURCAD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_DOWN_S2> EURCAD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_DOWN_S2> EURCAD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO3_DOWN_S2> EURCAD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static EURCAD_OCO3_DOWN_S2 EURCAD_PFO_OCO3_DOWN_S2_1 ;
        public static EURCAD_OCO3_DOWN_S2 EURCAD_PFO_OCO3_DOWN_S2_2 ;
        public static EURCAD_OCO3_DOWN_S2 EURCAD_PFO_OCO3_DOWN_S2_3 ;
        public static EURCAD_OCO3_DOWN_S2 EURCAD_PFO_OCO3_DOWN_S2_4 ;
        public static EURCAD_OCO3_DOWN_S2 EURCAD_PFO_OCO3_DOWN_S2_5 ;
        public static EURCAD_OCO3_DOWN_S2 EURCAD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<EURCAD_OCO3_DOWN_S2> EURCAD_DOWN_S2_OCO3Sets1 = new List<EURCAD_OCO3_DOWN_S2>();
        public static List<EURCAD_OCO3_DOWN_S2> EURCAD_DOWN_S2_OCO3Sets2 = new List<EURCAD_OCO3_DOWN_S2>();
        public static List<EURCAD_OCO3_DOWN_S2> EURCAD_DOWN_S2_OCO3Sets3 = new List<EURCAD_OCO3_DOWN_S2>();
        public static List<EURCAD_OCO3_DOWN_S2> EURCAD_DOWN_S2_OCO3Sets4 = new List<EURCAD_OCO3_DOWN_S2>();
        public static List<EURCAD_OCO3_DOWN_S2> EURCAD_DOWN_S2_OCO3Sets5 = new List<EURCAD_OCO3_DOWN_S2>();
        public static List<EURCAD_OCO3_DOWN_S2> EURCAD_DOWN_S2_OCO3Sets6 = new List<EURCAD_OCO3_DOWN_S2>();
        
        public static bool EURCAD_OCO3_DOWN_S2_IsReady = true;
        public static bool EURCAD_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket EURCAD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO6_UP_S2 ;
    	
    	public static int EURCAD_OCO4_EO1_UP_S2_ID ;
        public static int EURCAD_OCO4_EO2_UP_S2_ID ;
        public static int EURCAD_OCO4_EO3_UP_S2_ID ;
        public static int EURCAD_OCO4_EO4_UP_S2_ID ;
        public static int EURCAD_OCO4_EO5_UP_S2_ID ;
        public static int EURCAD_OCO4_EO6_UP_S2_ID ;
        
        public static bool EURCAD_OCO4_EO1_UP_S2 ;
        public static bool EURCAD_OCO4_EO2_UP_S2 ;
        public static bool EURCAD_OCO4_EO3_UP_S2 ;
        public static bool EURCAD_OCO4_EO4_UP_S2 ;
        public static bool EURCAD_OCO4_EO5_UP_S2 ;
        public static bool EURCAD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_UP_S2> EURCAD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_UP_S2> EURCAD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_UP_S2> EURCAD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_UP_S2> EURCAD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_UP_S2> EURCAD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_UP_S2> EURCAD_OOFE_OCO4_UP_S2_6 ;
        
        public static EURCAD_OCO4_UP_S2 EURCAD_PFO_OCO4_UP_S2_1 ;
        public static EURCAD_OCO4_UP_S2 EURCAD_PFO_OCO4_UP_S2_2 ;
        public static EURCAD_OCO4_UP_S2 EURCAD_PFO_OCO4_UP_S2_3 ;
        public static EURCAD_OCO4_UP_S2 EURCAD_PFO_OCO4_UP_S2_4 ;
        public static EURCAD_OCO4_UP_S2 EURCAD_PFO_OCO4_UP_S2_5 ;
        public static EURCAD_OCO4_UP_S2 EURCAD_PFO_OCO4_UP_S2_6 ;
        
        public static List<EURCAD_OCO4_UP_S2> EURCAD_UP_S2_OCO4Sets1 = new List<EURCAD_OCO4_UP_S2>();
        public static List<EURCAD_OCO4_UP_S2> EURCAD_UP_S2_OCO4Sets2 = new List<EURCAD_OCO4_UP_S2>();
        public static List<EURCAD_OCO4_UP_S2> EURCAD_UP_S2_OCO4Sets3 = new List<EURCAD_OCO4_UP_S2>();
        public static List<EURCAD_OCO4_UP_S2> EURCAD_UP_S2_OCO4Sets4 = new List<EURCAD_OCO4_UP_S2>();
        public static List<EURCAD_OCO4_UP_S2> EURCAD_UP_S2_OCO4Sets5 = new List<EURCAD_OCO4_UP_S2>();
        public static List<EURCAD_OCO4_UP_S2> EURCAD_UP_S2_OCO4Sets6 = new List<EURCAD_OCO4_UP_S2>();
        
        public static bool EURCAD_OCO4_UP_S2_IsReady = true;
        public static bool EURCAD_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket EURCAD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket EURCAD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int EURCAD_OCO4_EO1_DOWN_S2_ID ;
        public static int EURCAD_OCO4_EO2_DOWN_S2_ID ;
        public static int EURCAD_OCO4_EO3_DOWN_S2_ID ;
        public static int EURCAD_OCO4_EO4_DOWN_S2_ID ;
        public static int EURCAD_OCO4_EO5_DOWN_S2_ID ;
        public static int EURCAD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool EURCAD_OCO4_EO1_DOWN_S2 ;
        public static bool EURCAD_OCO4_EO2_DOWN_S2 ;
        public static bool EURCAD_OCO4_EO3_DOWN_S2 ;
        public static bool EURCAD_OCO4_EO4_DOWN_S2 ;
        public static bool EURCAD_OCO4_EO5_DOWN_S2 ;
        public static bool EURCAD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_DOWN_S2> EURCAD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_DOWN_S2> EURCAD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_DOWN_S2> EURCAD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_DOWN_S2> EURCAD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_DOWN_S2> EURCAD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCAD_OCO4_DOWN_S2> EURCAD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static EURCAD_OCO4_DOWN_S2 EURCAD_PFO_OCO4_DOWN_S2_1 ;
        public static EURCAD_OCO4_DOWN_S2 EURCAD_PFO_OCO4_DOWN_S2_2 ;
        public static EURCAD_OCO4_DOWN_S2 EURCAD_PFO_OCO4_DOWN_S2_3 ;
        public static EURCAD_OCO4_DOWN_S2 EURCAD_PFO_OCO4_DOWN_S2_4 ;
        public static EURCAD_OCO4_DOWN_S2 EURCAD_PFO_OCO4_DOWN_S2_5 ;
        public static EURCAD_OCO4_DOWN_S2 EURCAD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<EURCAD_OCO4_DOWN_S2> EURCAD_DOWN_S2_OCO4Sets1 = new List<EURCAD_OCO4_DOWN_S2>();
        public static List<EURCAD_OCO4_DOWN_S2> EURCAD_DOWN_S2_OCO4Sets2 = new List<EURCAD_OCO4_DOWN_S2>();
        public static List<EURCAD_OCO4_DOWN_S2> EURCAD_DOWN_S2_OCO4Sets3 = new List<EURCAD_OCO4_DOWN_S2>();
        public static List<EURCAD_OCO4_DOWN_S2> EURCAD_DOWN_S2_OCO4Sets4 = new List<EURCAD_OCO4_DOWN_S2>();
        public static List<EURCAD_OCO4_DOWN_S2> EURCAD_DOWN_S2_OCO4Sets5 = new List<EURCAD_OCO4_DOWN_S2>();
        public static List<EURCAD_OCO4_DOWN_S2> EURCAD_DOWN_S2_OCO4Sets6 = new List<EURCAD_OCO4_DOWN_S2>();
        
        public static bool EURCAD_OCO4_DOWN_S2_IsReady = true;
        public static bool EURCAD_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal EURCAD_UP_S2_SL {get; set;}
		public static decimal EURCAD_UP_S2_TP1 {get; set;}
		public static decimal EURCAD_UP_S2_TP2 {get; set;}
		public static decimal EURCAD_UP_S2_TP3 {get; set;}
		public static decimal EURCAD_UP_S2_TP4 {get; set;}
		public static decimal EURCAD_UP_S2_TP5 {get; set;}
		public static decimal EURCAD_UP_S2_TP6 {get; set;}
		
		public static decimal EURCAD_DOWN_S2_SL {get; set;}
		public static decimal EURCAD_DOWN_S2_TP1 {get; set;}
		public static decimal EURCAD_DOWN_S2_TP2 {get; set;}
		public static decimal EURCAD_DOWN_S2_TP3 {get; set;}
		public static decimal EURCAD_DOWN_S2_TP4 {get; set;}
		public static decimal EURCAD_DOWN_S2_TP5 {get; set;}
		public static decimal EURCAD_DOWN_S2_TP6 {get; set;}

        public static bool EURCAD_Signal_Condition_UP_1 ;
        public static bool EURCAD_Signal_Condition_UP_2 ;
        public static bool EURCAD_Signal_Condition_UP_3 ;
        public static bool EURCAD_Signal_Condition_DOWN_S2 ;
        
        public static int EURCAD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int EURCAD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int EURCAD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int EURCAD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int EURCAD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int EURCAD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int EURCAD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int EURCAD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int EURCAD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int EURCAD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_EURCAD_UP_S2 ;
        public static bool DOWM_EURCAD_UP_S2 ;
        public static bool DOWT_EURCAD_UP_S2 ;
        public static bool DOWW_EURCAD_UP_S2 ;
        public static bool DOWTH_EURCAD_UP_S2 ;
        
		public static bool DOWR_EURCAD_DOWN_S2 ;
        public static bool DOWM_EURCAD_DOWN_S2 ;
        public static bool DOWT_EURCAD_DOWN_S2 ;
        public static bool DOWW_EURCAD_DOWN_S2 ;
        public static bool DOWTH_EURCAD_DOWN_S2 ;
        
        
		public static int EURCAD_quantity_UP_S2 ;
		public static int EURCAD_quantity_SL_UP_S2 ;
		public static int EURCAD_quantity_TP1_UP_S2 ;
		public static int EURCAD_quantity_TP2_UP_S2 ;
		public static int EURCAD_quantity_TP3_UP_S2 ;
		public static int EURCAD_quantity_TP4_UP_S2 ;
		public static int EURCAD_quantity_TP5_UP_S2;
		public static int EURCAD_quantity_TP6_UP_S2 ;
		
		public static int EURCAD_quantity_DOWN_S2 ;
		public static int EURCAD_quantity_SL_DOWN_S2 ;
		public static int EURCAD_quantity_TP1_DOWN_S2 ;
		public static int EURCAD_quantity_TP2_DOWN_S2 ;
		public static int EURCAD_quantity_TP3_DOWN_S2 ;
		public static int EURCAD_quantity_TP4_DOWN_S2 ;
		public static int EURCAD_quantity_TP5_DOWN_S2;
		public static int EURCAD_quantity_TP6_DOWN_S2 ;
    }
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct CHFJPY_OCO1_DOWN_S2
    {
        public CHFJPY_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 =="TP1_CHFJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_CHFJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_CHFJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_CHFJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_CHFJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY 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 =="TP1_CHFJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_CHFJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_CHFJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_CHFJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_CHFJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY 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 CHFJPY_OCO1_UP_S2
    {
        public CHFJPY_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 =="TP1_CHFJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_CHFJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_CHFJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_CHFJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_CHFJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY 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 =="TP1_CHFJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_CHFJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_CHFJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_CHFJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_CHFJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CHFJPY 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 CHFJPY_OCO2_DOWN_S2
    {
        public CHFJPY_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 =="TP1_CHFJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_CHFJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_CHFJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_CHFJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_CHFJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY 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 =="TP1_CHFJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_CHFJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_CHFJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_CHFJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_CHFJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY 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 CHFJPY_OCO2_UP_S2
    {
        public CHFJPY_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 =="TP1_CHFJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_CHFJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_CHFJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_CHFJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_CHFJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY 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 =="TP1_CHFJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_CHFJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_CHFJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_CHFJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_CHFJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CHFJPY 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 CHFJPY_OCO3_DOWN_S2
    {
        public CHFJPY_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 =="TP1_CHFJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_CHFJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_CHFJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_CHFJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_CHFJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY 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 =="TP1_CHFJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_CHFJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_CHFJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_CHFJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_CHFJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY 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 CHFJPY_OCO3_UP_S2
    {
        public CHFJPY_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 =="TP1_CHFJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_CHFJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_CHFJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_CHFJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_CHFJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY 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 =="TP1_CHFJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_CHFJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_CHFJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_CHFJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_CHFJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CHFJPY 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 CHFJPY_OCO4_DOWN_S2
    {
        public CHFJPY_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 =="TP1_CHFJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_CHFJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_CHFJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_CHFJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_CHFJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY 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 =="TP1_CHFJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_CHFJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_CHFJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_CHFJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_CHFJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY 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 CHFJPY_OCO4_UP_S2
    {
        public CHFJPY_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 =="TP1_CHFJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_CHFJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_CHFJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_CHFJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_CHFJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY 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 =="TP1_CHFJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_CHFJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CHFJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_CHFJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CHFJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_CHFJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CHFJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_CHFJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CHFJPY 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_USDCHF_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_USDCHF_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(x=>x.Tag.Contains("USDCHF_UP_S2_OCO1")))
			{
				Base.USDCHF_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCHF_UP_S2_OCO2")))
			{
				Base.USDCHF_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCHF_UP_S2_OCO3")))
			{
				Base.USDCHF_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDCHF_UP_S2_OCO4")))
			{
				Base.USDCHF_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("USDCHF_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.USDCHF_OCO1_EO1_UP_S2)
	                Base.USDCHF_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.USDCHF_OCO1_EO2_UP_S2)
	                Base.USDCHF_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO1_EO3_UP_S2)
	                Base.USDCHF_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO1_EO4_UP_S2)
	                Base.USDCHF_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO1_EO5_UP_S2)
	                Base.USDCHF_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO1_EO6_UP_S2)
	                Base.USDCHF_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCHF_OCO1S1_UP_S2 = 0;
		                for (; USDCHF_OCO1S1_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets1.Count; USDCHF_OCO1S1_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO1Sets1[USDCHF_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO1Sets1[USDCHF_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_1__Time out_OCO1");
		                        Base.USDCHF_UP_S2_OCO1Sets1.Clear();
		                        USDCHF_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDCHF_OCO1S2_UP_S2 = 0;
		                for (; USDCHF_OCO1S2_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets2.Count; USDCHF_OCO1S2_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO1Sets2[USDCHF_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO1Sets2[USDCHF_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_2__Time out_OCO1");
		                        Base.USDCHF_UP_S2_OCO1Sets2.Clear();
		                        USDCHF_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO1S3_UP_S2 = 0;
		                for (; USDCHF_OCO1S3_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets3.Count; USDCHF_OCO1S3_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO1Sets3[USDCHF_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO1Sets3[USDCHF_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_3__Time out_OCO1");
		                        Base.USDCHF_UP_S2_OCO1Sets3.Clear();
		                        USDCHF_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO1S4_UP_S2 = 0;
		                for (; USDCHF_OCO1S4_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets4.Count; USDCHF_OCO1S4_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO1Sets4[USDCHF_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO1Sets4[USDCHF_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_4__Time out_OCO1");
		                        Base.USDCHF_UP_S2_OCO1Sets4.Clear();
		                        USDCHF_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO1S5_UP_S2 = 0;
		                for (; USDCHF_OCO1S5_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets5.Count; USDCHF_OCO1S5_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO1Sets5[USDCHF_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO1Sets5[USDCHF_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_5__Time out_OCO1");
		                        Base.USDCHF_UP_S2_OCO1Sets5.Clear();
		                        USDCHF_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO1S6_UP_S2 = 0;
		                for (; USDCHF_OCO1S6_UP_S2 < Base.USDCHF_UP_S2_OCO1Sets6.Count; USDCHF_OCO1S6_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO1Sets6[USDCHF_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO1Sets6[USDCHF_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_6__Time out_OCO1");
		                        Base.USDCHF_UP_S2_OCO1Sets6.Clear();
		                        USDCHF_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.USDCHF_OCO2_EO1_UP_S2)
                	Base.USDCHF_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.USDCHF_OCO2_EO2_UP_S2)
	                Base.USDCHF_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO2_EO3_UP_S2)
	                Base.USDCHF_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO2_EO4_UP_S2)
	                Base.USDCHF_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO2_EO5_UP_S2)
	                Base.USDCHF_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO2_EO6_UP_S2)
	                Base.USDCHF_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCHF_OCO2S1_UP_S2 = 0;
		                for (; USDCHF_OCO2S1_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets1.Count; USDCHF_OCO2S1_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO2Sets1[USDCHF_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO2Sets1[USDCHF_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_1__Time out_OCO2");
		                        Base.USDCHF_UP_S2_OCO2Sets1.Clear();
		                        USDCHF_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDCHF_OCO2S2_UP_S2 = 0;
		                for (; USDCHF_OCO2S2_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets2.Count; USDCHF_OCO2S2_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO2Sets2[USDCHF_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO2Sets2[USDCHF_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_2__Time out_OCO2");
		                        Base.USDCHF_UP_S2_OCO2Sets2.Clear();
		                        USDCHF_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO2S3_UP_S2 = 0;
		                for (; USDCHF_OCO2S3_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets3.Count; USDCHF_OCO2S3_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO2Sets3[USDCHF_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO2Sets3[USDCHF_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_3__Time out_OCO2");
		                        Base.USDCHF_UP_S2_OCO2Sets3.Clear();
		                        USDCHF_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO2S4_UP_S2 = 0;
		                for (; USDCHF_OCO2S4_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets4.Count; USDCHF_OCO2S4_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO2Sets4[USDCHF_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO2Sets4[USDCHF_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_4__Time out_OCO2");
		                        Base.USDCHF_UP_S2_OCO2Sets4.Clear();
		                        USDCHF_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO2S5_UP_S2 = 0;
		                for (; USDCHF_OCO2S5_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets5.Count; USDCHF_OCO2S5_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO2Sets5[USDCHF_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO2Sets5[USDCHF_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_5__Time out_OCO2");
		                        Base.USDCHF_UP_S2_OCO2Sets5.Clear();
		                        USDCHF_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO2S6_UP_S2 = 0;
		                for (; USDCHF_OCO2S6_UP_S2 < Base.USDCHF_UP_S2_OCO2Sets6.Count; USDCHF_OCO2S6_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO2Sets6[USDCHF_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO2Sets6[USDCHF_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_6__Time out_OCO2");
		                        Base.USDCHF_UP_S2_OCO2Sets6.Clear();
		                        USDCHF_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.USDCHF_OCO3_EO1_UP_S2)
            		Base.USDCHF_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.USDCHF_OCO3_EO2_UP_S2)
	                Base.USDCHF_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO3_EO3_UP_S2)
	                Base.USDCHF_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO3_EO4_UP_S2)
	                Base.USDCHF_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO3_EO5_UP_S2)
	                Base.USDCHF_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO3_EO6_UP_S2)
	                Base.USDCHF_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCHF_OCO3S1_UP_S2 = 0;
		                for (; USDCHF_OCO3S1_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets1.Count; USDCHF_OCO3S1_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO3Sets1[USDCHF_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO3Sets1[USDCHF_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_1__Time out_OCO3");
		                        Base.USDCHF_UP_S2_OCO3Sets1.Clear();
		                        USDCHF_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDCHF_OCO3S2_UP_S2 = 0;
		                for (; USDCHF_OCO3S2_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets2.Count; USDCHF_OCO3S2_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO3Sets2[USDCHF_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO3Sets2[USDCHF_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_2__Time out_OCO3");
		                        Base.USDCHF_UP_S2_OCO3Sets2.Clear();
		                        USDCHF_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO3S3_UP_S2 = 0;
		                for (; USDCHF_OCO3S3_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets3.Count; USDCHF_OCO3S3_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO3Sets3[USDCHF_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO3Sets3[USDCHF_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_3__Time out_OCO3");
		                        Base.USDCHF_UP_S2_OCO3Sets3.Clear();
		                        USDCHF_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO3S4_UP_S2 = 0;
		                for (; USDCHF_OCO3S4_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets4.Count; USDCHF_OCO3S4_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO3Sets4[USDCHF_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO3Sets4[USDCHF_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_4__Time out_OCO3");
		                        Base.USDCHF_UP_S2_OCO3Sets4.Clear();
		                        USDCHF_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO3S5_UP_S2 = 0;
		                for (; USDCHF_OCO3S5_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets5.Count; USDCHF_OCO3S5_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO3Sets5[USDCHF_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO3Sets5[USDCHF_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_5__Time out_OCO3");
		                        Base.USDCHF_UP_S2_OCO3Sets5.Clear();
		                        USDCHF_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO3S6_UP_S2 = 0;
		                for (; USDCHF_OCO3S6_UP_S2 < Base.USDCHF_UP_S2_OCO3Sets6.Count; USDCHF_OCO3S6_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO3Sets6[USDCHF_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO3Sets6[USDCHF_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_6__Time out_OCO3");
		                        Base.USDCHF_UP_S2_OCO3Sets6.Clear();
		                        USDCHF_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDCHF_OCO4_EO1_UP_S2)
            		Base.USDCHF_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.USDCHF_OCO4_EO2_UP_S2)
	                Base.USDCHF_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO4_EO3_UP_S2)
	                Base.USDCHF_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO4_EO4_UP_S2)
	                Base.USDCHF_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO4_EO5_UP_S2)
	                Base.USDCHF_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDCHF_OCO4_EO6_UP_S2)
	                Base.USDCHF_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDCHF_OCO4S1_UP_S2 = 0;
		                for (; USDCHF_OCO4S1_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets1.Count; USDCHF_OCO4S1_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO4Sets1[USDCHF_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO4Sets1[USDCHF_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_1__Time out_OCO4");
		                        Base.USDCHF_UP_S2_OCO4Sets1.Clear();
		                        USDCHF_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDCHF_OCO4S2_UP_S2 = 0;
		                for (; USDCHF_OCO4S2_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets2.Count; USDCHF_OCO4S2_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO4Sets2[USDCHF_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO4Sets2[USDCHF_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_2__Time out_OCO4");
		                        Base.USDCHF_UP_S2_OCO4Sets2.Clear();
		                        USDCHF_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO4S3_UP_S2 = 0;
		                for (; USDCHF_OCO4S3_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets3.Count; USDCHF_OCO4S3_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO4Sets3[USDCHF_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO4Sets3[USDCHF_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_3__Time out_OCO4");
		                        Base.USDCHF_UP_S2_OCO4Sets3.Clear();
		                        USDCHF_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDCHF_OCO4S4_UP_S2 = 0;
		                for (; USDCHF_OCO4S4_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets4.Count; USDCHF_OCO4S4_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO4Sets4[USDCHF_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO4Sets4[USDCHF_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_4__Time out_OCO4");
		                        Base.USDCHF_UP_S2_OCO4Sets4.Clear();
		                        USDCHF_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO4S5_UP_S2 = 0;
		                for (; USDCHF_OCO4S5_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets5.Count; USDCHF_OCO4S5_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO4Sets5[USDCHF_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO4Sets5[USDCHF_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_5__Time out_OCO4");
		                        Base.USDCHF_UP_S2_OCO4Sets5.Clear();
		                        USDCHF_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDCHF_OCO4S6_UP_S2 = 0;
		                for (; USDCHF_OCO4S6_UP_S2 < Base.USDCHF_UP_S2_OCO4Sets6.Count; USDCHF_OCO4S6_UP_S2++)
		                    if (Base.USDCHF_UP_S2_OCO4Sets6[USDCHF_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDCHF_UP_S2_OCO4Sets6[USDCHF_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("USDCHF", order.Quantity, false, "USDCHF_UP_S2_Entry_6__Time out_OCO4");
		                        Base.USDCHF_UP_S2_OCO4Sets6.Clear();
		                        USDCHF_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_USDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_USDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_USDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_USDCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_USDCHF_UP_S2 = DOWM_USDCHF_UP_S2 || DOWT_USDCHF_UP_S2 || DOWW_USDCHF_UP_S2 || DOWTH_USDCHF_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("USDCHF"))
	            	{
	            		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.USDCHF_OCO1_UP_S2_IsReady == false ||
	                    	Base.USDCHF_OCO2_UP_S2_IsReady == false ||
	                    	Base.USDCHF_OCO3_UP_S2_IsReady == false ||
	                    	Base.USDCHF_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.USDCHF_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.USDCHF_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.USDCHF_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.USDCHF_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.USDCHF_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.USDCHF_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.USDCHF_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.USDCHF_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	USDCHF_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.382m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.382m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                							
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	USDCHF_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.5m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.5m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	USDCHF_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
		
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.618m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.618m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (USDCHF_Signal_Condition_UP_1)
	                	{
	                    	USDCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (USDCHF_Signal_Condition_UP_2)
	                	{
	                    	USDCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (USDCHF_Signal_Condition_UP_3)
	                	{
	                    	USDCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (USDCHF_Signal_Condition_UP_1)
	                	{
	                    	USDCHF_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (USDCHF_Signal_Condition_UP_2)
	                	{
	                    	USDCHF_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (USDCHF_Signal_Condition_UP_3)
	                	{
	                    	USDCHF_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    USDCHF_UP_S2_TP2 =  USDCHF_UP_S2_SL * 0;
	                    USDCHF_UP_S2_TP3 =  USDCHF_UP_S2_SL * 0;
	                    USDCHF_UP_S2_TP4 =  USDCHF_UP_S2_SL * 0;
	                    USDCHF_UP_S2_TP5 =  USDCHF_UP_S2_SL * 0;
	                    USDCHF_UP_S2_TP6 =  USDCHF_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    USDCHF_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    USDCHF_quantity_SL_UP_S2 = USDCHF_quantity_UP_S2;
	                    USDCHF_quantity_TP1_UP_S2 = (int)Math.Floor(USDCHF_quantity_UP_S2 * 1m);
	                    USDCHF_quantity_TP2_UP_S2 = (int)Math.Floor(USDCHF_quantity_TP1_UP_S2 * 0m);
	                    USDCHF_quantity_TP3_UP_S2 = (int)Math.Floor(USDCHF_quantity_TP2_UP_S2 * 0m);
	                    USDCHF_quantity_TP4_UP_S2 = (int)Math.Floor(USDCHF_quantity_TP3_UP_S2 * 0m);
	                    USDCHF_quantity_TP5_UP_S2 = (int)Math.Floor(USDCHF_quantity_TP4_UP_S2 * 0m);
	                    USDCHF_quantity_TP6_UP_S2 = (int)Math.Floor(USDCHF_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((USDCHF_Signal_Condition_UP_1 || USDCHF_Signal_Condition_UP_2 || USDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_USDCHF_UP_S2 && 
	                    Base.USDCHF_OCO1_UP_S2_IsReady == true &&
	                    Base.USDCHF_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCHF_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP1_UP_S2, false,"USDCHF_UP_S2_Entry_TP1_OCO1");
	                         Base.USDCHF_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.USDCHF_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP2_UP_S2, false,"USDCHF_UP_S2_Entry_TP2_OCO1");
	                         Base.USDCHF_OCO1_EO2_UP_S2 = false;
	
	                         Base.USDCHF_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP3_UP_S2, false,"USDCHF_UP_S2_Entry_TP3_OCO1");
	                         Base.USDCHF_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.USDCHF_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP4_UP_S2, false,"USDCHF_UP_S2_Entry_TP4_OCO1");
	                         Base.USDCHF_OCO1_EO4_UP_S2 = false;

							Base.USDCHF_OCO1_UP_S2_IsReady = false;
							
							if (Base.USDCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((USDCHF_Signal_Condition_UP_1 || USDCHF_Signal_Condition_UP_2 || USDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_USDCHF_UP_S2 && 
	                    Base.USDCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.USDCHF_OCO2_UP_S2_IsReady == true &&
	                    Base.USDCHF_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCHF_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP1_UP_S2, false,"USDCHF_UP_S2_Entry_TP1_OCO2");
	                         Base.USDCHF_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.USDCHF_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP2_UP_S2, false,"USDCHF_UP_S2_Entry_TP2_OCO2");
	                         Base.USDCHF_OCO2_EO2_UP_S2 = false;
	
	                         Base.USDCHF_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP3_UP_S2, false,"USDCHF_UP_S2_Entry_TP3_OCO2");
	                         Base.USDCHF_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.USDCHF_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP4_UP_S2, false,"USDCHF_UP_S2_Entry_TP4_OCO2");
	                         Base.USDCHF_OCO2_EO4_UP_S2 = false;

							Base.USDCHF_OCO2_UP_S2_IsReady = false;
							
							if (Base.USDCHF_OCO2_UP_S2_IsReady == false && Base.USDCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((USDCHF_Signal_Condition_UP_1 || USDCHF_Signal_Condition_UP_2 || USDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_USDCHF_UP_S2 &&
	                    Base.USDCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.USDCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.USDCHF_OCO3_UP_S2_IsReady == true &&
	                    Base.USDCHF_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCHF_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP1_UP_S2, false,"USDCHF_UP_S2_Entry_TP1_OCO3");
	                         Base.USDCHF_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.USDCHF_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP2_UP_S2, false,"USDCHF_UP_S2_Entry_TP2_OCO3");
	                         Base.USDCHF_OCO3_EO2_UP_S2 = false;
	
	                         Base.USDCHF_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP3_UP_S2, false,"USDCHF_UP_S2_Entry_TP3_OCO3");
	                         Base.USDCHF_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.USDCHF_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP4_UP_S2, false,"USDCHF_UP_S2_Entry_TP4_OCO3");
	                         Base.USDCHF_OCO3_EO4_UP_S2 = false;

							Base.USDCHF_OCO3_UP_S2_IsReady = false;
							
							if (Base.USDCHF_OCO3_UP_S2_IsReady == false && Base.USDCHF_OCO2_UP_S2_IsReady == false && Base.USDCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((USDCHF_Signal_Condition_UP_1 || USDCHF_Signal_Condition_UP_2 || USDCHF_Signal_Condition_UP_3)  && 
	                    DOWR_USDCHF_UP_S2 && 
	                    Base.USDCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.USDCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.USDCHF_OCO3_UP_S2_IsReady == false &&
	                    Base.USDCHF_OCO4_UP_S2_IsReady == true &&
	                    Base.USDCHF_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDCHF_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP1_UP_S2, false,"USDCHF_UP_S2_Entry_TP1_OCO4");
	                         Base.USDCHF_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.USDCHF_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP2_UP_S2, false,"USDCHF_UP_S2_Entry_TP2_OCO4");
	                         Base.USDCHF_OCO4_EO2_UP_S2 = false;
	
	                         Base.USDCHF_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP3_UP_S2, false,"USDCHF_UP_S2_Entry_TP3_OCO4");
	                         Base.USDCHF_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.USDCHF_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDCHF_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDCHF_quantity_TP4_UP_S2, false,"USDCHF_UP_S2_Entry_TP4_OCO4");
	                         Base.USDCHF_OCO4_EO4_UP_S2 = false;

							Base.USDCHF_OCO4_UP_S2_IsReady = false;
							
							if (Base.USDCHF_OCO4_UP_S2_IsReady == false && Base.USDCHF_OCO3_UP_S2_IsReady == false && Base.USDCHF_OCO2_UP_S2_IsReady == false && Base.USDCHF_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.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 USDJPY_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public USDJPY_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("USDJPY OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDJPY OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDJPY OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDJPY OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDJPY OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDJPY OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDJPY OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("USDJPY OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("USDJPY OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDJPY S2");
		        	}
		        }
		        
				if (Base.USDJPY_OCO1_EO1_UP_S2)
	                Base.USDJPY_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDJPY_OCO1_EO2_UP_S2)
	                Base.USDJPY_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO1_EO3_UP_S2)
	                Base.USDJPY_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO1_EO4_UP_S2)
	                Base.USDJPY_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO1_EO5_UP_S2)
	                Base.USDJPY_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO1_EO6_UP_S2)
	                Base.USDJPY_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDJPY_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.USDJPY_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP1,"TP1_USDJPY_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP1_USDJPY_UP_S2_OCO1"));
		                 };
		                Base.USDJPY_UP_S2_OCO1Sets1.Add( Base.USDJPY_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDJPY_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP2,"TP2_USDJPY_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP2_USDJPY_UP_S2_OCO1"));
		                 };
	                    Base.USDJPY_UP_S2_OCO1Sets2.Add( Base.USDJPY_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP3,"TP3_USDJPY_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP3_USDJPY_UP_S2_OCO1"));
		                 };
	                    Base.USDJPY_UP_S2_OCO1Sets3.Add( Base.USDJPY_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP4,"TP4_USDJPY_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP4_USDJPY_UP_S2_OCO1"));
		                 };
	                    Base.USDJPY_UP_S2_OCO1Sets4.Add( Base.USDJPY_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP5,"TP5_USDJPY_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP5_USDJPY_UP_S2_OCO1"));
		                 };
	                    Base.USDJPY_UP_S2_OCO1Sets5.Add( Base.USDJPY_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP6,"TP6_USDJPY_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP6_USDJPY_UP_S2_OCO1"));
		                 };
	                    Base.USDJPY_UP_S2_OCO1Sets6.Add( Base.USDJPY_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDJPY_OCO1S1_UP_S2 = 0;
	                for (; USDJPY_OCO1S1_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets1.Count; USDJPY_OCO1S1_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO1Sets1[USDJPY_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO1Sets1[USDJPY_OCO1S1_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO1Sets1.RemoveAt(USDJPY_OCO1S1_UP_S2);
	                        USDJPY_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDJPY_OCO1S2_UP_S2 = 0;
	                for (; USDJPY_OCO1S2_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets2.Count; USDJPY_OCO1S2_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO1Sets2[USDJPY_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO1Sets2[USDJPY_OCO1S2_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO1Sets2.RemoveAt(USDJPY_OCO1S2_UP_S2);
	                        USDJPY_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO1S3_UP_S2 = 0;
	                for (; USDJPY_OCO1S3_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets3.Count; USDJPY_OCO1S3_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO1Sets3[USDJPY_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO1Sets3[USDJPY_OCO1S3_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO1Sets3.RemoveAt(USDJPY_OCO1S3_UP_S2);
	                        USDJPY_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO1S4_UP_S2 = 0;
	                for (; USDJPY_OCO1S4_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets4.Count; USDJPY_OCO1S4_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO1Sets4[USDJPY_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO1Sets4[USDJPY_OCO1S4_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO1Sets4.RemoveAt(USDJPY_OCO1S4_UP_S2);
	                        USDJPY_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDJPY_OCO1S5_UP_S2 = 0;
	                for (; USDJPY_OCO1S5_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets5.Count; USDJPY_OCO1S5_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO1Sets5[USDJPY_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO1Sets5[USDJPY_OCO1S5_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO1Sets5.RemoveAt(USDJPY_OCO1S5_UP_S2);
	                        USDJPY_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDJPY_OCO1S6_UP_S2 = 0;
	                for (; USDJPY_OCO1S6_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets6.Count; USDJPY_OCO1S6_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO1Sets6[USDJPY_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO1Sets6[USDJPY_OCO1S6_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO1Sets6.RemoveAt(USDJPY_OCO1S6_UP_S2);
	                        USDJPY_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.USDJPY_OCO2_EO1_UP_S2)
	                Base.USDJPY_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDJPY_OCO2_EO2_UP_S2)
	                Base.USDJPY_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO2_EO3_UP_S2)
	                Base.USDJPY_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO2_EO4_UP_S2)
	                Base.USDJPY_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO2_EO5_UP_S2)
	                Base.USDJPY_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO2_EO6_UP_S2)
	                Base.USDJPY_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDJPY_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.USDJPY_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP1,"TP1_USDJPY_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP1_USDJPY_UP_S2_OCO2"));
		                 };
		                Base.USDJPY_UP_S2_OCO2Sets1.Add( Base.USDJPY_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDJPY_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP2,"TP2_USDJPY_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP2_USDJPY_UP_S2_OCO2"));
		                 };
	                    Base.USDJPY_UP_S2_OCO2Sets2.Add( Base.USDJPY_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP3,"TP3_USDJPY_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP3_USDJPY_UP_S2_OCO2"));
		                 };
	                    Base.USDJPY_UP_S2_OCO2Sets3.Add( Base.USDJPY_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP4,"TP4_USDJPY_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP4_USDJPY_UP_S2_OCO2"));
		                 };
	                    Base.USDJPY_UP_S2_OCO2Sets4.Add( Base.USDJPY_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP5,"TP5_USDJPY_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP5_USDJPY_UP_S2_OCO2"));
		                 };
	                    Base.USDJPY_UP_S2_OCO2Sets5.Add( Base.USDJPY_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP6,"TP6_USDJPY_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP6_USDJPY_UP_S2_OCO2"));
		                 };
	                    Base.USDJPY_UP_S2_OCO2Sets6.Add( Base.USDJPY_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDJPY_OCO2S1_UP_S2 = 0;
	                for (; USDJPY_OCO2S1_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets1.Count; USDJPY_OCO2S1_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO2Sets1[USDJPY_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO2Sets1[USDJPY_OCO2S1_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO2Sets1.RemoveAt(USDJPY_OCO2S1_UP_S2);
	                        USDJPY_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDJPY_OCO2S2_UP_S2 = 0;
	                for (; USDJPY_OCO2S2_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets2.Count; USDJPY_OCO2S2_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO2Sets2[USDJPY_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO2Sets2[USDJPY_OCO2S2_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO2Sets2.RemoveAt(USDJPY_OCO2S2_UP_S2);
	                        USDJPY_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO2S3_UP_S2 = 0;
	                for (; USDJPY_OCO2S3_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets3.Count; USDJPY_OCO2S3_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO2Sets3[USDJPY_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO2Sets3[USDJPY_OCO2S3_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO2Sets3.RemoveAt(USDJPY_OCO2S3_UP_S2);
	                        USDJPY_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO2S4_UP_S2 = 0;
	                for (; USDJPY_OCO2S4_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets4.Count; USDJPY_OCO2S4_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO2Sets4[USDJPY_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO2Sets4[USDJPY_OCO2S4_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO2Sets4.RemoveAt(USDJPY_OCO2S4_UP_S2);
	                        USDJPY_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDJPY_OCO2S5_UP_S2 = 0;
	                for (; USDJPY_OCO2S5_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets5.Count; USDJPY_OCO2S5_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO2Sets5[USDJPY_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO2Sets5[USDJPY_OCO2S5_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO2Sets5.RemoveAt(USDJPY_OCO2S5_UP_S2);
	                        USDJPY_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDJPY_OCO2S6_UP_S2 = 0;
	                for (; USDJPY_OCO2S6_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets6.Count; USDJPY_OCO2S6_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO2Sets6[USDJPY_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO2Sets6[USDJPY_OCO2S6_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO2Sets6.RemoveAt(USDJPY_OCO2S6_UP_S2);
	                        USDJPY_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDJPY_OCO3_EO1_UP_S2)
	                Base.USDJPY_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDJPY_OCO3_EO2_UP_S2)
	                Base.USDJPY_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO3_EO3_UP_S2)
	                Base.USDJPY_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO3_EO4_UP_S2)
	                Base.USDJPY_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO3_EO5_UP_S2)
	                Base.USDJPY_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO3_EO6_UP_S2)
	                Base.USDJPY_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDJPY_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.USDJPY_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP1,"TP1_USDJPY_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP1_USDJPY_UP_S2_OCO3"));
		                 };
		                Base.USDJPY_UP_S2_OCO3Sets1.Add( Base.USDJPY_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDJPY_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP2,"TP2_USDJPY_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP2_USDJPY_UP_S2_OCO3"));
		                 };
	                    Base.USDJPY_UP_S2_OCO3Sets2.Add( Base.USDJPY_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP3,"TP3_USDJPY_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP3_USDJPY_UP_S2_OCO3"));
		                 };
	                    Base.USDJPY_UP_S2_OCO3Sets3.Add( Base.USDJPY_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP4,"TP4_USDJPY_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP4_USDJPY_UP_S2_OCO3"));
		                 };
	                    Base.USDJPY_UP_S2_OCO3Sets4.Add( Base.USDJPY_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP5,"TP5_USDJPY_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP5_USDJPY_UP_S2_OCO3"));
		                 };
	                    Base.USDJPY_UP_S2_OCO3Sets5.Add( Base.USDJPY_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP6,"TP6_USDJPY_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP6_USDJPY_UP_S2_OCO3"));
		                 };
	                    Base.USDJPY_UP_S2_OCO3Sets6.Add( Base.USDJPY_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDJPY_OCO3S1_UP_S2 = 0;
	                for (; USDJPY_OCO3S1_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets1.Count; USDJPY_OCO3S1_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO3Sets1[USDJPY_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO3Sets1[USDJPY_OCO3S1_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO3Sets1.RemoveAt(USDJPY_OCO3S1_UP_S2);
	                        USDJPY_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDJPY_OCO3S2_UP_S2 = 0;
	                for (; USDJPY_OCO3S2_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets2.Count; USDJPY_OCO3S2_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO3Sets2[USDJPY_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO3Sets2[USDJPY_OCO3S2_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO3Sets2.RemoveAt(USDJPY_OCO3S2_UP_S2);
	                        USDJPY_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO3S3_UP_S2 = 0;
	                for (; USDJPY_OCO3S3_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets3.Count; USDJPY_OCO3S3_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO3Sets3[USDJPY_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO3Sets3[USDJPY_OCO3S3_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO3Sets3.RemoveAt(USDJPY_OCO3S3_UP_S2);
	                        USDJPY_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO3S4_UP_S2 = 0;
	                for (; USDJPY_OCO3S4_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets4.Count; USDJPY_OCO3S4_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO3Sets4[USDJPY_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO3Sets4[USDJPY_OCO3S4_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO3Sets4.RemoveAt(USDJPY_OCO3S4_UP_S2);
	                        USDJPY_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDJPY_OCO3S5_UP_S2 = 0;
	                for (; USDJPY_OCO3S5_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets5.Count; USDJPY_OCO3S5_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO3Sets5[USDJPY_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO3Sets5[USDJPY_OCO3S5_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO3Sets5.RemoveAt(USDJPY_OCO3S5_UP_S2);
	                        USDJPY_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDJPY_OCO3S6_UP_S2 = 0;
	                for (; USDJPY_OCO3S6_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets6.Count; USDJPY_OCO3S6_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO3Sets6[USDJPY_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO3Sets6[USDJPY_OCO3S6_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO3Sets6.RemoveAt(USDJPY_OCO3S6_UP_S2);
	                        USDJPY_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDJPY_OCO4_EO1_UP_S2)
	                Base.USDJPY_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDJPY_OCO4_EO2_UP_S2)
	                Base.USDJPY_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO4_EO3_UP_S2)
	                Base.USDJPY_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO4_EO4_UP_S2)
	                Base.USDJPY_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO4_EO5_UP_S2)
	                Base.USDJPY_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDJPY_OCO4_EO6_UP_S2)
	                Base.USDJPY_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDJPY_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.USDJPY_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP1,"TP1_USDJPY_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP1_USDJPY_UP_S2_OCO4"));
		                 };
		                Base.USDJPY_UP_S2_OCO4Sets1.Add( Base.USDJPY_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDJPY_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP2,"TP2_USDJPY_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP2_USDJPY_UP_S2_OCO4"));
		                 };
	                    Base.USDJPY_UP_S2_OCO4Sets2.Add( Base.USDJPY_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP3,"TP3_USDJPY_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP3_USDJPY_UP_S2_OCO4"));
		                 };
	                    Base.USDJPY_UP_S2_OCO4Sets3.Add( Base.USDJPY_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP4,"TP4_USDJPY_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP4_USDJPY_UP_S2_OCO4"));
		                 };
	                    Base.USDJPY_UP_S2_OCO4Sets4.Add( Base.USDJPY_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP5,"TP5_USDJPY_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP5_USDJPY_UP_S2_OCO4"));
		                 };
	                    Base.USDJPY_UP_S2_OCO4Sets5.Add( Base.USDJPY_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDJPY_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.USDJPY_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDJPY_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDJPY_UP_S2_TP6,"TP6_USDJPY_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDJPY_UP_S2_SL,"SL_TP6_USDJPY_UP_S2_OCO4"));
		                 };
	                    Base.USDJPY_UP_S2_OCO4Sets6.Add( Base.USDJPY_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDJPY_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDJPY_OCO4S1_UP_S2 = 0;
	                for (; USDJPY_OCO4S1_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets1.Count; USDJPY_OCO4S1_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO4Sets1[USDJPY_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO4Sets1[USDJPY_OCO4S1_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO4Sets1.RemoveAt(USDJPY_OCO4S1_UP_S2);
	                        USDJPY_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDJPY_OCO4S2_UP_S2 = 0;
	                for (; USDJPY_OCO4S2_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets2.Count; USDJPY_OCO4S2_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO4Sets2[USDJPY_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO4Sets2[USDJPY_OCO4S2_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO4Sets2.RemoveAt(USDJPY_OCO4S2_UP_S2);
	                        USDJPY_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO4S3_UP_S2 = 0;
	                for (; USDJPY_OCO4S3_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets3.Count; USDJPY_OCO4S3_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO4Sets3[USDJPY_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO4Sets3[USDJPY_OCO4S3_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO4Sets3.RemoveAt(USDJPY_OCO4S3_UP_S2);
	                        USDJPY_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDJPY_OCO4S4_UP_S2 = 0;
	                for (; USDJPY_OCO4S4_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets4.Count; USDJPY_OCO4S4_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO4Sets4[USDJPY_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO4Sets4[USDJPY_OCO4S4_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO4Sets4.RemoveAt(USDJPY_OCO4S4_UP_S2);
	                        USDJPY_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDJPY_OCO4S5_UP_S2 = 0;
	                for (; USDJPY_OCO4S5_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets5.Count; USDJPY_OCO4S5_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO4Sets5[USDJPY_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO4Sets5[USDJPY_OCO4S5_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO4Sets5.RemoveAt(USDJPY_OCO4S5_UP_S2);
	                        USDJPY_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDJPY_OCO4S6_UP_S2 = 0;
	                for (; USDJPY_OCO4S6_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets6.Count; USDJPY_OCO4S6_UP_S2++)
	                    if (Base.USDJPY_UP_S2_OCO4Sets6[USDJPY_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDJPY_UP_S2_OCO4Sets6[USDJPY_OCO4S6_UP_S2].Filled();
	                        Base.USDJPY_UP_S2_OCO4Sets6.RemoveAt(USDJPY_OCO4S6_UP_S2);
	                        USDJPY_OCO4S6_UP_S2 = 0;
	                        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.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 USDCAD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public USDCAD_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("USDCAD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCAD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCAD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCAD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCAD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCAD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCAD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        }
		        
				if (Base.USDCAD_OCO1_EO1_UP_S2)
	                Base.USDCAD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDCAD_OCO1_EO2_UP_S2)
	                Base.USDCAD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO1_EO3_UP_S2)
	                Base.USDCAD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO1_EO4_UP_S2)
	                Base.USDCAD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO1_EO5_UP_S2)
	                Base.USDCAD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO1_EO6_UP_S2)
	                Base.USDCAD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCAD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.USDCAD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP1,"TP1_USDCAD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP1_USDCAD_UP_S2_OCO1"));
		                 };
		                Base.USDCAD_UP_S2_OCO1Sets1.Add( Base.USDCAD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCAD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP2,"TP2_USDCAD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP2_USDCAD_UP_S2_OCO1"));
		                 };
	                    Base.USDCAD_UP_S2_OCO1Sets2.Add( Base.USDCAD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP3,"TP3_USDCAD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP3_USDCAD_UP_S2_OCO1"));
		                 };
	                    Base.USDCAD_UP_S2_OCO1Sets3.Add( Base.USDCAD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP4,"TP4_USDCAD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP4_USDCAD_UP_S2_OCO1"));
		                 };
	                    Base.USDCAD_UP_S2_OCO1Sets4.Add( Base.USDCAD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP5,"TP5_USDCAD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP5_USDCAD_UP_S2_OCO1"));
		                 };
	                    Base.USDCAD_UP_S2_OCO1Sets5.Add( Base.USDCAD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP6,"TP6_USDCAD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP6_USDCAD_UP_S2_OCO1"));
		                 };
	                    Base.USDCAD_UP_S2_OCO1Sets6.Add( Base.USDCAD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDCAD_OCO1S1_UP_S2 = 0;
	                for (; USDCAD_OCO1S1_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets1.Count; USDCAD_OCO1S1_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO1Sets1[USDCAD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO1Sets1[USDCAD_OCO1S1_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO1Sets1.RemoveAt(USDCAD_OCO1S1_UP_S2);
	                        USDCAD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDCAD_OCO1S2_UP_S2 = 0;
	                for (; USDCAD_OCO1S2_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets2.Count; USDCAD_OCO1S2_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO1Sets2[USDCAD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO1Sets2[USDCAD_OCO1S2_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO1Sets2.RemoveAt(USDCAD_OCO1S2_UP_S2);
	                        USDCAD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO1S3_UP_S2 = 0;
	                for (; USDCAD_OCO1S3_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets3.Count; USDCAD_OCO1S3_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO1Sets3[USDCAD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO1Sets3[USDCAD_OCO1S3_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO1Sets3.RemoveAt(USDCAD_OCO1S3_UP_S2);
	                        USDCAD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO1S4_UP_S2 = 0;
	                for (; USDCAD_OCO1S4_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets4.Count; USDCAD_OCO1S4_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO1Sets4[USDCAD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO1Sets4[USDCAD_OCO1S4_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO1Sets4.RemoveAt(USDCAD_OCO1S4_UP_S2);
	                        USDCAD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCAD_OCO1S5_UP_S2 = 0;
	                for (; USDCAD_OCO1S5_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets5.Count; USDCAD_OCO1S5_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO1Sets5[USDCAD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO1Sets5[USDCAD_OCO1S5_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO1Sets5.RemoveAt(USDCAD_OCO1S5_UP_S2);
	                        USDCAD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCAD_OCO1S6_UP_S2 = 0;
	                for (; USDCAD_OCO1S6_UP_S2 < Base.USDCAD_UP_S2_OCO1Sets6.Count; USDCAD_OCO1S6_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO1Sets6[USDCAD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO1Sets6[USDCAD_OCO1S6_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO1Sets6.RemoveAt(USDCAD_OCO1S6_UP_S2);
	                        USDCAD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.USDCAD_OCO2_EO1_UP_S2)
	                Base.USDCAD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDCAD_OCO2_EO2_UP_S2)
	                Base.USDCAD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO2_EO3_UP_S2)
	                Base.USDCAD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO2_EO4_UP_S2)
	                Base.USDCAD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO2_EO5_UP_S2)
	                Base.USDCAD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO2_EO6_UP_S2)
	                Base.USDCAD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCAD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.USDCAD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP1,"TP1_USDCAD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP1_USDCAD_UP_S2_OCO2"));
		                 };
		                Base.USDCAD_UP_S2_OCO2Sets1.Add( Base.USDCAD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCAD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP2,"TP2_USDCAD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP2_USDCAD_UP_S2_OCO2"));
		                 };
	                    Base.USDCAD_UP_S2_OCO2Sets2.Add( Base.USDCAD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP3,"TP3_USDCAD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP3_USDCAD_UP_S2_OCO2"));
		                 };
	                    Base.USDCAD_UP_S2_OCO2Sets3.Add( Base.USDCAD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP4,"TP4_USDCAD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP4_USDCAD_UP_S2_OCO2"));
		                 };
	                    Base.USDCAD_UP_S2_OCO2Sets4.Add( Base.USDCAD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP5,"TP5_USDCAD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP5_USDCAD_UP_S2_OCO2"));
		                 };
	                    Base.USDCAD_UP_S2_OCO2Sets5.Add( Base.USDCAD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP6,"TP6_USDCAD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP6_USDCAD_UP_S2_OCO2"));
		                 };
	                    Base.USDCAD_UP_S2_OCO2Sets6.Add( Base.USDCAD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDCAD_OCO2S1_UP_S2 = 0;
	                for (; USDCAD_OCO2S1_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets1.Count; USDCAD_OCO2S1_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO2Sets1[USDCAD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO2Sets1[USDCAD_OCO2S1_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO2Sets1.RemoveAt(USDCAD_OCO2S1_UP_S2);
	                        USDCAD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDCAD_OCO2S2_UP_S2 = 0;
	                for (; USDCAD_OCO2S2_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets2.Count; USDCAD_OCO2S2_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO2Sets2[USDCAD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO2Sets2[USDCAD_OCO2S2_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO2Sets2.RemoveAt(USDCAD_OCO2S2_UP_S2);
	                        USDCAD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO2S3_UP_S2 = 0;
	                for (; USDCAD_OCO2S3_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets3.Count; USDCAD_OCO2S3_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO2Sets3[USDCAD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO2Sets3[USDCAD_OCO2S3_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO2Sets3.RemoveAt(USDCAD_OCO2S3_UP_S2);
	                        USDCAD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO2S4_UP_S2 = 0;
	                for (; USDCAD_OCO2S4_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets4.Count; USDCAD_OCO2S4_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO2Sets4[USDCAD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO2Sets4[USDCAD_OCO2S4_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO2Sets4.RemoveAt(USDCAD_OCO2S4_UP_S2);
	                        USDCAD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCAD_OCO2S5_UP_S2 = 0;
	                for (; USDCAD_OCO2S5_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets5.Count; USDCAD_OCO2S5_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO2Sets5[USDCAD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO2Sets5[USDCAD_OCO2S5_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO2Sets5.RemoveAt(USDCAD_OCO2S5_UP_S2);
	                        USDCAD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCAD_OCO2S6_UP_S2 = 0;
	                for (; USDCAD_OCO2S6_UP_S2 < Base.USDCAD_UP_S2_OCO2Sets6.Count; USDCAD_OCO2S6_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO2Sets6[USDCAD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO2Sets6[USDCAD_OCO2S6_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO2Sets6.RemoveAt(USDCAD_OCO2S6_UP_S2);
	                        USDCAD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCAD_OCO3_EO1_UP_S2)
	                Base.USDCAD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDCAD_OCO3_EO2_UP_S2)
	                Base.USDCAD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO3_EO3_UP_S2)
	                Base.USDCAD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO3_EO4_UP_S2)
	                Base.USDCAD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO3_EO5_UP_S2)
	                Base.USDCAD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO3_EO6_UP_S2)
	                Base.USDCAD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCAD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.USDCAD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP1,"TP1_USDCAD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP1_USDCAD_UP_S2_OCO3"));
		                 };
		                Base.USDCAD_UP_S2_OCO3Sets1.Add( Base.USDCAD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCAD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP2,"TP2_USDCAD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP2_USDCAD_UP_S2_OCO3"));
		                 };
	                    Base.USDCAD_UP_S2_OCO3Sets2.Add( Base.USDCAD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP3,"TP3_USDCAD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP3_USDCAD_UP_S2_OCO3"));
		                 };
	                    Base.USDCAD_UP_S2_OCO3Sets3.Add( Base.USDCAD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP4,"TP4_USDCAD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP4_USDCAD_UP_S2_OCO3"));
		                 };
	                    Base.USDCAD_UP_S2_OCO3Sets4.Add( Base.USDCAD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP5,"TP5_USDCAD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP5_USDCAD_UP_S2_OCO3"));
		                 };
	                    Base.USDCAD_UP_S2_OCO3Sets5.Add( Base.USDCAD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP6,"TP6_USDCAD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP6_USDCAD_UP_S2_OCO3"));
		                 };
	                    Base.USDCAD_UP_S2_OCO3Sets6.Add( Base.USDCAD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDCAD_OCO3S1_UP_S2 = 0;
	                for (; USDCAD_OCO3S1_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets1.Count; USDCAD_OCO3S1_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO3Sets1[USDCAD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO3Sets1[USDCAD_OCO3S1_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO3Sets1.RemoveAt(USDCAD_OCO3S1_UP_S2);
	                        USDCAD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDCAD_OCO3S2_UP_S2 = 0;
	                for (; USDCAD_OCO3S2_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets2.Count; USDCAD_OCO3S2_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO3Sets2[USDCAD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO3Sets2[USDCAD_OCO3S2_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO3Sets2.RemoveAt(USDCAD_OCO3S2_UP_S2);
	                        USDCAD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO3S3_UP_S2 = 0;
	                for (; USDCAD_OCO3S3_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets3.Count; USDCAD_OCO3S3_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO3Sets3[USDCAD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO3Sets3[USDCAD_OCO3S3_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO3Sets3.RemoveAt(USDCAD_OCO3S3_UP_S2);
	                        USDCAD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO3S4_UP_S2 = 0;
	                for (; USDCAD_OCO3S4_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets4.Count; USDCAD_OCO3S4_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO3Sets4[USDCAD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO3Sets4[USDCAD_OCO3S4_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO3Sets4.RemoveAt(USDCAD_OCO3S4_UP_S2);
	                        USDCAD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCAD_OCO3S5_UP_S2 = 0;
	                for (; USDCAD_OCO3S5_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets5.Count; USDCAD_OCO3S5_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO3Sets5[USDCAD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO3Sets5[USDCAD_OCO3S5_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO3Sets5.RemoveAt(USDCAD_OCO3S5_UP_S2);
	                        USDCAD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCAD_OCO3S6_UP_S2 = 0;
	                for (; USDCAD_OCO3S6_UP_S2 < Base.USDCAD_UP_S2_OCO3Sets6.Count; USDCAD_OCO3S6_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO3Sets6[USDCAD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO3Sets6[USDCAD_OCO3S6_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO3Sets6.RemoveAt(USDCAD_OCO3S6_UP_S2);
	                        USDCAD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCAD_OCO4_EO1_UP_S2)
	                Base.USDCAD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.USDCAD_OCO4_EO2_UP_S2)
	                Base.USDCAD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO4_EO3_UP_S2)
	                Base.USDCAD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO4_EO4_UP_S2)
	                Base.USDCAD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO4_EO5_UP_S2)
	                Base.USDCAD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO4_EO6_UP_S2)
	                Base.USDCAD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCAD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.USDCAD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP1,"TP1_USDCAD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP1_USDCAD_UP_S2_OCO4"));
		                 };
		                Base.USDCAD_UP_S2_OCO4Sets1.Add( Base.USDCAD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCAD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP2,"TP2_USDCAD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP2_USDCAD_UP_S2_OCO4"));
		                 };
	                    Base.USDCAD_UP_S2_OCO4Sets2.Add( Base.USDCAD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP3,"TP3_USDCAD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP3_USDCAD_UP_S2_OCO4"));
		                 };
	                    Base.USDCAD_UP_S2_OCO4Sets3.Add( Base.USDCAD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP4,"TP4_USDCAD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP4_USDCAD_UP_S2_OCO4"));
		                 };
	                    Base.USDCAD_UP_S2_OCO4Sets4.Add( Base.USDCAD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP5,"TP5_USDCAD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP5_USDCAD_UP_S2_OCO4"));
		                 };
	                    Base.USDCAD_UP_S2_OCO4Sets5.Add( Base.USDCAD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_UP_S2_TP6,"TP6_USDCAD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_UP_S2_SL,"SL_TP6_USDCAD_UP_S2_OCO4"));
		                 };
	                    Base.USDCAD_UP_S2_OCO4Sets6.Add( Base.USDCAD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int USDCAD_OCO4S1_UP_S2 = 0;
	                for (; USDCAD_OCO4S1_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets1.Count; USDCAD_OCO4S1_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO4Sets1[USDCAD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO4Sets1[USDCAD_OCO4S1_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO4Sets1.RemoveAt(USDCAD_OCO4S1_UP_S2);
	                        USDCAD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int USDCAD_OCO4S2_UP_S2 = 0;
	                for (; USDCAD_OCO4S2_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets2.Count; USDCAD_OCO4S2_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO4Sets2[USDCAD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO4Sets2[USDCAD_OCO4S2_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO4Sets2.RemoveAt(USDCAD_OCO4S2_UP_S2);
	                        USDCAD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO4S3_UP_S2 = 0;
	                for (; USDCAD_OCO4S3_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets3.Count; USDCAD_OCO4S3_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO4Sets3[USDCAD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO4Sets3[USDCAD_OCO4S3_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO4Sets3.RemoveAt(USDCAD_OCO4S3_UP_S2);
	                        USDCAD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO4S4_UP_S2 = 0;
	                for (; USDCAD_OCO4S4_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets4.Count; USDCAD_OCO4S4_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO4Sets4[USDCAD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO4Sets4[USDCAD_OCO4S4_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO4Sets4.RemoveAt(USDCAD_OCO4S4_UP_S2);
	                        USDCAD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCAD_OCO4S5_UP_S2 = 0;
	                for (; USDCAD_OCO4S5_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets5.Count; USDCAD_OCO4S5_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO4Sets5[USDCAD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO4Sets5[USDCAD_OCO4S5_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO4Sets5.RemoveAt(USDCAD_OCO4S5_UP_S2);
	                        USDCAD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int USDCAD_OCO4S6_UP_S2 = 0;
	                for (; USDCAD_OCO4S6_UP_S2 < Base.USDCAD_UP_S2_OCO4Sets6.Count; USDCAD_OCO4S6_UP_S2++)
	                    if (Base.USDCAD_UP_S2_OCO4Sets6[USDCAD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_UP_S2_OCO4Sets6[USDCAD_OCO4S6_UP_S2].Filled();
	                        Base.USDCAD_UP_S2_OCO4Sets6.RemoveAt(USDCAD_OCO4S6_UP_S2);
	                        USDCAD_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct GBPCHF_OCO1_DOWN_S2
    {
        public GBPCHF_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 =="TP1_GBPCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF 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 =="TP1_GBPCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF 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 GBPCHF_OCO1_UP_S2
    {
        public GBPCHF_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 =="TP1_GBPCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF 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 =="TP1_GBPCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCHF 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 GBPCHF_OCO2_DOWN_S2
    {
        public GBPCHF_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 =="TP1_GBPCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF 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 =="TP1_GBPCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF 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 GBPCHF_OCO2_UP_S2
    {
        public GBPCHF_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 =="TP1_GBPCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF 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 =="TP1_GBPCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCHF 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 GBPCHF_OCO3_DOWN_S2
    {
        public GBPCHF_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 =="TP1_GBPCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF 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 =="TP1_GBPCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF 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 GBPCHF_OCO3_UP_S2
    {
        public GBPCHF_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 =="TP1_GBPCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF 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 =="TP1_GBPCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCHF 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 GBPCHF_OCO4_DOWN_S2
    {
        public GBPCHF_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 =="TP1_GBPCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF 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 =="TP1_GBPCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF 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 GBPCHF_OCO4_UP_S2
    {
        public GBPCHF_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 =="TP1_GBPCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF 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 =="TP1_GBPCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCHF 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.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 _EURCHF;
		
    	///oco1 up
    	public static OrderTicket EURCHF_OCO1_MO1_UP_S2;
    	public static OrderTicket EURCHF_OCO1_MO2_UP_S2;
    	public static OrderTicket EURCHF_OCO1_MO3_UP_S2;
    	public static OrderTicket EURCHF_OCO1_MO4_UP_S2;
    	public static OrderTicket EURCHF_OCO1_MO5_UP_S2;
    	public static OrderTicket EURCHF_OCO1_MO6_UP_S2;
    	
    	public static int EURCHF_OCO1_EO1_UP_S2_ID ;
        public static int EURCHF_OCO1_EO2_UP_S2_ID ;
        public static int EURCHF_OCO1_EO3_UP_S2_ID ;
        public static int EURCHF_OCO1_EO4_UP_S2_ID ;
        public static int EURCHF_OCO1_EO5_UP_S2_ID ;
        public static int EURCHF_OCO1_EO6_UP_S2_ID ;
        
        public static bool EURCHF_OCO1_EO1_UP_S2 ;
        public static bool EURCHF_OCO1_EO2_UP_S2 ;
        public static bool EURCHF_OCO1_EO3_UP_S2 ;
        public static bool EURCHF_OCO1_EO4_UP_S2 ;
        public static bool EURCHF_OCO1_EO5_UP_S2 ;
        public static bool EURCHF_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_UP_S2> EURCHF_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_UP_S2> EURCHF_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_UP_S2> EURCHF_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_UP_S2> EURCHF_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_UP_S2> EURCHF_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_UP_S2> EURCHF_OOFE_OCO1_UP_S2_6 ;
        
        public static EURCHF_OCO1_UP_S2 EURCHF_PFO_OCO1_UP_S2_1 ;
        public static EURCHF_OCO1_UP_S2 EURCHF_PFO_OCO1_UP_S2_2 ;
        public static EURCHF_OCO1_UP_S2 EURCHF_PFO_OCO1_UP_S2_3 ;
        public static EURCHF_OCO1_UP_S2 EURCHF_PFO_OCO1_UP_S2_4 ;
        public static EURCHF_OCO1_UP_S2 EURCHF_PFO_OCO1_UP_S2_5 ;
        public static EURCHF_OCO1_UP_S2 EURCHF_PFO_OCO1_UP_S2_6 ;
        
        public static List<EURCHF_OCO1_UP_S2> EURCHF_UP_S2_OCO1Sets1 = new List<EURCHF_OCO1_UP_S2>();
        public static List<EURCHF_OCO1_UP_S2> EURCHF_UP_S2_OCO1Sets2 = new List<EURCHF_OCO1_UP_S2>();
        public static List<EURCHF_OCO1_UP_S2> EURCHF_UP_S2_OCO1Sets3 = new List<EURCHF_OCO1_UP_S2>();
        public static List<EURCHF_OCO1_UP_S2> EURCHF_UP_S2_OCO1Sets4 = new List<EURCHF_OCO1_UP_S2>();
        public static List<EURCHF_OCO1_UP_S2> EURCHF_UP_S2_OCO1Sets5 = new List<EURCHF_OCO1_UP_S2>();
        public static List<EURCHF_OCO1_UP_S2> EURCHF_UP_S2_OCO1Sets6 = new List<EURCHF_OCO1_UP_S2>();
        
        public static bool EURCHF_OCO1_UP_S2_IsReady = true;
        public static bool EURCHF_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket EURCHF_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO1_MO6_DOWN_S2 ;
    	
    	public static int EURCHF_OCO1_EO1_DOWN_S2_ID ;
        public static int EURCHF_OCO1_EO2_DOWN_S2_ID ;
        public static int EURCHF_OCO1_EO3_DOWN_S2_ID ;
        public static int EURCHF_OCO1_EO4_DOWN_S2_ID ;
        public static int EURCHF_OCO1_EO5_DOWN_S2_ID ;
        public static int EURCHF_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool EURCHF_OCO1_EO1_DOWN_S2 ;
        public static bool EURCHF_OCO1_EO2_DOWN_S2 ;
        public static bool EURCHF_OCO1_EO3_DOWN_S2 ;
        public static bool EURCHF_OCO1_EO4_DOWN_S2 ;
        public static bool EURCHF_OCO1_EO5_DOWN_S2 ;
        public static bool EURCHF_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_DOWN_S2> EURCHF_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_DOWN_S2> EURCHF_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_DOWN_S2> EURCHF_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_DOWN_S2> EURCHF_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_DOWN_S2> EURCHF_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO1_DOWN_S2> EURCHF_OOFE_OCO1_DOWN_S2_6 ;
        
        public static EURCHF_OCO1_DOWN_S2 EURCHF_PFO_OCO1_DOWN_S2_1 ;
        public static EURCHF_OCO1_DOWN_S2 EURCHF_PFO_OCO1_DOWN_S2_2 ;
        public static EURCHF_OCO1_DOWN_S2 EURCHF_PFO_OCO1_DOWN_S2_3 ;
        public static EURCHF_OCO1_DOWN_S2 EURCHF_PFO_OCO1_DOWN_S2_4 ;
        public static EURCHF_OCO1_DOWN_S2 EURCHF_PFO_OCO1_DOWN_S2_5 ;
        public static EURCHF_OCO1_DOWN_S2 EURCHF_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<EURCHF_OCO1_DOWN_S2> EURCHF_DOWN_S2_OCO1Sets1 = new List<EURCHF_OCO1_DOWN_S2>();
        public static List<EURCHF_OCO1_DOWN_S2> EURCHF_DOWN_S2_OCO1Sets2 = new List<EURCHF_OCO1_DOWN_S2>();
        public static List<EURCHF_OCO1_DOWN_S2> EURCHF_DOWN_S2_OCO1Sets3 = new List<EURCHF_OCO1_DOWN_S2>();
        public static List<EURCHF_OCO1_DOWN_S2> EURCHF_DOWN_S2_OCO1Sets4 = new List<EURCHF_OCO1_DOWN_S2>();
        public static List<EURCHF_OCO1_DOWN_S2> EURCHF_DOWN_S2_OCO1Sets5 = new List<EURCHF_OCO1_DOWN_S2>();
        public static List<EURCHF_OCO1_DOWN_S2> EURCHF_DOWN_S2_OCO1Sets6 = new List<EURCHF_OCO1_DOWN_S2>();
        
        public static bool EURCHF_OCO1_DOWN_S2_IsReady = true;
        public static bool EURCHF_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket EURCHF_OCO2_MO1_UP_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO2_UP_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO3_UP_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO4_UP_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO5_UP_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO6_UP_S2 ;
    	
    	public static int EURCHF_OCO2_EO1_UP_S2_ID ;
        public static int EURCHF_OCO2_EO2_UP_S2_ID ;
        public static int EURCHF_OCO2_EO3_UP_S2_ID ;
        public static int EURCHF_OCO2_EO4_UP_S2_ID ;
        public static int EURCHF_OCO2_EO5_UP_S2_ID ;
        public static int EURCHF_OCO2_EO6_UP_S2_ID ;
        
        public static bool EURCHF_OCO2_EO1_UP_S2 ;
        public static bool EURCHF_OCO2_EO2_UP_S2 ;
        public static bool EURCHF_OCO2_EO3_UP_S2 ;
        public static bool EURCHF_OCO2_EO4_UP_S2 ;
        public static bool EURCHF_OCO2_EO5_UP_S2 ;
        public static bool EURCHF_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_UP_S2> EURCHF_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_UP_S2> EURCHF_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_UP_S2> EURCHF_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_UP_S2> EURCHF_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_UP_S2> EURCHF_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_UP_S2> EURCHF_OOFE_OCO2_UP_S2_6 ;
        
        public static EURCHF_OCO2_UP_S2 EURCHF_PFO_OCO2_UP_S2_1 ;
        public static EURCHF_OCO2_UP_S2 EURCHF_PFO_OCO2_UP_S2_2 ;
        public static EURCHF_OCO2_UP_S2 EURCHF_PFO_OCO2_UP_S2_3 ;
        public static EURCHF_OCO2_UP_S2 EURCHF_PFO_OCO2_UP_S2_4 ;
        public static EURCHF_OCO2_UP_S2 EURCHF_PFO_OCO2_UP_S2_5 ;
        public static EURCHF_OCO2_UP_S2 EURCHF_PFO_OCO2_UP_S2_6 ;
        
        public static List<EURCHF_OCO2_UP_S2> EURCHF_UP_S2_OCO2Sets1 = new List<EURCHF_OCO2_UP_S2>();
        public static List<EURCHF_OCO2_UP_S2> EURCHF_UP_S2_OCO2Sets2 = new List<EURCHF_OCO2_UP_S2>();
        public static List<EURCHF_OCO2_UP_S2> EURCHF_UP_S2_OCO2Sets3 = new List<EURCHF_OCO2_UP_S2>();
        public static List<EURCHF_OCO2_UP_S2> EURCHF_UP_S2_OCO2Sets4 = new List<EURCHF_OCO2_UP_S2>();
        public static List<EURCHF_OCO2_UP_S2> EURCHF_UP_S2_OCO2Sets5 = new List<EURCHF_OCO2_UP_S2>();
        public static List<EURCHF_OCO2_UP_S2> EURCHF_UP_S2_OCO2Sets6 = new List<EURCHF_OCO2_UP_S2>();
        
        public static bool EURCHF_OCO2_UP_S2_IsReady = true;
        public static bool EURCHF_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket EURCHF_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO2_MO6_DOWN_S2 ;
    	
    	public static int EURCHF_OCO2_EO1_DOWN_S2_ID ;
        public static int EURCHF_OCO2_EO2_DOWN_S2_ID ;
        public static int EURCHF_OCO2_EO3_DOWN_S2_ID ;
        public static int EURCHF_OCO2_EO4_DOWN_S2_ID ;
        public static int EURCHF_OCO2_EO5_DOWN_S2_ID ;
        public static int EURCHF_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool EURCHF_OCO2_EO1_DOWN_S2 ;
        public static bool EURCHF_OCO2_EO2_DOWN_S2 ;
        public static bool EURCHF_OCO2_EO3_DOWN_S2 ;
        public static bool EURCHF_OCO2_EO4_DOWN_S2 ;
        public static bool EURCHF_OCO2_EO5_DOWN_S2 ;
        public static bool EURCHF_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_DOWN_S2> EURCHF_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_DOWN_S2> EURCHF_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_DOWN_S2> EURCHF_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_DOWN_S2> EURCHF_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_DOWN_S2> EURCHF_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO2_DOWN_S2> EURCHF_OOFE_OCO2_DOWN_S2_6 ;
        
        public static EURCHF_OCO2_DOWN_S2 EURCHF_PFO_OCO2_DOWN_S2_1 ;
        public static EURCHF_OCO2_DOWN_S2 EURCHF_PFO_OCO2_DOWN_S2_2 ;
        public static EURCHF_OCO2_DOWN_S2 EURCHF_PFO_OCO2_DOWN_S2_3 ;
        public static EURCHF_OCO2_DOWN_S2 EURCHF_PFO_OCO2_DOWN_S2_4 ;
        public static EURCHF_OCO2_DOWN_S2 EURCHF_PFO_OCO2_DOWN_S2_5 ;
        public static EURCHF_OCO2_DOWN_S2 EURCHF_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<EURCHF_OCO2_DOWN_S2> EURCHF_DOWN_S2_OCO2Sets1 = new List<EURCHF_OCO2_DOWN_S2>();
        public static List<EURCHF_OCO2_DOWN_S2> EURCHF_DOWN_S2_OCO2Sets2 = new List<EURCHF_OCO2_DOWN_S2>();
        public static List<EURCHF_OCO2_DOWN_S2> EURCHF_DOWN_S2_OCO2Sets3 = new List<EURCHF_OCO2_DOWN_S2>();
        public static List<EURCHF_OCO2_DOWN_S2> EURCHF_DOWN_S2_OCO2Sets4 = new List<EURCHF_OCO2_DOWN_S2>();
        public static List<EURCHF_OCO2_DOWN_S2> EURCHF_DOWN_S2_OCO2Sets5 = new List<EURCHF_OCO2_DOWN_S2>();
        public static List<EURCHF_OCO2_DOWN_S2> EURCHF_DOWN_S2_OCO2Sets6 = new List<EURCHF_OCO2_DOWN_S2>();
        
        public static bool EURCHF_OCO2_DOWN_S2_IsReady = true;
        public static bool EURCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket EURCHF_OCO3_MO1_UP_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO2_UP_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO3_UP_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO4_UP_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO5_UP_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO6_UP_S2 ;
    	
    	public static int EURCHF_OCO3_EO1_UP_S2_ID ;
        public static int EURCHF_OCO3_EO2_UP_S2_ID ;
        public static int EURCHF_OCO3_EO3_UP_S2_ID ;
        public static int EURCHF_OCO3_EO4_UP_S2_ID ;
        public static int EURCHF_OCO3_EO5_UP_S2_ID ;
        public static int EURCHF_OCO3_EO6_UP_S2_ID ;
        
        public static bool EURCHF_OCO3_EO1_UP_S2 ;
        public static bool EURCHF_OCO3_EO2_UP_S2 ;
        public static bool EURCHF_OCO3_EO3_UP_S2 ;
        public static bool EURCHF_OCO3_EO4_UP_S2 ;
        public static bool EURCHF_OCO3_EO5_UP_S2 ;
        public static bool EURCHF_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_UP_S2> EURCHF_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_UP_S2> EURCHF_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_UP_S2> EURCHF_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_UP_S2> EURCHF_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_UP_S2> EURCHF_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_UP_S2> EURCHF_OOFE_OCO3_UP_S2_6 ;
        
        public static EURCHF_OCO3_UP_S2 EURCHF_PFO_OCO3_UP_S2_1 ;
        public static EURCHF_OCO3_UP_S2 EURCHF_PFO_OCO3_UP_S2_2 ;
        public static EURCHF_OCO3_UP_S2 EURCHF_PFO_OCO3_UP_S2_3 ;
        public static EURCHF_OCO3_UP_S2 EURCHF_PFO_OCO3_UP_S2_4 ;
        public static EURCHF_OCO3_UP_S2 EURCHF_PFO_OCO3_UP_S2_5 ;
        public static EURCHF_OCO3_UP_S2 EURCHF_PFO_OCO3_UP_S2_6 ;
        
        public static List<EURCHF_OCO3_UP_S2> EURCHF_UP_S2_OCO3Sets1 = new List<EURCHF_OCO3_UP_S2>();
        public static List<EURCHF_OCO3_UP_S2> EURCHF_UP_S2_OCO3Sets2 = new List<EURCHF_OCO3_UP_S2>();
        public static List<EURCHF_OCO3_UP_S2> EURCHF_UP_S2_OCO3Sets3 = new List<EURCHF_OCO3_UP_S2>();
        public static List<EURCHF_OCO3_UP_S2> EURCHF_UP_S2_OCO3Sets4 = new List<EURCHF_OCO3_UP_S2>();
        public static List<EURCHF_OCO3_UP_S2> EURCHF_UP_S2_OCO3Sets5 = new List<EURCHF_OCO3_UP_S2>();
        public static List<EURCHF_OCO3_UP_S2> EURCHF_UP_S2_OCO3Sets6 = new List<EURCHF_OCO3_UP_S2>();
        
        public static bool EURCHF_OCO3_UP_S2_IsReady = true;
        public static bool EURCHF_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket EURCHF_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO3_MO6_DOWN_S2 ;
    	
    	public static int EURCHF_OCO3_EO1_DOWN_S2_ID ;
        public static int EURCHF_OCO3_EO2_DOWN_S2_ID ;
        public static int EURCHF_OCO3_EO3_DOWN_S2_ID ;
        public static int EURCHF_OCO3_EO4_DOWN_S2_ID ;
        public static int EURCHF_OCO3_EO5_DOWN_S2_ID ;
        public static int EURCHF_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool EURCHF_OCO3_EO1_DOWN_S2 ;
        public static bool EURCHF_OCO3_EO2_DOWN_S2 ;
        public static bool EURCHF_OCO3_EO3_DOWN_S2 ;
        public static bool EURCHF_OCO3_EO4_DOWN_S2 ;
        public static bool EURCHF_OCO3_EO5_DOWN_S2 ;
        public static bool EURCHF_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_DOWN_S2> EURCHF_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_DOWN_S2> EURCHF_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_DOWN_S2> EURCHF_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_DOWN_S2> EURCHF_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_DOWN_S2> EURCHF_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO3_DOWN_S2> EURCHF_OOFE_OCO3_DOWN_S2_6 ;
        
        public static EURCHF_OCO3_DOWN_S2 EURCHF_PFO_OCO3_DOWN_S2_1 ;
        public static EURCHF_OCO3_DOWN_S2 EURCHF_PFO_OCO3_DOWN_S2_2 ;
        public static EURCHF_OCO3_DOWN_S2 EURCHF_PFO_OCO3_DOWN_S2_3 ;
        public static EURCHF_OCO3_DOWN_S2 EURCHF_PFO_OCO3_DOWN_S2_4 ;
        public static EURCHF_OCO3_DOWN_S2 EURCHF_PFO_OCO3_DOWN_S2_5 ;
        public static EURCHF_OCO3_DOWN_S2 EURCHF_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<EURCHF_OCO3_DOWN_S2> EURCHF_DOWN_S2_OCO3Sets1 = new List<EURCHF_OCO3_DOWN_S2>();
        public static List<EURCHF_OCO3_DOWN_S2> EURCHF_DOWN_S2_OCO3Sets2 = new List<EURCHF_OCO3_DOWN_S2>();
        public static List<EURCHF_OCO3_DOWN_S2> EURCHF_DOWN_S2_OCO3Sets3 = new List<EURCHF_OCO3_DOWN_S2>();
        public static List<EURCHF_OCO3_DOWN_S2> EURCHF_DOWN_S2_OCO3Sets4 = new List<EURCHF_OCO3_DOWN_S2>();
        public static List<EURCHF_OCO3_DOWN_S2> EURCHF_DOWN_S2_OCO3Sets5 = new List<EURCHF_OCO3_DOWN_S2>();
        public static List<EURCHF_OCO3_DOWN_S2> EURCHF_DOWN_S2_OCO3Sets6 = new List<EURCHF_OCO3_DOWN_S2>();
        
        public static bool EURCHF_OCO3_DOWN_S2_IsReady = true;
        public static bool EURCHF_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket EURCHF_OCO4_MO1_UP_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO2_UP_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO3_UP_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO4_UP_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO5_UP_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO6_UP_S2 ;
    	
    	public static int EURCHF_OCO4_EO1_UP_S2_ID ;
        public static int EURCHF_OCO4_EO2_UP_S2_ID ;
        public static int EURCHF_OCO4_EO3_UP_S2_ID ;
        public static int EURCHF_OCO4_EO4_UP_S2_ID ;
        public static int EURCHF_OCO4_EO5_UP_S2_ID ;
        public static int EURCHF_OCO4_EO6_UP_S2_ID ;
        
        public static bool EURCHF_OCO4_EO1_UP_S2 ;
        public static bool EURCHF_OCO4_EO2_UP_S2 ;
        public static bool EURCHF_OCO4_EO3_UP_S2 ;
        public static bool EURCHF_OCO4_EO4_UP_S2 ;
        public static bool EURCHF_OCO4_EO5_UP_S2 ;
        public static bool EURCHF_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_UP_S2> EURCHF_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_UP_S2> EURCHF_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_UP_S2> EURCHF_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_UP_S2> EURCHF_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_UP_S2> EURCHF_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_UP_S2> EURCHF_OOFE_OCO4_UP_S2_6 ;
        
        public static EURCHF_OCO4_UP_S2 EURCHF_PFO_OCO4_UP_S2_1 ;
        public static EURCHF_OCO4_UP_S2 EURCHF_PFO_OCO4_UP_S2_2 ;
        public static EURCHF_OCO4_UP_S2 EURCHF_PFO_OCO4_UP_S2_3 ;
        public static EURCHF_OCO4_UP_S2 EURCHF_PFO_OCO4_UP_S2_4 ;
        public static EURCHF_OCO4_UP_S2 EURCHF_PFO_OCO4_UP_S2_5 ;
        public static EURCHF_OCO4_UP_S2 EURCHF_PFO_OCO4_UP_S2_6 ;
        
        public static List<EURCHF_OCO4_UP_S2> EURCHF_UP_S2_OCO4Sets1 = new List<EURCHF_OCO4_UP_S2>();
        public static List<EURCHF_OCO4_UP_S2> EURCHF_UP_S2_OCO4Sets2 = new List<EURCHF_OCO4_UP_S2>();
        public static List<EURCHF_OCO4_UP_S2> EURCHF_UP_S2_OCO4Sets3 = new List<EURCHF_OCO4_UP_S2>();
        public static List<EURCHF_OCO4_UP_S2> EURCHF_UP_S2_OCO4Sets4 = new List<EURCHF_OCO4_UP_S2>();
        public static List<EURCHF_OCO4_UP_S2> EURCHF_UP_S2_OCO4Sets5 = new List<EURCHF_OCO4_UP_S2>();
        public static List<EURCHF_OCO4_UP_S2> EURCHF_UP_S2_OCO4Sets6 = new List<EURCHF_OCO4_UP_S2>();
        
        public static bool EURCHF_OCO4_UP_S2_IsReady = true;
        public static bool EURCHF_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket EURCHF_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket EURCHF_OCO4_MO6_DOWN_S2 ;
    	
    	public static int EURCHF_OCO4_EO1_DOWN_S2_ID ;
        public static int EURCHF_OCO4_EO2_DOWN_S2_ID ;
        public static int EURCHF_OCO4_EO3_DOWN_S2_ID ;
        public static int EURCHF_OCO4_EO4_DOWN_S2_ID ;
        public static int EURCHF_OCO4_EO5_DOWN_S2_ID ;
        public static int EURCHF_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool EURCHF_OCO4_EO1_DOWN_S2 ;
        public static bool EURCHF_OCO4_EO2_DOWN_S2 ;
        public static bool EURCHF_OCO4_EO3_DOWN_S2 ;
        public static bool EURCHF_OCO4_EO4_DOWN_S2 ;
        public static bool EURCHF_OCO4_EO5_DOWN_S2 ;
        public static bool EURCHF_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_DOWN_S2> EURCHF_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_DOWN_S2> EURCHF_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_DOWN_S2> EURCHF_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_DOWN_S2> EURCHF_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_DOWN_S2> EURCHF_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURCHF_OCO4_DOWN_S2> EURCHF_OOFE_OCO4_DOWN_S2_6 ;
        
        public static EURCHF_OCO4_DOWN_S2 EURCHF_PFO_OCO4_DOWN_S2_1 ;
        public static EURCHF_OCO4_DOWN_S2 EURCHF_PFO_OCO4_DOWN_S2_2 ;
        public static EURCHF_OCO4_DOWN_S2 EURCHF_PFO_OCO4_DOWN_S2_3 ;
        public static EURCHF_OCO4_DOWN_S2 EURCHF_PFO_OCO4_DOWN_S2_4 ;
        public static EURCHF_OCO4_DOWN_S2 EURCHF_PFO_OCO4_DOWN_S2_5 ;
        public static EURCHF_OCO4_DOWN_S2 EURCHF_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<EURCHF_OCO4_DOWN_S2> EURCHF_DOWN_S2_OCO4Sets1 = new List<EURCHF_OCO4_DOWN_S2>();
        public static List<EURCHF_OCO4_DOWN_S2> EURCHF_DOWN_S2_OCO4Sets2 = new List<EURCHF_OCO4_DOWN_S2>();
        public static List<EURCHF_OCO4_DOWN_S2> EURCHF_DOWN_S2_OCO4Sets3 = new List<EURCHF_OCO4_DOWN_S2>();
        public static List<EURCHF_OCO4_DOWN_S2> EURCHF_DOWN_S2_OCO4Sets4 = new List<EURCHF_OCO4_DOWN_S2>();
        public static List<EURCHF_OCO4_DOWN_S2> EURCHF_DOWN_S2_OCO4Sets5 = new List<EURCHF_OCO4_DOWN_S2>();
        public static List<EURCHF_OCO4_DOWN_S2> EURCHF_DOWN_S2_OCO4Sets6 = new List<EURCHF_OCO4_DOWN_S2>();
        
        public static bool EURCHF_OCO4_DOWN_S2_IsReady = true;
        public static bool EURCHF_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal EURCHF_UP_S2_SL {get; set;}
		public static decimal EURCHF_UP_S2_TP1 {get; set;}
		public static decimal EURCHF_UP_S2_TP2 {get; set;}
		public static decimal EURCHF_UP_S2_TP3 {get; set;}
		public static decimal EURCHF_UP_S2_TP4 {get; set;}
		public static decimal EURCHF_UP_S2_TP5 {get; set;}
		public static decimal EURCHF_UP_S2_TP6 {get; set;}
		
		public static decimal EURCHF_DOWN_S2_SL {get; set;}
		public static decimal EURCHF_DOWN_S2_TP1 {get; set;}
		public static decimal EURCHF_DOWN_S2_TP2 {get; set;}
		public static decimal EURCHF_DOWN_S2_TP3 {get; set;}
		public static decimal EURCHF_DOWN_S2_TP4 {get; set;}
		public static decimal EURCHF_DOWN_S2_TP5 {get; set;}
		public static decimal EURCHF_DOWN_S2_TP6 {get; set;}

        public static bool EURCHF_Signal_Condition_UP_1 ;
        public static bool EURCHF_Signal_Condition_UP_2 ;
        public static bool EURCHF_Signal_Condition_UP_3 ;
        public static bool EURCHF_Signal_Condition_DOWN_S2 ;
        
        public static int EURCHF_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int EURCHF_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int EURCHF_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int EURCHF_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int EURCHF_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int EURCHF_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int EURCHF_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int EURCHF_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int EURCHF_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int EURCHF_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_EURCHF_UP_S2 ;
        public static bool DOWM_EURCHF_UP_S2 ;
        public static bool DOWT_EURCHF_UP_S2 ;
        public static bool DOWW_EURCHF_UP_S2 ;
        public static bool DOWTH_EURCHF_UP_S2 ;
        
		public static bool DOWR_EURCHF_DOWN_S2 ;
        public static bool DOWM_EURCHF_DOWN_S2 ;
        public static bool DOWT_EURCHF_DOWN_S2 ;
        public static bool DOWW_EURCHF_DOWN_S2 ;
        public static bool DOWTH_EURCHF_DOWN_S2 ;
        
        
		public static int EURCHF_quantity_UP_S2 ;
		public static int EURCHF_quantity_SL_UP_S2 ;
		public static int EURCHF_quantity_TP1_UP_S2 ;
		public static int EURCHF_quantity_TP2_UP_S2 ;
		public static int EURCHF_quantity_TP3_UP_S2 ;
		public static int EURCHF_quantity_TP4_UP_S2 ;
		public static int EURCHF_quantity_TP5_UP_S2;
		public static int EURCHF_quantity_TP6_UP_S2 ;
		
		public static int EURCHF_quantity_DOWN_S2 ;
		public static int EURCHF_quantity_SL_DOWN_S2 ;
		public static int EURCHF_quantity_TP1_DOWN_S2 ;
		public static int EURCHF_quantity_TP2_DOWN_S2 ;
		public static int EURCHF_quantity_TP3_DOWN_S2 ;
		public static int EURCHF_quantity_TP4_DOWN_S2 ;
		public static int EURCHF_quantity_TP5_DOWN_S2;
		public static int EURCHF_quantity_TP6_DOWN_S2 ;
    }
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct GBPJPY_OCO1_DOWN_S2
    {
        public GBPJPY_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 =="TP1_GBPJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY 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 =="TP1_GBPJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY 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 GBPJPY_OCO1_UP_S2
    {
        public GBPJPY_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 =="TP1_GBPJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY 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 =="TP1_GBPJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPJPY 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 GBPJPY_OCO2_DOWN_S2
    {
        public GBPJPY_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 =="TP1_GBPJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY 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 =="TP1_GBPJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY 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 GBPJPY_OCO2_UP_S2
    {
        public GBPJPY_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 =="TP1_GBPJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY 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 =="TP1_GBPJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPJPY 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 GBPJPY_OCO3_DOWN_S2
    {
        public GBPJPY_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 =="TP1_GBPJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY 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 =="TP1_GBPJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY 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 GBPJPY_OCO3_UP_S2
    {
        public GBPJPY_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 =="TP1_GBPJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY 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 =="TP1_GBPJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPJPY 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 GBPJPY_OCO4_DOWN_S2
    {
        public GBPJPY_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 =="TP1_GBPJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY 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 =="TP1_GBPJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY 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 GBPJPY_OCO4_UP_S2
    {
        public GBPJPY_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 =="TP1_GBPJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY 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 =="TP1_GBPJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPJPY 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 NZDUSD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public NZDUSD_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("NZDUSD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDUSD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDUSD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDUSD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDUSD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDUSD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDUSD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        }
		        
				if (Base.NZDUSD_OCO1_EO1_UP_S2)
	                Base.NZDUSD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDUSD_OCO1_EO2_UP_S2)
	                Base.NZDUSD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO1_EO3_UP_S2)
	                Base.NZDUSD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO1_EO4_UP_S2)
	                Base.NZDUSD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO1_EO5_UP_S2)
	                Base.NZDUSD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO1_EO6_UP_S2)
	                Base.NZDUSD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.NZDUSD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP1,"TP1_NZDUSD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP1_NZDUSD_UP_S2_OCO1"));
		                 };
		                Base.NZDUSD_UP_S2_OCO1Sets1.Add( Base.NZDUSD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP2,"TP2_NZDUSD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP2_NZDUSD_UP_S2_OCO1"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO1Sets2.Add( Base.NZDUSD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP3,"TP3_NZDUSD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP3_NZDUSD_UP_S2_OCO1"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO1Sets3.Add( Base.NZDUSD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP4,"TP4_NZDUSD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP4_NZDUSD_UP_S2_OCO1"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO1Sets4.Add( Base.NZDUSD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP5,"TP5_NZDUSD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP5_NZDUSD_UP_S2_OCO1"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO1Sets5.Add( Base.NZDUSD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP6,"TP6_NZDUSD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP6_NZDUSD_UP_S2_OCO1"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO1Sets6.Add( Base.NZDUSD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDUSD_OCO1S1_UP_S2 = 0;
	                for (; NZDUSD_OCO1S1_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets1.Count; NZDUSD_OCO1S1_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO1Sets1[NZDUSD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO1Sets1[NZDUSD_OCO1S1_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO1Sets1.RemoveAt(NZDUSD_OCO1S1_UP_S2);
	                        NZDUSD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDUSD_OCO1S2_UP_S2 = 0;
	                for (; NZDUSD_OCO1S2_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets2.Count; NZDUSD_OCO1S2_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO1Sets2[NZDUSD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO1Sets2[NZDUSD_OCO1S2_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO1Sets2.RemoveAt(NZDUSD_OCO1S2_UP_S2);
	                        NZDUSD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO1S3_UP_S2 = 0;
	                for (; NZDUSD_OCO1S3_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets3.Count; NZDUSD_OCO1S3_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO1Sets3[NZDUSD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO1Sets3[NZDUSD_OCO1S3_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO1Sets3.RemoveAt(NZDUSD_OCO1S3_UP_S2);
	                        NZDUSD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO1S4_UP_S2 = 0;
	                for (; NZDUSD_OCO1S4_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets4.Count; NZDUSD_OCO1S4_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO1Sets4[NZDUSD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO1Sets4[NZDUSD_OCO1S4_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO1Sets4.RemoveAt(NZDUSD_OCO1S4_UP_S2);
	                        NZDUSD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDUSD_OCO1S5_UP_S2 = 0;
	                for (; NZDUSD_OCO1S5_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets5.Count; NZDUSD_OCO1S5_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO1Sets5[NZDUSD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO1Sets5[NZDUSD_OCO1S5_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO1Sets5.RemoveAt(NZDUSD_OCO1S5_UP_S2);
	                        NZDUSD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDUSD_OCO1S6_UP_S2 = 0;
	                for (; NZDUSD_OCO1S6_UP_S2 < Base.NZDUSD_UP_S2_OCO1Sets6.Count; NZDUSD_OCO1S6_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO1Sets6[NZDUSD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO1Sets6[NZDUSD_OCO1S6_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO1Sets6.RemoveAt(NZDUSD_OCO1S6_UP_S2);
	                        NZDUSD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.NZDUSD_OCO2_EO1_UP_S2)
	                Base.NZDUSD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDUSD_OCO2_EO2_UP_S2)
	                Base.NZDUSD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO2_EO3_UP_S2)
	                Base.NZDUSD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO2_EO4_UP_S2)
	                Base.NZDUSD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO2_EO5_UP_S2)
	                Base.NZDUSD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO2_EO6_UP_S2)
	                Base.NZDUSD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.NZDUSD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP1,"TP1_NZDUSD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP1_NZDUSD_UP_S2_OCO2"));
		                 };
		                Base.NZDUSD_UP_S2_OCO2Sets1.Add( Base.NZDUSD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP2,"TP2_NZDUSD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP2_NZDUSD_UP_S2_OCO2"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO2Sets2.Add( Base.NZDUSD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP3,"TP3_NZDUSD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP3_NZDUSD_UP_S2_OCO2"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO2Sets3.Add( Base.NZDUSD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP4,"TP4_NZDUSD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP4_NZDUSD_UP_S2_OCO2"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO2Sets4.Add( Base.NZDUSD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP5,"TP5_NZDUSD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP5_NZDUSD_UP_S2_OCO2"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO2Sets5.Add( Base.NZDUSD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP6,"TP6_NZDUSD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP6_NZDUSD_UP_S2_OCO2"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO2Sets6.Add( Base.NZDUSD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDUSD_OCO2S1_UP_S2 = 0;
	                for (; NZDUSD_OCO2S1_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets1.Count; NZDUSD_OCO2S1_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO2Sets1[NZDUSD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO2Sets1[NZDUSD_OCO2S1_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO2Sets1.RemoveAt(NZDUSD_OCO2S1_UP_S2);
	                        NZDUSD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDUSD_OCO2S2_UP_S2 = 0;
	                for (; NZDUSD_OCO2S2_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets2.Count; NZDUSD_OCO2S2_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO2Sets2[NZDUSD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO2Sets2[NZDUSD_OCO2S2_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO2Sets2.RemoveAt(NZDUSD_OCO2S2_UP_S2);
	                        NZDUSD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO2S3_UP_S2 = 0;
	                for (; NZDUSD_OCO2S3_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets3.Count; NZDUSD_OCO2S3_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO2Sets3[NZDUSD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO2Sets3[NZDUSD_OCO2S3_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO2Sets3.RemoveAt(NZDUSD_OCO2S3_UP_S2);
	                        NZDUSD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO2S4_UP_S2 = 0;
	                for (; NZDUSD_OCO2S4_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets4.Count; NZDUSD_OCO2S4_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO2Sets4[NZDUSD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO2Sets4[NZDUSD_OCO2S4_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO2Sets4.RemoveAt(NZDUSD_OCO2S4_UP_S2);
	                        NZDUSD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDUSD_OCO2S5_UP_S2 = 0;
	                for (; NZDUSD_OCO2S5_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets5.Count; NZDUSD_OCO2S5_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO2Sets5[NZDUSD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO2Sets5[NZDUSD_OCO2S5_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO2Sets5.RemoveAt(NZDUSD_OCO2S5_UP_S2);
	                        NZDUSD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDUSD_OCO2S6_UP_S2 = 0;
	                for (; NZDUSD_OCO2S6_UP_S2 < Base.NZDUSD_UP_S2_OCO2Sets6.Count; NZDUSD_OCO2S6_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO2Sets6[NZDUSD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO2Sets6[NZDUSD_OCO2S6_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO2Sets6.RemoveAt(NZDUSD_OCO2S6_UP_S2);
	                        NZDUSD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDUSD_OCO3_EO1_UP_S2)
	                Base.NZDUSD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDUSD_OCO3_EO2_UP_S2)
	                Base.NZDUSD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO3_EO3_UP_S2)
	                Base.NZDUSD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO3_EO4_UP_S2)
	                Base.NZDUSD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO3_EO5_UP_S2)
	                Base.NZDUSD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO3_EO6_UP_S2)
	                Base.NZDUSD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.NZDUSD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP1,"TP1_NZDUSD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP1_NZDUSD_UP_S2_OCO3"));
		                 };
		                Base.NZDUSD_UP_S2_OCO3Sets1.Add( Base.NZDUSD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP2,"TP2_NZDUSD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP2_NZDUSD_UP_S2_OCO3"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO3Sets2.Add( Base.NZDUSD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP3,"TP3_NZDUSD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP3_NZDUSD_UP_S2_OCO3"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO3Sets3.Add( Base.NZDUSD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP4,"TP4_NZDUSD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP4_NZDUSD_UP_S2_OCO3"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO3Sets4.Add( Base.NZDUSD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP5,"TP5_NZDUSD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP5_NZDUSD_UP_S2_OCO3"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO3Sets5.Add( Base.NZDUSD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP6,"TP6_NZDUSD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP6_NZDUSD_UP_S2_OCO3"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO3Sets6.Add( Base.NZDUSD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDUSD_OCO3S1_UP_S2 = 0;
	                for (; NZDUSD_OCO3S1_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets1.Count; NZDUSD_OCO3S1_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO3Sets1[NZDUSD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO3Sets1[NZDUSD_OCO3S1_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO3Sets1.RemoveAt(NZDUSD_OCO3S1_UP_S2);
	                        NZDUSD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDUSD_OCO3S2_UP_S2 = 0;
	                for (; NZDUSD_OCO3S2_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets2.Count; NZDUSD_OCO3S2_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO3Sets2[NZDUSD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO3Sets2[NZDUSD_OCO3S2_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO3Sets2.RemoveAt(NZDUSD_OCO3S2_UP_S2);
	                        NZDUSD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO3S3_UP_S2 = 0;
	                for (; NZDUSD_OCO3S3_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets3.Count; NZDUSD_OCO3S3_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO3Sets3[NZDUSD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO3Sets3[NZDUSD_OCO3S3_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO3Sets3.RemoveAt(NZDUSD_OCO3S3_UP_S2);
	                        NZDUSD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO3S4_UP_S2 = 0;
	                for (; NZDUSD_OCO3S4_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets4.Count; NZDUSD_OCO3S4_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO3Sets4[NZDUSD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO3Sets4[NZDUSD_OCO3S4_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO3Sets4.RemoveAt(NZDUSD_OCO3S4_UP_S2);
	                        NZDUSD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDUSD_OCO3S5_UP_S2 = 0;
	                for (; NZDUSD_OCO3S5_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets5.Count; NZDUSD_OCO3S5_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO3Sets5[NZDUSD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO3Sets5[NZDUSD_OCO3S5_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO3Sets5.RemoveAt(NZDUSD_OCO3S5_UP_S2);
	                        NZDUSD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDUSD_OCO3S6_UP_S2 = 0;
	                for (; NZDUSD_OCO3S6_UP_S2 < Base.NZDUSD_UP_S2_OCO3Sets6.Count; NZDUSD_OCO3S6_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO3Sets6[NZDUSD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO3Sets6[NZDUSD_OCO3S6_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO3Sets6.RemoveAt(NZDUSD_OCO3S6_UP_S2);
	                        NZDUSD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDUSD_OCO4_EO1_UP_S2)
	                Base.NZDUSD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.NZDUSD_OCO4_EO2_UP_S2)
	                Base.NZDUSD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO4_EO3_UP_S2)
	                Base.NZDUSD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO4_EO4_UP_S2)
	                Base.NZDUSD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO4_EO5_UP_S2)
	                Base.NZDUSD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO4_EO6_UP_S2)
	                Base.NZDUSD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.NZDUSD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP1,"TP1_NZDUSD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP1_NZDUSD_UP_S2_OCO4"));
		                 };
		                Base.NZDUSD_UP_S2_OCO4Sets1.Add( Base.NZDUSD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP2,"TP2_NZDUSD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP2_NZDUSD_UP_S2_OCO4"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO4Sets2.Add( Base.NZDUSD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP3,"TP3_NZDUSD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP3_NZDUSD_UP_S2_OCO4"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO4Sets3.Add( Base.NZDUSD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP4,"TP4_NZDUSD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP4_NZDUSD_UP_S2_OCO4"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO4Sets4.Add( Base.NZDUSD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP5,"TP5_NZDUSD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP5_NZDUSD_UP_S2_OCO4"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO4Sets5.Add( Base.NZDUSD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_UP_S2_TP6,"TP6_NZDUSD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_UP_S2_SL,"SL_TP6_NZDUSD_UP_S2_OCO4"));
		                 };
	                    Base.NZDUSD_UP_S2_OCO4Sets6.Add( Base.NZDUSD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int NZDUSD_OCO4S1_UP_S2 = 0;
	                for (; NZDUSD_OCO4S1_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets1.Count; NZDUSD_OCO4S1_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO4Sets1[NZDUSD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO4Sets1[NZDUSD_OCO4S1_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO4Sets1.RemoveAt(NZDUSD_OCO4S1_UP_S2);
	                        NZDUSD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int NZDUSD_OCO4S2_UP_S2 = 0;
	                for (; NZDUSD_OCO4S2_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets2.Count; NZDUSD_OCO4S2_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO4Sets2[NZDUSD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO4Sets2[NZDUSD_OCO4S2_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO4Sets2.RemoveAt(NZDUSD_OCO4S2_UP_S2);
	                        NZDUSD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO4S3_UP_S2 = 0;
	                for (; NZDUSD_OCO4S3_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets3.Count; NZDUSD_OCO4S3_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO4Sets3[NZDUSD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO4Sets3[NZDUSD_OCO4S3_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO4Sets3.RemoveAt(NZDUSD_OCO4S3_UP_S2);
	                        NZDUSD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO4S4_UP_S2 = 0;
	                for (; NZDUSD_OCO4S4_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets4.Count; NZDUSD_OCO4S4_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO4Sets4[NZDUSD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO4Sets4[NZDUSD_OCO4S4_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO4Sets4.RemoveAt(NZDUSD_OCO4S4_UP_S2);
	                        NZDUSD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDUSD_OCO4S5_UP_S2 = 0;
	                for (; NZDUSD_OCO4S5_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets5.Count; NZDUSD_OCO4S5_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO4Sets5[NZDUSD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO4Sets5[NZDUSD_OCO4S5_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO4Sets5.RemoveAt(NZDUSD_OCO4S5_UP_S2);
	                        NZDUSD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int NZDUSD_OCO4S6_UP_S2 = 0;
	                for (; NZDUSD_OCO4S6_UP_S2 < Base.NZDUSD_UP_S2_OCO4Sets6.Count; NZDUSD_OCO4S6_UP_S2++)
	                    if (Base.NZDUSD_UP_S2_OCO4Sets6[NZDUSD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_UP_S2_OCO4Sets6[NZDUSD_OCO4S6_UP_S2].Filled();
	                        Base.NZDUSD_UP_S2_OCO4Sets6.RemoveAt(NZDUSD_OCO4S6_UP_S2);
	                        NZDUSD_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct USDJPY_OCO1_DOWN_S2
    {
        public USDJPY_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 =="TP1_USDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY 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 =="TP1_USDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY 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 USDJPY_OCO1_UP_S2
    {
        public USDJPY_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 =="TP1_USDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY 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 =="TP1_USDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_USDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_USDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_USDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_USDJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("USDJPY 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 USDJPY_OCO2_DOWN_S2
    {
        public USDJPY_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 =="TP1_USDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY 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 =="TP1_USDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY 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 USDJPY_OCO2_UP_S2
    {
        public USDJPY_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 =="TP1_USDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY 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 =="TP1_USDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_USDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_USDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_USDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_USDJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("USDJPY 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 USDJPY_OCO3_DOWN_S2
    {
        public USDJPY_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 =="TP1_USDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY 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 =="TP1_USDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY 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 USDJPY_OCO3_UP_S2
    {
        public USDJPY_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 =="TP1_USDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY 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 =="TP1_USDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_USDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_USDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_USDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_USDJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("USDJPY 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 USDJPY_OCO4_DOWN_S2
    {
        public USDJPY_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 =="TP1_USDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY 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 =="TP1_USDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY 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 USDJPY_OCO4_UP_S2
    {
        public USDJPY_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 =="TP1_USDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY 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 =="TP1_USDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_USDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_USDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_USDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_USDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_USDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_USDJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_USDJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("USDJPY 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.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct GBPCAD_OCO1_DOWN_S2
    {
        public GBPCAD_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 =="TP1_GBPCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD 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 =="TP1_GBPCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD 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 GBPCAD_OCO1_UP_S2
    {
        public GBPCAD_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 =="TP1_GBPCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD 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 =="TP1_GBPCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPCAD 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 GBPCAD_OCO2_DOWN_S2
    {
        public GBPCAD_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 =="TP1_GBPCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD 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 =="TP1_GBPCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD 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 GBPCAD_OCO2_UP_S2
    {
        public GBPCAD_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 =="TP1_GBPCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD 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 =="TP1_GBPCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPCAD 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 GBPCAD_OCO3_DOWN_S2
    {
        public GBPCAD_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 =="TP1_GBPCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD 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 =="TP1_GBPCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD 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 GBPCAD_OCO3_UP_S2
    {
        public GBPCAD_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 =="TP1_GBPCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD 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 =="TP1_GBPCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPCAD 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 GBPCAD_OCO4_DOWN_S2
    {
        public GBPCAD_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 =="TP1_GBPCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD 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 =="TP1_GBPCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD 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 GBPCAD_OCO4_UP_S2
    {
        public GBPCAD_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 =="TP1_GBPCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD 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 =="TP1_GBPCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPCAD 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_USDJPY_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_USDJPY_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("USDJPY_DOWN_S2_OCO1")))
			{
				Base.USDJPY_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDJPY_DOWN_S2_OCO2")))
			{
				Base.USDJPY_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDJPY_DOWN_S2_OCO3")))
			{
				Base.USDJPY_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDJPY_DOWN_S2_OCO4")))
			{
				Base.USDJPY_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("USDJPY_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.USDJPY_OCO1_EO1_DOWN_S2)
	                Base.USDJPY_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDJPY_OCO1_EO2_DOWN_S2)
	                Base.USDJPY_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO1_EO3_DOWN_S2)
	                Base.USDJPY_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO1_EO4_DOWN_S2)
	                Base.USDJPY_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO1_EO5_DOWN_S2)
	                Base.USDJPY_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO1_EO6_DOWN_S2)
	                Base.USDJPY_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDJPY_OCO1S1_DOWN_S2 = 0;
		                for (; USDJPY_OCO1S1_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets1.Count; USDJPY_OCO1S1_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO1Sets1[USDJPY_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO1Sets1[USDJPY_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.USDJPY_DOWN_S2_OCO1Sets1.Clear();
		                        USDJPY_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDJPY_OCO1S2_DOWN_S2 = 0;
		                for (; USDJPY_OCO1S2_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets2.Count; USDJPY_OCO1S2_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO1Sets2[USDJPY_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO1Sets2[USDJPY_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.USDJPY_DOWN_S2_OCO1Sets2.Clear();
		                        USDJPY_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO1S3_DOWN_S2 = 0;
		                for (; USDJPY_OCO1S3_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets3.Count; USDJPY_OCO1S3_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO1Sets3[USDJPY_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO1Sets3[USDJPY_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.USDJPY_DOWN_S2_OCO1Sets3.Clear();
		                        USDJPY_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO1S4_DOWN_S2 = 0;
		                for (; USDJPY_OCO1S4_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets4.Count; USDJPY_OCO1S4_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO1Sets4[USDJPY_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO1Sets4[USDJPY_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.USDJPY_DOWN_S2_OCO1Sets4.Clear();
		                        USDJPY_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO1S5_DOWN_S2 = 0;
		                for (; USDJPY_OCO1S5_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets5.Count; USDJPY_OCO1S5_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO1Sets5[USDJPY_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO1Sets5[USDJPY_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.USDJPY_DOWN_S2_OCO1Sets5.Clear();
		                        USDJPY_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO1S6_DOWN_S2 = 0;
		                for (; USDJPY_OCO1S6_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO1Sets6.Count; USDJPY_OCO1S6_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO1Sets6[USDJPY_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO1Sets6[USDJPY_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.USDJPY_DOWN_S2_OCO1Sets6.Clear();
		                        USDJPY_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDJPY_OCO2_EO1_DOWN_S2)
	                Base.USDJPY_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDJPY_OCO2_EO2_DOWN_S2)
	                Base.USDJPY_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO2_EO3_DOWN_S2)
	                Base.USDJPY_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO2_EO4_DOWN_S2)
	                Base.USDJPY_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO2_EO5_DOWN_S2)
	                Base.USDJPY_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO2_EO6_DOWN_S2)
	                Base.USDJPY_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDJPY_OCO2S1_DOWN_S2 = 0;
		                for (; USDJPY_OCO2S1_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets1.Count; USDJPY_OCO2S1_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO2Sets1[USDJPY_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO2Sets1[USDJPY_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.USDJPY_DOWN_S2_OCO2Sets1.Clear();
		                        USDJPY_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDJPY_OCO2S2_DOWN_S2 = 0;
		                for (; USDJPY_OCO2S2_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets2.Count; USDJPY_OCO2S2_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO2Sets2[USDJPY_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO2Sets2[USDJPY_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.USDJPY_DOWN_S2_OCO2Sets2.Clear();
		                        USDJPY_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO2S3_DOWN_S2 = 0;
		                for (; USDJPY_OCO2S3_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets3.Count; USDJPY_OCO2S3_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO2Sets3[USDJPY_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO2Sets3[USDJPY_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.USDJPY_DOWN_S2_OCO2Sets3.Clear();
		                        USDJPY_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO2S4_DOWN_S2 = 0;
		                for (; USDJPY_OCO2S4_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets4.Count; USDJPY_OCO2S4_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO2Sets4[USDJPY_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO2Sets4[USDJPY_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.USDJPY_DOWN_S2_OCO2Sets4.Clear();
		                        USDJPY_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO2S5_DOWN_S2 = 0;
		                for (; USDJPY_OCO2S5_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets5.Count; USDJPY_OCO2S5_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO2Sets5[USDJPY_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO2Sets5[USDJPY_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.USDJPY_DOWN_S2_OCO2Sets5.Clear();
		                        USDJPY_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO2S6_DOWN_S2 = 0;
		                for (; USDJPY_OCO2S6_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO2Sets6.Count; USDJPY_OCO2S6_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO2Sets6[USDJPY_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO2Sets6[USDJPY_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.USDJPY_DOWN_S2_OCO2Sets6.Clear();
		                        USDJPY_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDJPY_OCO3_EO1_DOWN_S2)
	                Base.USDJPY_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDJPY_OCO3_EO2_DOWN_S2)
	                Base.USDJPY_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO3_EO3_DOWN_S2)
	                Base.USDJPY_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO3_EO4_DOWN_S2)
	                Base.USDJPY_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO3_EO5_DOWN_S2)
	                Base.USDJPY_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO3_EO6_DOWN_S2)
	                Base.USDJPY_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDJPY_OCO3S1_DOWN_S2 = 0;
		                for (; USDJPY_OCO3S1_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets1.Count; USDJPY_OCO3S1_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO3Sets1[USDJPY_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO3Sets1[USDJPY_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.USDJPY_DOWN_S2_OCO3Sets1.Clear();
		                        USDJPY_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDJPY_OCO3S2_DOWN_S2 = 0;
		                for (; USDJPY_OCO3S2_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets2.Count; USDJPY_OCO3S2_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO3Sets2[USDJPY_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO3Sets2[USDJPY_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.USDJPY_DOWN_S2_OCO3Sets2.Clear();
		                        USDJPY_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO3S3_DOWN_S2 = 0;
		                for (; USDJPY_OCO3S3_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets3.Count; USDJPY_OCO3S3_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO3Sets3[USDJPY_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO3Sets3[USDJPY_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.USDJPY_DOWN_S2_OCO3Sets3.Clear();
		                        USDJPY_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO3S4_DOWN_S2 = 0;
		                for (; USDJPY_OCO3S4_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets4.Count; USDJPY_OCO3S4_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO3Sets4[USDJPY_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO3Sets4[USDJPY_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.USDJPY_DOWN_S2_OCO3Sets4.Clear();
		                        USDJPY_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO3S5_DOWN_S2 = 0;
		                for (; USDJPY_OCO3S5_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets5.Count; USDJPY_OCO3S5_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO3Sets5[USDJPY_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO3Sets5[USDJPY_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.USDJPY_DOWN_S2_OCO3Sets5.Clear();
		                        USDJPY_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO3S6_DOWN_S2 = 0;
		                for (; USDJPY_OCO3S6_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO3Sets6.Count; USDJPY_OCO3S6_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO3Sets6[USDJPY_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO3Sets6[USDJPY_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.USDJPY_DOWN_S2_OCO3Sets6.Clear();
		                        USDJPY_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDJPY_OCO4_EO1_DOWN_S2)
	                Base.USDJPY_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.USDJPY_OCO4_EO2_DOWN_S2)
	                Base.USDJPY_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO4_EO3_DOWN_S2)
	                Base.USDJPY_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO4_EO4_DOWN_S2)
	                Base.USDJPY_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO4_EO5_DOWN_S2)
	                Base.USDJPY_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO4_EO6_DOWN_S2)
	                Base.USDJPY_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int USDJPY_OCO4S1_DOWN_S2 = 0;
		                for (; USDJPY_OCO4S1_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets1.Count; USDJPY_OCO4S1_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO4Sets1[USDJPY_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO4Sets1[USDJPY_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.USDJPY_DOWN_S2_OCO4Sets1.Clear();
		                        USDJPY_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int USDJPY_OCO4S2_DOWN_S2 = 0;
		                for (; USDJPY_OCO4S2_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets2.Count; USDJPY_OCO4S2_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO4Sets2[USDJPY_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO4Sets2[USDJPY_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.USDJPY_DOWN_S2_OCO4Sets2.Clear();
		                        USDJPY_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO4S3_DOWN_S2 = 0;
		                for (; USDJPY_OCO4S3_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets3.Count; USDJPY_OCO4S3_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO4Sets3[USDJPY_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO4Sets3[USDJPY_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.USDJPY_DOWN_S2_OCO4Sets3.Clear();
		                        USDJPY_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO4S4_DOWN_S2 = 0;
		                for (; USDJPY_OCO4S4_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets4.Count; USDJPY_OCO4S4_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO4Sets4[USDJPY_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO4Sets4[USDJPY_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.USDJPY_DOWN_S2_OCO4Sets4.Clear();
		                        USDJPY_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO4S5_DOWN_S2 = 0;
		                for (; USDJPY_OCO4S5_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets5.Count; USDJPY_OCO4S5_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO4Sets5[USDJPY_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO4Sets5[USDJPY_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.USDJPY_DOWN_S2_OCO4Sets5.Clear();
		                        USDJPY_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO4S6_DOWN_S2 = 0;
		                for (; USDJPY_OCO4S6_DOWN_S2 < Base.USDJPY_DOWN_S2_OCO4Sets6.Count; USDJPY_OCO4S6_DOWN_S2++)
		                    if (Base.USDJPY_DOWN_S2_OCO4Sets6[USDJPY_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_DOWN_S2_OCO4Sets6[USDJPY_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.USDJPY_DOWN_S2_OCO4Sets6.Clear();
		                        USDJPY_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();
	            	}
	            	
					DOWM_USDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_USDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_USDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_USDJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_USDJPY_DOWN_S2 = DOWM_USDJPY_DOWN_S2 || DOWT_USDJPY_DOWN_S2 || DOWW_USDJPY_DOWN_S2 || DOWTH_USDJPY_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("USDJPY"))
	            	{
	            		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.USDJPY_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.USDJPY_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.USDJPY_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.USDJPY_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.USDJPY_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.USDJPY_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.USDJPY_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.USDJPY_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.USDJPY_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.USDJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.USDJPY_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.USDJPY_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	USDJPY_Signal_Condition_DOWN_S2 =  
	                									(
	                										//ricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.04m &&
	                										
	                										//prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										prices_ASK_High[0] > pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[0] > prices_ASK_Close[0] * 0.02m &&

	                										pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										
	                										//prices_BID_Close[0] - prices_ASK_Open[0] > 0 &&
 	                										
	                										//prices_BID_Open[0] > pricesM_ASK_High[0] && 
	                										//prices_ASK_Close[0] < pricesM_ASK_High[0] && 
	                										
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.1m
	                									);
	                									
	                    USDJPY_DOWN_S2_SL  =  0.5m;
	                    USDJPY_DOWN_S2_TP1 =  1m;
	                    USDJPY_DOWN_S2_TP2 =  USDJPY_DOWN_S2_TP1 * 1m;
	                    USDJPY_DOWN_S2_TP3 =  USDJPY_DOWN_S2_TP1 * 0;
	                    USDJPY_DOWN_S2_TP4 =  USDJPY_DOWN_S2_TP1 * 0;
	                    USDJPY_DOWN_S2_TP5 =  USDJPY_DOWN_S2_SL * 0;
	                    USDJPY_DOWN_S2_TP6 =  USDJPY_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    USDJPY_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    USDJPY_quantity_SL_DOWN_S2 = USDJPY_quantity_DOWN_S2;
	                    USDJPY_quantity_TP1_DOWN_S2 = (int)Math.Floor(USDJPY_quantity_DOWN_S2 * 1m);
	                    USDJPY_quantity_TP2_DOWN_S2 = (int)Math.Floor(USDJPY_quantity_TP1_DOWN_S2 * 0m);
	                    USDJPY_quantity_TP3_DOWN_S2 = (int)Math.Floor(USDJPY_quantity_TP2_DOWN_S2 * 0m);
	                    USDJPY_quantity_TP4_DOWN_S2 = (int)Math.Floor(USDJPY_quantity_TP3_DOWN_S2 * 0m);
	                    USDJPY_quantity_TP5_DOWN_S2 = (int)Math.Floor(USDJPY_quantity_TP4_DOWN_S2 * 0m);
	                    USDJPY_quantity_TP6_DOWN_S2 = (int)Math.Floor(USDJPY_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (USDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_USDJPY_DOWN_S2 && 
	                    Base.USDJPY_OCO1_DOWN_S2_IsReady == true &&
	                    Base.USDJPY_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDJPY_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP1_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP1_OCO1");
	                         Base.USDJPY_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.USDJPY_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP2_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP2_OCO1");
	                         Base.USDJPY_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.USDJPY_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP3_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP3_OCO1");
	                         Base.USDJPY_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.USDJPY_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP4_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP4_OCO1");
	                         Base.USDJPY_OCO1_EO4_DOWN_S2 = false;

							Base.USDJPY_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.USDJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (USDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_USDJPY_DOWN_S2 && 
	                    Base.USDJPY_OCO2_DOWN_S2_IsReady == true &&
	                    Base.USDJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.USDJPY_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDJPY_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP1_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP1_OCO2");
	                         Base.USDJPY_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.USDJPY_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP2_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP2_OCO2");
	                         Base.USDJPY_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.USDJPY_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP3_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP3_OCO2");
	                         Base.USDJPY_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.USDJPY_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP4_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP4_OCO2");
	                         Base.USDJPY_OCO2_EO4_DOWN_S2 = false;

							Base.USDJPY_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.USDJPY_OCO2_DOWN_S2_IsReady == false && Base.USDJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (USDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_USDJPY_DOWN_S2 &&
	                    Base.USDJPY_OCO3_DOWN_S2_IsReady == true &&
	                    Base.USDJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.USDJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.USDJPY_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDJPY_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP1_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP1_OCO3");
	                         Base.USDJPY_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.USDJPY_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP2_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP2_OCO3");
	                         Base.USDJPY_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.USDJPY_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP3_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP3_OCO3");
	                         Base.USDJPY_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.USDJPY_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP4_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP4_OCO3");
	                         Base.USDJPY_OCO3_EO4_DOWN_S2 = false;

							Base.USDJPY_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.USDJPY_OCO3_DOWN_S2_IsReady == false && Base.USDJPY_OCO2_DOWN_S2_IsReady == false && Base.USDJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (USDJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_USDJPY_DOWN_S2 && 
	                    Base.USDJPY_OCO4_DOWN_S2_IsReady == true &&
	                    Base.USDJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.USDJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.USDJPY_OCO3_DOWN_S2_IsReady == false &&
	                    Base.USDJPY_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDJPY_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP1_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP1_OCO4");
	                         Base.USDJPY_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.USDJPY_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP2_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP2_OCO4");
	                         Base.USDJPY_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.USDJPY_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP3_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP3_OCO4");
	                         Base.USDJPY_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.USDJPY_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         USDJPY_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP4_DOWN_S2, false,"USDJPY_DOWN_S2_Entry_TP4_OCO4");
	                         Base.USDJPY_OCO4_EO4_DOWN_S2 = false;

							Base.USDJPY_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.USDJPY_OCO4_DOWN_S2_IsReady == false && Base.USDJPY_OCO3_DOWN_S2_IsReady == false && Base.USDJPY_OCO2_DOWN_S2_IsReady == false && Base.USDJPY_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct CADJPY_OCO1_DOWN_S2
    {
        public CADJPY_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 =="TP1_CADJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_CADJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_CADJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_CADJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_CADJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY 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 =="TP1_CADJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_CADJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_CADJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_CADJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_CADJPY_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY 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 CADJPY_OCO1_UP_S2
    {
        public CADJPY_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 =="TP1_CADJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_CADJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_CADJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_CADJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_CADJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY 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 =="TP1_CADJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_CADJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_CADJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_CADJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_CADJPY_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("CADJPY 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 CADJPY_OCO2_DOWN_S2
    {
        public CADJPY_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 =="TP1_CADJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_CADJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_CADJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_CADJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_CADJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY 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 =="TP1_CADJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_CADJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_CADJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_CADJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_CADJPY_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY 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 CADJPY_OCO2_UP_S2
    {
        public CADJPY_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 =="TP1_CADJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_CADJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_CADJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_CADJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_CADJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY 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 =="TP1_CADJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_CADJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_CADJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_CADJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_CADJPY_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("CADJPY 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 CADJPY_OCO3_DOWN_S2
    {
        public CADJPY_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 =="TP1_CADJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_CADJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_CADJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_CADJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_CADJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY 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 =="TP1_CADJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_CADJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_CADJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_CADJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_CADJPY_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY 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 CADJPY_OCO3_UP_S2
    {
        public CADJPY_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 =="TP1_CADJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_CADJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_CADJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_CADJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_CADJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY 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 =="TP1_CADJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_CADJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_CADJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_CADJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_CADJPY_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("CADJPY 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 CADJPY_OCO4_DOWN_S2
    {
        public CADJPY_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 =="TP1_CADJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_CADJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_CADJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_CADJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_CADJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY 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 =="TP1_CADJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_CADJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_CADJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_CADJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_CADJPY_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY 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 CADJPY_OCO4_UP_S2
    {
        public CADJPY_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 =="TP1_CADJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_CADJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_CADJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_CADJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_CADJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY 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 =="TP1_CADJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_CADJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_CADJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_CADJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_CADJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_CADJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_CADJPY_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_CADJPY_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("CADJPY 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.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct GBPAUD_OCO1_DOWN_S2
    {
        public GBPAUD_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 =="TP1_GBPAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD 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 =="TP1_GBPAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD 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 GBPAUD_OCO1_UP_S2
    {
        public GBPAUD_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 =="TP1_GBPAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD 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 =="TP1_GBPAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_GBPAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_GBPAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_GBPAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_GBPAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("GBPAUD 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 GBPAUD_OCO2_DOWN_S2
    {
        public GBPAUD_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 =="TP1_GBPAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD 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 =="TP1_GBPAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD 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 GBPAUD_OCO2_UP_S2
    {
        public GBPAUD_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 =="TP1_GBPAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD 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 =="TP1_GBPAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_GBPAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_GBPAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_GBPAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_GBPAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("GBPAUD 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 GBPAUD_OCO3_DOWN_S2
    {
        public GBPAUD_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 =="TP1_GBPAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD 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 =="TP1_GBPAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD 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 GBPAUD_OCO3_UP_S2
    {
        public GBPAUD_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 =="TP1_GBPAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD 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 =="TP1_GBPAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_GBPAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_GBPAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_GBPAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_GBPAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("GBPAUD 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 GBPAUD_OCO4_DOWN_S2
    {
        public GBPAUD_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 =="TP1_GBPAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD 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 =="TP1_GBPAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD 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 GBPAUD_OCO4_UP_S2
    {
        public GBPAUD_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 =="TP1_GBPAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD 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 =="TP1_GBPAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_GBPAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_GBPAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_GBPAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_GBPAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_GBPAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_GBPAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_GBPAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("GBPAUD 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPJPY_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPJPY_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(x=>x.Tag.Contains("GBPJPY_UP_S2_OCO1")))
			{
				Base.GBPJPY_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPJPY_UP_S2_OCO2")))
			{
				Base.GBPJPY_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPJPY_UP_S2_OCO3")))
			{
				Base.GBPJPY_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPJPY_UP_S2_OCO4")))
			{
				Base.GBPJPY_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPJPY_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.GBPJPY_OCO1_EO1_UP_S2)
	                Base.GBPJPY_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPJPY_OCO1_EO2_UP_S2)
	                Base.GBPJPY_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO1_EO3_UP_S2)
	                Base.GBPJPY_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO1_EO4_UP_S2)
	                Base.GBPJPY_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO1_EO5_UP_S2)
	                Base.GBPJPY_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO1_EO6_UP_S2)
	                Base.GBPJPY_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPJPY_OCO1S1_UP_S2 = 0;
		                for (; GBPJPY_OCO1S1_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets1.Count; GBPJPY_OCO1S1_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO1Sets1[GBPJPY_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO1Sets1[GBPJPY_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_1__Time out_OCO1");
		                        Base.GBPJPY_UP_S2_OCO1Sets1.Clear();
		                        GBPJPY_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPJPY_OCO1S2_UP_S2 = 0;
		                for (; GBPJPY_OCO1S2_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets2.Count; GBPJPY_OCO1S2_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO1Sets2[GBPJPY_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO1Sets2[GBPJPY_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_2__Time out_OCO1");
		                        Base.GBPJPY_UP_S2_OCO1Sets2.Clear();
		                        GBPJPY_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO1S3_UP_S2 = 0;
		                for (; GBPJPY_OCO1S3_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets3.Count; GBPJPY_OCO1S3_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO1Sets3[GBPJPY_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO1Sets3[GBPJPY_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_3__Time out_OCO1");
		                        Base.GBPJPY_UP_S2_OCO1Sets3.Clear();
		                        GBPJPY_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO1S4_UP_S2 = 0;
		                for (; GBPJPY_OCO1S4_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets4.Count; GBPJPY_OCO1S4_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO1Sets4[GBPJPY_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO1Sets4[GBPJPY_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_4__Time out_OCO1");
		                        Base.GBPJPY_UP_S2_OCO1Sets4.Clear();
		                        GBPJPY_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO1S5_UP_S2 = 0;
		                for (; GBPJPY_OCO1S5_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets5.Count; GBPJPY_OCO1S5_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO1Sets5[GBPJPY_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO1Sets5[GBPJPY_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_5__Time out_OCO1");
		                        Base.GBPJPY_UP_S2_OCO1Sets5.Clear();
		                        GBPJPY_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO1S6_UP_S2 = 0;
		                for (; GBPJPY_OCO1S6_UP_S2 < Base.GBPJPY_UP_S2_OCO1Sets6.Count; GBPJPY_OCO1S6_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO1Sets6[GBPJPY_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO1Sets6[GBPJPY_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_6__Time out_OCO1");
		                        Base.GBPJPY_UP_S2_OCO1Sets6.Clear();
		                        GBPJPY_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPJPY_OCO2_EO1_UP_S2)
                	Base.GBPJPY_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPJPY_OCO2_EO2_UP_S2)
	                Base.GBPJPY_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO2_EO3_UP_S2)
	                Base.GBPJPY_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO2_EO4_UP_S2)
	                Base.GBPJPY_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO2_EO5_UP_S2)
	                Base.GBPJPY_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO2_EO6_UP_S2)
	                Base.GBPJPY_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPJPY_OCO2S1_UP_S2 = 0;
		                for (; GBPJPY_OCO2S1_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets1.Count; GBPJPY_OCO2S1_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO2Sets1[GBPJPY_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO2Sets1[GBPJPY_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_1__Time out_OCO2");
		                        Base.GBPJPY_UP_S2_OCO2Sets1.Clear();
		                        GBPJPY_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPJPY_OCO2S2_UP_S2 = 0;
		                for (; GBPJPY_OCO2S2_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets2.Count; GBPJPY_OCO2S2_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO2Sets2[GBPJPY_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO2Sets2[GBPJPY_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_2__Time out_OCO2");
		                        Base.GBPJPY_UP_S2_OCO2Sets2.Clear();
		                        GBPJPY_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO2S3_UP_S2 = 0;
		                for (; GBPJPY_OCO2S3_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets3.Count; GBPJPY_OCO2S3_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO2Sets3[GBPJPY_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO2Sets3[GBPJPY_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_3__Time out_OCO2");
		                        Base.GBPJPY_UP_S2_OCO2Sets3.Clear();
		                        GBPJPY_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO2S4_UP_S2 = 0;
		                for (; GBPJPY_OCO2S4_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets4.Count; GBPJPY_OCO2S4_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO2Sets4[GBPJPY_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO2Sets4[GBPJPY_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_4__Time out_OCO2");
		                        Base.GBPJPY_UP_S2_OCO2Sets4.Clear();
		                        GBPJPY_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO2S5_UP_S2 = 0;
		                for (; GBPJPY_OCO2S5_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets5.Count; GBPJPY_OCO2S5_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO2Sets5[GBPJPY_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO2Sets5[GBPJPY_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_5__Time out_OCO2");
		                        Base.GBPJPY_UP_S2_OCO2Sets5.Clear();
		                        GBPJPY_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO2S6_UP_S2 = 0;
		                for (; GBPJPY_OCO2S6_UP_S2 < Base.GBPJPY_UP_S2_OCO2Sets6.Count; GBPJPY_OCO2S6_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO2Sets6[GBPJPY_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO2Sets6[GBPJPY_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_6__Time out_OCO2");
		                        Base.GBPJPY_UP_S2_OCO2Sets6.Clear();
		                        GBPJPY_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPJPY_OCO3_EO1_UP_S2)
            		Base.GBPJPY_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPJPY_OCO3_EO2_UP_S2)
	                Base.GBPJPY_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO3_EO3_UP_S2)
	                Base.GBPJPY_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO3_EO4_UP_S2)
	                Base.GBPJPY_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO3_EO5_UP_S2)
	                Base.GBPJPY_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO3_EO6_UP_S2)
	                Base.GBPJPY_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPJPY_OCO3S1_UP_S2 = 0;
		                for (; GBPJPY_OCO3S1_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets1.Count; GBPJPY_OCO3S1_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO3Sets1[GBPJPY_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO3Sets1[GBPJPY_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_1__Time out_OCO3");
		                        Base.GBPJPY_UP_S2_OCO3Sets1.Clear();
		                        GBPJPY_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPJPY_OCO3S2_UP_S2 = 0;
		                for (; GBPJPY_OCO3S2_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets2.Count; GBPJPY_OCO3S2_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO3Sets2[GBPJPY_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO3Sets2[GBPJPY_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_2__Time out_OCO3");
		                        Base.GBPJPY_UP_S2_OCO3Sets2.Clear();
		                        GBPJPY_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO3S3_UP_S2 = 0;
		                for (; GBPJPY_OCO3S3_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets3.Count; GBPJPY_OCO3S3_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO3Sets3[GBPJPY_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO3Sets3[GBPJPY_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_3__Time out_OCO3");
		                        Base.GBPJPY_UP_S2_OCO3Sets3.Clear();
		                        GBPJPY_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO3S4_UP_S2 = 0;
		                for (; GBPJPY_OCO3S4_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets4.Count; GBPJPY_OCO3S4_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO3Sets4[GBPJPY_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO3Sets4[GBPJPY_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_4__Time out_OCO3");
		                        Base.GBPJPY_UP_S2_OCO3Sets4.Clear();
		                        GBPJPY_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO3S5_UP_S2 = 0;
		                for (; GBPJPY_OCO3S5_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets5.Count; GBPJPY_OCO3S5_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO3Sets5[GBPJPY_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO3Sets5[GBPJPY_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_5__Time out_OCO3");
		                        Base.GBPJPY_UP_S2_OCO3Sets5.Clear();
		                        GBPJPY_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO3S6_UP_S2 = 0;
		                for (; GBPJPY_OCO3S6_UP_S2 < Base.GBPJPY_UP_S2_OCO3Sets6.Count; GBPJPY_OCO3S6_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO3Sets6[GBPJPY_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO3Sets6[GBPJPY_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_6__Time out_OCO3");
		                        Base.GBPJPY_UP_S2_OCO3Sets6.Clear();
		                        GBPJPY_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPJPY_OCO4_EO1_UP_S2)
            		Base.GBPJPY_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPJPY_OCO4_EO2_UP_S2)
	                Base.GBPJPY_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO4_EO3_UP_S2)
	                Base.GBPJPY_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO4_EO4_UP_S2)
	                Base.GBPJPY_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO4_EO5_UP_S2)
	                Base.GBPJPY_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPJPY_OCO4_EO6_UP_S2)
	                Base.GBPJPY_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPJPY_OCO4S1_UP_S2 = 0;
		                for (; GBPJPY_OCO4S1_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets1.Count; GBPJPY_OCO4S1_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO4Sets1[GBPJPY_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO4Sets1[GBPJPY_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_1__Time out_OCO4");
		                        Base.GBPJPY_UP_S2_OCO4Sets1.Clear();
		                        GBPJPY_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPJPY_OCO4S2_UP_S2 = 0;
		                for (; GBPJPY_OCO4S2_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets2.Count; GBPJPY_OCO4S2_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO4Sets2[GBPJPY_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO4Sets2[GBPJPY_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_2__Time out_OCO4");
		                        Base.GBPJPY_UP_S2_OCO4Sets2.Clear();
		                        GBPJPY_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO4S3_UP_S2 = 0;
		                for (; GBPJPY_OCO4S3_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets3.Count; GBPJPY_OCO4S3_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO4Sets3[GBPJPY_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO4Sets3[GBPJPY_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_3__Time out_OCO4");
		                        Base.GBPJPY_UP_S2_OCO4Sets3.Clear();
		                        GBPJPY_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPJPY_OCO4S4_UP_S2 = 0;
		                for (; GBPJPY_OCO4S4_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets4.Count; GBPJPY_OCO4S4_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO4Sets4[GBPJPY_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO4Sets4[GBPJPY_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_4__Time out_OCO4");
		                        Base.GBPJPY_UP_S2_OCO4Sets4.Clear();
		                        GBPJPY_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO4S5_UP_S2 = 0;
		                for (; GBPJPY_OCO4S5_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets5.Count; GBPJPY_OCO4S5_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO4Sets5[GBPJPY_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO4Sets5[GBPJPY_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_5__Time out_OCO4");
		                        Base.GBPJPY_UP_S2_OCO4Sets5.Clear();
		                        GBPJPY_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPJPY_OCO4S6_UP_S2 = 0;
		                for (; GBPJPY_OCO4S6_UP_S2 < Base.GBPJPY_UP_S2_OCO4Sets6.Count; GBPJPY_OCO4S6_UP_S2++)
		                    if (Base.GBPJPY_UP_S2_OCO4Sets6[GBPJPY_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPJPY_UP_S2_OCO4Sets6[GBPJPY_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("GBPJPY", order.Quantity, false, "GBPJPY_UP_S2_Entry_6__Time out_OCO4");
		                        Base.GBPJPY_UP_S2_OCO4Sets6.Clear();
		                        GBPJPY_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_GBPJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPJPY_UP_S2 = DOWM_GBPJPY_UP_S2 || DOWT_GBPJPY_UP_S2 || DOWW_GBPJPY_UP_S2 || DOWTH_GBPJPY_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPJPY") && SY1D.Symbol.ID.Market == Market.FXCM)
	            	{
	            		if(SY1D.BQ[0].Open != 0)
	            		{
	            			algorithm.Debug("ID : " + SY1D.Symbol.ID.Market);
	            		}
	            		
	            		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.GBPJPY_OCO1_UP_S2_IsReady == false ||
	                    	Base.GBPJPY_OCO2_UP_S2_IsReady == false ||
	                    	Base.GBPJPY_OCO3_UP_S2_IsReady == false ||
	                    	Base.GBPJPY_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.GBPJPY_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPJPY_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPJPY_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPJPY_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPJPY_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.GBPJPY_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.GBPJPY_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.GBPJPY_OCO4_UP_S2_Monthly_IsReady = true;
                    	}

	                	GBPJPY_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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.Yen_Min_SPRD
	                									);
	                									
	                	GBPJPY_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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.Yen_Min_SPRD
	                									);
	                									
	                									
	                	GBPJPY_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[0] < pricesM_BID_Low[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.Yen_Min_SPRD
	                									);
	                									
	                	if (GBPJPY_Signal_Condition_UP_1)
	                	{
	                    	GBPJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPJPY_Signal_Condition_UP_2)
	                	{
	                    	GBPJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPJPY_Signal_Condition_UP_3)
	                	{
	                    	GBPJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (GBPJPY_Signal_Condition_UP_1)
	                	{
	                    	GBPJPY_UP_S2_TP1  =  Base.Yen_TP_1 ;
	                	}
	                	
	                	if (GBPJPY_Signal_Condition_UP_2)
	                	{
	                    	GBPJPY_UP_S2_TP1  =  Base.Yen_TP_2 ;
	                	}
	                	
	                	if (GBPJPY_Signal_Condition_UP_3)
	                	{
	                    	GBPJPY_UP_S2_TP1  =  Base.Yen_TP_3 ;
	                	}

	                    GBPJPY_UP_S2_TP2 =  GBPJPY_UP_S2_SL * 0;
	                    GBPJPY_UP_S2_TP3 =  GBPJPY_UP_S2_SL * 0;
	                    GBPJPY_UP_S2_TP4 =  GBPJPY_UP_S2_SL * 0;
	                    GBPJPY_UP_S2_TP5 =  GBPJPY_UP_S2_SL * 0;
	                    GBPJPY_UP_S2_TP6 =  GBPJPY_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPJPY_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPJPY_quantity_SL_UP_S2 = GBPJPY_quantity_UP_S2;
	                    GBPJPY_quantity_TP1_UP_S2 = (int)Math.Floor(GBPJPY_quantity_UP_S2 * 1m);
	                    GBPJPY_quantity_TP2_UP_S2 = (int)Math.Floor(GBPJPY_quantity_TP1_UP_S2 * 0m);
	                    GBPJPY_quantity_TP3_UP_S2 = (int)Math.Floor(GBPJPY_quantity_TP2_UP_S2 * 0m);
	                    GBPJPY_quantity_TP4_UP_S2 = (int)Math.Floor(GBPJPY_quantity_TP3_UP_S2 * 0m);
	                    GBPJPY_quantity_TP5_UP_S2 = (int)Math.Floor(GBPJPY_quantity_TP4_UP_S2 * 0m);
	                    GBPJPY_quantity_TP6_UP_S2 = (int)Math.Floor(GBPJPY_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((GBPJPY_Signal_Condition_UP_1 || GBPJPY_Signal_Condition_UP_2 || GBPJPY_Signal_Condition_UP_3)  && 
	                    DOWR_GBPJPY_UP_S2 && 
	                    Base.GBPJPY_OCO1_UP_S2_IsReady == true &&
	                    Base.GBPJPY_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPJPY_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP1_UP_S2, false,"GBPJPY_UP_S2_Entry_TP1_OCO1");
	                         Base.GBPJPY_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.GBPJPY_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP2_UP_S2, false,"GBPJPY_UP_S2_Entry_TP2_OCO1");
	                         Base.GBPJPY_OCO1_EO2_UP_S2 = false;
	
	                         Base.GBPJPY_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP3_UP_S2, false,"GBPJPY_UP_S2_Entry_TP3_OCO1");
	                         Base.GBPJPY_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.GBPJPY_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP4_UP_S2, false,"GBPJPY_UP_S2_Entry_TP4_OCO1");
	                         Base.GBPJPY_OCO1_EO4_UP_S2 = false;

							Base.GBPJPY_OCO1_UP_S2_IsReady = false;
							
							if (Base.GBPJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco2:
	                    if ((GBPJPY_Signal_Condition_UP_1 || GBPJPY_Signal_Condition_UP_2 || GBPJPY_Signal_Condition_UP_3)  && 
	                    DOWR_GBPJPY_UP_S2 && 
	                    Base.GBPJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPJPY_OCO2_UP_S2_IsReady == true &&
	                    Base.GBPJPY_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPJPY_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP1_UP_S2, false,"GBPJPY_UP_S2_Entry_TP1_OCO2");
	                         Base.GBPJPY_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.GBPJPY_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP2_UP_S2, false,"GBPJPY_UP_S2_Entry_TP2_OCO2");
	                         Base.GBPJPY_OCO2_EO2_UP_S2 = false;
	
	                         Base.GBPJPY_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP3_UP_S2, false,"GBPJPY_UP_S2_Entry_TP3_OCO2");
	                         Base.GBPJPY_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.GBPJPY_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP4_UP_S2, false,"GBPJPY_UP_S2_Entry_TP4_OCO2");
	                         Base.GBPJPY_OCO2_EO4_UP_S2 = false;

							Base.GBPJPY_OCO2_UP_S2_IsReady = false;
							
							if (Base.GBPJPY_OCO2_UP_S2_IsReady == false && Base.GBPJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco3:
	                    if ((GBPJPY_Signal_Condition_UP_1 || GBPJPY_Signal_Condition_UP_2 || GBPJPY_Signal_Condition_UP_3)  && 
	                    DOWR_GBPJPY_UP_S2 &&
	                    Base.GBPJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPJPY_OCO3_UP_S2_IsReady == true &&
	                    Base.GBPJPY_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPJPY_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP1_UP_S2, false,"GBPJPY_UP_S2_Entry_TP1_OCO3");
	                         Base.GBPJPY_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.GBPJPY_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP2_UP_S2, false,"GBPJPY_UP_S2_Entry_TP2_OCO3");
	                         Base.GBPJPY_OCO3_EO2_UP_S2 = false;
	
	                         Base.GBPJPY_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP3_UP_S2, false,"GBPJPY_UP_S2_Entry_TP3_OCO3");
	                         Base.GBPJPY_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.GBPJPY_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP4_UP_S2, false,"GBPJPY_UP_S2_Entry_TP4_OCO3");
	                         Base.GBPJPY_OCO3_EO4_UP_S2 = false;

							Base.GBPJPY_OCO3_UP_S2_IsReady = false;
							
							if (Base.GBPJPY_OCO3_UP_S2_IsReady == false && Base.GBPJPY_OCO2_UP_S2_IsReady == false && Base.GBPJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco4:
	                    if ((GBPJPY_Signal_Condition_UP_1 || GBPJPY_Signal_Condition_UP_2 || GBPJPY_Signal_Condition_UP_3)  && 
	                    DOWR_GBPJPY_UP_S2 && 
	                    Base.GBPJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPJPY_OCO3_UP_S2_IsReady == false &&
	                    Base.GBPJPY_OCO4_UP_S2_IsReady == true &&
	                    Base.GBPJPY_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPJPY_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP1_UP_S2, false,"GBPJPY_UP_S2_Entry_TP1_OCO4");
	                         Base.GBPJPY_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.GBPJPY_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP2_UP_S2, false,"GBPJPY_UP_S2_Entry_TP2_OCO4");
	                         Base.GBPJPY_OCO4_EO2_UP_S2 = false;
	
	                         Base.GBPJPY_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP3_UP_S2, false,"GBPJPY_UP_S2_Entry_TP3_OCO4");
	                         Base.GBPJPY_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.GBPJPY_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPJPY_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPJPY_quantity_TP4_UP_S2, false,"GBPJPY_UP_S2_Entry_TP4_OCO4");
	                         Base.GBPJPY_OCO4_EO4_UP_S2 = false;

							Base.GBPJPY_OCO4_UP_S2_IsReady = false;
							
							if (Base.GBPJPY_OCO4_UP_S2_IsReady == false && Base.GBPJPY_OCO3_UP_S2_IsReady == false && Base.GBPJPY_OCO2_UP_S2_IsReady == false && Base.GBPJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURCAD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURCAD_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(x=>x.Tag.Contains("EURCAD_UP_S2_OCO1")))
			{
				Base.EURCAD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCAD_UP_S2_OCO2")))
			{
				Base.EURCAD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCAD_UP_S2_OCO3")))
			{
				Base.EURCAD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCAD_UP_S2_OCO4")))
			{
				Base.EURCAD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURCAD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.EURCAD_OCO1_EO1_UP_S2)
	                Base.EURCAD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.EURCAD_OCO1_EO2_UP_S2)
	                Base.EURCAD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO1_EO3_UP_S2)
	                Base.EURCAD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO1_EO4_UP_S2)
	                Base.EURCAD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO1_EO5_UP_S2)
	                Base.EURCAD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO1_EO6_UP_S2)
	                Base.EURCAD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCAD_OCO1S1_UP_S2 = 0;
		                for (; EURCAD_OCO1S1_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets1.Count; EURCAD_OCO1S1_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO1Sets1[EURCAD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO1Sets1[EURCAD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.EURCAD_UP_S2_OCO1Sets1.Clear();
		                        EURCAD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURCAD_OCO1S2_UP_S2 = 0;
		                for (; EURCAD_OCO1S2_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets2.Count; EURCAD_OCO1S2_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO1Sets2[EURCAD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO1Sets2[EURCAD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.EURCAD_UP_S2_OCO1Sets2.Clear();
		                        EURCAD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO1S3_UP_S2 = 0;
		                for (; EURCAD_OCO1S3_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets3.Count; EURCAD_OCO1S3_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO1Sets3[EURCAD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO1Sets3[EURCAD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.EURCAD_UP_S2_OCO1Sets3.Clear();
		                        EURCAD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO1S4_UP_S2 = 0;
		                for (; EURCAD_OCO1S4_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets4.Count; EURCAD_OCO1S4_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO1Sets4[EURCAD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO1Sets4[EURCAD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.EURCAD_UP_S2_OCO1Sets4.Clear();
		                        EURCAD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO1S5_UP_S2 = 0;
		                for (; EURCAD_OCO1S5_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets5.Count; EURCAD_OCO1S5_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO1Sets5[EURCAD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO1Sets5[EURCAD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.EURCAD_UP_S2_OCO1Sets5.Clear();
		                        EURCAD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO1S6_UP_S2 = 0;
		                for (; EURCAD_OCO1S6_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets6.Count; EURCAD_OCO1S6_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO1Sets6[EURCAD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO1Sets6[EURCAD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.EURCAD_UP_S2_OCO1Sets6.Clear();
		                        EURCAD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURCAD_OCO2_EO1_UP_S2)
                	Base.EURCAD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.EURCAD_OCO2_EO2_UP_S2)
	                Base.EURCAD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO2_EO3_UP_S2)
	                Base.EURCAD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO2_EO4_UP_S2)
	                Base.EURCAD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO2_EO5_UP_S2)
	                Base.EURCAD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO2_EO6_UP_S2)
	                Base.EURCAD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCAD_OCO2S1_UP_S2 = 0;
		                for (; EURCAD_OCO2S1_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets1.Count; EURCAD_OCO2S1_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO2Sets1[EURCAD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO2Sets1[EURCAD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.EURCAD_UP_S2_OCO2Sets1.Clear();
		                        EURCAD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURCAD_OCO2S2_UP_S2 = 0;
		                for (; EURCAD_OCO2S2_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets2.Count; EURCAD_OCO2S2_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO2Sets2[EURCAD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO2Sets2[EURCAD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.EURCAD_UP_S2_OCO2Sets2.Clear();
		                        EURCAD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO2S3_UP_S2 = 0;
		                for (; EURCAD_OCO2S3_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets3.Count; EURCAD_OCO2S3_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO2Sets3[EURCAD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO2Sets3[EURCAD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.EURCAD_UP_S2_OCO2Sets3.Clear();
		                        EURCAD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO2S4_UP_S2 = 0;
		                for (; EURCAD_OCO2S4_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets4.Count; EURCAD_OCO2S4_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO2Sets4[EURCAD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO2Sets4[EURCAD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.EURCAD_UP_S2_OCO2Sets4.Clear();
		                        EURCAD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO2S5_UP_S2 = 0;
		                for (; EURCAD_OCO2S5_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets5.Count; EURCAD_OCO2S5_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO2Sets5[EURCAD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO2Sets5[EURCAD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.EURCAD_UP_S2_OCO2Sets5.Clear();
		                        EURCAD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO2S6_UP_S2 = 0;
		                for (; EURCAD_OCO2S6_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets6.Count; EURCAD_OCO2S6_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO2Sets6[EURCAD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO2Sets6[EURCAD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.EURCAD_UP_S2_OCO2Sets6.Clear();
		                        EURCAD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURCAD_OCO3_EO1_UP_S2)
            		Base.EURCAD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.EURCAD_OCO3_EO2_UP_S2)
	                Base.EURCAD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO3_EO3_UP_S2)
	                Base.EURCAD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO3_EO4_UP_S2)
	                Base.EURCAD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO3_EO5_UP_S2)
	                Base.EURCAD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO3_EO6_UP_S2)
	                Base.EURCAD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCAD_OCO3S1_UP_S2 = 0;
		                for (; EURCAD_OCO3S1_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets1.Count; EURCAD_OCO3S1_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO3Sets1[EURCAD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO3Sets1[EURCAD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.EURCAD_UP_S2_OCO3Sets1.Clear();
		                        EURCAD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURCAD_OCO3S2_UP_S2 = 0;
		                for (; EURCAD_OCO3S2_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets2.Count; EURCAD_OCO3S2_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO3Sets2[EURCAD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO3Sets2[EURCAD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.EURCAD_UP_S2_OCO3Sets2.Clear();
		                        EURCAD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO3S3_UP_S2 = 0;
		                for (; EURCAD_OCO3S3_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets3.Count; EURCAD_OCO3S3_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO3Sets3[EURCAD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO3Sets3[EURCAD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.EURCAD_UP_S2_OCO3Sets3.Clear();
		                        EURCAD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO3S4_UP_S2 = 0;
		                for (; EURCAD_OCO3S4_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets4.Count; EURCAD_OCO3S4_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO3Sets4[EURCAD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO3Sets4[EURCAD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.EURCAD_UP_S2_OCO3Sets4.Clear();
		                        EURCAD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO3S5_UP_S2 = 0;
		                for (; EURCAD_OCO3S5_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets5.Count; EURCAD_OCO3S5_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO3Sets5[EURCAD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO3Sets5[EURCAD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.EURCAD_UP_S2_OCO3Sets5.Clear();
		                        EURCAD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO3S6_UP_S2 = 0;
		                for (; EURCAD_OCO3S6_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets6.Count; EURCAD_OCO3S6_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO3Sets6[EURCAD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO3Sets6[EURCAD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.EURCAD_UP_S2_OCO3Sets6.Clear();
		                        EURCAD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURCAD_OCO4_EO1_UP_S2)
            		Base.EURCAD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.EURCAD_OCO4_EO2_UP_S2)
	                Base.EURCAD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO4_EO3_UP_S2)
	                Base.EURCAD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO4_EO4_UP_S2)
	                Base.EURCAD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO4_EO5_UP_S2)
	                Base.EURCAD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO4_EO6_UP_S2)
	                Base.EURCAD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCAD_OCO4S1_UP_S2 = 0;
		                for (; EURCAD_OCO4S1_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets1.Count; EURCAD_OCO4S1_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO4Sets1[EURCAD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO4Sets1[EURCAD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.EURCAD_UP_S2_OCO4Sets1.Clear();
		                        EURCAD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURCAD_OCO4S2_UP_S2 = 0;
		                for (; EURCAD_OCO4S2_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets2.Count; EURCAD_OCO4S2_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO4Sets2[EURCAD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO4Sets2[EURCAD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.EURCAD_UP_S2_OCO4Sets2.Clear();
		                        EURCAD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO4S3_UP_S2 = 0;
		                for (; EURCAD_OCO4S3_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets3.Count; EURCAD_OCO4S3_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO4Sets3[EURCAD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO4Sets3[EURCAD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.EURCAD_UP_S2_OCO4Sets3.Clear();
		                        EURCAD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO4S4_UP_S2 = 0;
		                for (; EURCAD_OCO4S4_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets4.Count; EURCAD_OCO4S4_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO4Sets4[EURCAD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO4Sets4[EURCAD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.EURCAD_UP_S2_OCO4Sets4.Clear();
		                        EURCAD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO4S5_UP_S2 = 0;
		                for (; EURCAD_OCO4S5_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets5.Count; EURCAD_OCO4S5_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO4Sets5[EURCAD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO4Sets5[EURCAD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.EURCAD_UP_S2_OCO4Sets5.Clear();
		                        EURCAD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO4S6_UP_S2 = 0;
		                for (; EURCAD_OCO4S6_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets6.Count; EURCAD_OCO4S6_UP_S2++)
		                    if (Base.EURCAD_UP_S2_OCO4Sets6[EURCAD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_UP_S2_OCO4Sets6[EURCAD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.EURCAD_UP_S2_OCO4Sets6.Clear();
		                        EURCAD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_EURCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURCAD_UP_S2 = DOWM_EURCAD_UP_S2 || DOWT_EURCAD_UP_S2 || DOWW_EURCAD_UP_S2 || DOWTH_EURCAD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURCAD"))
	            	{
	            		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.EURCAD_OCO1_UP_S2_IsReady == false ||
	                    	Base.EURCAD_OCO2_UP_S2_IsReady == false ||
	                    	Base.EURCAD_OCO3_UP_S2_IsReady == false ||
	                    	Base.EURCAD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.EURCAD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.EURCAD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.EURCAD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.EURCAD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURCAD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.EURCAD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.EURCAD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.EURCAD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	EURCAD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                	EURCAD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                									
	                	EURCAD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[0] < pricesM_BID_Low[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 (EURCAD_Signal_Condition_UP_1)
	                	{
	                    	EURCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURCAD_Signal_Condition_UP_2)
	                	{
	                    	EURCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURCAD_Signal_Condition_UP_3)
	                	{
	                    	EURCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (EURCAD_Signal_Condition_UP_1)
	                	{
	                    	EURCAD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (EURCAD_Signal_Condition_UP_2)
	                	{
	                    	EURCAD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (EURCAD_Signal_Condition_UP_3)
	                	{
	                    	EURCAD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    EURCAD_UP_S2_TP2 =  EURCAD_UP_S2_SL * 0;
	                    EURCAD_UP_S2_TP3 =  EURCAD_UP_S2_SL * 0;
	                    EURCAD_UP_S2_TP4 =  EURCAD_UP_S2_SL * 0;
	                    EURCAD_UP_S2_TP5 =  EURCAD_UP_S2_SL * 0;
	                    EURCAD_UP_S2_TP6 =  EURCAD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURCAD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURCAD_quantity_SL_UP_S2 = EURCAD_quantity_UP_S2;
	                    EURCAD_quantity_TP1_UP_S2 = (int)Math.Floor(EURCAD_quantity_UP_S2 * 1m);
	                    EURCAD_quantity_TP2_UP_S2 = (int)Math.Floor(EURCAD_quantity_TP1_UP_S2 * 0m);
	                    EURCAD_quantity_TP3_UP_S2 = (int)Math.Floor(EURCAD_quantity_TP2_UP_S2 * 0m);
	                    EURCAD_quantity_TP4_UP_S2 = (int)Math.Floor(EURCAD_quantity_TP3_UP_S2 * 0m);
	                    EURCAD_quantity_TP5_UP_S2 = (int)Math.Floor(EURCAD_quantity_TP4_UP_S2 * 0m);
	                    EURCAD_quantity_TP6_UP_S2 = (int)Math.Floor(EURCAD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((EURCAD_Signal_Condition_UP_1 || EURCAD_Signal_Condition_UP_2 || EURCAD_Signal_Condition_UP_3)  && 
	                    DOWR_EURCAD_UP_S2 && 
	                    Base.EURCAD_OCO1_UP_S2_IsReady == true &&
	                    Base.EURCAD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCAD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP1_UP_S2, false,"EURCAD_UP_S2_Entry_TP1_OCO1");
	                         Base.EURCAD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.EURCAD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP2_UP_S2, false,"EURCAD_UP_S2_Entry_TP2_OCO1");
	                         Base.EURCAD_OCO1_EO2_UP_S2 = false;
	
	                         Base.EURCAD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP3_UP_S2, false,"EURCAD_UP_S2_Entry_TP3_OCO1");
	                         Base.EURCAD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.EURCAD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP4_UP_S2, false,"EURCAD_UP_S2_Entry_TP4_OCO1");
	                         Base.EURCAD_OCO1_EO4_UP_S2 = false;

							Base.EURCAD_OCO1_UP_S2_IsReady = false;
							
							if (Base.EURCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((EURCAD_Signal_Condition_UP_1 || EURCAD_Signal_Condition_UP_2 || EURCAD_Signal_Condition_UP_3)  && 
	                    DOWR_EURCAD_UP_S2 && 
	                    Base.EURCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURCAD_OCO2_UP_S2_IsReady == true &&
	                    Base.EURCAD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCAD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP1_UP_S2, false,"EURCAD_UP_S2_Entry_TP1_OCO2");
	                         Base.EURCAD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.EURCAD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP2_UP_S2, false,"EURCAD_UP_S2_Entry_TP2_OCO2");
	                         Base.EURCAD_OCO2_EO2_UP_S2 = false;
	
	                         Base.EURCAD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP3_UP_S2, false,"EURCAD_UP_S2_Entry_TP3_OCO2");
	                         Base.EURCAD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.EURCAD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP4_UP_S2, false,"EURCAD_UP_S2_Entry_TP4_OCO2");
	                         Base.EURCAD_OCO2_EO4_UP_S2 = false;

							Base.EURCAD_OCO2_UP_S2_IsReady = false;
							
							if (Base.EURCAD_OCO2_UP_S2_IsReady == false && Base.EURCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((EURCAD_Signal_Condition_UP_1 || EURCAD_Signal_Condition_UP_2 || EURCAD_Signal_Condition_UP_3)  && 
	                    DOWR_EURCAD_UP_S2 &&
	                    Base.EURCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.EURCAD_OCO3_UP_S2_IsReady == true &&
	                    Base.EURCAD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCAD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP1_UP_S2, false,"EURCAD_UP_S2_Entry_TP1_OCO3");
	                         Base.EURCAD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.EURCAD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP2_UP_S2, false,"EURCAD_UP_S2_Entry_TP2_OCO3");
	                         Base.EURCAD_OCO3_EO2_UP_S2 = false;
	
	                         Base.EURCAD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP3_UP_S2, false,"EURCAD_UP_S2_Entry_TP3_OCO3");
	                         Base.EURCAD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.EURCAD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP4_UP_S2, false,"EURCAD_UP_S2_Entry_TP4_OCO3");
	                         Base.EURCAD_OCO3_EO4_UP_S2 = false;

							Base.EURCAD_OCO3_UP_S2_IsReady = false;
							
							if (Base.EURCAD_OCO3_UP_S2_IsReady == false && Base.EURCAD_OCO2_UP_S2_IsReady == false && Base.EURCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((EURCAD_Signal_Condition_UP_1 || EURCAD_Signal_Condition_UP_2 || EURCAD_Signal_Condition_UP_3)  && 
	                    DOWR_EURCAD_UP_S2 && 
	                    Base.EURCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.EURCAD_OCO3_UP_S2_IsReady == false &&
	                    Base.EURCAD_OCO4_UP_S2_IsReady == true &&
	                    Base.EURCAD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCAD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP1_UP_S2, false,"EURCAD_UP_S2_Entry_TP1_OCO4");
	                         Base.EURCAD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.EURCAD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP2_UP_S2, false,"EURCAD_UP_S2_Entry_TP2_OCO4");
	                         Base.EURCAD_OCO4_EO2_UP_S2 = false;
	
	                         Base.EURCAD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP3_UP_S2, false,"EURCAD_UP_S2_Entry_TP3_OCO4");
	                         Base.EURCAD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.EURCAD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCAD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP4_UP_S2, false,"EURCAD_UP_S2_Entry_TP4_OCO4");
	                         Base.EURCAD_OCO4_EO4_UP_S2 = false;

							Base.EURCAD_OCO4_UP_S2_IsReady = false;
							
							if (Base.EURCAD_OCO4_UP_S2_IsReady == false && Base.EURCAD_OCO3_UP_S2_IsReady == false && Base.EURCAD_OCO2_UP_S2_IsReady == false && Base.EURCAD_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURCAD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURCAD_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("EURCAD_DOWN_S2_OCO1")))
			{
				Base.EURCAD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCAD_DOWN_S2_OCO2")))
			{
				Base.EURCAD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCAD_DOWN_S2_OCO3")))
			{
				Base.EURCAD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCAD_DOWN_S2_OCO4")))
			{
				Base.EURCAD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURCAD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.EURCAD_OCO1_EO1_DOWN_S2)
	                Base.EURCAD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURCAD_OCO1_EO2_DOWN_S2)
	                Base.EURCAD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO1_EO3_DOWN_S2)
	                Base.EURCAD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO1_EO4_DOWN_S2)
	                Base.EURCAD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO1_EO5_DOWN_S2)
	                Base.EURCAD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO1_EO6_DOWN_S2)
	                Base.EURCAD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCAD_OCO1S1_DOWN_S2 = 0;
		                for (; EURCAD_OCO1S1_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets1.Count; EURCAD_OCO1S1_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO1Sets1[EURCAD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO1Sets1[EURCAD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.EURCAD_DOWN_S2_OCO1Sets1.Clear();
		                        EURCAD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURCAD_OCO1S2_DOWN_S2 = 0;
		                for (; EURCAD_OCO1S2_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets2.Count; EURCAD_OCO1S2_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO1Sets2[EURCAD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO1Sets2[EURCAD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.EURCAD_DOWN_S2_OCO1Sets2.Clear();
		                        EURCAD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO1S3_DOWN_S2 = 0;
		                for (; EURCAD_OCO1S3_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets3.Count; EURCAD_OCO1S3_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO1Sets3[EURCAD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO1Sets3[EURCAD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.EURCAD_DOWN_S2_OCO1Sets3.Clear();
		                        EURCAD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO1S4_DOWN_S2 = 0;
		                for (; EURCAD_OCO1S4_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets4.Count; EURCAD_OCO1S4_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO1Sets4[EURCAD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO1Sets4[EURCAD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.EURCAD_DOWN_S2_OCO1Sets4.Clear();
		                        EURCAD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO1S5_DOWN_S2 = 0;
		                for (; EURCAD_OCO1S5_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets5.Count; EURCAD_OCO1S5_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO1Sets5[EURCAD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO1Sets5[EURCAD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.EURCAD_DOWN_S2_OCO1Sets5.Clear();
		                        EURCAD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO1S6_DOWN_S2 = 0;
		                for (; EURCAD_OCO1S6_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets6.Count; EURCAD_OCO1S6_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO1Sets6[EURCAD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO1Sets6[EURCAD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.EURCAD_DOWN_S2_OCO1Sets6.Clear();
		                        EURCAD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURCAD_OCO2_EO1_DOWN_S2)
	                Base.EURCAD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURCAD_OCO2_EO2_DOWN_S2)
	                Base.EURCAD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO2_EO3_DOWN_S2)
	                Base.EURCAD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO2_EO4_DOWN_S2)
	                Base.EURCAD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO2_EO5_DOWN_S2)
	                Base.EURCAD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO2_EO6_DOWN_S2)
	                Base.EURCAD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCAD_OCO2S1_DOWN_S2 = 0;
		                for (; EURCAD_OCO2S1_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets1.Count; EURCAD_OCO2S1_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO2Sets1[EURCAD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO2Sets1[EURCAD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.EURCAD_DOWN_S2_OCO2Sets1.Clear();
		                        EURCAD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURCAD_OCO2S2_DOWN_S2 = 0;
		                for (; EURCAD_OCO2S2_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets2.Count; EURCAD_OCO2S2_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO2Sets2[EURCAD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO2Sets2[EURCAD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.EURCAD_DOWN_S2_OCO2Sets2.Clear();
		                        EURCAD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO2S3_DOWN_S2 = 0;
		                for (; EURCAD_OCO2S3_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets3.Count; EURCAD_OCO2S3_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO2Sets3[EURCAD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO2Sets3[EURCAD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.EURCAD_DOWN_S2_OCO2Sets3.Clear();
		                        EURCAD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO2S4_DOWN_S2 = 0;
		                for (; EURCAD_OCO2S4_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets4.Count; EURCAD_OCO2S4_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO2Sets4[EURCAD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO2Sets4[EURCAD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.EURCAD_DOWN_S2_OCO2Sets4.Clear();
		                        EURCAD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO2S5_DOWN_S2 = 0;
		                for (; EURCAD_OCO2S5_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets5.Count; EURCAD_OCO2S5_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO2Sets5[EURCAD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO2Sets5[EURCAD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.EURCAD_DOWN_S2_OCO2Sets5.Clear();
		                        EURCAD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO2S6_DOWN_S2 = 0;
		                for (; EURCAD_OCO2S6_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets6.Count; EURCAD_OCO2S6_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO2Sets6[EURCAD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO2Sets6[EURCAD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.EURCAD_DOWN_S2_OCO2Sets6.Clear();
		                        EURCAD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURCAD_OCO3_EO1_DOWN_S2)
	                Base.EURCAD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURCAD_OCO3_EO2_DOWN_S2)
	                Base.EURCAD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO3_EO3_DOWN_S2)
	                Base.EURCAD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO3_EO4_DOWN_S2)
	                Base.EURCAD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO3_EO5_DOWN_S2)
	                Base.EURCAD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO3_EO6_DOWN_S2)
	                Base.EURCAD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCAD_OCO3S1_DOWN_S2 = 0;
		                for (; EURCAD_OCO3S1_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets1.Count; EURCAD_OCO3S1_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO3Sets1[EURCAD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO3Sets1[EURCAD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.EURCAD_DOWN_S2_OCO3Sets1.Clear();
		                        EURCAD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURCAD_OCO3S2_DOWN_S2 = 0;
		                for (; EURCAD_OCO3S2_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets2.Count; EURCAD_OCO3S2_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO3Sets2[EURCAD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO3Sets2[EURCAD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.EURCAD_DOWN_S2_OCO3Sets2.Clear();
		                        EURCAD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO3S3_DOWN_S2 = 0;
		                for (; EURCAD_OCO3S3_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets3.Count; EURCAD_OCO3S3_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO3Sets3[EURCAD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO3Sets3[EURCAD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.EURCAD_DOWN_S2_OCO3Sets3.Clear();
		                        EURCAD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO3S4_DOWN_S2 = 0;
		                for (; EURCAD_OCO3S4_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets4.Count; EURCAD_OCO3S4_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO3Sets4[EURCAD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO3Sets4[EURCAD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.EURCAD_DOWN_S2_OCO3Sets4.Clear();
		                        EURCAD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO3S5_DOWN_S2 = 0;
		                for (; EURCAD_OCO3S5_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets5.Count; EURCAD_OCO3S5_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO3Sets5[EURCAD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO3Sets5[EURCAD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.EURCAD_DOWN_S2_OCO3Sets5.Clear();
		                        EURCAD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO3S6_DOWN_S2 = 0;
		                for (; EURCAD_OCO3S6_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets6.Count; EURCAD_OCO3S6_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO3Sets6[EURCAD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO3Sets6[EURCAD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.EURCAD_DOWN_S2_OCO3Sets6.Clear();
		                        EURCAD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURCAD_OCO4_EO1_DOWN_S2)
	                Base.EURCAD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURCAD_OCO4_EO2_DOWN_S2)
	                Base.EURCAD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO4_EO3_DOWN_S2)
	                Base.EURCAD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO4_EO4_DOWN_S2)
	                Base.EURCAD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO4_EO5_DOWN_S2)
	                Base.EURCAD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURCAD_OCO4_EO6_DOWN_S2)
	                Base.EURCAD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCAD_OCO4S1_DOWN_S2 = 0;
		                for (; EURCAD_OCO4S1_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets1.Count; EURCAD_OCO4S1_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO4Sets1[EURCAD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO4Sets1[EURCAD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.EURCAD_DOWN_S2_OCO4Sets1.Clear();
		                        EURCAD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURCAD_OCO4S2_DOWN_S2 = 0;
		                for (; EURCAD_OCO4S2_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets2.Count; EURCAD_OCO4S2_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO4Sets2[EURCAD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO4Sets2[EURCAD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.EURCAD_DOWN_S2_OCO4Sets2.Clear();
		                        EURCAD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO4S3_DOWN_S2 = 0;
		                for (; EURCAD_OCO4S3_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets3.Count; EURCAD_OCO4S3_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO4Sets3[EURCAD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO4Sets3[EURCAD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.EURCAD_DOWN_S2_OCO4Sets3.Clear();
		                        EURCAD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCAD_OCO4S4_DOWN_S2 = 0;
		                for (; EURCAD_OCO4S4_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets4.Count; EURCAD_OCO4S4_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO4Sets4[EURCAD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO4Sets4[EURCAD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.EURCAD_DOWN_S2_OCO4Sets4.Clear();
		                        EURCAD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO4S5_DOWN_S2 = 0;
		                for (; EURCAD_OCO4S5_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets5.Count; EURCAD_OCO4S5_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO4Sets5[EURCAD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO4Sets5[EURCAD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.EURCAD_DOWN_S2_OCO4Sets5.Clear();
		                        EURCAD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCAD_OCO4S6_DOWN_S2 = 0;
		                for (; EURCAD_OCO4S6_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets6.Count; EURCAD_OCO4S6_DOWN_S2++)
		                    if (Base.EURCAD_DOWN_S2_OCO4Sets6[EURCAD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCAD_DOWN_S2_OCO4Sets6[EURCAD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCAD", order.Quantity, false, "EURCAD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.EURCAD_DOWN_S2_OCO4Sets6.Clear();
		                        EURCAD_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();
	            	}
	            	
					DOWM_EURCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURCAD_DOWN_S2 = DOWM_EURCAD_DOWN_S2 || DOWT_EURCAD_DOWN_S2 || DOWW_EURCAD_DOWN_S2 || DOWTH_EURCAD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;
					
					if (SY1D.Symbol.Equals("EURCAD"))
	            	{
	            		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.EURCAD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.EURCAD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.EURCAD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.EURCAD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.EURCAD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURCAD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURCAD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURCAD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURCAD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURCAD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURCAD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	EURCAD_Signal_Condition_DOWN_S2 =  
	                									(
	                										//pricesM_ASK_OpenpricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_OpenpricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.04m &&
	                										
	                										//pricesM_ASK_Openprices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//pricesM_ASK_Openprices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[0] > prices_ASK_Close[0] * 0.02m &&

	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 && //yuhukj
	                										
	                										//prices_BID_Close[0] - prices_ASK_Open[0] > 0 &&
 	                										
	                										//prices_BID_Close[0] > pricesM_ASK_High[0] && 
	                										//prices_ASK_High[0] > pricesM_ASK_High[0] && 
	                										
	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										//pricesM_BID_Open[1] - pricesM_ASK_Close[1] > 0 &&
	                										
	                										//pricesM_BID_High[0] - pricesM_ASK_Open[0] > pricesM_BID_High[1] - pricesM_ASK_Open[1] &&
	                										
	                										//pricesM_BID_High[0] > pricesM_BID_High[1] &&
	                										
	                										//prices_BID_Close[0] > prices_ASK_Close[0]
	                										
	                										prices_BID_Close[0] - prices_ASK_Open[0] > prices_ASK_Open[0] * 0.00025m &&
	                										
	                										prices_ASK_High[0] > pricesM_ASK_High[0] &&
	                										prices_BID_Close[0] < pricesM_BID_High[0] &&
	                										
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.001m
	                									);

	                    EURCAD_DOWN_S2_SL  =  0.002m;
	                    EURCAD_DOWN_S2_TP1 =  0.005m;
	                    EURCAD_DOWN_S2_TP2 =  EURCAD_DOWN_S2_SL * 0;
	                    EURCAD_DOWN_S2_TP3 =  EURCAD_DOWN_S2_SL * 0;
	                    EURCAD_DOWN_S2_TP4 =  EURCAD_DOWN_S2_SL * 0;
	                    EURCAD_DOWN_S2_TP5 =  EURCAD_DOWN_S2_SL * 0;
	                    EURCAD_DOWN_S2_TP6 =  EURCAD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURCAD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURCAD_quantity_SL_DOWN_S2 = EURCAD_quantity_DOWN_S2;
	                    EURCAD_quantity_TP1_DOWN_S2 = (int)Math.Floor(EURCAD_quantity_DOWN_S2 * 1m);
	                    EURCAD_quantity_TP2_DOWN_S2 = (int)Math.Floor(EURCAD_quantity_TP1_DOWN_S2 * 0m);
	                    EURCAD_quantity_TP3_DOWN_S2 = (int)Math.Floor(EURCAD_quantity_TP2_DOWN_S2 * 0m);
	                    EURCAD_quantity_TP4_DOWN_S2 = (int)Math.Floor(EURCAD_quantity_TP3_DOWN_S2 * 0m);
	                    EURCAD_quantity_TP5_DOWN_S2 = (int)Math.Floor(EURCAD_quantity_TP4_DOWN_S2 * 0m);
	                    EURCAD_quantity_TP6_DOWN_S2 = (int)Math.Floor(EURCAD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (EURCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURCAD_DOWN_S2 && 
	                    Base.EURCAD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.EURCAD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCAD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP1_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.EURCAD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.EURCAD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP2_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.EURCAD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.EURCAD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP3_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.EURCAD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.EURCAD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP4_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.EURCAD_OCO1_EO4_DOWN_S2 = false;

							Base.EURCAD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.EURCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (EURCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURCAD_DOWN_S2 && 
	                    Base.EURCAD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.EURCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURCAD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCAD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP1_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.EURCAD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.EURCAD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP2_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.EURCAD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.EURCAD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP3_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.EURCAD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.EURCAD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP4_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.EURCAD_OCO2_EO4_DOWN_S2 = false;

							Base.EURCAD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.EURCAD_OCO2_DOWN_S2_IsReady == false && Base.EURCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (EURCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURCAD_DOWN_S2 &&
	                    Base.EURCAD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.EURCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURCAD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCAD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP1_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.EURCAD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.EURCAD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP2_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.EURCAD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.EURCAD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP3_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.EURCAD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.EURCAD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP4_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.EURCAD_OCO3_EO4_DOWN_S2 = false;

							Base.EURCAD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.EURCAD_OCO3_DOWN_S2_IsReady == false && Base.EURCAD_OCO2_DOWN_S2_IsReady == false && Base.EURCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (EURCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURCAD_DOWN_S2 && 
	                    Base.EURCAD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.EURCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURCAD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.EURCAD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCAD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP1_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.EURCAD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.EURCAD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP2_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.EURCAD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.EURCAD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP3_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.EURCAD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.EURCAD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCAD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCAD_quantity_TP4_DOWN_S2, false,"EURCAD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.EURCAD_OCO4_EO4_DOWN_S2 = false;

							Base.EURCAD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.EURCAD_OCO4_DOWN_S2_IsReady == false && Base.EURCAD_OCO3_DOWN_S2_IsReady == false && Base.EURCAD_OCO2_DOWN_S2_IsReady == false && Base.EURCAD_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
    {
    	
    	public static Symbol _EURAUD;
		
    	///oco1 up
    	public static OrderTicket EURAUD_OCO1_MO1_UP_S2;
    	public static OrderTicket EURAUD_OCO1_MO2_UP_S2;
    	public static OrderTicket EURAUD_OCO1_MO3_UP_S2;
    	public static OrderTicket EURAUD_OCO1_MO4_UP_S2;
    	public static OrderTicket EURAUD_OCO1_MO5_UP_S2;
    	public static OrderTicket EURAUD_OCO1_MO6_UP_S2;
    	
    	public static int EURAUD_OCO1_EO1_UP_S2_ID ;
        public static int EURAUD_OCO1_EO2_UP_S2_ID ;
        public static int EURAUD_OCO1_EO3_UP_S2_ID ;
        public static int EURAUD_OCO1_EO4_UP_S2_ID ;
        public static int EURAUD_OCO1_EO5_UP_S2_ID ;
        public static int EURAUD_OCO1_EO6_UP_S2_ID ;
        
        public static bool EURAUD_OCO1_EO1_UP_S2 ;
        public static bool EURAUD_OCO1_EO2_UP_S2 ;
        public static bool EURAUD_OCO1_EO3_UP_S2 ;
        public static bool EURAUD_OCO1_EO4_UP_S2 ;
        public static bool EURAUD_OCO1_EO5_UP_S2 ;
        public static bool EURAUD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_UP_S2> EURAUD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_UP_S2> EURAUD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_UP_S2> EURAUD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_UP_S2> EURAUD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_UP_S2> EURAUD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_UP_S2> EURAUD_OOFE_OCO1_UP_S2_6 ;
        
        public static EURAUD_OCO1_UP_S2 EURAUD_PFO_OCO1_UP_S2_1 ;
        public static EURAUD_OCO1_UP_S2 EURAUD_PFO_OCO1_UP_S2_2 ;
        public static EURAUD_OCO1_UP_S2 EURAUD_PFO_OCO1_UP_S2_3 ;
        public static EURAUD_OCO1_UP_S2 EURAUD_PFO_OCO1_UP_S2_4 ;
        public static EURAUD_OCO1_UP_S2 EURAUD_PFO_OCO1_UP_S2_5 ;
        public static EURAUD_OCO1_UP_S2 EURAUD_PFO_OCO1_UP_S2_6 ;
        
        public static List<EURAUD_OCO1_UP_S2> EURAUD_UP_S2_OCO1Sets1 = new List<EURAUD_OCO1_UP_S2>();
        public static List<EURAUD_OCO1_UP_S2> EURAUD_UP_S2_OCO1Sets2 = new List<EURAUD_OCO1_UP_S2>();
        public static List<EURAUD_OCO1_UP_S2> EURAUD_UP_S2_OCO1Sets3 = new List<EURAUD_OCO1_UP_S2>();
        public static List<EURAUD_OCO1_UP_S2> EURAUD_UP_S2_OCO1Sets4 = new List<EURAUD_OCO1_UP_S2>();
        public static List<EURAUD_OCO1_UP_S2> EURAUD_UP_S2_OCO1Sets5 = new List<EURAUD_OCO1_UP_S2>();
        public static List<EURAUD_OCO1_UP_S2> EURAUD_UP_S2_OCO1Sets6 = new List<EURAUD_OCO1_UP_S2>();
        
        public static bool EURAUD_OCO1_UP_S2_IsReady = true;
        public static bool EURAUD_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket EURAUD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int EURAUD_OCO1_EO1_DOWN_S2_ID ;
        public static int EURAUD_OCO1_EO2_DOWN_S2_ID ;
        public static int EURAUD_OCO1_EO3_DOWN_S2_ID ;
        public static int EURAUD_OCO1_EO4_DOWN_S2_ID ;
        public static int EURAUD_OCO1_EO5_DOWN_S2_ID ;
        public static int EURAUD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool EURAUD_OCO1_EO1_DOWN_S2 ;
        public static bool EURAUD_OCO1_EO2_DOWN_S2 ;
        public static bool EURAUD_OCO1_EO3_DOWN_S2 ;
        public static bool EURAUD_OCO1_EO4_DOWN_S2 ;
        public static bool EURAUD_OCO1_EO5_DOWN_S2 ;
        public static bool EURAUD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_DOWN_S2> EURAUD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_DOWN_S2> EURAUD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_DOWN_S2> EURAUD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_DOWN_S2> EURAUD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_DOWN_S2> EURAUD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO1_DOWN_S2> EURAUD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static EURAUD_OCO1_DOWN_S2 EURAUD_PFO_OCO1_DOWN_S2_1 ;
        public static EURAUD_OCO1_DOWN_S2 EURAUD_PFO_OCO1_DOWN_S2_2 ;
        public static EURAUD_OCO1_DOWN_S2 EURAUD_PFO_OCO1_DOWN_S2_3 ;
        public static EURAUD_OCO1_DOWN_S2 EURAUD_PFO_OCO1_DOWN_S2_4 ;
        public static EURAUD_OCO1_DOWN_S2 EURAUD_PFO_OCO1_DOWN_S2_5 ;
        public static EURAUD_OCO1_DOWN_S2 EURAUD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<EURAUD_OCO1_DOWN_S2> EURAUD_DOWN_S2_OCO1Sets1 = new List<EURAUD_OCO1_DOWN_S2>();
        public static List<EURAUD_OCO1_DOWN_S2> EURAUD_DOWN_S2_OCO1Sets2 = new List<EURAUD_OCO1_DOWN_S2>();
        public static List<EURAUD_OCO1_DOWN_S2> EURAUD_DOWN_S2_OCO1Sets3 = new List<EURAUD_OCO1_DOWN_S2>();
        public static List<EURAUD_OCO1_DOWN_S2> EURAUD_DOWN_S2_OCO1Sets4 = new List<EURAUD_OCO1_DOWN_S2>();
        public static List<EURAUD_OCO1_DOWN_S2> EURAUD_DOWN_S2_OCO1Sets5 = new List<EURAUD_OCO1_DOWN_S2>();
        public static List<EURAUD_OCO1_DOWN_S2> EURAUD_DOWN_S2_OCO1Sets6 = new List<EURAUD_OCO1_DOWN_S2>();
        
        public static bool EURAUD_OCO1_DOWN_S2_IsReady = true;
        public static bool EURAUD_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket EURAUD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO6_UP_S2 ;
    	
    	public static int EURAUD_OCO2_EO1_UP_S2_ID ;
        public static int EURAUD_OCO2_EO2_UP_S2_ID ;
        public static int EURAUD_OCO2_EO3_UP_S2_ID ;
        public static int EURAUD_OCO2_EO4_UP_S2_ID ;
        public static int EURAUD_OCO2_EO5_UP_S2_ID ;
        public static int EURAUD_OCO2_EO6_UP_S2_ID ;
        
        public static bool EURAUD_OCO2_EO1_UP_S2 ;
        public static bool EURAUD_OCO2_EO2_UP_S2 ;
        public static bool EURAUD_OCO2_EO3_UP_S2 ;
        public static bool EURAUD_OCO2_EO4_UP_S2 ;
        public static bool EURAUD_OCO2_EO5_UP_S2 ;
        public static bool EURAUD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_UP_S2> EURAUD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_UP_S2> EURAUD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_UP_S2> EURAUD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_UP_S2> EURAUD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_UP_S2> EURAUD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_UP_S2> EURAUD_OOFE_OCO2_UP_S2_6 ;
        
        public static EURAUD_OCO2_UP_S2 EURAUD_PFO_OCO2_UP_S2_1 ;
        public static EURAUD_OCO2_UP_S2 EURAUD_PFO_OCO2_UP_S2_2 ;
        public static EURAUD_OCO2_UP_S2 EURAUD_PFO_OCO2_UP_S2_3 ;
        public static EURAUD_OCO2_UP_S2 EURAUD_PFO_OCO2_UP_S2_4 ;
        public static EURAUD_OCO2_UP_S2 EURAUD_PFO_OCO2_UP_S2_5 ;
        public static EURAUD_OCO2_UP_S2 EURAUD_PFO_OCO2_UP_S2_6 ;
        
        public static List<EURAUD_OCO2_UP_S2> EURAUD_UP_S2_OCO2Sets1 = new List<EURAUD_OCO2_UP_S2>();
        public static List<EURAUD_OCO2_UP_S2> EURAUD_UP_S2_OCO2Sets2 = new List<EURAUD_OCO2_UP_S2>();
        public static List<EURAUD_OCO2_UP_S2> EURAUD_UP_S2_OCO2Sets3 = new List<EURAUD_OCO2_UP_S2>();
        public static List<EURAUD_OCO2_UP_S2> EURAUD_UP_S2_OCO2Sets4 = new List<EURAUD_OCO2_UP_S2>();
        public static List<EURAUD_OCO2_UP_S2> EURAUD_UP_S2_OCO2Sets5 = new List<EURAUD_OCO2_UP_S2>();
        public static List<EURAUD_OCO2_UP_S2> EURAUD_UP_S2_OCO2Sets6 = new List<EURAUD_OCO2_UP_S2>();
        
        public static bool EURAUD_OCO2_UP_S2_IsReady = true;
        public static bool EURAUD_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket EURAUD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int EURAUD_OCO2_EO1_DOWN_S2_ID ;
        public static int EURAUD_OCO2_EO2_DOWN_S2_ID ;
        public static int EURAUD_OCO2_EO3_DOWN_S2_ID ;
        public static int EURAUD_OCO2_EO4_DOWN_S2_ID ;
        public static int EURAUD_OCO2_EO5_DOWN_S2_ID ;
        public static int EURAUD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool EURAUD_OCO2_EO1_DOWN_S2 ;
        public static bool EURAUD_OCO2_EO2_DOWN_S2 ;
        public static bool EURAUD_OCO2_EO3_DOWN_S2 ;
        public static bool EURAUD_OCO2_EO4_DOWN_S2 ;
        public static bool EURAUD_OCO2_EO5_DOWN_S2 ;
        public static bool EURAUD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_DOWN_S2> EURAUD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_DOWN_S2> EURAUD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_DOWN_S2> EURAUD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_DOWN_S2> EURAUD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_DOWN_S2> EURAUD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO2_DOWN_S2> EURAUD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static EURAUD_OCO2_DOWN_S2 EURAUD_PFO_OCO2_DOWN_S2_1 ;
        public static EURAUD_OCO2_DOWN_S2 EURAUD_PFO_OCO2_DOWN_S2_2 ;
        public static EURAUD_OCO2_DOWN_S2 EURAUD_PFO_OCO2_DOWN_S2_3 ;
        public static EURAUD_OCO2_DOWN_S2 EURAUD_PFO_OCO2_DOWN_S2_4 ;
        public static EURAUD_OCO2_DOWN_S2 EURAUD_PFO_OCO2_DOWN_S2_5 ;
        public static EURAUD_OCO2_DOWN_S2 EURAUD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<EURAUD_OCO2_DOWN_S2> EURAUD_DOWN_S2_OCO2Sets1 = new List<EURAUD_OCO2_DOWN_S2>();
        public static List<EURAUD_OCO2_DOWN_S2> EURAUD_DOWN_S2_OCO2Sets2 = new List<EURAUD_OCO2_DOWN_S2>();
        public static List<EURAUD_OCO2_DOWN_S2> EURAUD_DOWN_S2_OCO2Sets3 = new List<EURAUD_OCO2_DOWN_S2>();
        public static List<EURAUD_OCO2_DOWN_S2> EURAUD_DOWN_S2_OCO2Sets4 = new List<EURAUD_OCO2_DOWN_S2>();
        public static List<EURAUD_OCO2_DOWN_S2> EURAUD_DOWN_S2_OCO2Sets5 = new List<EURAUD_OCO2_DOWN_S2>();
        public static List<EURAUD_OCO2_DOWN_S2> EURAUD_DOWN_S2_OCO2Sets6 = new List<EURAUD_OCO2_DOWN_S2>();
        
        public static bool EURAUD_OCO2_DOWN_S2_IsReady = true;
        public static bool EURAUD_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket EURAUD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO6_UP_S2 ;
    	
    	public static int EURAUD_OCO3_EO1_UP_S2_ID ;
        public static int EURAUD_OCO3_EO2_UP_S2_ID ;
        public static int EURAUD_OCO3_EO3_UP_S2_ID ;
        public static int EURAUD_OCO3_EO4_UP_S2_ID ;
        public static int EURAUD_OCO3_EO5_UP_S2_ID ;
        public static int EURAUD_OCO3_EO6_UP_S2_ID ;
        
        public static bool EURAUD_OCO3_EO1_UP_S2 ;
        public static bool EURAUD_OCO3_EO2_UP_S2 ;
        public static bool EURAUD_OCO3_EO3_UP_S2 ;
        public static bool EURAUD_OCO3_EO4_UP_S2 ;
        public static bool EURAUD_OCO3_EO5_UP_S2 ;
        public static bool EURAUD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_UP_S2> EURAUD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_UP_S2> EURAUD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_UP_S2> EURAUD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_UP_S2> EURAUD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_UP_S2> EURAUD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_UP_S2> EURAUD_OOFE_OCO3_UP_S2_6 ;
        
        public static EURAUD_OCO3_UP_S2 EURAUD_PFO_OCO3_UP_S2_1 ;
        public static EURAUD_OCO3_UP_S2 EURAUD_PFO_OCO3_UP_S2_2 ;
        public static EURAUD_OCO3_UP_S2 EURAUD_PFO_OCO3_UP_S2_3 ;
        public static EURAUD_OCO3_UP_S2 EURAUD_PFO_OCO3_UP_S2_4 ;
        public static EURAUD_OCO3_UP_S2 EURAUD_PFO_OCO3_UP_S2_5 ;
        public static EURAUD_OCO3_UP_S2 EURAUD_PFO_OCO3_UP_S2_6 ;
        
        public static List<EURAUD_OCO3_UP_S2> EURAUD_UP_S2_OCO3Sets1 = new List<EURAUD_OCO3_UP_S2>();
        public static List<EURAUD_OCO3_UP_S2> EURAUD_UP_S2_OCO3Sets2 = new List<EURAUD_OCO3_UP_S2>();
        public static List<EURAUD_OCO3_UP_S2> EURAUD_UP_S2_OCO3Sets3 = new List<EURAUD_OCO3_UP_S2>();
        public static List<EURAUD_OCO3_UP_S2> EURAUD_UP_S2_OCO3Sets4 = new List<EURAUD_OCO3_UP_S2>();
        public static List<EURAUD_OCO3_UP_S2> EURAUD_UP_S2_OCO3Sets5 = new List<EURAUD_OCO3_UP_S2>();
        public static List<EURAUD_OCO3_UP_S2> EURAUD_UP_S2_OCO3Sets6 = new List<EURAUD_OCO3_UP_S2>();
        
        public static bool EURAUD_OCO3_UP_S2_IsReady = true;
        public static bool EURAUD_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket EURAUD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int EURAUD_OCO3_EO1_DOWN_S2_ID ;
        public static int EURAUD_OCO3_EO2_DOWN_S2_ID ;
        public static int EURAUD_OCO3_EO3_DOWN_S2_ID ;
        public static int EURAUD_OCO3_EO4_DOWN_S2_ID ;
        public static int EURAUD_OCO3_EO5_DOWN_S2_ID ;
        public static int EURAUD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool EURAUD_OCO3_EO1_DOWN_S2 ;
        public static bool EURAUD_OCO3_EO2_DOWN_S2 ;
        public static bool EURAUD_OCO3_EO3_DOWN_S2 ;
        public static bool EURAUD_OCO3_EO4_DOWN_S2 ;
        public static bool EURAUD_OCO3_EO5_DOWN_S2 ;
        public static bool EURAUD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_DOWN_S2> EURAUD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_DOWN_S2> EURAUD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_DOWN_S2> EURAUD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_DOWN_S2> EURAUD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_DOWN_S2> EURAUD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO3_DOWN_S2> EURAUD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static EURAUD_OCO3_DOWN_S2 EURAUD_PFO_OCO3_DOWN_S2_1 ;
        public static EURAUD_OCO3_DOWN_S2 EURAUD_PFO_OCO3_DOWN_S2_2 ;
        public static EURAUD_OCO3_DOWN_S2 EURAUD_PFO_OCO3_DOWN_S2_3 ;
        public static EURAUD_OCO3_DOWN_S2 EURAUD_PFO_OCO3_DOWN_S2_4 ;
        public static EURAUD_OCO3_DOWN_S2 EURAUD_PFO_OCO3_DOWN_S2_5 ;
        public static EURAUD_OCO3_DOWN_S2 EURAUD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<EURAUD_OCO3_DOWN_S2> EURAUD_DOWN_S2_OCO3Sets1 = new List<EURAUD_OCO3_DOWN_S2>();
        public static List<EURAUD_OCO3_DOWN_S2> EURAUD_DOWN_S2_OCO3Sets2 = new List<EURAUD_OCO3_DOWN_S2>();
        public static List<EURAUD_OCO3_DOWN_S2> EURAUD_DOWN_S2_OCO3Sets3 = new List<EURAUD_OCO3_DOWN_S2>();
        public static List<EURAUD_OCO3_DOWN_S2> EURAUD_DOWN_S2_OCO3Sets4 = new List<EURAUD_OCO3_DOWN_S2>();
        public static List<EURAUD_OCO3_DOWN_S2> EURAUD_DOWN_S2_OCO3Sets5 = new List<EURAUD_OCO3_DOWN_S2>();
        public static List<EURAUD_OCO3_DOWN_S2> EURAUD_DOWN_S2_OCO3Sets6 = new List<EURAUD_OCO3_DOWN_S2>();
        
        public static bool EURAUD_OCO3_DOWN_S2_IsReady = true;
        public static bool EURAUD_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket EURAUD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO6_UP_S2 ;
    	
    	public static int EURAUD_OCO4_EO1_UP_S2_ID ;
        public static int EURAUD_OCO4_EO2_UP_S2_ID ;
        public static int EURAUD_OCO4_EO3_UP_S2_ID ;
        public static int EURAUD_OCO4_EO4_UP_S2_ID ;
        public static int EURAUD_OCO4_EO5_UP_S2_ID ;
        public static int EURAUD_OCO4_EO6_UP_S2_ID ;
        
        public static bool EURAUD_OCO4_EO1_UP_S2 ;
        public static bool EURAUD_OCO4_EO2_UP_S2 ;
        public static bool EURAUD_OCO4_EO3_UP_S2 ;
        public static bool EURAUD_OCO4_EO4_UP_S2 ;
        public static bool EURAUD_OCO4_EO5_UP_S2 ;
        public static bool EURAUD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_UP_S2> EURAUD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_UP_S2> EURAUD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_UP_S2> EURAUD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_UP_S2> EURAUD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_UP_S2> EURAUD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_UP_S2> EURAUD_OOFE_OCO4_UP_S2_6 ;
        
        public static EURAUD_OCO4_UP_S2 EURAUD_PFO_OCO4_UP_S2_1 ;
        public static EURAUD_OCO4_UP_S2 EURAUD_PFO_OCO4_UP_S2_2 ;
        public static EURAUD_OCO4_UP_S2 EURAUD_PFO_OCO4_UP_S2_3 ;
        public static EURAUD_OCO4_UP_S2 EURAUD_PFO_OCO4_UP_S2_4 ;
        public static EURAUD_OCO4_UP_S2 EURAUD_PFO_OCO4_UP_S2_5 ;
        public static EURAUD_OCO4_UP_S2 EURAUD_PFO_OCO4_UP_S2_6 ;
        
        public static List<EURAUD_OCO4_UP_S2> EURAUD_UP_S2_OCO4Sets1 = new List<EURAUD_OCO4_UP_S2>();
        public static List<EURAUD_OCO4_UP_S2> EURAUD_UP_S2_OCO4Sets2 = new List<EURAUD_OCO4_UP_S2>();
        public static List<EURAUD_OCO4_UP_S2> EURAUD_UP_S2_OCO4Sets3 = new List<EURAUD_OCO4_UP_S2>();
        public static List<EURAUD_OCO4_UP_S2> EURAUD_UP_S2_OCO4Sets4 = new List<EURAUD_OCO4_UP_S2>();
        public static List<EURAUD_OCO4_UP_S2> EURAUD_UP_S2_OCO4Sets5 = new List<EURAUD_OCO4_UP_S2>();
        public static List<EURAUD_OCO4_UP_S2> EURAUD_UP_S2_OCO4Sets6 = new List<EURAUD_OCO4_UP_S2>();
        
        public static bool EURAUD_OCO4_UP_S2_IsReady = true;
        public static bool EURAUD_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket EURAUD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket EURAUD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int EURAUD_OCO4_EO1_DOWN_S2_ID ;
        public static int EURAUD_OCO4_EO2_DOWN_S2_ID ;
        public static int EURAUD_OCO4_EO3_DOWN_S2_ID ;
        public static int EURAUD_OCO4_EO4_DOWN_S2_ID ;
        public static int EURAUD_OCO4_EO5_DOWN_S2_ID ;
        public static int EURAUD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool EURAUD_OCO4_EO1_DOWN_S2 ;
        public static bool EURAUD_OCO4_EO2_DOWN_S2 ;
        public static bool EURAUD_OCO4_EO3_DOWN_S2 ;
        public static bool EURAUD_OCO4_EO4_DOWN_S2 ;
        public static bool EURAUD_OCO4_EO5_DOWN_S2 ;
        public static bool EURAUD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_DOWN_S2> EURAUD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_DOWN_S2> EURAUD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_DOWN_S2> EURAUD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_DOWN_S2> EURAUD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_DOWN_S2> EURAUD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURAUD_OCO4_DOWN_S2> EURAUD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static EURAUD_OCO4_DOWN_S2 EURAUD_PFO_OCO4_DOWN_S2_1 ;
        public static EURAUD_OCO4_DOWN_S2 EURAUD_PFO_OCO4_DOWN_S2_2 ;
        public static EURAUD_OCO4_DOWN_S2 EURAUD_PFO_OCO4_DOWN_S2_3 ;
        public static EURAUD_OCO4_DOWN_S2 EURAUD_PFO_OCO4_DOWN_S2_4 ;
        public static EURAUD_OCO4_DOWN_S2 EURAUD_PFO_OCO4_DOWN_S2_5 ;
        public static EURAUD_OCO4_DOWN_S2 EURAUD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<EURAUD_OCO4_DOWN_S2> EURAUD_DOWN_S2_OCO4Sets1 = new List<EURAUD_OCO4_DOWN_S2>();
        public static List<EURAUD_OCO4_DOWN_S2> EURAUD_DOWN_S2_OCO4Sets2 = new List<EURAUD_OCO4_DOWN_S2>();
        public static List<EURAUD_OCO4_DOWN_S2> EURAUD_DOWN_S2_OCO4Sets3 = new List<EURAUD_OCO4_DOWN_S2>();
        public static List<EURAUD_OCO4_DOWN_S2> EURAUD_DOWN_S2_OCO4Sets4 = new List<EURAUD_OCO4_DOWN_S2>();
        public static List<EURAUD_OCO4_DOWN_S2> EURAUD_DOWN_S2_OCO4Sets5 = new List<EURAUD_OCO4_DOWN_S2>();
        public static List<EURAUD_OCO4_DOWN_S2> EURAUD_DOWN_S2_OCO4Sets6 = new List<EURAUD_OCO4_DOWN_S2>();
        
        public static bool EURAUD_OCO4_DOWN_S2_IsReady = true;
        public static bool EURAUD_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal EURAUD_UP_S2_SL {get; set;}
		public static decimal EURAUD_UP_S2_TP1 {get; set;}
		public static decimal EURAUD_UP_S2_TP2 {get; set;}
		public static decimal EURAUD_UP_S2_TP3 {get; set;}
		public static decimal EURAUD_UP_S2_TP4 {get; set;}
		public static decimal EURAUD_UP_S2_TP5 {get; set;}
		public static decimal EURAUD_UP_S2_TP6 {get; set;}
		
		public static decimal EURAUD_DOWN_S2_SL {get; set;}
		public static decimal EURAUD_DOWN_S2_TP1 {get; set;}
		public static decimal EURAUD_DOWN_S2_TP2 {get; set;}
		public static decimal EURAUD_DOWN_S2_TP3 {get; set;}
		public static decimal EURAUD_DOWN_S2_TP4 {get; set;}
		public static decimal EURAUD_DOWN_S2_TP5 {get; set;}
		public static decimal EURAUD_DOWN_S2_TP6 {get; set;}

        public static bool EURAUD_Signal_Condition_UP_1 ;
        public static bool EURAUD_Signal_Condition_UP_2 ;
        public static bool EURAUD_Signal_Condition_UP_3 ;
        public static bool EURAUD_Signal_Condition_DOWN_S2 ;
        
        public static int EURAUD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int EURAUD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int EURAUD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int EURAUD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int EURAUD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int EURAUD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int EURAUD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int EURAUD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int EURAUD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int EURAUD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_EURAUD_UP_S2 ;
        public static bool DOWM_EURAUD_UP_S2 ;
        public static bool DOWT_EURAUD_UP_S2 ;
        public static bool DOWW_EURAUD_UP_S2 ;
        public static bool DOWTH_EURAUD_UP_S2 ;
        
		public static bool DOWR_EURAUD_DOWN_S2 ;
        public static bool DOWM_EURAUD_DOWN_S2 ;
        public static bool DOWT_EURAUD_DOWN_S2 ;
        public static bool DOWW_EURAUD_DOWN_S2 ;
        public static bool DOWTH_EURAUD_DOWN_S2 ;
        
        
		public static int EURAUD_quantity_UP_S2 ;
		public static int EURAUD_quantity_SL_UP_S2 ;
		public static int EURAUD_quantity_TP1_UP_S2 ;
		public static int EURAUD_quantity_TP2_UP_S2 ;
		public static int EURAUD_quantity_TP3_UP_S2 ;
		public static int EURAUD_quantity_TP4_UP_S2 ;
		public static int EURAUD_quantity_TP5_UP_S2;
		public static int EURAUD_quantity_TP6_UP_S2 ;
		
		public static int EURAUD_quantity_DOWN_S2 ;
		public static int EURAUD_quantity_SL_DOWN_S2 ;
		public static int EURAUD_quantity_TP1_DOWN_S2 ;
		public static int EURAUD_quantity_TP2_DOWN_S2 ;
		public static int EURAUD_quantity_TP3_DOWN_S2 ;
		public static int EURAUD_quantity_TP4_DOWN_S2 ;
		public static int EURAUD_quantity_TP5_DOWN_S2;
		public static int EURAUD_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 NZDUSD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public NZDUSD_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("NZDUSD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDUSD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDUSD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("NZDUSD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("NZDUSD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("NZDUSD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue NZDUSD S2");
		        	}
		        }
		        
				if (Base.NZDUSD_OCO1_EO1_DOWN_S2)
	                Base.NZDUSD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDUSD_OCO1_EO2_DOWN_S2)
	                Base.NZDUSD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO1_EO3_DOWN_S2)
	                Base.NZDUSD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO1_EO4_DOWN_S2)
	                Base.NZDUSD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDUSD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP1_NZDUSD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP1,"TP1_NZDUSD_DOWN_S2_OCO1"));
		                 };
		                Base.NZDUSD_DOWN_S2_OCO1Sets1.Add( Base.NZDUSD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP2_NZDUSD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP2,"TP2_NZDUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO1Sets2.Add( Base.NZDUSD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP3_NZDUSD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP3,"TP3_NZDUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO1Sets3.Add( Base.NZDUSD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP4_NZDUSD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP4,"TP4_NZDUSD_DOWN_S2_OCO1"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO1Sets4.Add( Base.NZDUSD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int NZDUSD_OCO1S1_DOWN_S2 = 0;
	                for (; NZDUSD_OCO1S1_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets1.Count; NZDUSD_OCO1S1_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO1Sets1[NZDUSD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO1Sets1[NZDUSD_OCO1S1_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO1Sets1.RemoveAt(NZDUSD_OCO1S1_DOWN_S2);
	                        NZDUSD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDUSD_OCO1S2_DOWN_S2 = 0;
	                for (; NZDUSD_OCO1S2_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets2.Count; NZDUSD_OCO1S2_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO1Sets2[NZDUSD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO1Sets2[NZDUSD_OCO1S2_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO1Sets2.RemoveAt(NZDUSD_OCO1S2_DOWN_S2);
	                        NZDUSD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO1S3_DOWN_S2 = 0;
	                for (; NZDUSD_OCO1S3_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets3.Count; NZDUSD_OCO1S3_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO1Sets3[NZDUSD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO1Sets3[NZDUSD_OCO1S3_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO1Sets3.RemoveAt(NZDUSD_OCO1S3_DOWN_S2);
	                        NZDUSD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO1S4_DOWN_S2 = 0;
	                for (; NZDUSD_OCO1S4_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO1Sets4.Count; NZDUSD_OCO1S4_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO1Sets4[NZDUSD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO1Sets4[NZDUSD_OCO1S4_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO1Sets4.RemoveAt(NZDUSD_OCO1S4_DOWN_S2);
	                        NZDUSD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDUSD_OCO2_EO1_DOWN_S2)
	                Base.NZDUSD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDUSD_OCO2_EO2_DOWN_S2)
	                Base.NZDUSD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO2_EO3_DOWN_S2)
	                Base.NZDUSD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO2_EO4_DOWN_S2)
	                Base.NZDUSD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDUSD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP1_NZDUSD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP1,"TP1_NZDUSD_DOWN_S2_OCO2"));
		                 };
		                Base.NZDUSD_DOWN_S2_OCO2Sets1.Add( Base.NZDUSD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP2_NZDUSD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP2,"TP2_NZDUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO2Sets2.Add( Base.NZDUSD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP3_NZDUSD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP3,"TP3_NZDUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO2Sets3.Add( Base.NZDUSD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP4_NZDUSD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP4,"TP4_NZDUSD_DOWN_S2_OCO2"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO2Sets4.Add( Base.NZDUSD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int NZDUSD_OCO2S1_DOWN_S2 = 0;
	                for (; NZDUSD_OCO2S1_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets1.Count; NZDUSD_OCO2S1_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO2Sets1[NZDUSD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO2Sets1[NZDUSD_OCO2S1_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO2Sets1.RemoveAt(NZDUSD_OCO2S1_DOWN_S2);
	                        NZDUSD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDUSD_OCO2S2_DOWN_S2 = 0;
	                for (; NZDUSD_OCO2S2_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets2.Count; NZDUSD_OCO2S2_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO2Sets2[NZDUSD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO2Sets2[NZDUSD_OCO2S2_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO2Sets2.RemoveAt(NZDUSD_OCO2S2_DOWN_S2);
	                        NZDUSD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO2S3_DOWN_S2 = 0;
	                for (; NZDUSD_OCO2S3_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets3.Count; NZDUSD_OCO2S3_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO2Sets3[NZDUSD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO2Sets3[NZDUSD_OCO2S3_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO2Sets3.RemoveAt(NZDUSD_OCO2S3_DOWN_S2);
	                        NZDUSD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO2S4_DOWN_S2 = 0;
	                for (; NZDUSD_OCO2S4_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO2Sets4.Count; NZDUSD_OCO2S4_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO2Sets4[NZDUSD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO2Sets4[NZDUSD_OCO2S4_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO2Sets4.RemoveAt(NZDUSD_OCO2S4_DOWN_S2);
	                        NZDUSD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDUSD_OCO3_EO1_DOWN_S2)
	                Base.NZDUSD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDUSD_OCO3_EO2_DOWN_S2)
	                Base.NZDUSD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO3_EO3_DOWN_S2)
	                Base.NZDUSD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO3_EO4_DOWN_S2)
	                Base.NZDUSD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDUSD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP1_NZDUSD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP1,"TP1_NZDUSD_DOWN_S2_OCO3"));
		                 };
		                Base.NZDUSD_DOWN_S2_OCO3Sets1.Add( Base.NZDUSD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP2_NZDUSD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP2,"TP2_NZDUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO3Sets2.Add( Base.NZDUSD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP3_NZDUSD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP3,"TP3_NZDUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO3Sets3.Add( Base.NZDUSD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP4_NZDUSD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP4,"TP4_NZDUSD_DOWN_S2_OCO3"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO3Sets4.Add( Base.NZDUSD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int NZDUSD_OCO3S1_DOWN_S2 = 0;
	                for (; NZDUSD_OCO3S1_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets1.Count; NZDUSD_OCO3S1_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO3Sets1[NZDUSD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO3Sets1[NZDUSD_OCO3S1_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO3Sets1.RemoveAt(NZDUSD_OCO3S1_DOWN_S2);
	                        NZDUSD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDUSD_OCO3S2_DOWN_S2 = 0;
	                for (; NZDUSD_OCO3S2_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets2.Count; NZDUSD_OCO3S2_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO3Sets2[NZDUSD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO3Sets2[NZDUSD_OCO3S2_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO3Sets2.RemoveAt(NZDUSD_OCO3S2_DOWN_S2);
	                        NZDUSD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO3S3_DOWN_S2 = 0;
	                for (; NZDUSD_OCO3S3_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets3.Count; NZDUSD_OCO3S3_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO3Sets3[NZDUSD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO3Sets3[NZDUSD_OCO3S3_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO3Sets3.RemoveAt(NZDUSD_OCO3S3_DOWN_S2);
	                        NZDUSD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO3S4_DOWN_S2 = 0;
	                for (; NZDUSD_OCO3S4_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO3Sets4.Count; NZDUSD_OCO3S4_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO3Sets4[NZDUSD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO3Sets4[NZDUSD_OCO3S4_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO3Sets4.RemoveAt(NZDUSD_OCO3S4_DOWN_S2);
	                        NZDUSD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.NZDUSD_OCO4_EO1_DOWN_S2)
	                Base.NZDUSD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.NZDUSD_OCO4_EO2_DOWN_S2)
	                Base.NZDUSD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO4_EO3_DOWN_S2)
	                Base.NZDUSD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.NZDUSD_OCO4_EO4_DOWN_S2)
	                Base.NZDUSD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.NZDUSD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP1_NZDUSD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP1,"TP1_NZDUSD_DOWN_S2_OCO4"));
		                 };
		                Base.NZDUSD_DOWN_S2_OCO4Sets1.Add( Base.NZDUSD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP2_NZDUSD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP2,"TP2_NZDUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO4Sets2.Add( Base.NZDUSD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP3_NZDUSD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP3,"TP3_NZDUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO4Sets3.Add( Base.NZDUSD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.NZDUSD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.NZDUSD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new NZDUSD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.NZDUSD_DOWN_S2_SL,"SL_TP4_NZDUSD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.NZDUSD_DOWN_S2_TP4,"TP4_NZDUSD_DOWN_S2_OCO4"));
		                 };
	                    Base.NZDUSD_DOWN_S2_OCO4Sets4.Add( Base.NZDUSD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.NZDUSD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int NZDUSD_OCO4S1_DOWN_S2 = 0;
	                for (; NZDUSD_OCO4S1_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets1.Count; NZDUSD_OCO4S1_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO4Sets1[NZDUSD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO4Sets1[NZDUSD_OCO4S1_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO4Sets1.RemoveAt(NZDUSD_OCO4S1_DOWN_S2);
	                        NZDUSD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int NZDUSD_OCO4S2_DOWN_S2 = 0;
	                for (; NZDUSD_OCO4S2_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets2.Count; NZDUSD_OCO4S2_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO4Sets2[NZDUSD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO4Sets2[NZDUSD_OCO4S2_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO4Sets2.RemoveAt(NZDUSD_OCO4S2_DOWN_S2);
	                        NZDUSD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO4S3_DOWN_S2 = 0;
	                for (; NZDUSD_OCO4S3_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets3.Count; NZDUSD_OCO4S3_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO4Sets3[NZDUSD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO4Sets3[NZDUSD_OCO4S3_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO4Sets3.RemoveAt(NZDUSD_OCO4S3_DOWN_S2);
	                        NZDUSD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int NZDUSD_OCO4S4_DOWN_S2 = 0;
	                for (; NZDUSD_OCO4S4_DOWN_S2 < Base.NZDUSD_DOWN_S2_OCO4Sets4.Count; NZDUSD_OCO4S4_DOWN_S2++)
	                    if (Base.NZDUSD_DOWN_S2_OCO4Sets4[NZDUSD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.NZDUSD_DOWN_S2_OCO4Sets4[NZDUSD_OCO4S4_DOWN_S2].Filled();
	                        Base.NZDUSD_DOWN_S2_OCO4Sets4.RemoveAt(NZDUSD_OCO4S4_DOWN_S2);
	                        NZDUSD_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct EURCHF_OCO1_DOWN_S2
    {
        public EURCHF_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 =="TP1_EURCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF 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 =="TP1_EURCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURCHF_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF 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 EURCHF_OCO1_UP_S2
    {
        public EURCHF_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 =="TP1_EURCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF 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 =="TP1_EURCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURCHF_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCHF 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 EURCHF_OCO2_DOWN_S2
    {
        public EURCHF_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 =="TP1_EURCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF 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 =="TP1_EURCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURCHF_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF 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 EURCHF_OCO2_UP_S2
    {
        public EURCHF_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 =="TP1_EURCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF 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 =="TP1_EURCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURCHF_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCHF 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 EURCHF_OCO3_DOWN_S2
    {
        public EURCHF_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 =="TP1_EURCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF 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 =="TP1_EURCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURCHF_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF 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 EURCHF_OCO3_UP_S2
    {
        public EURCHF_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 =="TP1_EURCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF 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 =="TP1_EURCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURCHF_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCHF 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 EURCHF_OCO4_DOWN_S2
    {
        public EURCHF_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 =="TP1_EURCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF 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 =="TP1_EURCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURCHF_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF 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 EURCHF_OCO4_UP_S2
    {
        public EURCHF_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 =="TP1_EURCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF 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 =="TP1_EURCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCHF_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURCHF_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCHF 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 USDCAD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public USDCAD_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("USDCAD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCAD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCAD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("USDCAD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("USDCAD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("USDCAD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue USDCAD S2");
		        	}
		        }
		        
				if (Base.USDCAD_OCO1_EO1_DOWN_S2)
	                Base.USDCAD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDCAD_OCO1_EO2_DOWN_S2)
	                Base.USDCAD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO1_EO3_DOWN_S2)
	                Base.USDCAD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO1_EO4_DOWN_S2)
	                Base.USDCAD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCAD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.USDCAD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP1_USDCAD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP1,"TP1_USDCAD_DOWN_S2_OCO1"));
		                 };
		                Base.USDCAD_DOWN_S2_OCO1Sets1.Add( Base.USDCAD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCAD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP2_USDCAD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP2,"TP2_USDCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO1Sets2.Add( Base.USDCAD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP3_USDCAD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP3,"TP3_USDCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO1Sets3.Add( Base.USDCAD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP4_USDCAD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP4,"TP4_USDCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO1Sets4.Add( Base.USDCAD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int USDCAD_OCO1S1_DOWN_S2 = 0;
	                for (; USDCAD_OCO1S1_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets1.Count; USDCAD_OCO1S1_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO1Sets1[USDCAD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO1Sets1[USDCAD_OCO1S1_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO1Sets1.RemoveAt(USDCAD_OCO1S1_DOWN_S2);
	                        USDCAD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDCAD_OCO1S2_DOWN_S2 = 0;
	                for (; USDCAD_OCO1S2_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets2.Count; USDCAD_OCO1S2_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO1Sets2[USDCAD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO1Sets2[USDCAD_OCO1S2_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO1Sets2.RemoveAt(USDCAD_OCO1S2_DOWN_S2);
	                        USDCAD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO1S3_DOWN_S2 = 0;
	                for (; USDCAD_OCO1S3_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets3.Count; USDCAD_OCO1S3_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO1Sets3[USDCAD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO1Sets3[USDCAD_OCO1S3_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO1Sets3.RemoveAt(USDCAD_OCO1S3_DOWN_S2);
	                        USDCAD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO1S4_DOWN_S2 = 0;
	                for (; USDCAD_OCO1S4_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO1Sets4.Count; USDCAD_OCO1S4_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO1Sets4[USDCAD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO1Sets4[USDCAD_OCO1S4_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO1Sets4.RemoveAt(USDCAD_OCO1S4_DOWN_S2);
	                        USDCAD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCAD_OCO2_EO1_DOWN_S2)
	                Base.USDCAD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDCAD_OCO2_EO2_DOWN_S2)
	                Base.USDCAD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO2_EO3_DOWN_S2)
	                Base.USDCAD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO2_EO4_DOWN_S2)
	                Base.USDCAD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCAD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.USDCAD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP1_USDCAD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP1,"TP1_USDCAD_DOWN_S2_OCO2"));
		                 };
		                Base.USDCAD_DOWN_S2_OCO2Sets1.Add( Base.USDCAD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCAD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP2_USDCAD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP2,"TP2_USDCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO2Sets2.Add( Base.USDCAD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP3_USDCAD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP3,"TP3_USDCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO2Sets3.Add( Base.USDCAD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP4_USDCAD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP4,"TP4_USDCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO2Sets4.Add( Base.USDCAD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int USDCAD_OCO2S1_DOWN_S2 = 0;
	                for (; USDCAD_OCO2S1_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets1.Count; USDCAD_OCO2S1_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO2Sets1[USDCAD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO2Sets1[USDCAD_OCO2S1_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO2Sets1.RemoveAt(USDCAD_OCO2S1_DOWN_S2);
	                        USDCAD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDCAD_OCO2S2_DOWN_S2 = 0;
	                for (; USDCAD_OCO2S2_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets2.Count; USDCAD_OCO2S2_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO2Sets2[USDCAD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO2Sets2[USDCAD_OCO2S2_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO2Sets2.RemoveAt(USDCAD_OCO2S2_DOWN_S2);
	                        USDCAD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO2S3_DOWN_S2 = 0;
	                for (; USDCAD_OCO2S3_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets3.Count; USDCAD_OCO2S3_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO2Sets3[USDCAD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO2Sets3[USDCAD_OCO2S3_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO2Sets3.RemoveAt(USDCAD_OCO2S3_DOWN_S2);
	                        USDCAD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO2S4_DOWN_S2 = 0;
	                for (; USDCAD_OCO2S4_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO2Sets4.Count; USDCAD_OCO2S4_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO2Sets4[USDCAD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO2Sets4[USDCAD_OCO2S4_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO2Sets4.RemoveAt(USDCAD_OCO2S4_DOWN_S2);
	                        USDCAD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCAD_OCO3_EO1_DOWN_S2)
	                Base.USDCAD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDCAD_OCO3_EO2_DOWN_S2)
	                Base.USDCAD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO3_EO3_DOWN_S2)
	                Base.USDCAD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO3_EO4_DOWN_S2)
	                Base.USDCAD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCAD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.USDCAD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP1_USDCAD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP1,"TP1_USDCAD_DOWN_S2_OCO3"));
		                 };
		                Base.USDCAD_DOWN_S2_OCO3Sets1.Add( Base.USDCAD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCAD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP2_USDCAD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP2,"TP2_USDCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO3Sets2.Add( Base.USDCAD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP3_USDCAD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP3,"TP3_USDCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO3Sets3.Add( Base.USDCAD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP4_USDCAD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP4,"TP4_USDCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO3Sets4.Add( Base.USDCAD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int USDCAD_OCO3S1_DOWN_S2 = 0;
	                for (; USDCAD_OCO3S1_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets1.Count; USDCAD_OCO3S1_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO3Sets1[USDCAD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO3Sets1[USDCAD_OCO3S1_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO3Sets1.RemoveAt(USDCAD_OCO3S1_DOWN_S2);
	                        USDCAD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDCAD_OCO3S2_DOWN_S2 = 0;
	                for (; USDCAD_OCO3S2_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets2.Count; USDCAD_OCO3S2_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO3Sets2[USDCAD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO3Sets2[USDCAD_OCO3S2_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO3Sets2.RemoveAt(USDCAD_OCO3S2_DOWN_S2);
	                        USDCAD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO3S3_DOWN_S2 = 0;
	                for (; USDCAD_OCO3S3_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets3.Count; USDCAD_OCO3S3_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO3Sets3[USDCAD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO3Sets3[USDCAD_OCO3S3_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO3Sets3.RemoveAt(USDCAD_OCO3S3_DOWN_S2);
	                        USDCAD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO3S4_DOWN_S2 = 0;
	                for (; USDCAD_OCO3S4_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO3Sets4.Count; USDCAD_OCO3S4_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO3Sets4[USDCAD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO3Sets4[USDCAD_OCO3S4_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO3Sets4.RemoveAt(USDCAD_OCO3S4_DOWN_S2);
	                        USDCAD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.USDCAD_OCO4_EO1_DOWN_S2)
	                Base.USDCAD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.USDCAD_OCO4_EO2_DOWN_S2)
	                Base.USDCAD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO4_EO3_DOWN_S2)
	                Base.USDCAD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.USDCAD_OCO4_EO4_DOWN_S2)
	                Base.USDCAD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.USDCAD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.USDCAD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP1_USDCAD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP1,"TP1_USDCAD_DOWN_S2_OCO4"));
		                 };
		                Base.USDCAD_DOWN_S2_OCO4Sets1.Add( Base.USDCAD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.USDCAD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP2_USDCAD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP2,"TP2_USDCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO4Sets2.Add( Base.USDCAD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP3_USDCAD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP3,"TP3_USDCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO4Sets3.Add( Base.USDCAD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.USDCAD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.USDCAD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new USDCAD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.USDCAD_DOWN_S2_SL,"SL_TP4_USDCAD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.USDCAD_DOWN_S2_TP4,"TP4_USDCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.USDCAD_DOWN_S2_OCO4Sets4.Add( Base.USDCAD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.USDCAD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int USDCAD_OCO4S1_DOWN_S2 = 0;
	                for (; USDCAD_OCO4S1_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets1.Count; USDCAD_OCO4S1_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO4Sets1[USDCAD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO4Sets1[USDCAD_OCO4S1_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO4Sets1.RemoveAt(USDCAD_OCO4S1_DOWN_S2);
	                        USDCAD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int USDCAD_OCO4S2_DOWN_S2 = 0;
	                for (; USDCAD_OCO4S2_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets2.Count; USDCAD_OCO4S2_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO4Sets2[USDCAD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO4Sets2[USDCAD_OCO4S2_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO4Sets2.RemoveAt(USDCAD_OCO4S2_DOWN_S2);
	                        USDCAD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO4S3_DOWN_S2 = 0;
	                for (; USDCAD_OCO4S3_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets3.Count; USDCAD_OCO4S3_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO4Sets3[USDCAD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO4Sets3[USDCAD_OCO4S3_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO4Sets3.RemoveAt(USDCAD_OCO4S3_DOWN_S2);
	                        USDCAD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int USDCAD_OCO4S4_DOWN_S2 = 0;
	                for (; USDCAD_OCO4S4_DOWN_S2 < Base.USDCAD_DOWN_S2_OCO4Sets4.Count; USDCAD_OCO4S4_DOWN_S2++)
	                    if (Base.USDCAD_DOWN_S2_OCO4Sets4[USDCAD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.USDCAD_DOWN_S2_OCO4Sets4[USDCAD_OCO4S4_DOWN_S2].Filled();
	                        Base.USDCAD_DOWN_S2_OCO4Sets4.RemoveAt(USDCAD_OCO4S4_DOWN_S2);
	                        USDCAD_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_USDJPY_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_USDJPY_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(x=>x.Tag.Contains("USDJPY_UP_S2_OCO1")))
			{
				Base.USDJPY_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDJPY_UP_S2_OCO2")))
			{
				Base.USDJPY_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDJPY_UP_S2_OCO3")))
			{
				Base.USDJPY_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("USDJPY_UP_S2_OCO4")))
			{
				Base.USDJPY_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("USDJPY_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.USDJPY_OCO1_EO1_UP_S2)
	                Base.USDJPY_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.USDJPY_OCO1_EO2_UP_S2)
	                Base.USDJPY_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO1_EO3_UP_S2)
	                Base.USDJPY_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO1_EO4_UP_S2)
	                Base.USDJPY_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO1_EO5_UP_S2)
	                Base.USDJPY_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO1_EO6_UP_S2)
	                Base.USDJPY_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDJPY_OCO1S1_UP_S2 = 0;
		                for (; USDJPY_OCO1S1_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets1.Count; USDJPY_OCO1S1_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO1Sets1[USDJPY_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO1Sets1[USDJPY_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_1__Time out_OCO1");
		                        Base.USDJPY_UP_S2_OCO1Sets1.Clear();
		                        USDJPY_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDJPY_OCO1S2_UP_S2 = 0;
		                for (; USDJPY_OCO1S2_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets2.Count; USDJPY_OCO1S2_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO1Sets2[USDJPY_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO1Sets2[USDJPY_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_2__Time out_OCO1");
		                        Base.USDJPY_UP_S2_OCO1Sets2.Clear();
		                        USDJPY_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO1S3_UP_S2 = 0;
		                for (; USDJPY_OCO1S3_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets3.Count; USDJPY_OCO1S3_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO1Sets3[USDJPY_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO1Sets3[USDJPY_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_3__Time out_OCO1");
		                        Base.USDJPY_UP_S2_OCO1Sets3.Clear();
		                        USDJPY_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO1S4_UP_S2 = 0;
		                for (; USDJPY_OCO1S4_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets4.Count; USDJPY_OCO1S4_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO1Sets4[USDJPY_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO1Sets4[USDJPY_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_4__Time out_OCO1");
		                        Base.USDJPY_UP_S2_OCO1Sets4.Clear();
		                        USDJPY_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO1S5_UP_S2 = 0;
		                for (; USDJPY_OCO1S5_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets5.Count; USDJPY_OCO1S5_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO1Sets5[USDJPY_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO1Sets5[USDJPY_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_5__Time out_OCO1");
		                        Base.USDJPY_UP_S2_OCO1Sets5.Clear();
		                        USDJPY_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO1S6_UP_S2 = 0;
		                for (; USDJPY_OCO1S6_UP_S2 < Base.USDJPY_UP_S2_OCO1Sets6.Count; USDJPY_OCO1S6_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO1Sets6[USDJPY_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO1Sets6[USDJPY_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_6__Time out_OCO1");
		                        Base.USDJPY_UP_S2_OCO1Sets6.Clear();
		                        USDJPY_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.USDJPY_OCO2_EO1_UP_S2)
                	Base.USDJPY_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.USDJPY_OCO2_EO2_UP_S2)
	                Base.USDJPY_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO2_EO3_UP_S2)
	                Base.USDJPY_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO2_EO4_UP_S2)
	                Base.USDJPY_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO2_EO5_UP_S2)
	                Base.USDJPY_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO2_EO6_UP_S2)
	                Base.USDJPY_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDJPY_OCO2S1_UP_S2 = 0;
		                for (; USDJPY_OCO2S1_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets1.Count; USDJPY_OCO2S1_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO2Sets1[USDJPY_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO2Sets1[USDJPY_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_1__Time out_OCO2");
		                        Base.USDJPY_UP_S2_OCO2Sets1.Clear();
		                        USDJPY_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDJPY_OCO2S2_UP_S2 = 0;
		                for (; USDJPY_OCO2S2_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets2.Count; USDJPY_OCO2S2_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO2Sets2[USDJPY_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO2Sets2[USDJPY_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_2__Time out_OCO2");
		                        Base.USDJPY_UP_S2_OCO2Sets2.Clear();
		                        USDJPY_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO2S3_UP_S2 = 0;
		                for (; USDJPY_OCO2S3_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets3.Count; USDJPY_OCO2S3_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO2Sets3[USDJPY_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO2Sets3[USDJPY_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_3__Time out_OCO2");
		                        Base.USDJPY_UP_S2_OCO2Sets3.Clear();
		                        USDJPY_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO2S4_UP_S2 = 0;
		                for (; USDJPY_OCO2S4_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets4.Count; USDJPY_OCO2S4_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO2Sets4[USDJPY_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO2Sets4[USDJPY_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_4__Time out_OCO2");
		                        Base.USDJPY_UP_S2_OCO2Sets4.Clear();
		                        USDJPY_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO2S5_UP_S2 = 0;
		                for (; USDJPY_OCO2S5_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets5.Count; USDJPY_OCO2S5_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO2Sets5[USDJPY_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO2Sets5[USDJPY_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_5__Time out_OCO2");
		                        Base.USDJPY_UP_S2_OCO2Sets5.Clear();
		                        USDJPY_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO2S6_UP_S2 = 0;
		                for (; USDJPY_OCO2S6_UP_S2 < Base.USDJPY_UP_S2_OCO2Sets6.Count; USDJPY_OCO2S6_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO2Sets6[USDJPY_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO2Sets6[USDJPY_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_6__Time out_OCO2");
		                        Base.USDJPY_UP_S2_OCO2Sets6.Clear();
		                        USDJPY_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.USDJPY_OCO3_EO1_UP_S2)
            		Base.USDJPY_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.USDJPY_OCO3_EO2_UP_S2)
	                Base.USDJPY_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO3_EO3_UP_S2)
	                Base.USDJPY_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO3_EO4_UP_S2)
	                Base.USDJPY_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO3_EO5_UP_S2)
	                Base.USDJPY_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO3_EO6_UP_S2)
	                Base.USDJPY_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDJPY_OCO3S1_UP_S2 = 0;
		                for (; USDJPY_OCO3S1_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets1.Count; USDJPY_OCO3S1_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO3Sets1[USDJPY_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO3Sets1[USDJPY_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_1__Time out_OCO3");
		                        Base.USDJPY_UP_S2_OCO3Sets1.Clear();
		                        USDJPY_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDJPY_OCO3S2_UP_S2 = 0;
		                for (; USDJPY_OCO3S2_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets2.Count; USDJPY_OCO3S2_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO3Sets2[USDJPY_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO3Sets2[USDJPY_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_2__Time out_OCO3");
		                        Base.USDJPY_UP_S2_OCO3Sets2.Clear();
		                        USDJPY_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO3S3_UP_S2 = 0;
		                for (; USDJPY_OCO3S3_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets3.Count; USDJPY_OCO3S3_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO3Sets3[USDJPY_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO3Sets3[USDJPY_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_3__Time out_OCO3");
		                        Base.USDJPY_UP_S2_OCO3Sets3.Clear();
		                        USDJPY_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO3S4_UP_S2 = 0;
		                for (; USDJPY_OCO3S4_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets4.Count; USDJPY_OCO3S4_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO3Sets4[USDJPY_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO3Sets4[USDJPY_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_4__Time out_OCO3");
		                        Base.USDJPY_UP_S2_OCO3Sets4.Clear();
		                        USDJPY_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO3S5_UP_S2 = 0;
		                for (; USDJPY_OCO3S5_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets5.Count; USDJPY_OCO3S5_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO3Sets5[USDJPY_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO3Sets5[USDJPY_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_5__Time out_OCO3");
		                        Base.USDJPY_UP_S2_OCO3Sets5.Clear();
		                        USDJPY_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO3S6_UP_S2 = 0;
		                for (; USDJPY_OCO3S6_UP_S2 < Base.USDJPY_UP_S2_OCO3Sets6.Count; USDJPY_OCO3S6_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO3Sets6[USDJPY_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO3Sets6[USDJPY_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_6__Time out_OCO3");
		                        Base.USDJPY_UP_S2_OCO3Sets6.Clear();
		                        USDJPY_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.USDJPY_OCO4_EO1_UP_S2)
            		Base.USDJPY_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.USDJPY_OCO4_EO2_UP_S2)
	                Base.USDJPY_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO4_EO3_UP_S2)
	                Base.USDJPY_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO4_EO4_UP_S2)
	                Base.USDJPY_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO4_EO5_UP_S2)
	                Base.USDJPY_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.USDJPY_OCO4_EO6_UP_S2)
	                Base.USDJPY_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.USDJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int USDJPY_OCO4S1_UP_S2 = 0;
		                for (; USDJPY_OCO4S1_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets1.Count; USDJPY_OCO4S1_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO4Sets1[USDJPY_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO4Sets1[USDJPY_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_1__Time out_OCO4");
		                        Base.USDJPY_UP_S2_OCO4Sets1.Clear();
		                        USDJPY_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int USDJPY_OCO4S2_UP_S2 = 0;
		                for (; USDJPY_OCO4S2_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets2.Count; USDJPY_OCO4S2_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO4Sets2[USDJPY_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO4Sets2[USDJPY_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_2__Time out_OCO4");
		                        Base.USDJPY_UP_S2_OCO4Sets2.Clear();
		                        USDJPY_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO4S3_UP_S2 = 0;
		                for (; USDJPY_OCO4S3_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets3.Count; USDJPY_OCO4S3_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO4Sets3[USDJPY_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO4Sets3[USDJPY_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_3__Time out_OCO4");
		                        Base.USDJPY_UP_S2_OCO4Sets3.Clear();
		                        USDJPY_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int USDJPY_OCO4S4_UP_S2 = 0;
		                for (; USDJPY_OCO4S4_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets4.Count; USDJPY_OCO4S4_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO4Sets4[USDJPY_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO4Sets4[USDJPY_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_4__Time out_OCO4");
		                        Base.USDJPY_UP_S2_OCO4Sets4.Clear();
		                        USDJPY_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO4S5_UP_S2 = 0;
		                for (; USDJPY_OCO4S5_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets5.Count; USDJPY_OCO4S5_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO4Sets5[USDJPY_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO4Sets5[USDJPY_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_5__Time out_OCO4");
		                        Base.USDJPY_UP_S2_OCO4Sets5.Clear();
		                        USDJPY_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int USDJPY_OCO4S6_UP_S2 = 0;
		                for (; USDJPY_OCO4S6_UP_S2 < Base.USDJPY_UP_S2_OCO4Sets6.Count; USDJPY_OCO4S6_UP_S2++)
		                    if (Base.USDJPY_UP_S2_OCO4Sets6[USDJPY_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.USDJPY_UP_S2_OCO4Sets6[USDJPY_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("USDJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("USDJPY", order.Quantity, false, "USDJPY_UP_S2_Entry_6__Time out_OCO4");
		                        Base.USDJPY_UP_S2_OCO4Sets6.Clear();
		                        USDJPY_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_USDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_USDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_USDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_USDJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_USDJPY_UP_S2 = DOWM_USDJPY_UP_S2 || DOWT_USDJPY_UP_S2 || DOWW_USDJPY_UP_S2 || DOWTH_USDJPY_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("USDJPY") && SY1D.Symbol.ID.Market == Market.FXCM)
	            	{
	            		if(SY1D.BQ[0].Open != 0)
	            		{
	            			algorithm.Debug("ID : " + SY1D.Symbol.ID.Market);
	            		}
	            		
	            		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.USDJPY_OCO1_UP_S2_IsReady == false ||
	                    	Base.USDJPY_OCO2_UP_S2_IsReady == false ||
	                    	Base.USDJPY_OCO3_UP_S2_IsReady == false ||
	                    	Base.USDJPY_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.USDJPY_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.USDJPY_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.USDJPY_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.USDJPY_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.USDJPY_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.USDJPY_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.USDJPY_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.USDJPY_OCO4_UP_S2_Monthly_IsReady = true;
                    	}

	                	USDJPY_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										&&
		                										(
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.382m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.382m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										)
		                										&&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                	USDJPY_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										&&
		                										(
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.5m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.5m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
				                								)
		                										&&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                									
	                	USDJPY_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										&&
		                										(
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.618m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.618m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										)
		                										&&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                	if (USDJPY_Signal_Condition_UP_1)
	                	{
	                    	USDJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (USDJPY_Signal_Condition_UP_2)
	                	{
	                    	USDJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (USDJPY_Signal_Condition_UP_3)
	                	{
	                    	USDJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (USDJPY_Signal_Condition_UP_1)
	                	{
	                    	USDJPY_UP_S2_TP1  =  Base.Yen_TP_1 ;
	                	}
	                	
	                	if (USDJPY_Signal_Condition_UP_2)
	                	{
	                    	USDJPY_UP_S2_TP1  =  Base.Yen_TP_2 ;
	                	}
	                	
	                	if (USDJPY_Signal_Condition_UP_3)
	                	{
	                    	USDJPY_UP_S2_TP1  =  Base.Yen_TP_3 ;
	                	}

	                    USDJPY_UP_S2_TP2 =  USDJPY_UP_S2_SL * 0;
	                    USDJPY_UP_S2_TP3 =  USDJPY_UP_S2_SL * 0;
	                    USDJPY_UP_S2_TP4 =  USDJPY_UP_S2_SL * 0;
	                    USDJPY_UP_S2_TP5 =  USDJPY_UP_S2_SL * 0;
	                    USDJPY_UP_S2_TP6 =  USDJPY_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    USDJPY_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    USDJPY_quantity_SL_UP_S2 = USDJPY_quantity_UP_S2;
	                    USDJPY_quantity_TP1_UP_S2 = (int)Math.Floor(USDJPY_quantity_UP_S2 * 1m);
	                    USDJPY_quantity_TP2_UP_S2 = (int)Math.Floor(USDJPY_quantity_TP1_UP_S2 * 0m);
	                    USDJPY_quantity_TP3_UP_S2 = (int)Math.Floor(USDJPY_quantity_TP2_UP_S2 * 0m);
	                    USDJPY_quantity_TP4_UP_S2 = (int)Math.Floor(USDJPY_quantity_TP3_UP_S2 * 0m);
	                    USDJPY_quantity_TP5_UP_S2 = (int)Math.Floor(USDJPY_quantity_TP4_UP_S2 * 0m);
	                    USDJPY_quantity_TP6_UP_S2 = (int)Math.Floor(USDJPY_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((USDJPY_Signal_Condition_UP_1 || USDJPY_Signal_Condition_UP_2 || USDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_USDJPY_UP_S2 && 
	                    Base.USDJPY_OCO1_UP_S2_IsReady == true &&
	                    Base.USDJPY_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDJPY_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP1_UP_S2, false,"USDJPY_UP_S2_Entry_TP1_OCO1");
	                         Base.USDJPY_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.USDJPY_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP2_UP_S2, false,"USDJPY_UP_S2_Entry_TP2_OCO1");
	                         Base.USDJPY_OCO1_EO2_UP_S2 = false;
	
	                         Base.USDJPY_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP3_UP_S2, false,"USDJPY_UP_S2_Entry_TP3_OCO1");
	                         Base.USDJPY_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.USDJPY_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP4_UP_S2, false,"USDJPY_UP_S2_Entry_TP4_OCO1");
	                         Base.USDJPY_OCO1_EO4_UP_S2 = false;

							Base.USDJPY_OCO1_UP_S2_IsReady = false;
							
							if (Base.USDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco2:
	                    if ((USDJPY_Signal_Condition_UP_1 || USDJPY_Signal_Condition_UP_2 || USDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_USDJPY_UP_S2 && 
	                    Base.USDJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.USDJPY_OCO2_UP_S2_IsReady == true &&
	                    Base.USDJPY_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDJPY_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP1_UP_S2, false,"USDJPY_UP_S2_Entry_TP1_OCO2");
	                         Base.USDJPY_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.USDJPY_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP2_UP_S2, false,"USDJPY_UP_S2_Entry_TP2_OCO2");
	                         Base.USDJPY_OCO2_EO2_UP_S2 = false;
	
	                         Base.USDJPY_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP3_UP_S2, false,"USDJPY_UP_S2_Entry_TP3_OCO2");
	                         Base.USDJPY_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.USDJPY_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP4_UP_S2, false,"USDJPY_UP_S2_Entry_TP4_OCO2");
	                         Base.USDJPY_OCO2_EO4_UP_S2 = false;

							Base.USDJPY_OCO2_UP_S2_IsReady = false;
							
							if (Base.USDJPY_OCO2_UP_S2_IsReady == false && Base.USDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco3:
	                    if ((USDJPY_Signal_Condition_UP_1 || USDJPY_Signal_Condition_UP_2 || USDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_USDJPY_UP_S2 &&
	                    Base.USDJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.USDJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.USDJPY_OCO3_UP_S2_IsReady == true &&
	                    Base.USDJPY_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDJPY_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP1_UP_S2, false,"USDJPY_UP_S2_Entry_TP1_OCO3");
	                         Base.USDJPY_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.USDJPY_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP2_UP_S2, false,"USDJPY_UP_S2_Entry_TP2_OCO3");
	                         Base.USDJPY_OCO3_EO2_UP_S2 = false;
	
	                         Base.USDJPY_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP3_UP_S2, false,"USDJPY_UP_S2_Entry_TP3_OCO3");
	                         Base.USDJPY_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.USDJPY_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP4_UP_S2, false,"USDJPY_UP_S2_Entry_TP4_OCO3");
	                         Base.USDJPY_OCO3_EO4_UP_S2 = false;

							Base.USDJPY_OCO3_UP_S2_IsReady = false;
							
							if (Base.USDJPY_OCO3_UP_S2_IsReady == false && Base.USDJPY_OCO2_UP_S2_IsReady == false && Base.USDJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco4:
	                    if ((USDJPY_Signal_Condition_UP_1 || USDJPY_Signal_Condition_UP_2 || USDJPY_Signal_Condition_UP_3)  && 
	                    DOWR_USDJPY_UP_S2 && 
	                    Base.USDJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.USDJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.USDJPY_OCO3_UP_S2_IsReady == false &&
	                    Base.USDJPY_OCO4_UP_S2_IsReady == true &&
	                    Base.USDJPY_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.USDJPY_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP1_UP_S2, false,"USDJPY_UP_S2_Entry_TP1_OCO4");
	                         Base.USDJPY_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.USDJPY_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP2_UP_S2, false,"USDJPY_UP_S2_Entry_TP2_OCO4");
	                         Base.USDJPY_OCO4_EO2_UP_S2 = false;
	
	                         Base.USDJPY_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP3_UP_S2, false,"USDJPY_UP_S2_Entry_TP3_OCO4");
	                         Base.USDJPY_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.USDJPY_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         USDJPY_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, USDJPY_quantity_TP4_UP_S2, false,"USDJPY_UP_S2_Entry_TP4_OCO4");
	                         Base.USDJPY_OCO4_EO4_UP_S2 = false;

							Base.USDJPY_OCO4_UP_S2_IsReady = false;
							
							if (Base.USDJPY_OCO4_UP_S2_IsReady == false && Base.USDJPY_OCO3_UP_S2_IsReady == false && Base.USDJPY_OCO2_UP_S2_IsReady == false && Base.USDJPY_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.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 EURCHF_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURCHF_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("EURCHF OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCHF OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCHF OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCHF OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCHF OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCHF OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCHF OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        }
		        
				if (Base.EURCHF_OCO1_EO1_UP_S2)
	                Base.EURCHF_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURCHF_OCO1_EO2_UP_S2)
	                Base.EURCHF_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO1_EO3_UP_S2)
	                Base.EURCHF_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO1_EO4_UP_S2)
	                Base.EURCHF_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO1_EO5_UP_S2)
	                Base.EURCHF_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO1_EO6_UP_S2)
	                Base.EURCHF_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCHF_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.EURCHF_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP1,"TP1_EURCHF_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP1_EURCHF_UP_S2_OCO1"));
		                 };
		                Base.EURCHF_UP_S2_OCO1Sets1.Add( Base.EURCHF_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCHF_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP2,"TP2_EURCHF_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP2_EURCHF_UP_S2_OCO1"));
		                 };
	                    Base.EURCHF_UP_S2_OCO1Sets2.Add( Base.EURCHF_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP3,"TP3_EURCHF_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP3_EURCHF_UP_S2_OCO1"));
		                 };
	                    Base.EURCHF_UP_S2_OCO1Sets3.Add( Base.EURCHF_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP4,"TP4_EURCHF_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP4_EURCHF_UP_S2_OCO1"));
		                 };
	                    Base.EURCHF_UP_S2_OCO1Sets4.Add( Base.EURCHF_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP5,"TP5_EURCHF_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP5_EURCHF_UP_S2_OCO1"));
		                 };
	                    Base.EURCHF_UP_S2_OCO1Sets5.Add( Base.EURCHF_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP6,"TP6_EURCHF_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP6_EURCHF_UP_S2_OCO1"));
		                 };
	                    Base.EURCHF_UP_S2_OCO1Sets6.Add( Base.EURCHF_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURCHF_OCO1S1_UP_S2 = 0;
	                for (; EURCHF_OCO1S1_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets1.Count; EURCHF_OCO1S1_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO1Sets1[EURCHF_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO1Sets1[EURCHF_OCO1S1_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO1Sets1.RemoveAt(EURCHF_OCO1S1_UP_S2);
	                        EURCHF_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURCHF_OCO1S2_UP_S2 = 0;
	                for (; EURCHF_OCO1S2_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets2.Count; EURCHF_OCO1S2_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO1Sets2[EURCHF_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO1Sets2[EURCHF_OCO1S2_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO1Sets2.RemoveAt(EURCHF_OCO1S2_UP_S2);
	                        EURCHF_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO1S3_UP_S2 = 0;
	                for (; EURCHF_OCO1S3_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets3.Count; EURCHF_OCO1S3_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO1Sets3[EURCHF_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO1Sets3[EURCHF_OCO1S3_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO1Sets3.RemoveAt(EURCHF_OCO1S3_UP_S2);
	                        EURCHF_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO1S4_UP_S2 = 0;
	                for (; EURCHF_OCO1S4_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets4.Count; EURCHF_OCO1S4_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO1Sets4[EURCHF_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO1Sets4[EURCHF_OCO1S4_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO1Sets4.RemoveAt(EURCHF_OCO1S4_UP_S2);
	                        EURCHF_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCHF_OCO1S5_UP_S2 = 0;
	                for (; EURCHF_OCO1S5_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets5.Count; EURCHF_OCO1S5_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO1Sets5[EURCHF_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO1Sets5[EURCHF_OCO1S5_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO1Sets5.RemoveAt(EURCHF_OCO1S5_UP_S2);
	                        EURCHF_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCHF_OCO1S6_UP_S2 = 0;
	                for (; EURCHF_OCO1S6_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets6.Count; EURCHF_OCO1S6_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO1Sets6[EURCHF_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO1Sets6[EURCHF_OCO1S6_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO1Sets6.RemoveAt(EURCHF_OCO1S6_UP_S2);
	                        EURCHF_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.EURCHF_OCO2_EO1_UP_S2)
	                Base.EURCHF_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURCHF_OCO2_EO2_UP_S2)
	                Base.EURCHF_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO2_EO3_UP_S2)
	                Base.EURCHF_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO2_EO4_UP_S2)
	                Base.EURCHF_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO2_EO5_UP_S2)
	                Base.EURCHF_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO2_EO6_UP_S2)
	                Base.EURCHF_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCHF_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.EURCHF_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP1,"TP1_EURCHF_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP1_EURCHF_UP_S2_OCO2"));
		                 };
		                Base.EURCHF_UP_S2_OCO2Sets1.Add( Base.EURCHF_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCHF_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP2,"TP2_EURCHF_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP2_EURCHF_UP_S2_OCO2"));
		                 };
	                    Base.EURCHF_UP_S2_OCO2Sets2.Add( Base.EURCHF_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP3,"TP3_EURCHF_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP3_EURCHF_UP_S2_OCO2"));
		                 };
	                    Base.EURCHF_UP_S2_OCO2Sets3.Add( Base.EURCHF_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP4,"TP4_EURCHF_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP4_EURCHF_UP_S2_OCO2"));
		                 };
	                    Base.EURCHF_UP_S2_OCO2Sets4.Add( Base.EURCHF_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP5,"TP5_EURCHF_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP5_EURCHF_UP_S2_OCO2"));
		                 };
	                    Base.EURCHF_UP_S2_OCO2Sets5.Add( Base.EURCHF_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP6,"TP6_EURCHF_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP6_EURCHF_UP_S2_OCO2"));
		                 };
	                    Base.EURCHF_UP_S2_OCO2Sets6.Add( Base.EURCHF_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURCHF_OCO2S1_UP_S2 = 0;
	                for (; EURCHF_OCO2S1_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets1.Count; EURCHF_OCO2S1_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO2Sets1[EURCHF_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO2Sets1[EURCHF_OCO2S1_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO2Sets1.RemoveAt(EURCHF_OCO2S1_UP_S2);
	                        EURCHF_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURCHF_OCO2S2_UP_S2 = 0;
	                for (; EURCHF_OCO2S2_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets2.Count; EURCHF_OCO2S2_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO2Sets2[EURCHF_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO2Sets2[EURCHF_OCO2S2_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO2Sets2.RemoveAt(EURCHF_OCO2S2_UP_S2);
	                        EURCHF_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO2S3_UP_S2 = 0;
	                for (; EURCHF_OCO2S3_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets3.Count; EURCHF_OCO2S3_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO2Sets3[EURCHF_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO2Sets3[EURCHF_OCO2S3_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO2Sets3.RemoveAt(EURCHF_OCO2S3_UP_S2);
	                        EURCHF_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO2S4_UP_S2 = 0;
	                for (; EURCHF_OCO2S4_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets4.Count; EURCHF_OCO2S4_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO2Sets4[EURCHF_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO2Sets4[EURCHF_OCO2S4_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO2Sets4.RemoveAt(EURCHF_OCO2S4_UP_S2);
	                        EURCHF_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCHF_OCO2S5_UP_S2 = 0;
	                for (; EURCHF_OCO2S5_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets5.Count; EURCHF_OCO2S5_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO2Sets5[EURCHF_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO2Sets5[EURCHF_OCO2S5_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO2Sets5.RemoveAt(EURCHF_OCO2S5_UP_S2);
	                        EURCHF_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCHF_OCO2S6_UP_S2 = 0;
	                for (; EURCHF_OCO2S6_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets6.Count; EURCHF_OCO2S6_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO2Sets6[EURCHF_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO2Sets6[EURCHF_OCO2S6_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO2Sets6.RemoveAt(EURCHF_OCO2S6_UP_S2);
	                        EURCHF_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCHF_OCO3_EO1_UP_S2)
	                Base.EURCHF_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURCHF_OCO3_EO2_UP_S2)
	                Base.EURCHF_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO3_EO3_UP_S2)
	                Base.EURCHF_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO3_EO4_UP_S2)
	                Base.EURCHF_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO3_EO5_UP_S2)
	                Base.EURCHF_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO3_EO6_UP_S2)
	                Base.EURCHF_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCHF_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.EURCHF_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP1,"TP1_EURCHF_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP1_EURCHF_UP_S2_OCO3"));
		                 };
		                Base.EURCHF_UP_S2_OCO3Sets1.Add( Base.EURCHF_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCHF_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP2,"TP2_EURCHF_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP2_EURCHF_UP_S2_OCO3"));
		                 };
	                    Base.EURCHF_UP_S2_OCO3Sets2.Add( Base.EURCHF_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP3,"TP3_EURCHF_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP3_EURCHF_UP_S2_OCO3"));
		                 };
	                    Base.EURCHF_UP_S2_OCO3Sets3.Add( Base.EURCHF_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP4,"TP4_EURCHF_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP4_EURCHF_UP_S2_OCO3"));
		                 };
	                    Base.EURCHF_UP_S2_OCO3Sets4.Add( Base.EURCHF_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP5,"TP5_EURCHF_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP5_EURCHF_UP_S2_OCO3"));
		                 };
	                    Base.EURCHF_UP_S2_OCO3Sets5.Add( Base.EURCHF_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP6,"TP6_EURCHF_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP6_EURCHF_UP_S2_OCO3"));
		                 };
	                    Base.EURCHF_UP_S2_OCO3Sets6.Add( Base.EURCHF_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURCHF_OCO3S1_UP_S2 = 0;
	                for (; EURCHF_OCO3S1_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets1.Count; EURCHF_OCO3S1_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO3Sets1[EURCHF_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO3Sets1[EURCHF_OCO3S1_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO3Sets1.RemoveAt(EURCHF_OCO3S1_UP_S2);
	                        EURCHF_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURCHF_OCO3S2_UP_S2 = 0;
	                for (; EURCHF_OCO3S2_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets2.Count; EURCHF_OCO3S2_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO3Sets2[EURCHF_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO3Sets2[EURCHF_OCO3S2_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO3Sets2.RemoveAt(EURCHF_OCO3S2_UP_S2);
	                        EURCHF_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO3S3_UP_S2 = 0;
	                for (; EURCHF_OCO3S3_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets3.Count; EURCHF_OCO3S3_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO3Sets3[EURCHF_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO3Sets3[EURCHF_OCO3S3_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO3Sets3.RemoveAt(EURCHF_OCO3S3_UP_S2);
	                        EURCHF_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO3S4_UP_S2 = 0;
	                for (; EURCHF_OCO3S4_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets4.Count; EURCHF_OCO3S4_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO3Sets4[EURCHF_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO3Sets4[EURCHF_OCO3S4_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO3Sets4.RemoveAt(EURCHF_OCO3S4_UP_S2);
	                        EURCHF_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCHF_OCO3S5_UP_S2 = 0;
	                for (; EURCHF_OCO3S5_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets5.Count; EURCHF_OCO3S5_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO3Sets5[EURCHF_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO3Sets5[EURCHF_OCO3S5_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO3Sets5.RemoveAt(EURCHF_OCO3S5_UP_S2);
	                        EURCHF_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCHF_OCO3S6_UP_S2 = 0;
	                for (; EURCHF_OCO3S6_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets6.Count; EURCHF_OCO3S6_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO3Sets6[EURCHF_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO3Sets6[EURCHF_OCO3S6_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO3Sets6.RemoveAt(EURCHF_OCO3S6_UP_S2);
	                        EURCHF_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCHF_OCO4_EO1_UP_S2)
	                Base.EURCHF_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURCHF_OCO4_EO2_UP_S2)
	                Base.EURCHF_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO4_EO3_UP_S2)
	                Base.EURCHF_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO4_EO4_UP_S2)
	                Base.EURCHF_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO4_EO5_UP_S2)
	                Base.EURCHF_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO4_EO6_UP_S2)
	                Base.EURCHF_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCHF_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.EURCHF_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP1,"TP1_EURCHF_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP1_EURCHF_UP_S2_OCO4"));
		                 };
		                Base.EURCHF_UP_S2_OCO4Sets1.Add( Base.EURCHF_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCHF_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP2,"TP2_EURCHF_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP2_EURCHF_UP_S2_OCO4"));
		                 };
	                    Base.EURCHF_UP_S2_OCO4Sets2.Add( Base.EURCHF_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP3,"TP3_EURCHF_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP3_EURCHF_UP_S2_OCO4"));
		                 };
	                    Base.EURCHF_UP_S2_OCO4Sets3.Add( Base.EURCHF_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP4,"TP4_EURCHF_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP4_EURCHF_UP_S2_OCO4"));
		                 };
	                    Base.EURCHF_UP_S2_OCO4Sets4.Add( Base.EURCHF_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP5,"TP5_EURCHF_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP5_EURCHF_UP_S2_OCO4"));
		                 };
	                    Base.EURCHF_UP_S2_OCO4Sets5.Add( Base.EURCHF_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_UP_S2_TP6,"TP6_EURCHF_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_UP_S2_SL,"SL_TP6_EURCHF_UP_S2_OCO4"));
		                 };
	                    Base.EURCHF_UP_S2_OCO4Sets6.Add( Base.EURCHF_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURCHF_OCO4S1_UP_S2 = 0;
	                for (; EURCHF_OCO4S1_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets1.Count; EURCHF_OCO4S1_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO4Sets1[EURCHF_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO4Sets1[EURCHF_OCO4S1_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO4Sets1.RemoveAt(EURCHF_OCO4S1_UP_S2);
	                        EURCHF_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURCHF_OCO4S2_UP_S2 = 0;
	                for (; EURCHF_OCO4S2_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets2.Count; EURCHF_OCO4S2_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO4Sets2[EURCHF_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO4Sets2[EURCHF_OCO4S2_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO4Sets2.RemoveAt(EURCHF_OCO4S2_UP_S2);
	                        EURCHF_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO4S3_UP_S2 = 0;
	                for (; EURCHF_OCO4S3_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets3.Count; EURCHF_OCO4S3_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO4Sets3[EURCHF_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO4Sets3[EURCHF_OCO4S3_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO4Sets3.RemoveAt(EURCHF_OCO4S3_UP_S2);
	                        EURCHF_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO4S4_UP_S2 = 0;
	                for (; EURCHF_OCO4S4_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets4.Count; EURCHF_OCO4S4_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO4Sets4[EURCHF_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO4Sets4[EURCHF_OCO4S4_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO4Sets4.RemoveAt(EURCHF_OCO4S4_UP_S2);
	                        EURCHF_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCHF_OCO4S5_UP_S2 = 0;
	                for (; EURCHF_OCO4S5_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets5.Count; EURCHF_OCO4S5_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO4Sets5[EURCHF_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO4Sets5[EURCHF_OCO4S5_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO4Sets5.RemoveAt(EURCHF_OCO4S5_UP_S2);
	                        EURCHF_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCHF_OCO4S6_UP_S2 = 0;
	                for (; EURCHF_OCO4S6_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets6.Count; EURCHF_OCO4S6_UP_S2++)
	                    if (Base.EURCHF_UP_S2_OCO4Sets6[EURCHF_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_UP_S2_OCO4Sets6[EURCHF_OCO4S6_UP_S2].Filled();
	                        Base.EURCHF_UP_S2_OCO4Sets6.RemoveAt(EURCHF_OCO4S6_UP_S2);
	                        EURCHF_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPCHF_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPCHF_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("GBPCHF_DOWN_S2_OCO1")))
			{
				Base.GBPCHF_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCHF_DOWN_S2_OCO2")))
			{
				Base.GBPCHF_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCHF_DOWN_S2_OCO3")))
			{
				Base.GBPCHF_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCHF_DOWN_S2_OCO4")))
			{
				Base.GBPCHF_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPCHF_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.GBPCHF_OCO1_EO1_DOWN_S2)
	                Base.GBPCHF_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPCHF_OCO1_EO2_DOWN_S2)
	                Base.GBPCHF_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO1_EO3_DOWN_S2)
	                Base.GBPCHF_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO1_EO4_DOWN_S2)
	                Base.GBPCHF_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO1_EO5_DOWN_S2)
	                Base.GBPCHF_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO1_EO6_DOWN_S2)
	                Base.GBPCHF_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCHF_OCO1S1_DOWN_S2 = 0;
		                for (; GBPCHF_OCO1S1_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets1.Count; GBPCHF_OCO1S1_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO1Sets1[GBPCHF_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO1Sets1[GBPCHF_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.GBPCHF_DOWN_S2_OCO1Sets1.Clear();
		                        GBPCHF_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCHF_OCO1S2_DOWN_S2 = 0;
		                for (; GBPCHF_OCO1S2_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets2.Count; GBPCHF_OCO1S2_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO1Sets2[GBPCHF_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO1Sets2[GBPCHF_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.GBPCHF_DOWN_S2_OCO1Sets2.Clear();
		                        GBPCHF_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO1S3_DOWN_S2 = 0;
		                for (; GBPCHF_OCO1S3_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets3.Count; GBPCHF_OCO1S3_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO1Sets3[GBPCHF_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO1Sets3[GBPCHF_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.GBPCHF_DOWN_S2_OCO1Sets3.Clear();
		                        GBPCHF_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO1S4_DOWN_S2 = 0;
		                for (; GBPCHF_OCO1S4_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets4.Count; GBPCHF_OCO1S4_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO1Sets4[GBPCHF_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO1Sets4[GBPCHF_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.GBPCHF_DOWN_S2_OCO1Sets4.Clear();
		                        GBPCHF_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO1S5_DOWN_S2 = 0;
		                for (; GBPCHF_OCO1S5_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets5.Count; GBPCHF_OCO1S5_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO1Sets5[GBPCHF_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO1Sets5[GBPCHF_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.GBPCHF_DOWN_S2_OCO1Sets5.Clear();
		                        GBPCHF_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO1S6_DOWN_S2 = 0;
		                for (; GBPCHF_OCO1S6_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO1Sets6.Count; GBPCHF_OCO1S6_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO1Sets6[GBPCHF_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO1Sets6[GBPCHF_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.GBPCHF_DOWN_S2_OCO1Sets6.Clear();
		                        GBPCHF_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPCHF_OCO2_EO1_DOWN_S2)
	                Base.GBPCHF_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPCHF_OCO2_EO2_DOWN_S2)
	                Base.GBPCHF_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO2_EO3_DOWN_S2)
	                Base.GBPCHF_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO2_EO4_DOWN_S2)
	                Base.GBPCHF_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO2_EO5_DOWN_S2)
	                Base.GBPCHF_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO2_EO6_DOWN_S2)
	                Base.GBPCHF_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCHF_OCO2S1_DOWN_S2 = 0;
		                for (; GBPCHF_OCO2S1_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets1.Count; GBPCHF_OCO2S1_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO2Sets1[GBPCHF_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO2Sets1[GBPCHF_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.GBPCHF_DOWN_S2_OCO2Sets1.Clear();
		                        GBPCHF_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCHF_OCO2S2_DOWN_S2 = 0;
		                for (; GBPCHF_OCO2S2_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets2.Count; GBPCHF_OCO2S2_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO2Sets2[GBPCHF_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO2Sets2[GBPCHF_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.GBPCHF_DOWN_S2_OCO2Sets2.Clear();
		                        GBPCHF_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO2S3_DOWN_S2 = 0;
		                for (; GBPCHF_OCO2S3_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets3.Count; GBPCHF_OCO2S3_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO2Sets3[GBPCHF_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO2Sets3[GBPCHF_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.GBPCHF_DOWN_S2_OCO2Sets3.Clear();
		                        GBPCHF_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO2S4_DOWN_S2 = 0;
		                for (; GBPCHF_OCO2S4_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets4.Count; GBPCHF_OCO2S4_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO2Sets4[GBPCHF_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO2Sets4[GBPCHF_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.GBPCHF_DOWN_S2_OCO2Sets4.Clear();
		                        GBPCHF_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO2S5_DOWN_S2 = 0;
		                for (; GBPCHF_OCO2S5_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets5.Count; GBPCHF_OCO2S5_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO2Sets5[GBPCHF_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO2Sets5[GBPCHF_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.GBPCHF_DOWN_S2_OCO2Sets5.Clear();
		                        GBPCHF_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO2S6_DOWN_S2 = 0;
		                for (; GBPCHF_OCO2S6_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO2Sets6.Count; GBPCHF_OCO2S6_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO2Sets6[GBPCHF_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO2Sets6[GBPCHF_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.GBPCHF_DOWN_S2_OCO2Sets6.Clear();
		                        GBPCHF_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPCHF_OCO3_EO1_DOWN_S2)
	                Base.GBPCHF_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPCHF_OCO3_EO2_DOWN_S2)
	                Base.GBPCHF_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO3_EO3_DOWN_S2)
	                Base.GBPCHF_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO3_EO4_DOWN_S2)
	                Base.GBPCHF_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO3_EO5_DOWN_S2)
	                Base.GBPCHF_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO3_EO6_DOWN_S2)
	                Base.GBPCHF_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCHF_OCO3S1_DOWN_S2 = 0;
		                for (; GBPCHF_OCO3S1_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets1.Count; GBPCHF_OCO3S1_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO3Sets1[GBPCHF_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO3Sets1[GBPCHF_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.GBPCHF_DOWN_S2_OCO3Sets1.Clear();
		                        GBPCHF_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCHF_OCO3S2_DOWN_S2 = 0;
		                for (; GBPCHF_OCO3S2_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets2.Count; GBPCHF_OCO3S2_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO3Sets2[GBPCHF_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO3Sets2[GBPCHF_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.GBPCHF_DOWN_S2_OCO3Sets2.Clear();
		                        GBPCHF_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO3S3_DOWN_S2 = 0;
		                for (; GBPCHF_OCO3S3_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets3.Count; GBPCHF_OCO3S3_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO3Sets3[GBPCHF_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO3Sets3[GBPCHF_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.GBPCHF_DOWN_S2_OCO3Sets3.Clear();
		                        GBPCHF_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO3S4_DOWN_S2 = 0;
		                for (; GBPCHF_OCO3S4_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets4.Count; GBPCHF_OCO3S4_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO3Sets4[GBPCHF_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO3Sets4[GBPCHF_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.GBPCHF_DOWN_S2_OCO3Sets4.Clear();
		                        GBPCHF_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO3S5_DOWN_S2 = 0;
		                for (; GBPCHF_OCO3S5_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets5.Count; GBPCHF_OCO3S5_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO3Sets5[GBPCHF_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO3Sets5[GBPCHF_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.GBPCHF_DOWN_S2_OCO3Sets5.Clear();
		                        GBPCHF_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO3S6_DOWN_S2 = 0;
		                for (; GBPCHF_OCO3S6_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO3Sets6.Count; GBPCHF_OCO3S6_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO3Sets6[GBPCHF_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO3Sets6[GBPCHF_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.GBPCHF_DOWN_S2_OCO3Sets6.Clear();
		                        GBPCHF_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPCHF_OCO4_EO1_DOWN_S2)
	                Base.GBPCHF_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPCHF_OCO4_EO2_DOWN_S2)
	                Base.GBPCHF_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO4_EO3_DOWN_S2)
	                Base.GBPCHF_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO4_EO4_DOWN_S2)
	                Base.GBPCHF_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO4_EO5_DOWN_S2)
	                Base.GBPCHF_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO4_EO6_DOWN_S2)
	                Base.GBPCHF_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCHF_OCO4S1_DOWN_S2 = 0;
		                for (; GBPCHF_OCO4S1_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets1.Count; GBPCHF_OCO4S1_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO4Sets1[GBPCHF_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO4Sets1[GBPCHF_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.GBPCHF_DOWN_S2_OCO4Sets1.Clear();
		                        GBPCHF_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCHF_OCO4S2_DOWN_S2 = 0;
		                for (; GBPCHF_OCO4S2_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets2.Count; GBPCHF_OCO4S2_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO4Sets2[GBPCHF_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO4Sets2[GBPCHF_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.GBPCHF_DOWN_S2_OCO4Sets2.Clear();
		                        GBPCHF_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO4S3_DOWN_S2 = 0;
		                for (; GBPCHF_OCO4S3_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets3.Count; GBPCHF_OCO4S3_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO4Sets3[GBPCHF_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO4Sets3[GBPCHF_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.GBPCHF_DOWN_S2_OCO4Sets3.Clear();
		                        GBPCHF_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO4S4_DOWN_S2 = 0;
		                for (; GBPCHF_OCO4S4_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets4.Count; GBPCHF_OCO4S4_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO4Sets4[GBPCHF_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO4Sets4[GBPCHF_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.GBPCHF_DOWN_S2_OCO4Sets4.Clear();
		                        GBPCHF_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO4S5_DOWN_S2 = 0;
		                for (; GBPCHF_OCO4S5_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets5.Count; GBPCHF_OCO4S5_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO4Sets5[GBPCHF_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO4Sets5[GBPCHF_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.GBPCHF_DOWN_S2_OCO4Sets5.Clear();
		                        GBPCHF_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO4S6_DOWN_S2 = 0;
		                for (; GBPCHF_OCO4S6_DOWN_S2 < Base.GBPCHF_DOWN_S2_OCO4Sets6.Count; GBPCHF_OCO4S6_DOWN_S2++)
		                    if (Base.GBPCHF_DOWN_S2_OCO4Sets6[GBPCHF_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_DOWN_S2_OCO4Sets6[GBPCHF_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.GBPCHF_DOWN_S2_OCO4Sets6.Clear();
		                        GBPCHF_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();
	            	}
	            	
					DOWM_GBPCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPCHF_DOWN_S2 = DOWM_GBPCHF_DOWN_S2 || DOWT_GBPCHF_DOWN_S2 || DOWW_GBPCHF_DOWN_S2 || DOWTH_GBPCHF_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPCHF"))
	            	{
	            		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.GBPCHF_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.GBPCHF_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.GBPCHF_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.GBPCHF_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.GBPCHF_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPCHF_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPCHF_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPCHF_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPCHF_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPCHF_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPCHF_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	GBPCHF_Signal_Condition_DOWN_S2 =  
	                									(
															prices_ASK_Close[0] - pricesM_ASK_High[0] > prices_ASK_Close[0] * 0.005m &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.0005m 
	                									);
	                									
	                    GBPCHF_DOWN_S2_SL  =  0.01m;
	                    GBPCHF_DOWN_S2_TP1 =  0.0006m;
	                    GBPCHF_DOWN_S2_TP2 =  GBPCHF_DOWN_S2_SL * 0;
	                    GBPCHF_DOWN_S2_TP3 =  GBPCHF_DOWN_S2_SL * 0;
	                    GBPCHF_DOWN_S2_TP4 =  GBPCHF_DOWN_S2_SL * 0;
	                    GBPCHF_DOWN_S2_TP5 =  GBPCHF_DOWN_S2_SL * 0;
	                    GBPCHF_DOWN_S2_TP6 =  GBPCHF_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPCHF_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPCHF_quantity_SL_DOWN_S2 = GBPCHF_quantity_DOWN_S2;
	                    GBPCHF_quantity_TP1_DOWN_S2 = (int)Math.Floor(GBPCHF_quantity_DOWN_S2 * 1m);
	                    GBPCHF_quantity_TP2_DOWN_S2 = (int)Math.Floor(GBPCHF_quantity_TP1_DOWN_S2 * 0m);
	                    GBPCHF_quantity_TP3_DOWN_S2 = (int)Math.Floor(GBPCHF_quantity_TP2_DOWN_S2 * 0m);
	                    GBPCHF_quantity_TP4_DOWN_S2 = (int)Math.Floor(GBPCHF_quantity_TP3_DOWN_S2 * 0m);
	                    GBPCHF_quantity_TP5_DOWN_S2 = (int)Math.Floor(GBPCHF_quantity_TP4_DOWN_S2 * 0m);
	                    GBPCHF_quantity_TP6_DOWN_S2 = (int)Math.Floor(GBPCHF_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (GBPCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPCHF_DOWN_S2 && 
	                    Base.GBPCHF_OCO1_DOWN_S2_IsReady == true &&
	                    Base.GBPCHF_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCHF_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP1_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP1_OCO1");
	                         Base.GBPCHF_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPCHF_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP2_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP2_OCO1");
	                         Base.GBPCHF_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.GBPCHF_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP3_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP3_OCO1");
	                         Base.GBPCHF_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPCHF_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP4_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP4_OCO1");
	                         Base.GBPCHF_OCO1_EO4_DOWN_S2 = false;

							Base.GBPCHF_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.GBPCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (GBPCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPCHF_DOWN_S2 && 
	                    Base.GBPCHF_OCO2_DOWN_S2_IsReady == true &&
	                    Base.GBPCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPCHF_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCHF_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP1_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP1_OCO2");
	                         Base.GBPCHF_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPCHF_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP2_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP2_OCO2");
	                         Base.GBPCHF_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.GBPCHF_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP3_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP3_OCO2");
	                         Base.GBPCHF_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPCHF_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP4_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP4_OCO2");
	                         Base.GBPCHF_OCO2_EO4_DOWN_S2 = false;

							Base.GBPCHF_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.GBPCHF_OCO2_DOWN_S2_IsReady == false && Base.GBPCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (GBPCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPCHF_DOWN_S2 &&
	                    Base.GBPCHF_OCO3_DOWN_S2_IsReady == true &&
	                    Base.GBPCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPCHF_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCHF_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP1_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP1_OCO3");
	                         Base.GBPCHF_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPCHF_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP2_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP2_OCO3");
	                         Base.GBPCHF_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.GBPCHF_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP3_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP3_OCO3");
	                         Base.GBPCHF_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPCHF_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP4_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP4_OCO3");
	                         Base.GBPCHF_OCO3_EO4_DOWN_S2 = false;

							Base.GBPCHF_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.GBPCHF_OCO3_DOWN_S2_IsReady == false && Base.GBPCHF_OCO2_DOWN_S2_IsReady == false && Base.GBPCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (GBPCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPCHF_DOWN_S2 && 
	                    Base.GBPCHF_OCO4_DOWN_S2_IsReady == true &&
	                    Base.GBPCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPCHF_OCO3_DOWN_S2_IsReady == false &&
	                    Base.GBPCHF_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCHF_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP1_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP1_OCO4");
	                         Base.GBPCHF_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPCHF_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP2_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP2_OCO4");
	                         Base.GBPCHF_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.GBPCHF_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP3_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP3_OCO4");
	                         Base.GBPCHF_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPCHF_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCHF_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP4_DOWN_S2, false,"GBPCHF_DOWN_S2_Entry_TP4_OCO4");
	                         Base.GBPCHF_OCO4_EO4_DOWN_S2 = false;

							Base.GBPCHF_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.GBPCHF_OCO4_DOWN_S2_IsReady == false && Base.GBPCHF_OCO3_DOWN_S2_IsReady == false && Base.GBPCHF_OCO2_DOWN_S2_IsReady == false && Base.GBPCHF_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.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 EURAUD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURAUD_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("EURAUD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURAUD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURAUD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURAUD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURAUD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURAUD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURAUD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        }
		        
				if (Base.EURAUD_OCO1_EO1_UP_S2)
	                Base.EURAUD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURAUD_OCO1_EO2_UP_S2)
	                Base.EURAUD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO1_EO3_UP_S2)
	                Base.EURAUD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO1_EO4_UP_S2)
	                Base.EURAUD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO1_EO5_UP_S2)
	                Base.EURAUD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO1_EO6_UP_S2)
	                Base.EURAUD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURAUD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.EURAUD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP1,"TP1_EURAUD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP1_EURAUD_UP_S2_OCO1"));
		                 };
		                Base.EURAUD_UP_S2_OCO1Sets1.Add( Base.EURAUD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURAUD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP2,"TP2_EURAUD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP2_EURAUD_UP_S2_OCO1"));
		                 };
	                    Base.EURAUD_UP_S2_OCO1Sets2.Add( Base.EURAUD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP3,"TP3_EURAUD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP3_EURAUD_UP_S2_OCO1"));
		                 };
	                    Base.EURAUD_UP_S2_OCO1Sets3.Add( Base.EURAUD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP4,"TP4_EURAUD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP4_EURAUD_UP_S2_OCO1"));
		                 };
	                    Base.EURAUD_UP_S2_OCO1Sets4.Add( Base.EURAUD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP5,"TP5_EURAUD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP5_EURAUD_UP_S2_OCO1"));
		                 };
	                    Base.EURAUD_UP_S2_OCO1Sets5.Add( Base.EURAUD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP6,"TP6_EURAUD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP6_EURAUD_UP_S2_OCO1"));
		                 };
	                    Base.EURAUD_UP_S2_OCO1Sets6.Add( Base.EURAUD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURAUD_OCO1S1_UP_S2 = 0;
	                for (; EURAUD_OCO1S1_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets1.Count; EURAUD_OCO1S1_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO1Sets1[EURAUD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO1Sets1[EURAUD_OCO1S1_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO1Sets1.RemoveAt(EURAUD_OCO1S1_UP_S2);
	                        EURAUD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURAUD_OCO1S2_UP_S2 = 0;
	                for (; EURAUD_OCO1S2_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets2.Count; EURAUD_OCO1S2_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO1Sets2[EURAUD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO1Sets2[EURAUD_OCO1S2_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO1Sets2.RemoveAt(EURAUD_OCO1S2_UP_S2);
	                        EURAUD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO1S3_UP_S2 = 0;
	                for (; EURAUD_OCO1S3_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets3.Count; EURAUD_OCO1S3_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO1Sets3[EURAUD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO1Sets3[EURAUD_OCO1S3_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO1Sets3.RemoveAt(EURAUD_OCO1S3_UP_S2);
	                        EURAUD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO1S4_UP_S2 = 0;
	                for (; EURAUD_OCO1S4_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets4.Count; EURAUD_OCO1S4_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO1Sets4[EURAUD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO1Sets4[EURAUD_OCO1S4_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO1Sets4.RemoveAt(EURAUD_OCO1S4_UP_S2);
	                        EURAUD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURAUD_OCO1S5_UP_S2 = 0;
	                for (; EURAUD_OCO1S5_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets5.Count; EURAUD_OCO1S5_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO1Sets5[EURAUD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO1Sets5[EURAUD_OCO1S5_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO1Sets5.RemoveAt(EURAUD_OCO1S5_UP_S2);
	                        EURAUD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURAUD_OCO1S6_UP_S2 = 0;
	                for (; EURAUD_OCO1S6_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets6.Count; EURAUD_OCO1S6_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO1Sets6[EURAUD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO1Sets6[EURAUD_OCO1S6_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO1Sets6.RemoveAt(EURAUD_OCO1S6_UP_S2);
	                        EURAUD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.EURAUD_OCO2_EO1_UP_S2)
	                Base.EURAUD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURAUD_OCO2_EO2_UP_S2)
	                Base.EURAUD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO2_EO3_UP_S2)
	                Base.EURAUD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO2_EO4_UP_S2)
	                Base.EURAUD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO2_EO5_UP_S2)
	                Base.EURAUD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO2_EO6_UP_S2)
	                Base.EURAUD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURAUD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.EURAUD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP1,"TP1_EURAUD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP1_EURAUD_UP_S2_OCO2"));
		                 };
		                Base.EURAUD_UP_S2_OCO2Sets1.Add( Base.EURAUD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURAUD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP2,"TP2_EURAUD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP2_EURAUD_UP_S2_OCO2"));
		                 };
	                    Base.EURAUD_UP_S2_OCO2Sets2.Add( Base.EURAUD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP3,"TP3_EURAUD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP3_EURAUD_UP_S2_OCO2"));
		                 };
	                    Base.EURAUD_UP_S2_OCO2Sets3.Add( Base.EURAUD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP4,"TP4_EURAUD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP4_EURAUD_UP_S2_OCO2"));
		                 };
	                    Base.EURAUD_UP_S2_OCO2Sets4.Add( Base.EURAUD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP5,"TP5_EURAUD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP5_EURAUD_UP_S2_OCO2"));
		                 };
	                    Base.EURAUD_UP_S2_OCO2Sets5.Add( Base.EURAUD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP6,"TP6_EURAUD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP6_EURAUD_UP_S2_OCO2"));
		                 };
	                    Base.EURAUD_UP_S2_OCO2Sets6.Add( Base.EURAUD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURAUD_OCO2S1_UP_S2 = 0;
	                for (; EURAUD_OCO2S1_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets1.Count; EURAUD_OCO2S1_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO2Sets1[EURAUD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO2Sets1[EURAUD_OCO2S1_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO2Sets1.RemoveAt(EURAUD_OCO2S1_UP_S2);
	                        EURAUD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURAUD_OCO2S2_UP_S2 = 0;
	                for (; EURAUD_OCO2S2_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets2.Count; EURAUD_OCO2S2_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO2Sets2[EURAUD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO2Sets2[EURAUD_OCO2S2_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO2Sets2.RemoveAt(EURAUD_OCO2S2_UP_S2);
	                        EURAUD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO2S3_UP_S2 = 0;
	                for (; EURAUD_OCO2S3_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets3.Count; EURAUD_OCO2S3_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO2Sets3[EURAUD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO2Sets3[EURAUD_OCO2S3_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO2Sets3.RemoveAt(EURAUD_OCO2S3_UP_S2);
	                        EURAUD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO2S4_UP_S2 = 0;
	                for (; EURAUD_OCO2S4_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets4.Count; EURAUD_OCO2S4_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO2Sets4[EURAUD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO2Sets4[EURAUD_OCO2S4_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO2Sets4.RemoveAt(EURAUD_OCO2S4_UP_S2);
	                        EURAUD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURAUD_OCO2S5_UP_S2 = 0;
	                for (; EURAUD_OCO2S5_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets5.Count; EURAUD_OCO2S5_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO2Sets5[EURAUD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO2Sets5[EURAUD_OCO2S5_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO2Sets5.RemoveAt(EURAUD_OCO2S5_UP_S2);
	                        EURAUD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURAUD_OCO2S6_UP_S2 = 0;
	                for (; EURAUD_OCO2S6_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets6.Count; EURAUD_OCO2S6_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO2Sets6[EURAUD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO2Sets6[EURAUD_OCO2S6_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO2Sets6.RemoveAt(EURAUD_OCO2S6_UP_S2);
	                        EURAUD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURAUD_OCO3_EO1_UP_S2)
	                Base.EURAUD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURAUD_OCO3_EO2_UP_S2)
	                Base.EURAUD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO3_EO3_UP_S2)
	                Base.EURAUD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO3_EO4_UP_S2)
	                Base.EURAUD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO3_EO5_UP_S2)
	                Base.EURAUD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO3_EO6_UP_S2)
	                Base.EURAUD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURAUD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.EURAUD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP1,"TP1_EURAUD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP1_EURAUD_UP_S2_OCO3"));
		                 };
		                Base.EURAUD_UP_S2_OCO3Sets1.Add( Base.EURAUD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURAUD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP2,"TP2_EURAUD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP2_EURAUD_UP_S2_OCO3"));
		                 };
	                    Base.EURAUD_UP_S2_OCO3Sets2.Add( Base.EURAUD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP3,"TP3_EURAUD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP3_EURAUD_UP_S2_OCO3"));
		                 };
	                    Base.EURAUD_UP_S2_OCO3Sets3.Add( Base.EURAUD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP4,"TP4_EURAUD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP4_EURAUD_UP_S2_OCO3"));
		                 };
	                    Base.EURAUD_UP_S2_OCO3Sets4.Add( Base.EURAUD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP5,"TP5_EURAUD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP5_EURAUD_UP_S2_OCO3"));
		                 };
	                    Base.EURAUD_UP_S2_OCO3Sets5.Add( Base.EURAUD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP6,"TP6_EURAUD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP6_EURAUD_UP_S2_OCO3"));
		                 };
	                    Base.EURAUD_UP_S2_OCO3Sets6.Add( Base.EURAUD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURAUD_OCO3S1_UP_S2 = 0;
	                for (; EURAUD_OCO3S1_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets1.Count; EURAUD_OCO3S1_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO3Sets1[EURAUD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO3Sets1[EURAUD_OCO3S1_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO3Sets1.RemoveAt(EURAUD_OCO3S1_UP_S2);
	                        EURAUD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURAUD_OCO3S2_UP_S2 = 0;
	                for (; EURAUD_OCO3S2_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets2.Count; EURAUD_OCO3S2_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO3Sets2[EURAUD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO3Sets2[EURAUD_OCO3S2_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO3Sets2.RemoveAt(EURAUD_OCO3S2_UP_S2);
	                        EURAUD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO3S3_UP_S2 = 0;
	                for (; EURAUD_OCO3S3_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets3.Count; EURAUD_OCO3S3_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO3Sets3[EURAUD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO3Sets3[EURAUD_OCO3S3_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO3Sets3.RemoveAt(EURAUD_OCO3S3_UP_S2);
	                        EURAUD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO3S4_UP_S2 = 0;
	                for (; EURAUD_OCO3S4_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets4.Count; EURAUD_OCO3S4_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO3Sets4[EURAUD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO3Sets4[EURAUD_OCO3S4_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO3Sets4.RemoveAt(EURAUD_OCO3S4_UP_S2);
	                        EURAUD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURAUD_OCO3S5_UP_S2 = 0;
	                for (; EURAUD_OCO3S5_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets5.Count; EURAUD_OCO3S5_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO3Sets5[EURAUD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO3Sets5[EURAUD_OCO3S5_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO3Sets5.RemoveAt(EURAUD_OCO3S5_UP_S2);
	                        EURAUD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURAUD_OCO3S6_UP_S2 = 0;
	                for (; EURAUD_OCO3S6_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets6.Count; EURAUD_OCO3S6_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO3Sets6[EURAUD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO3Sets6[EURAUD_OCO3S6_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO3Sets6.RemoveAt(EURAUD_OCO3S6_UP_S2);
	                        EURAUD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURAUD_OCO4_EO1_UP_S2)
	                Base.EURAUD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURAUD_OCO4_EO2_UP_S2)
	                Base.EURAUD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO4_EO3_UP_S2)
	                Base.EURAUD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO4_EO4_UP_S2)
	                Base.EURAUD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO4_EO5_UP_S2)
	                Base.EURAUD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO4_EO6_UP_S2)
	                Base.EURAUD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURAUD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.EURAUD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP1,"TP1_EURAUD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP1_EURAUD_UP_S2_OCO4"));
		                 };
		                Base.EURAUD_UP_S2_OCO4Sets1.Add( Base.EURAUD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURAUD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP2,"TP2_EURAUD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP2_EURAUD_UP_S2_OCO4"));
		                 };
	                    Base.EURAUD_UP_S2_OCO4Sets2.Add( Base.EURAUD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP3,"TP3_EURAUD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP3_EURAUD_UP_S2_OCO4"));
		                 };
	                    Base.EURAUD_UP_S2_OCO4Sets3.Add( Base.EURAUD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP4,"TP4_EURAUD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP4_EURAUD_UP_S2_OCO4"));
		                 };
	                    Base.EURAUD_UP_S2_OCO4Sets4.Add( Base.EURAUD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP5,"TP5_EURAUD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP5_EURAUD_UP_S2_OCO4"));
		                 };
	                    Base.EURAUD_UP_S2_OCO4Sets5.Add( Base.EURAUD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_UP_S2_TP6,"TP6_EURAUD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_UP_S2_SL,"SL_TP6_EURAUD_UP_S2_OCO4"));
		                 };
	                    Base.EURAUD_UP_S2_OCO4Sets6.Add( Base.EURAUD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURAUD_OCO4S1_UP_S2 = 0;
	                for (; EURAUD_OCO4S1_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets1.Count; EURAUD_OCO4S1_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO4Sets1[EURAUD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO4Sets1[EURAUD_OCO4S1_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO4Sets1.RemoveAt(EURAUD_OCO4S1_UP_S2);
	                        EURAUD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURAUD_OCO4S2_UP_S2 = 0;
	                for (; EURAUD_OCO4S2_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets2.Count; EURAUD_OCO4S2_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO4Sets2[EURAUD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO4Sets2[EURAUD_OCO4S2_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO4Sets2.RemoveAt(EURAUD_OCO4S2_UP_S2);
	                        EURAUD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO4S3_UP_S2 = 0;
	                for (; EURAUD_OCO4S3_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets3.Count; EURAUD_OCO4S3_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO4Sets3[EURAUD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO4Sets3[EURAUD_OCO4S3_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO4Sets3.RemoveAt(EURAUD_OCO4S3_UP_S2);
	                        EURAUD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO4S4_UP_S2 = 0;
	                for (; EURAUD_OCO4S4_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets4.Count; EURAUD_OCO4S4_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO4Sets4[EURAUD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO4Sets4[EURAUD_OCO4S4_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO4Sets4.RemoveAt(EURAUD_OCO4S4_UP_S2);
	                        EURAUD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURAUD_OCO4S5_UP_S2 = 0;
	                for (; EURAUD_OCO4S5_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets5.Count; EURAUD_OCO4S5_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO4Sets5[EURAUD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO4Sets5[EURAUD_OCO4S5_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO4Sets5.RemoveAt(EURAUD_OCO4S5_UP_S2);
	                        EURAUD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURAUD_OCO4S6_UP_S2 = 0;
	                for (; EURAUD_OCO4S6_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets6.Count; EURAUD_OCO4S6_UP_S2++)
	                    if (Base.EURAUD_UP_S2_OCO4Sets6[EURAUD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_UP_S2_OCO4Sets6[EURAUD_OCO4S6_UP_S2].Filled();
	                        Base.EURAUD_UP_S2_OCO4Sets6.RemoveAt(EURAUD_OCO4S6_UP_S2);
	                        EURAUD_OCO4S6_UP_S2 = 0;
	                        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 _EURJPY;
		
    	///oco1 up
    	public static OrderTicket EURJPY_OCO1_MO1_UP_S2;
    	public static OrderTicket EURJPY_OCO1_MO2_UP_S2;
    	public static OrderTicket EURJPY_OCO1_MO3_UP_S2;
    	public static OrderTicket EURJPY_OCO1_MO4_UP_S2;
    	public static OrderTicket EURJPY_OCO1_MO5_UP_S2;
    	public static OrderTicket EURJPY_OCO1_MO6_UP_S2;
    	
    	public static int EURJPY_OCO1_EO1_UP_S2_ID ;
        public static int EURJPY_OCO1_EO2_UP_S2_ID ;
        public static int EURJPY_OCO1_EO3_UP_S2_ID ;
        public static int EURJPY_OCO1_EO4_UP_S2_ID ;
        public static int EURJPY_OCO1_EO5_UP_S2_ID ;
        public static int EURJPY_OCO1_EO6_UP_S2_ID ;
        
        public static bool EURJPY_OCO1_EO1_UP_S2 ;
        public static bool EURJPY_OCO1_EO2_UP_S2 ;
        public static bool EURJPY_OCO1_EO3_UP_S2 ;
        public static bool EURJPY_OCO1_EO4_UP_S2 ;
        public static bool EURJPY_OCO1_EO5_UP_S2 ;
        public static bool EURJPY_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_UP_S2> EURJPY_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_UP_S2> EURJPY_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_UP_S2> EURJPY_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_UP_S2> EURJPY_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_UP_S2> EURJPY_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_UP_S2> EURJPY_OOFE_OCO1_UP_S2_6 ;
        
        public static EURJPY_OCO1_UP_S2 EURJPY_PFO_OCO1_UP_S2_1 ;
        public static EURJPY_OCO1_UP_S2 EURJPY_PFO_OCO1_UP_S2_2 ;
        public static EURJPY_OCO1_UP_S2 EURJPY_PFO_OCO1_UP_S2_3 ;
        public static EURJPY_OCO1_UP_S2 EURJPY_PFO_OCO1_UP_S2_4 ;
        public static EURJPY_OCO1_UP_S2 EURJPY_PFO_OCO1_UP_S2_5 ;
        public static EURJPY_OCO1_UP_S2 EURJPY_PFO_OCO1_UP_S2_6 ;
        
        public static List<EURJPY_OCO1_UP_S2> EURJPY_UP_S2_OCO1Sets1 = new List<EURJPY_OCO1_UP_S2>();
        public static List<EURJPY_OCO1_UP_S2> EURJPY_UP_S2_OCO1Sets2 = new List<EURJPY_OCO1_UP_S2>();
        public static List<EURJPY_OCO1_UP_S2> EURJPY_UP_S2_OCO1Sets3 = new List<EURJPY_OCO1_UP_S2>();
        public static List<EURJPY_OCO1_UP_S2> EURJPY_UP_S2_OCO1Sets4 = new List<EURJPY_OCO1_UP_S2>();
        public static List<EURJPY_OCO1_UP_S2> EURJPY_UP_S2_OCO1Sets5 = new List<EURJPY_OCO1_UP_S2>();
        public static List<EURJPY_OCO1_UP_S2> EURJPY_UP_S2_OCO1Sets6 = new List<EURJPY_OCO1_UP_S2>();
        
        public static bool EURJPY_OCO1_UP_S2_IsReady = true;
        public static bool EURJPY_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket EURJPY_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO1_MO6_DOWN_S2 ;
    	
    	public static int EURJPY_OCO1_EO1_DOWN_S2_ID ;
        public static int EURJPY_OCO1_EO2_DOWN_S2_ID ;
        public static int EURJPY_OCO1_EO3_DOWN_S2_ID ;
        public static int EURJPY_OCO1_EO4_DOWN_S2_ID ;
        public static int EURJPY_OCO1_EO5_DOWN_S2_ID ;
        public static int EURJPY_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool EURJPY_OCO1_EO1_DOWN_S2 ;
        public static bool EURJPY_OCO1_EO2_DOWN_S2 ;
        public static bool EURJPY_OCO1_EO3_DOWN_S2 ;
        public static bool EURJPY_OCO1_EO4_DOWN_S2 ;
        public static bool EURJPY_OCO1_EO5_DOWN_S2 ;
        public static bool EURJPY_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_DOWN_S2> EURJPY_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_DOWN_S2> EURJPY_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_DOWN_S2> EURJPY_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_DOWN_S2> EURJPY_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_DOWN_S2> EURJPY_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO1_DOWN_S2> EURJPY_OOFE_OCO1_DOWN_S2_6 ;
        
        public static EURJPY_OCO1_DOWN_S2 EURJPY_PFO_OCO1_DOWN_S2_1 ;
        public static EURJPY_OCO1_DOWN_S2 EURJPY_PFO_OCO1_DOWN_S2_2 ;
        public static EURJPY_OCO1_DOWN_S2 EURJPY_PFO_OCO1_DOWN_S2_3 ;
        public static EURJPY_OCO1_DOWN_S2 EURJPY_PFO_OCO1_DOWN_S2_4 ;
        public static EURJPY_OCO1_DOWN_S2 EURJPY_PFO_OCO1_DOWN_S2_5 ;
        public static EURJPY_OCO1_DOWN_S2 EURJPY_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<EURJPY_OCO1_DOWN_S2> EURJPY_DOWN_S2_OCO1Sets1 = new List<EURJPY_OCO1_DOWN_S2>();
        public static List<EURJPY_OCO1_DOWN_S2> EURJPY_DOWN_S2_OCO1Sets2 = new List<EURJPY_OCO1_DOWN_S2>();
        public static List<EURJPY_OCO1_DOWN_S2> EURJPY_DOWN_S2_OCO1Sets3 = new List<EURJPY_OCO1_DOWN_S2>();
        public static List<EURJPY_OCO1_DOWN_S2> EURJPY_DOWN_S2_OCO1Sets4 = new List<EURJPY_OCO1_DOWN_S2>();
        public static List<EURJPY_OCO1_DOWN_S2> EURJPY_DOWN_S2_OCO1Sets5 = new List<EURJPY_OCO1_DOWN_S2>();
        public static List<EURJPY_OCO1_DOWN_S2> EURJPY_DOWN_S2_OCO1Sets6 = new List<EURJPY_OCO1_DOWN_S2>();
        
        public static bool EURJPY_OCO1_DOWN_S2_IsReady = true;
        public static bool EURJPY_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket EURJPY_OCO2_MO1_UP_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO2_UP_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO3_UP_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO4_UP_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO5_UP_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO6_UP_S2 ;
    	
    	public static int EURJPY_OCO2_EO1_UP_S2_ID ;
        public static int EURJPY_OCO2_EO2_UP_S2_ID ;
        public static int EURJPY_OCO2_EO3_UP_S2_ID ;
        public static int EURJPY_OCO2_EO4_UP_S2_ID ;
        public static int EURJPY_OCO2_EO5_UP_S2_ID ;
        public static int EURJPY_OCO2_EO6_UP_S2_ID ;
        
        public static bool EURJPY_OCO2_EO1_UP_S2 ;
        public static bool EURJPY_OCO2_EO2_UP_S2 ;
        public static bool EURJPY_OCO2_EO3_UP_S2 ;
        public static bool EURJPY_OCO2_EO4_UP_S2 ;
        public static bool EURJPY_OCO2_EO5_UP_S2 ;
        public static bool EURJPY_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_UP_S2> EURJPY_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_UP_S2> EURJPY_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_UP_S2> EURJPY_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_UP_S2> EURJPY_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_UP_S2> EURJPY_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_UP_S2> EURJPY_OOFE_OCO2_UP_S2_6 ;
        
        public static EURJPY_OCO2_UP_S2 EURJPY_PFO_OCO2_UP_S2_1 ;
        public static EURJPY_OCO2_UP_S2 EURJPY_PFO_OCO2_UP_S2_2 ;
        public static EURJPY_OCO2_UP_S2 EURJPY_PFO_OCO2_UP_S2_3 ;
        public static EURJPY_OCO2_UP_S2 EURJPY_PFO_OCO2_UP_S2_4 ;
        public static EURJPY_OCO2_UP_S2 EURJPY_PFO_OCO2_UP_S2_5 ;
        public static EURJPY_OCO2_UP_S2 EURJPY_PFO_OCO2_UP_S2_6 ;
        
        public static List<EURJPY_OCO2_UP_S2> EURJPY_UP_S2_OCO2Sets1 = new List<EURJPY_OCO2_UP_S2>();
        public static List<EURJPY_OCO2_UP_S2> EURJPY_UP_S2_OCO2Sets2 = new List<EURJPY_OCO2_UP_S2>();
        public static List<EURJPY_OCO2_UP_S2> EURJPY_UP_S2_OCO2Sets3 = new List<EURJPY_OCO2_UP_S2>();
        public static List<EURJPY_OCO2_UP_S2> EURJPY_UP_S2_OCO2Sets4 = new List<EURJPY_OCO2_UP_S2>();
        public static List<EURJPY_OCO2_UP_S2> EURJPY_UP_S2_OCO2Sets5 = new List<EURJPY_OCO2_UP_S2>();
        public static List<EURJPY_OCO2_UP_S2> EURJPY_UP_S2_OCO2Sets6 = new List<EURJPY_OCO2_UP_S2>();
        
        public static bool EURJPY_OCO2_UP_S2_IsReady = true;
        public static bool EURJPY_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket EURJPY_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO2_MO6_DOWN_S2 ;
    	
    	public static int EURJPY_OCO2_EO1_DOWN_S2_ID ;
        public static int EURJPY_OCO2_EO2_DOWN_S2_ID ;
        public static int EURJPY_OCO2_EO3_DOWN_S2_ID ;
        public static int EURJPY_OCO2_EO4_DOWN_S2_ID ;
        public static int EURJPY_OCO2_EO5_DOWN_S2_ID ;
        public static int EURJPY_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool EURJPY_OCO2_EO1_DOWN_S2 ;
        public static bool EURJPY_OCO2_EO2_DOWN_S2 ;
        public static bool EURJPY_OCO2_EO3_DOWN_S2 ;
        public static bool EURJPY_OCO2_EO4_DOWN_S2 ;
        public static bool EURJPY_OCO2_EO5_DOWN_S2 ;
        public static bool EURJPY_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_DOWN_S2> EURJPY_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_DOWN_S2> EURJPY_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_DOWN_S2> EURJPY_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_DOWN_S2> EURJPY_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_DOWN_S2> EURJPY_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO2_DOWN_S2> EURJPY_OOFE_OCO2_DOWN_S2_6 ;
        
        public static EURJPY_OCO2_DOWN_S2 EURJPY_PFO_OCO2_DOWN_S2_1 ;
        public static EURJPY_OCO2_DOWN_S2 EURJPY_PFO_OCO2_DOWN_S2_2 ;
        public static EURJPY_OCO2_DOWN_S2 EURJPY_PFO_OCO2_DOWN_S2_3 ;
        public static EURJPY_OCO2_DOWN_S2 EURJPY_PFO_OCO2_DOWN_S2_4 ;
        public static EURJPY_OCO2_DOWN_S2 EURJPY_PFO_OCO2_DOWN_S2_5 ;
        public static EURJPY_OCO2_DOWN_S2 EURJPY_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<EURJPY_OCO2_DOWN_S2> EURJPY_DOWN_S2_OCO2Sets1 = new List<EURJPY_OCO2_DOWN_S2>();
        public static List<EURJPY_OCO2_DOWN_S2> EURJPY_DOWN_S2_OCO2Sets2 = new List<EURJPY_OCO2_DOWN_S2>();
        public static List<EURJPY_OCO2_DOWN_S2> EURJPY_DOWN_S2_OCO2Sets3 = new List<EURJPY_OCO2_DOWN_S2>();
        public static List<EURJPY_OCO2_DOWN_S2> EURJPY_DOWN_S2_OCO2Sets4 = new List<EURJPY_OCO2_DOWN_S2>();
        public static List<EURJPY_OCO2_DOWN_S2> EURJPY_DOWN_S2_OCO2Sets5 = new List<EURJPY_OCO2_DOWN_S2>();
        public static List<EURJPY_OCO2_DOWN_S2> EURJPY_DOWN_S2_OCO2Sets6 = new List<EURJPY_OCO2_DOWN_S2>();
        
        public static bool EURJPY_OCO2_DOWN_S2_IsReady = true;
        public static bool EURJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket EURJPY_OCO3_MO1_UP_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO2_UP_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO3_UP_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO4_UP_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO5_UP_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO6_UP_S2 ;
    	
    	public static int EURJPY_OCO3_EO1_UP_S2_ID ;
        public static int EURJPY_OCO3_EO2_UP_S2_ID ;
        public static int EURJPY_OCO3_EO3_UP_S2_ID ;
        public static int EURJPY_OCO3_EO4_UP_S2_ID ;
        public static int EURJPY_OCO3_EO5_UP_S2_ID ;
        public static int EURJPY_OCO3_EO6_UP_S2_ID ;
        
        public static bool EURJPY_OCO3_EO1_UP_S2 ;
        public static bool EURJPY_OCO3_EO2_UP_S2 ;
        public static bool EURJPY_OCO3_EO3_UP_S2 ;
        public static bool EURJPY_OCO3_EO4_UP_S2 ;
        public static bool EURJPY_OCO3_EO5_UP_S2 ;
        public static bool EURJPY_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_UP_S2> EURJPY_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_UP_S2> EURJPY_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_UP_S2> EURJPY_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_UP_S2> EURJPY_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_UP_S2> EURJPY_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_UP_S2> EURJPY_OOFE_OCO3_UP_S2_6 ;
        
        public static EURJPY_OCO3_UP_S2 EURJPY_PFO_OCO3_UP_S2_1 ;
        public static EURJPY_OCO3_UP_S2 EURJPY_PFO_OCO3_UP_S2_2 ;
        public static EURJPY_OCO3_UP_S2 EURJPY_PFO_OCO3_UP_S2_3 ;
        public static EURJPY_OCO3_UP_S2 EURJPY_PFO_OCO3_UP_S2_4 ;
        public static EURJPY_OCO3_UP_S2 EURJPY_PFO_OCO3_UP_S2_5 ;
        public static EURJPY_OCO3_UP_S2 EURJPY_PFO_OCO3_UP_S2_6 ;
        
        public static List<EURJPY_OCO3_UP_S2> EURJPY_UP_S2_OCO3Sets1 = new List<EURJPY_OCO3_UP_S2>();
        public static List<EURJPY_OCO3_UP_S2> EURJPY_UP_S2_OCO3Sets2 = new List<EURJPY_OCO3_UP_S2>();
        public static List<EURJPY_OCO3_UP_S2> EURJPY_UP_S2_OCO3Sets3 = new List<EURJPY_OCO3_UP_S2>();
        public static List<EURJPY_OCO3_UP_S2> EURJPY_UP_S2_OCO3Sets4 = new List<EURJPY_OCO3_UP_S2>();
        public static List<EURJPY_OCO3_UP_S2> EURJPY_UP_S2_OCO3Sets5 = new List<EURJPY_OCO3_UP_S2>();
        public static List<EURJPY_OCO3_UP_S2> EURJPY_UP_S2_OCO3Sets6 = new List<EURJPY_OCO3_UP_S2>();
        
        public static bool EURJPY_OCO3_UP_S2_IsReady = true;
        public static bool EURJPY_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket EURJPY_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO3_MO6_DOWN_S2 ;
    	
    	public static int EURJPY_OCO3_EO1_DOWN_S2_ID ;
        public static int EURJPY_OCO3_EO2_DOWN_S2_ID ;
        public static int EURJPY_OCO3_EO3_DOWN_S2_ID ;
        public static int EURJPY_OCO3_EO4_DOWN_S2_ID ;
        public static int EURJPY_OCO3_EO5_DOWN_S2_ID ;
        public static int EURJPY_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool EURJPY_OCO3_EO1_DOWN_S2 ;
        public static bool EURJPY_OCO3_EO2_DOWN_S2 ;
        public static bool EURJPY_OCO3_EO3_DOWN_S2 ;
        public static bool EURJPY_OCO3_EO4_DOWN_S2 ;
        public static bool EURJPY_OCO3_EO5_DOWN_S2 ;
        public static bool EURJPY_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_DOWN_S2> EURJPY_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_DOWN_S2> EURJPY_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_DOWN_S2> EURJPY_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_DOWN_S2> EURJPY_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_DOWN_S2> EURJPY_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO3_DOWN_S2> EURJPY_OOFE_OCO3_DOWN_S2_6 ;
        
        public static EURJPY_OCO3_DOWN_S2 EURJPY_PFO_OCO3_DOWN_S2_1 ;
        public static EURJPY_OCO3_DOWN_S2 EURJPY_PFO_OCO3_DOWN_S2_2 ;
        public static EURJPY_OCO3_DOWN_S2 EURJPY_PFO_OCO3_DOWN_S2_3 ;
        public static EURJPY_OCO3_DOWN_S2 EURJPY_PFO_OCO3_DOWN_S2_4 ;
        public static EURJPY_OCO3_DOWN_S2 EURJPY_PFO_OCO3_DOWN_S2_5 ;
        public static EURJPY_OCO3_DOWN_S2 EURJPY_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<EURJPY_OCO3_DOWN_S2> EURJPY_DOWN_S2_OCO3Sets1 = new List<EURJPY_OCO3_DOWN_S2>();
        public static List<EURJPY_OCO3_DOWN_S2> EURJPY_DOWN_S2_OCO3Sets2 = new List<EURJPY_OCO3_DOWN_S2>();
        public static List<EURJPY_OCO3_DOWN_S2> EURJPY_DOWN_S2_OCO3Sets3 = new List<EURJPY_OCO3_DOWN_S2>();
        public static List<EURJPY_OCO3_DOWN_S2> EURJPY_DOWN_S2_OCO3Sets4 = new List<EURJPY_OCO3_DOWN_S2>();
        public static List<EURJPY_OCO3_DOWN_S2> EURJPY_DOWN_S2_OCO3Sets5 = new List<EURJPY_OCO3_DOWN_S2>();
        public static List<EURJPY_OCO3_DOWN_S2> EURJPY_DOWN_S2_OCO3Sets6 = new List<EURJPY_OCO3_DOWN_S2>();
        
        public static bool EURJPY_OCO3_DOWN_S2_IsReady = true;
        public static bool EURJPY_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket EURJPY_OCO4_MO1_UP_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO2_UP_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO3_UP_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO4_UP_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO5_UP_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO6_UP_S2 ;
    	
    	public static int EURJPY_OCO4_EO1_UP_S2_ID ;
        public static int EURJPY_OCO4_EO2_UP_S2_ID ;
        public static int EURJPY_OCO4_EO3_UP_S2_ID ;
        public static int EURJPY_OCO4_EO4_UP_S2_ID ;
        public static int EURJPY_OCO4_EO5_UP_S2_ID ;
        public static int EURJPY_OCO4_EO6_UP_S2_ID ;
        
        public static bool EURJPY_OCO4_EO1_UP_S2 ;
        public static bool EURJPY_OCO4_EO2_UP_S2 ;
        public static bool EURJPY_OCO4_EO3_UP_S2 ;
        public static bool EURJPY_OCO4_EO4_UP_S2 ;
        public static bool EURJPY_OCO4_EO5_UP_S2 ;
        public static bool EURJPY_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_UP_S2> EURJPY_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_UP_S2> EURJPY_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_UP_S2> EURJPY_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_UP_S2> EURJPY_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_UP_S2> EURJPY_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_UP_S2> EURJPY_OOFE_OCO4_UP_S2_6 ;
        
        public static EURJPY_OCO4_UP_S2 EURJPY_PFO_OCO4_UP_S2_1 ;
        public static EURJPY_OCO4_UP_S2 EURJPY_PFO_OCO4_UP_S2_2 ;
        public static EURJPY_OCO4_UP_S2 EURJPY_PFO_OCO4_UP_S2_3 ;
        public static EURJPY_OCO4_UP_S2 EURJPY_PFO_OCO4_UP_S2_4 ;
        public static EURJPY_OCO4_UP_S2 EURJPY_PFO_OCO4_UP_S2_5 ;
        public static EURJPY_OCO4_UP_S2 EURJPY_PFO_OCO4_UP_S2_6 ;
        
        public static List<EURJPY_OCO4_UP_S2> EURJPY_UP_S2_OCO4Sets1 = new List<EURJPY_OCO4_UP_S2>();
        public static List<EURJPY_OCO4_UP_S2> EURJPY_UP_S2_OCO4Sets2 = new List<EURJPY_OCO4_UP_S2>();
        public static List<EURJPY_OCO4_UP_S2> EURJPY_UP_S2_OCO4Sets3 = new List<EURJPY_OCO4_UP_S2>();
        public static List<EURJPY_OCO4_UP_S2> EURJPY_UP_S2_OCO4Sets4 = new List<EURJPY_OCO4_UP_S2>();
        public static List<EURJPY_OCO4_UP_S2> EURJPY_UP_S2_OCO4Sets5 = new List<EURJPY_OCO4_UP_S2>();
        public static List<EURJPY_OCO4_UP_S2> EURJPY_UP_S2_OCO4Sets6 = new List<EURJPY_OCO4_UP_S2>();
        
        public static bool EURJPY_OCO4_UP_S2_IsReady = true;
        public static bool EURJPY_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket EURJPY_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket EURJPY_OCO4_MO6_DOWN_S2 ;
    	
    	public static int EURJPY_OCO4_EO1_DOWN_S2_ID ;
        public static int EURJPY_OCO4_EO2_DOWN_S2_ID ;
        public static int EURJPY_OCO4_EO3_DOWN_S2_ID ;
        public static int EURJPY_OCO4_EO4_DOWN_S2_ID ;
        public static int EURJPY_OCO4_EO5_DOWN_S2_ID ;
        public static int EURJPY_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool EURJPY_OCO4_EO1_DOWN_S2 ;
        public static bool EURJPY_OCO4_EO2_DOWN_S2 ;
        public static bool EURJPY_OCO4_EO3_DOWN_S2 ;
        public static bool EURJPY_OCO4_EO4_DOWN_S2 ;
        public static bool EURJPY_OCO4_EO5_DOWN_S2 ;
        public static bool EURJPY_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_DOWN_S2> EURJPY_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_DOWN_S2> EURJPY_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_DOWN_S2> EURJPY_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_DOWN_S2> EURJPY_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_DOWN_S2> EURJPY_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURJPY_OCO4_DOWN_S2> EURJPY_OOFE_OCO4_DOWN_S2_6 ;
        
        public static EURJPY_OCO4_DOWN_S2 EURJPY_PFO_OCO4_DOWN_S2_1 ;
        public static EURJPY_OCO4_DOWN_S2 EURJPY_PFO_OCO4_DOWN_S2_2 ;
        public static EURJPY_OCO4_DOWN_S2 EURJPY_PFO_OCO4_DOWN_S2_3 ;
        public static EURJPY_OCO4_DOWN_S2 EURJPY_PFO_OCO4_DOWN_S2_4 ;
        public static EURJPY_OCO4_DOWN_S2 EURJPY_PFO_OCO4_DOWN_S2_5 ;
        public static EURJPY_OCO4_DOWN_S2 EURJPY_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<EURJPY_OCO4_DOWN_S2> EURJPY_DOWN_S2_OCO4Sets1 = new List<EURJPY_OCO4_DOWN_S2>();
        public static List<EURJPY_OCO4_DOWN_S2> EURJPY_DOWN_S2_OCO4Sets2 = new List<EURJPY_OCO4_DOWN_S2>();
        public static List<EURJPY_OCO4_DOWN_S2> EURJPY_DOWN_S2_OCO4Sets3 = new List<EURJPY_OCO4_DOWN_S2>();
        public static List<EURJPY_OCO4_DOWN_S2> EURJPY_DOWN_S2_OCO4Sets4 = new List<EURJPY_OCO4_DOWN_S2>();
        public static List<EURJPY_OCO4_DOWN_S2> EURJPY_DOWN_S2_OCO4Sets5 = new List<EURJPY_OCO4_DOWN_S2>();
        public static List<EURJPY_OCO4_DOWN_S2> EURJPY_DOWN_S2_OCO4Sets6 = new List<EURJPY_OCO4_DOWN_S2>();
        
        public static bool EURJPY_OCO4_DOWN_S2_IsReady = true;
        public static bool EURJPY_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal EURJPY_UP_S2_SL {get; set;}
		public static decimal EURJPY_UP_S2_TP1 {get; set;}
		public static decimal EURJPY_UP_S2_TP2 {get; set;}
		public static decimal EURJPY_UP_S2_TP3 {get; set;}
		public static decimal EURJPY_UP_S2_TP4 {get; set;}
		public static decimal EURJPY_UP_S2_TP5 {get; set;}
		public static decimal EURJPY_UP_S2_TP6 {get; set;}
		
		public static decimal EURJPY_DOWN_S2_SL {get; set;}
		public static decimal EURJPY_DOWN_S2_TP1 {get; set;}
		public static decimal EURJPY_DOWN_S2_TP2 {get; set;}
		public static decimal EURJPY_DOWN_S2_TP3 {get; set;}
		public static decimal EURJPY_DOWN_S2_TP4 {get; set;}
		public static decimal EURJPY_DOWN_S2_TP5 {get; set;}
		public static decimal EURJPY_DOWN_S2_TP6 {get; set;}

        public static bool EURJPY_Signal_Condition_UP_1 ;
        public static bool EURJPY_Signal_Condition_UP_2 ;
        public static bool EURJPY_Signal_Condition_UP_3 ;
        public static bool EURJPY_Signal_Condition_DOWN_S2 ;
        
        public static int EURJPY_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int EURJPY_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int EURJPY_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int EURJPY_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int EURJPY_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int EURJPY_DOWN_S2_OCO_DELAY_7DAY = 10080 * 4;
		public static int EURJPY_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int EURJPY_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int EURJPY_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int EURJPY_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_EURJPY_UP_S2 ;
        public static bool DOWM_EURJPY_UP_S2 ;
        public static bool DOWT_EURJPY_UP_S2 ;
        public static bool DOWW_EURJPY_UP_S2 ;
        public static bool DOWTH_EURJPY_UP_S2 ;
        
		public static bool DOWR_EURJPY_DOWN_S2 ;
        public static bool DOWM_EURJPY_DOWN_S2 ;
        public static bool DOWT_EURJPY_DOWN_S2 ;
        public static bool DOWW_EURJPY_DOWN_S2 ;
        public static bool DOWTH_EURJPY_DOWN_S2 ;
        
        
		public static int EURJPY_quantity_UP_S2 ;
		public static int EURJPY_quantity_SL_UP_S2 ;
		public static int EURJPY_quantity_TP1_UP_S2 ;
		public static int EURJPY_quantity_TP2_UP_S2 ;
		public static int EURJPY_quantity_TP3_UP_S2 ;
		public static int EURJPY_quantity_TP4_UP_S2 ;
		public static int EURJPY_quantity_TP5_UP_S2;
		public static int EURJPY_quantity_TP6_UP_S2 ;
		
		public static int EURJPY_quantity_DOWN_S2 ;
		public static int EURJPY_quantity_SL_DOWN_S2 ;
		public static int EURJPY_quantity_TP1_DOWN_S2 ;
		public static int EURJPY_quantity_TP2_DOWN_S2 ;
		public static int EURJPY_quantity_TP3_DOWN_S2 ;
		public static int EURJPY_quantity_TP4_DOWN_S2 ;
		public static int EURJPY_quantity_TP5_DOWN_S2;
		public static int EURJPY_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 EURCAD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURCAD_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("EURCAD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCAD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCAD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCAD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCAD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCAD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCAD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        }
		        
				if (Base.EURCAD_OCO1_EO1_UP_S2)
	                Base.EURCAD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURCAD_OCO1_EO2_UP_S2)
	                Base.EURCAD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO1_EO3_UP_S2)
	                Base.EURCAD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO1_EO4_UP_S2)
	                Base.EURCAD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO1_EO5_UP_S2)
	                Base.EURCAD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO1_EO6_UP_S2)
	                Base.EURCAD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCAD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.EURCAD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP1,"TP1_EURCAD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP1_EURCAD_UP_S2_OCO1"));
		                 };
		                Base.EURCAD_UP_S2_OCO1Sets1.Add( Base.EURCAD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCAD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP2,"TP2_EURCAD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP2_EURCAD_UP_S2_OCO1"));
		                 };
	                    Base.EURCAD_UP_S2_OCO1Sets2.Add( Base.EURCAD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP3,"TP3_EURCAD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP3_EURCAD_UP_S2_OCO1"));
		                 };
	                    Base.EURCAD_UP_S2_OCO1Sets3.Add( Base.EURCAD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP4,"TP4_EURCAD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP4_EURCAD_UP_S2_OCO1"));
		                 };
	                    Base.EURCAD_UP_S2_OCO1Sets4.Add( Base.EURCAD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP5,"TP5_EURCAD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP5_EURCAD_UP_S2_OCO1"));
		                 };
	                    Base.EURCAD_UP_S2_OCO1Sets5.Add( Base.EURCAD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP6,"TP6_EURCAD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP6_EURCAD_UP_S2_OCO1"));
		                 };
	                    Base.EURCAD_UP_S2_OCO1Sets6.Add( Base.EURCAD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURCAD_OCO1S1_UP_S2 = 0;
	                for (; EURCAD_OCO1S1_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets1.Count; EURCAD_OCO1S1_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO1Sets1[EURCAD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO1Sets1[EURCAD_OCO1S1_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO1Sets1.RemoveAt(EURCAD_OCO1S1_UP_S2);
	                        EURCAD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURCAD_OCO1S2_UP_S2 = 0;
	                for (; EURCAD_OCO1S2_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets2.Count; EURCAD_OCO1S2_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO1Sets2[EURCAD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO1Sets2[EURCAD_OCO1S2_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO1Sets2.RemoveAt(EURCAD_OCO1S2_UP_S2);
	                        EURCAD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO1S3_UP_S2 = 0;
	                for (; EURCAD_OCO1S3_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets3.Count; EURCAD_OCO1S3_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO1Sets3[EURCAD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO1Sets3[EURCAD_OCO1S3_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO1Sets3.RemoveAt(EURCAD_OCO1S3_UP_S2);
	                        EURCAD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO1S4_UP_S2 = 0;
	                for (; EURCAD_OCO1S4_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets4.Count; EURCAD_OCO1S4_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO1Sets4[EURCAD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO1Sets4[EURCAD_OCO1S4_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO1Sets4.RemoveAt(EURCAD_OCO1S4_UP_S2);
	                        EURCAD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCAD_OCO1S5_UP_S2 = 0;
	                for (; EURCAD_OCO1S5_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets5.Count; EURCAD_OCO1S5_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO1Sets5[EURCAD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO1Sets5[EURCAD_OCO1S5_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO1Sets5.RemoveAt(EURCAD_OCO1S5_UP_S2);
	                        EURCAD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCAD_OCO1S6_UP_S2 = 0;
	                for (; EURCAD_OCO1S6_UP_S2 < Base.EURCAD_UP_S2_OCO1Sets6.Count; EURCAD_OCO1S6_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO1Sets6[EURCAD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO1Sets6[EURCAD_OCO1S6_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO1Sets6.RemoveAt(EURCAD_OCO1S6_UP_S2);
	                        EURCAD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.EURCAD_OCO2_EO1_UP_S2)
	                Base.EURCAD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURCAD_OCO2_EO2_UP_S2)
	                Base.EURCAD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO2_EO3_UP_S2)
	                Base.EURCAD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO2_EO4_UP_S2)
	                Base.EURCAD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO2_EO5_UP_S2)
	                Base.EURCAD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO2_EO6_UP_S2)
	                Base.EURCAD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCAD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.EURCAD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP1,"TP1_EURCAD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP1_EURCAD_UP_S2_OCO2"));
		                 };
		                Base.EURCAD_UP_S2_OCO2Sets1.Add( Base.EURCAD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCAD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP2,"TP2_EURCAD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP2_EURCAD_UP_S2_OCO2"));
		                 };
	                    Base.EURCAD_UP_S2_OCO2Sets2.Add( Base.EURCAD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP3,"TP3_EURCAD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP3_EURCAD_UP_S2_OCO2"));
		                 };
	                    Base.EURCAD_UP_S2_OCO2Sets3.Add( Base.EURCAD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP4,"TP4_EURCAD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP4_EURCAD_UP_S2_OCO2"));
		                 };
	                    Base.EURCAD_UP_S2_OCO2Sets4.Add( Base.EURCAD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP5,"TP5_EURCAD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP5_EURCAD_UP_S2_OCO2"));
		                 };
	                    Base.EURCAD_UP_S2_OCO2Sets5.Add( Base.EURCAD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP6,"TP6_EURCAD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP6_EURCAD_UP_S2_OCO2"));
		                 };
	                    Base.EURCAD_UP_S2_OCO2Sets6.Add( Base.EURCAD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURCAD_OCO2S1_UP_S2 = 0;
	                for (; EURCAD_OCO2S1_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets1.Count; EURCAD_OCO2S1_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO2Sets1[EURCAD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO2Sets1[EURCAD_OCO2S1_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO2Sets1.RemoveAt(EURCAD_OCO2S1_UP_S2);
	                        EURCAD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURCAD_OCO2S2_UP_S2 = 0;
	                for (; EURCAD_OCO2S2_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets2.Count; EURCAD_OCO2S2_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO2Sets2[EURCAD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO2Sets2[EURCAD_OCO2S2_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO2Sets2.RemoveAt(EURCAD_OCO2S2_UP_S2);
	                        EURCAD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO2S3_UP_S2 = 0;
	                for (; EURCAD_OCO2S3_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets3.Count; EURCAD_OCO2S3_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO2Sets3[EURCAD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO2Sets3[EURCAD_OCO2S3_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO2Sets3.RemoveAt(EURCAD_OCO2S3_UP_S2);
	                        EURCAD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO2S4_UP_S2 = 0;
	                for (; EURCAD_OCO2S4_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets4.Count; EURCAD_OCO2S4_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO2Sets4[EURCAD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO2Sets4[EURCAD_OCO2S4_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO2Sets4.RemoveAt(EURCAD_OCO2S4_UP_S2);
	                        EURCAD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCAD_OCO2S5_UP_S2 = 0;
	                for (; EURCAD_OCO2S5_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets5.Count; EURCAD_OCO2S5_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO2Sets5[EURCAD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO2Sets5[EURCAD_OCO2S5_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO2Sets5.RemoveAt(EURCAD_OCO2S5_UP_S2);
	                        EURCAD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCAD_OCO2S6_UP_S2 = 0;
	                for (; EURCAD_OCO2S6_UP_S2 < Base.EURCAD_UP_S2_OCO2Sets6.Count; EURCAD_OCO2S6_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO2Sets6[EURCAD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO2Sets6[EURCAD_OCO2S6_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO2Sets6.RemoveAt(EURCAD_OCO2S6_UP_S2);
	                        EURCAD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCAD_OCO3_EO1_UP_S2)
	                Base.EURCAD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURCAD_OCO3_EO2_UP_S2)
	                Base.EURCAD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO3_EO3_UP_S2)
	                Base.EURCAD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO3_EO4_UP_S2)
	                Base.EURCAD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO3_EO5_UP_S2)
	                Base.EURCAD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO3_EO6_UP_S2)
	                Base.EURCAD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCAD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.EURCAD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP1,"TP1_EURCAD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP1_EURCAD_UP_S2_OCO3"));
		                 };
		                Base.EURCAD_UP_S2_OCO3Sets1.Add( Base.EURCAD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCAD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP2,"TP2_EURCAD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP2_EURCAD_UP_S2_OCO3"));
		                 };
	                    Base.EURCAD_UP_S2_OCO3Sets2.Add( Base.EURCAD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP3,"TP3_EURCAD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP3_EURCAD_UP_S2_OCO3"));
		                 };
	                    Base.EURCAD_UP_S2_OCO3Sets3.Add( Base.EURCAD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP4,"TP4_EURCAD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP4_EURCAD_UP_S2_OCO3"));
		                 };
	                    Base.EURCAD_UP_S2_OCO3Sets4.Add( Base.EURCAD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP5,"TP5_EURCAD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP5_EURCAD_UP_S2_OCO3"));
		                 };
	                    Base.EURCAD_UP_S2_OCO3Sets5.Add( Base.EURCAD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP6,"TP6_EURCAD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP6_EURCAD_UP_S2_OCO3"));
		                 };
	                    Base.EURCAD_UP_S2_OCO3Sets6.Add( Base.EURCAD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURCAD_OCO3S1_UP_S2 = 0;
	                for (; EURCAD_OCO3S1_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets1.Count; EURCAD_OCO3S1_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO3Sets1[EURCAD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO3Sets1[EURCAD_OCO3S1_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO3Sets1.RemoveAt(EURCAD_OCO3S1_UP_S2);
	                        EURCAD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURCAD_OCO3S2_UP_S2 = 0;
	                for (; EURCAD_OCO3S2_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets2.Count; EURCAD_OCO3S2_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO3Sets2[EURCAD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO3Sets2[EURCAD_OCO3S2_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO3Sets2.RemoveAt(EURCAD_OCO3S2_UP_S2);
	                        EURCAD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO3S3_UP_S2 = 0;
	                for (; EURCAD_OCO3S3_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets3.Count; EURCAD_OCO3S3_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO3Sets3[EURCAD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO3Sets3[EURCAD_OCO3S3_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO3Sets3.RemoveAt(EURCAD_OCO3S3_UP_S2);
	                        EURCAD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO3S4_UP_S2 = 0;
	                for (; EURCAD_OCO3S4_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets4.Count; EURCAD_OCO3S4_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO3Sets4[EURCAD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO3Sets4[EURCAD_OCO3S4_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO3Sets4.RemoveAt(EURCAD_OCO3S4_UP_S2);
	                        EURCAD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCAD_OCO3S5_UP_S2 = 0;
	                for (; EURCAD_OCO3S5_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets5.Count; EURCAD_OCO3S5_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO3Sets5[EURCAD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO3Sets5[EURCAD_OCO3S5_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO3Sets5.RemoveAt(EURCAD_OCO3S5_UP_S2);
	                        EURCAD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCAD_OCO3S6_UP_S2 = 0;
	                for (; EURCAD_OCO3S6_UP_S2 < Base.EURCAD_UP_S2_OCO3Sets6.Count; EURCAD_OCO3S6_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO3Sets6[EURCAD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO3Sets6[EURCAD_OCO3S6_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO3Sets6.RemoveAt(EURCAD_OCO3S6_UP_S2);
	                        EURCAD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCAD_OCO4_EO1_UP_S2)
	                Base.EURCAD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURCAD_OCO4_EO2_UP_S2)
	                Base.EURCAD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO4_EO3_UP_S2)
	                Base.EURCAD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO4_EO4_UP_S2)
	                Base.EURCAD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO4_EO5_UP_S2)
	                Base.EURCAD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO4_EO6_UP_S2)
	                Base.EURCAD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCAD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.EURCAD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP1,"TP1_EURCAD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP1_EURCAD_UP_S2_OCO4"));
		                 };
		                Base.EURCAD_UP_S2_OCO4Sets1.Add( Base.EURCAD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCAD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP2,"TP2_EURCAD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP2_EURCAD_UP_S2_OCO4"));
		                 };
	                    Base.EURCAD_UP_S2_OCO4Sets2.Add( Base.EURCAD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP3,"TP3_EURCAD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP3_EURCAD_UP_S2_OCO4"));
		                 };
	                    Base.EURCAD_UP_S2_OCO4Sets3.Add( Base.EURCAD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP4,"TP4_EURCAD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP4_EURCAD_UP_S2_OCO4"));
		                 };
	                    Base.EURCAD_UP_S2_OCO4Sets4.Add( Base.EURCAD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP5,"TP5_EURCAD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP5_EURCAD_UP_S2_OCO4"));
		                 };
	                    Base.EURCAD_UP_S2_OCO4Sets5.Add( Base.EURCAD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_UP_S2_TP6,"TP6_EURCAD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_UP_S2_SL,"SL_TP6_EURCAD_UP_S2_OCO4"));
		                 };
	                    Base.EURCAD_UP_S2_OCO4Sets6.Add( Base.EURCAD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURCAD_OCO4S1_UP_S2 = 0;
	                for (; EURCAD_OCO4S1_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets1.Count; EURCAD_OCO4S1_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO4Sets1[EURCAD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO4Sets1[EURCAD_OCO4S1_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO4Sets1.RemoveAt(EURCAD_OCO4S1_UP_S2);
	                        EURCAD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURCAD_OCO4S2_UP_S2 = 0;
	                for (; EURCAD_OCO4S2_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets2.Count; EURCAD_OCO4S2_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO4Sets2[EURCAD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO4Sets2[EURCAD_OCO4S2_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO4Sets2.RemoveAt(EURCAD_OCO4S2_UP_S2);
	                        EURCAD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO4S3_UP_S2 = 0;
	                for (; EURCAD_OCO4S3_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets3.Count; EURCAD_OCO4S3_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO4Sets3[EURCAD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO4Sets3[EURCAD_OCO4S3_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO4Sets3.RemoveAt(EURCAD_OCO4S3_UP_S2);
	                        EURCAD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO4S4_UP_S2 = 0;
	                for (; EURCAD_OCO4S4_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets4.Count; EURCAD_OCO4S4_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO4Sets4[EURCAD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO4Sets4[EURCAD_OCO4S4_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO4Sets4.RemoveAt(EURCAD_OCO4S4_UP_S2);
	                        EURCAD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCAD_OCO4S5_UP_S2 = 0;
	                for (; EURCAD_OCO4S5_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets5.Count; EURCAD_OCO4S5_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO4Sets5[EURCAD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO4Sets5[EURCAD_OCO4S5_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO4Sets5.RemoveAt(EURCAD_OCO4S5_UP_S2);
	                        EURCAD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURCAD_OCO4S6_UP_S2 = 0;
	                for (; EURCAD_OCO4S6_UP_S2 < Base.EURCAD_UP_S2_OCO4Sets6.Count; EURCAD_OCO4S6_UP_S2++)
	                    if (Base.EURCAD_UP_S2_OCO4Sets6[EURCAD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_UP_S2_OCO4Sets6[EURCAD_OCO4S6_UP_S2].Filled();
	                        Base.EURCAD_UP_S2_OCO4Sets6.RemoveAt(EURCAD_OCO4S6_UP_S2);
	                        EURCAD_OCO4S6_UP_S2 = 0;
	                        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.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 EURAUD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURAUD_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("EURAUD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURAUD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURAUD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURAUD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURAUD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURAUD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURAUD S2");
		        	}
		        }
		        
				if (Base.EURAUD_OCO1_EO1_DOWN_S2)
	                Base.EURAUD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURAUD_OCO1_EO2_DOWN_S2)
	                Base.EURAUD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO1_EO3_DOWN_S2)
	                Base.EURAUD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO1_EO4_DOWN_S2)
	                Base.EURAUD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURAUD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.EURAUD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP1_EURAUD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP1,"TP1_EURAUD_DOWN_S2_OCO1"));
		                 };
		                Base.EURAUD_DOWN_S2_OCO1Sets1.Add( Base.EURAUD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURAUD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP2_EURAUD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP2,"TP2_EURAUD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO1Sets2.Add( Base.EURAUD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP3_EURAUD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP3,"TP3_EURAUD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO1Sets3.Add( Base.EURAUD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP4_EURAUD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP4,"TP4_EURAUD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO1Sets4.Add( Base.EURAUD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURAUD_OCO1S1_DOWN_S2 = 0;
	                for (; EURAUD_OCO1S1_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets1.Count; EURAUD_OCO1S1_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO1Sets1[EURAUD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO1Sets1[EURAUD_OCO1S1_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO1Sets1.RemoveAt(EURAUD_OCO1S1_DOWN_S2);
	                        EURAUD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURAUD_OCO1S2_DOWN_S2 = 0;
	                for (; EURAUD_OCO1S2_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets2.Count; EURAUD_OCO1S2_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO1Sets2[EURAUD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO1Sets2[EURAUD_OCO1S2_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO1Sets2.RemoveAt(EURAUD_OCO1S2_DOWN_S2);
	                        EURAUD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO1S3_DOWN_S2 = 0;
	                for (; EURAUD_OCO1S3_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets3.Count; EURAUD_OCO1S3_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO1Sets3[EURAUD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO1Sets3[EURAUD_OCO1S3_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO1Sets3.RemoveAt(EURAUD_OCO1S3_DOWN_S2);
	                        EURAUD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO1S4_DOWN_S2 = 0;
	                for (; EURAUD_OCO1S4_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets4.Count; EURAUD_OCO1S4_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO1Sets4[EURAUD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO1Sets4[EURAUD_OCO1S4_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO1Sets4.RemoveAt(EURAUD_OCO1S4_DOWN_S2);
	                        EURAUD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURAUD_OCO2_EO1_DOWN_S2)
	                Base.EURAUD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURAUD_OCO2_EO2_DOWN_S2)
	                Base.EURAUD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO2_EO3_DOWN_S2)
	                Base.EURAUD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO2_EO4_DOWN_S2)
	                Base.EURAUD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURAUD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.EURAUD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP1_EURAUD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP1,"TP1_EURAUD_DOWN_S2_OCO2"));
		                 };
		                Base.EURAUD_DOWN_S2_OCO2Sets1.Add( Base.EURAUD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURAUD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP2_EURAUD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP2,"TP2_EURAUD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO2Sets2.Add( Base.EURAUD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP3_EURAUD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP3,"TP3_EURAUD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO2Sets3.Add( Base.EURAUD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP4_EURAUD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP4,"TP4_EURAUD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO2Sets4.Add( Base.EURAUD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURAUD_OCO2S1_DOWN_S2 = 0;
	                for (; EURAUD_OCO2S1_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets1.Count; EURAUD_OCO2S1_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO2Sets1[EURAUD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO2Sets1[EURAUD_OCO2S1_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO2Sets1.RemoveAt(EURAUD_OCO2S1_DOWN_S2);
	                        EURAUD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURAUD_OCO2S2_DOWN_S2 = 0;
	                for (; EURAUD_OCO2S2_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets2.Count; EURAUD_OCO2S2_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO2Sets2[EURAUD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO2Sets2[EURAUD_OCO2S2_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO2Sets2.RemoveAt(EURAUD_OCO2S2_DOWN_S2);
	                        EURAUD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO2S3_DOWN_S2 = 0;
	                for (; EURAUD_OCO2S3_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets3.Count; EURAUD_OCO2S3_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO2Sets3[EURAUD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO2Sets3[EURAUD_OCO2S3_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO2Sets3.RemoveAt(EURAUD_OCO2S3_DOWN_S2);
	                        EURAUD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO2S4_DOWN_S2 = 0;
	                for (; EURAUD_OCO2S4_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets4.Count; EURAUD_OCO2S4_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO2Sets4[EURAUD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO2Sets4[EURAUD_OCO2S4_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO2Sets4.RemoveAt(EURAUD_OCO2S4_DOWN_S2);
	                        EURAUD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURAUD_OCO3_EO1_DOWN_S2)
	                Base.EURAUD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURAUD_OCO3_EO2_DOWN_S2)
	                Base.EURAUD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO3_EO3_DOWN_S2)
	                Base.EURAUD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO3_EO4_DOWN_S2)
	                Base.EURAUD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURAUD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.EURAUD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP1_EURAUD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP1,"TP1_EURAUD_DOWN_S2_OCO3"));
		                 };
		                Base.EURAUD_DOWN_S2_OCO3Sets1.Add( Base.EURAUD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURAUD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP2_EURAUD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP2,"TP2_EURAUD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO3Sets2.Add( Base.EURAUD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP3_EURAUD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP3,"TP3_EURAUD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO3Sets3.Add( Base.EURAUD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP4_EURAUD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP4,"TP4_EURAUD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO3Sets4.Add( Base.EURAUD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURAUD_OCO3S1_DOWN_S2 = 0;
	                for (; EURAUD_OCO3S1_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets1.Count; EURAUD_OCO3S1_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO3Sets1[EURAUD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO3Sets1[EURAUD_OCO3S1_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO3Sets1.RemoveAt(EURAUD_OCO3S1_DOWN_S2);
	                        EURAUD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURAUD_OCO3S2_DOWN_S2 = 0;
	                for (; EURAUD_OCO3S2_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets2.Count; EURAUD_OCO3S2_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO3Sets2[EURAUD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO3Sets2[EURAUD_OCO3S2_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO3Sets2.RemoveAt(EURAUD_OCO3S2_DOWN_S2);
	                        EURAUD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO3S3_DOWN_S2 = 0;
	                for (; EURAUD_OCO3S3_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets3.Count; EURAUD_OCO3S3_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO3Sets3[EURAUD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO3Sets3[EURAUD_OCO3S3_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO3Sets3.RemoveAt(EURAUD_OCO3S3_DOWN_S2);
	                        EURAUD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO3S4_DOWN_S2 = 0;
	                for (; EURAUD_OCO3S4_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets4.Count; EURAUD_OCO3S4_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO3Sets4[EURAUD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO3Sets4[EURAUD_OCO3S4_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO3Sets4.RemoveAt(EURAUD_OCO3S4_DOWN_S2);
	                        EURAUD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURAUD_OCO4_EO1_DOWN_S2)
	                Base.EURAUD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURAUD_OCO4_EO2_DOWN_S2)
	                Base.EURAUD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO4_EO3_DOWN_S2)
	                Base.EURAUD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURAUD_OCO4_EO4_DOWN_S2)
	                Base.EURAUD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURAUD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.EURAUD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP1_EURAUD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP1,"TP1_EURAUD_DOWN_S2_OCO4"));
		                 };
		                Base.EURAUD_DOWN_S2_OCO4Sets1.Add( Base.EURAUD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURAUD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP2_EURAUD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP2,"TP2_EURAUD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO4Sets2.Add( Base.EURAUD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP3_EURAUD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP3,"TP3_EURAUD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO4Sets3.Add( Base.EURAUD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURAUD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURAUD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURAUD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURAUD_DOWN_S2_SL,"SL_TP4_EURAUD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURAUD_DOWN_S2_TP4,"TP4_EURAUD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURAUD_DOWN_S2_OCO4Sets4.Add( Base.EURAUD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURAUD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURAUD_OCO4S1_DOWN_S2 = 0;
	                for (; EURAUD_OCO4S1_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets1.Count; EURAUD_OCO4S1_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO4Sets1[EURAUD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO4Sets1[EURAUD_OCO4S1_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO4Sets1.RemoveAt(EURAUD_OCO4S1_DOWN_S2);
	                        EURAUD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURAUD_OCO4S2_DOWN_S2 = 0;
	                for (; EURAUD_OCO4S2_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets2.Count; EURAUD_OCO4S2_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO4Sets2[EURAUD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO4Sets2[EURAUD_OCO4S2_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO4Sets2.RemoveAt(EURAUD_OCO4S2_DOWN_S2);
	                        EURAUD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO4S3_DOWN_S2 = 0;
	                for (; EURAUD_OCO4S3_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets3.Count; EURAUD_OCO4S3_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO4Sets3[EURAUD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO4Sets3[EURAUD_OCO4S3_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO4Sets3.RemoveAt(EURAUD_OCO4S3_DOWN_S2);
	                        EURAUD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURAUD_OCO4S4_DOWN_S2 = 0;
	                for (; EURAUD_OCO4S4_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets4.Count; EURAUD_OCO4S4_DOWN_S2++)
	                    if (Base.EURAUD_DOWN_S2_OCO4Sets4[EURAUD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURAUD_DOWN_S2_OCO4Sets4[EURAUD_OCO4S4_DOWN_S2].Filled();
	                        Base.EURAUD_DOWN_S2_OCO4Sets4.RemoveAt(EURAUD_OCO4S4_DOWN_S2);
	                        EURAUD_OCO4S4_DOWN_S2 = 0;
	                        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.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 EURCAD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURCAD_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("EURCAD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCAD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCAD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCAD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURCAD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCAD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCAD S2");
		        	}
		        }
		        
				if (Base.EURCAD_OCO1_EO1_DOWN_S2)
	                Base.EURCAD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURCAD_OCO1_EO2_DOWN_S2)
	                Base.EURCAD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO1_EO3_DOWN_S2)
	                Base.EURCAD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO1_EO4_DOWN_S2)
	                Base.EURCAD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCAD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.EURCAD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP1_EURCAD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP1,"TP1_EURCAD_DOWN_S2_OCO1"));
		                 };
		                Base.EURCAD_DOWN_S2_OCO1Sets1.Add( Base.EURCAD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCAD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP2_EURCAD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP2,"TP2_EURCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO1Sets2.Add( Base.EURCAD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP3_EURCAD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP3,"TP3_EURCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO1Sets3.Add( Base.EURCAD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP4_EURCAD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP4,"TP4_EURCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO1Sets4.Add( Base.EURCAD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURCAD_OCO1S1_DOWN_S2 = 0;
	                for (; EURCAD_OCO1S1_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets1.Count; EURCAD_OCO1S1_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO1Sets1[EURCAD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO1Sets1[EURCAD_OCO1S1_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO1Sets1.RemoveAt(EURCAD_OCO1S1_DOWN_S2);
	                        EURCAD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURCAD_OCO1S2_DOWN_S2 = 0;
	                for (; EURCAD_OCO1S2_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets2.Count; EURCAD_OCO1S2_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO1Sets2[EURCAD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO1Sets2[EURCAD_OCO1S2_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO1Sets2.RemoveAt(EURCAD_OCO1S2_DOWN_S2);
	                        EURCAD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO1S3_DOWN_S2 = 0;
	                for (; EURCAD_OCO1S3_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets3.Count; EURCAD_OCO1S3_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO1Sets3[EURCAD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO1Sets3[EURCAD_OCO1S3_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO1Sets3.RemoveAt(EURCAD_OCO1S3_DOWN_S2);
	                        EURCAD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO1S4_DOWN_S2 = 0;
	                for (; EURCAD_OCO1S4_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO1Sets4.Count; EURCAD_OCO1S4_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO1Sets4[EURCAD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO1Sets4[EURCAD_OCO1S4_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO1Sets4.RemoveAt(EURCAD_OCO1S4_DOWN_S2);
	                        EURCAD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCAD_OCO2_EO1_DOWN_S2)
	                Base.EURCAD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURCAD_OCO2_EO2_DOWN_S2)
	                Base.EURCAD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO2_EO3_DOWN_S2)
	                Base.EURCAD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO2_EO4_DOWN_S2)
	                Base.EURCAD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCAD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.EURCAD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP1_EURCAD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP1,"TP1_EURCAD_DOWN_S2_OCO2"));
		                 };
		                Base.EURCAD_DOWN_S2_OCO2Sets1.Add( Base.EURCAD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCAD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP2_EURCAD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP2,"TP2_EURCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO2Sets2.Add( Base.EURCAD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP3_EURCAD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP3,"TP3_EURCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO2Sets3.Add( Base.EURCAD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP4_EURCAD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP4,"TP4_EURCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO2Sets4.Add( Base.EURCAD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURCAD_OCO2S1_DOWN_S2 = 0;
	                for (; EURCAD_OCO2S1_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets1.Count; EURCAD_OCO2S1_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO2Sets1[EURCAD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO2Sets1[EURCAD_OCO2S1_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO2Sets1.RemoveAt(EURCAD_OCO2S1_DOWN_S2);
	                        EURCAD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURCAD_OCO2S2_DOWN_S2 = 0;
	                for (; EURCAD_OCO2S2_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets2.Count; EURCAD_OCO2S2_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO2Sets2[EURCAD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO2Sets2[EURCAD_OCO2S2_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO2Sets2.RemoveAt(EURCAD_OCO2S2_DOWN_S2);
	                        EURCAD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO2S3_DOWN_S2 = 0;
	                for (; EURCAD_OCO2S3_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets3.Count; EURCAD_OCO2S3_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO2Sets3[EURCAD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO2Sets3[EURCAD_OCO2S3_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO2Sets3.RemoveAt(EURCAD_OCO2S3_DOWN_S2);
	                        EURCAD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO2S4_DOWN_S2 = 0;
	                for (; EURCAD_OCO2S4_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO2Sets4.Count; EURCAD_OCO2S4_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO2Sets4[EURCAD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO2Sets4[EURCAD_OCO2S4_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO2Sets4.RemoveAt(EURCAD_OCO2S4_DOWN_S2);
	                        EURCAD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCAD_OCO3_EO1_DOWN_S2)
	                Base.EURCAD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURCAD_OCO3_EO2_DOWN_S2)
	                Base.EURCAD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO3_EO3_DOWN_S2)
	                Base.EURCAD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO3_EO4_DOWN_S2)
	                Base.EURCAD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCAD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.EURCAD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP1_EURCAD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP1,"TP1_EURCAD_DOWN_S2_OCO3"));
		                 };
		                Base.EURCAD_DOWN_S2_OCO3Sets1.Add( Base.EURCAD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCAD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP2_EURCAD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP2,"TP2_EURCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO3Sets2.Add( Base.EURCAD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP3_EURCAD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP3,"TP3_EURCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO3Sets3.Add( Base.EURCAD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP4_EURCAD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP4,"TP4_EURCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO3Sets4.Add( Base.EURCAD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURCAD_OCO3S1_DOWN_S2 = 0;
	                for (; EURCAD_OCO3S1_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets1.Count; EURCAD_OCO3S1_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO3Sets1[EURCAD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO3Sets1[EURCAD_OCO3S1_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO3Sets1.RemoveAt(EURCAD_OCO3S1_DOWN_S2);
	                        EURCAD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURCAD_OCO3S2_DOWN_S2 = 0;
	                for (; EURCAD_OCO3S2_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets2.Count; EURCAD_OCO3S2_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO3Sets2[EURCAD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO3Sets2[EURCAD_OCO3S2_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO3Sets2.RemoveAt(EURCAD_OCO3S2_DOWN_S2);
	                        EURCAD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO3S3_DOWN_S2 = 0;
	                for (; EURCAD_OCO3S3_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets3.Count; EURCAD_OCO3S3_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO3Sets3[EURCAD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO3Sets3[EURCAD_OCO3S3_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO3Sets3.RemoveAt(EURCAD_OCO3S3_DOWN_S2);
	                        EURCAD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO3S4_DOWN_S2 = 0;
	                for (; EURCAD_OCO3S4_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO3Sets4.Count; EURCAD_OCO3S4_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO3Sets4[EURCAD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO3Sets4[EURCAD_OCO3S4_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO3Sets4.RemoveAt(EURCAD_OCO3S4_DOWN_S2);
	                        EURCAD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCAD_OCO4_EO1_DOWN_S2)
	                Base.EURCAD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURCAD_OCO4_EO2_DOWN_S2)
	                Base.EURCAD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO4_EO3_DOWN_S2)
	                Base.EURCAD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCAD_OCO4_EO4_DOWN_S2)
	                Base.EURCAD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCAD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.EURCAD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP1_EURCAD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP1,"TP1_EURCAD_DOWN_S2_OCO4"));
		                 };
		                Base.EURCAD_DOWN_S2_OCO4Sets1.Add( Base.EURCAD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCAD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP2_EURCAD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP2,"TP2_EURCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO4Sets2.Add( Base.EURCAD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP3_EURCAD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP3,"TP3_EURCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO4Sets3.Add( Base.EURCAD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCAD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURCAD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCAD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCAD_DOWN_S2_SL,"SL_TP4_EURCAD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCAD_DOWN_S2_TP4,"TP4_EURCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURCAD_DOWN_S2_OCO4Sets4.Add( Base.EURCAD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCAD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURCAD_OCO4S1_DOWN_S2 = 0;
	                for (; EURCAD_OCO4S1_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets1.Count; EURCAD_OCO4S1_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO4Sets1[EURCAD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO4Sets1[EURCAD_OCO4S1_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO4Sets1.RemoveAt(EURCAD_OCO4S1_DOWN_S2);
	                        EURCAD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURCAD_OCO4S2_DOWN_S2 = 0;
	                for (; EURCAD_OCO4S2_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets2.Count; EURCAD_OCO4S2_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO4Sets2[EURCAD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO4Sets2[EURCAD_OCO4S2_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO4Sets2.RemoveAt(EURCAD_OCO4S2_DOWN_S2);
	                        EURCAD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO4S3_DOWN_S2 = 0;
	                for (; EURCAD_OCO4S3_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets3.Count; EURCAD_OCO4S3_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO4Sets3[EURCAD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO4Sets3[EURCAD_OCO4S3_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO4Sets3.RemoveAt(EURCAD_OCO4S3_DOWN_S2);
	                        EURCAD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCAD_OCO4S4_DOWN_S2 = 0;
	                for (; EURCAD_OCO4S4_DOWN_S2 < Base.EURCAD_DOWN_S2_OCO4Sets4.Count; EURCAD_OCO4S4_DOWN_S2++)
	                    if (Base.EURCAD_DOWN_S2_OCO4Sets4[EURCAD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCAD_DOWN_S2_OCO4Sets4[EURCAD_OCO4S4_DOWN_S2].Filled();
	                        Base.EURCAD_DOWN_S2_OCO4Sets4.RemoveAt(EURCAD_OCO4S4_DOWN_S2);
	                        EURCAD_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPCHF_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPCHF_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(x=>x.Tag.Contains("GBPCHF_UP_S2_OCO1")))
			{
				Base.GBPCHF_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCHF_UP_S2_OCO2")))
			{
				Base.GBPCHF_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCHF_UP_S2_OCO3")))
			{
				Base.GBPCHF_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCHF_UP_S2_OCO4")))
			{
				Base.GBPCHF_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPCHF_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.GBPCHF_OCO1_EO1_UP_S2)
	                Base.GBPCHF_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPCHF_OCO1_EO2_UP_S2)
	                Base.GBPCHF_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO1_EO3_UP_S2)
	                Base.GBPCHF_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO1_EO4_UP_S2)
	                Base.GBPCHF_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO1_EO5_UP_S2)
	                Base.GBPCHF_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO1_EO6_UP_S2)
	                Base.GBPCHF_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCHF_OCO1S1_UP_S2 = 0;
		                for (; GBPCHF_OCO1S1_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets1.Count; GBPCHF_OCO1S1_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO1Sets1[GBPCHF_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO1Sets1[GBPCHF_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_1__Time out_OCO1");
		                        Base.GBPCHF_UP_S2_OCO1Sets1.Clear();
		                        GBPCHF_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCHF_OCO1S2_UP_S2 = 0;
		                for (; GBPCHF_OCO1S2_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets2.Count; GBPCHF_OCO1S2_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO1Sets2[GBPCHF_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO1Sets2[GBPCHF_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_2__Time out_OCO1");
		                        Base.GBPCHF_UP_S2_OCO1Sets2.Clear();
		                        GBPCHF_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO1S3_UP_S2 = 0;
		                for (; GBPCHF_OCO1S3_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets3.Count; GBPCHF_OCO1S3_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO1Sets3[GBPCHF_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO1Sets3[GBPCHF_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_3__Time out_OCO1");
		                        Base.GBPCHF_UP_S2_OCO1Sets3.Clear();
		                        GBPCHF_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO1S4_UP_S2 = 0;
		                for (; GBPCHF_OCO1S4_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets4.Count; GBPCHF_OCO1S4_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO1Sets4[GBPCHF_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO1Sets4[GBPCHF_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_4__Time out_OCO1");
		                        Base.GBPCHF_UP_S2_OCO1Sets4.Clear();
		                        GBPCHF_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO1S5_UP_S2 = 0;
		                for (; GBPCHF_OCO1S5_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets5.Count; GBPCHF_OCO1S5_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO1Sets5[GBPCHF_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO1Sets5[GBPCHF_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_5__Time out_OCO1");
		                        Base.GBPCHF_UP_S2_OCO1Sets5.Clear();
		                        GBPCHF_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO1S6_UP_S2 = 0;
		                for (; GBPCHF_OCO1S6_UP_S2 < Base.GBPCHF_UP_S2_OCO1Sets6.Count; GBPCHF_OCO1S6_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO1Sets6[GBPCHF_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO1Sets6[GBPCHF_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_6__Time out_OCO1");
		                        Base.GBPCHF_UP_S2_OCO1Sets6.Clear();
		                        GBPCHF_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPCHF_OCO2_EO1_UP_S2)
                	Base.GBPCHF_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPCHF_OCO2_EO2_UP_S2)
	                Base.GBPCHF_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO2_EO3_UP_S2)
	                Base.GBPCHF_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO2_EO4_UP_S2)
	                Base.GBPCHF_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO2_EO5_UP_S2)
	                Base.GBPCHF_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO2_EO6_UP_S2)
	                Base.GBPCHF_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCHF_OCO2S1_UP_S2 = 0;
		                for (; GBPCHF_OCO2S1_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets1.Count; GBPCHF_OCO2S1_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO2Sets1[GBPCHF_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO2Sets1[GBPCHF_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_1__Time out_OCO2");
		                        Base.GBPCHF_UP_S2_OCO2Sets1.Clear();
		                        GBPCHF_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCHF_OCO2S2_UP_S2 = 0;
		                for (; GBPCHF_OCO2S2_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets2.Count; GBPCHF_OCO2S2_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO2Sets2[GBPCHF_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO2Sets2[GBPCHF_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_2__Time out_OCO2");
		                        Base.GBPCHF_UP_S2_OCO2Sets2.Clear();
		                        GBPCHF_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO2S3_UP_S2 = 0;
		                for (; GBPCHF_OCO2S3_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets3.Count; GBPCHF_OCO2S3_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO2Sets3[GBPCHF_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO2Sets3[GBPCHF_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_3__Time out_OCO2");
		                        Base.GBPCHF_UP_S2_OCO2Sets3.Clear();
		                        GBPCHF_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO2S4_UP_S2 = 0;
		                for (; GBPCHF_OCO2S4_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets4.Count; GBPCHF_OCO2S4_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO2Sets4[GBPCHF_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO2Sets4[GBPCHF_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_4__Time out_OCO2");
		                        Base.GBPCHF_UP_S2_OCO2Sets4.Clear();
		                        GBPCHF_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO2S5_UP_S2 = 0;
		                for (; GBPCHF_OCO2S5_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets5.Count; GBPCHF_OCO2S5_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO2Sets5[GBPCHF_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO2Sets5[GBPCHF_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_5__Time out_OCO2");
		                        Base.GBPCHF_UP_S2_OCO2Sets5.Clear();
		                        GBPCHF_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO2S6_UP_S2 = 0;
		                for (; GBPCHF_OCO2S6_UP_S2 < Base.GBPCHF_UP_S2_OCO2Sets6.Count; GBPCHF_OCO2S6_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO2Sets6[GBPCHF_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO2Sets6[GBPCHF_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_6__Time out_OCO2");
		                        Base.GBPCHF_UP_S2_OCO2Sets6.Clear();
		                        GBPCHF_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPCHF_OCO3_EO1_UP_S2)
            		Base.GBPCHF_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPCHF_OCO3_EO2_UP_S2)
	                Base.GBPCHF_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO3_EO3_UP_S2)
	                Base.GBPCHF_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO3_EO4_UP_S2)
	                Base.GBPCHF_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO3_EO5_UP_S2)
	                Base.GBPCHF_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO3_EO6_UP_S2)
	                Base.GBPCHF_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCHF_OCO3S1_UP_S2 = 0;
		                for (; GBPCHF_OCO3S1_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets1.Count; GBPCHF_OCO3S1_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO3Sets1[GBPCHF_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO3Sets1[GBPCHF_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_1__Time out_OCO3");
		                        Base.GBPCHF_UP_S2_OCO3Sets1.Clear();
		                        GBPCHF_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCHF_OCO3S2_UP_S2 = 0;
		                for (; GBPCHF_OCO3S2_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets2.Count; GBPCHF_OCO3S2_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO3Sets2[GBPCHF_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO3Sets2[GBPCHF_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_2__Time out_OCO3");
		                        Base.GBPCHF_UP_S2_OCO3Sets2.Clear();
		                        GBPCHF_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO3S3_UP_S2 = 0;
		                for (; GBPCHF_OCO3S3_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets3.Count; GBPCHF_OCO3S3_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO3Sets3[GBPCHF_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO3Sets3[GBPCHF_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_3__Time out_OCO3");
		                        Base.GBPCHF_UP_S2_OCO3Sets3.Clear();
		                        GBPCHF_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO3S4_UP_S2 = 0;
		                for (; GBPCHF_OCO3S4_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets4.Count; GBPCHF_OCO3S4_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO3Sets4[GBPCHF_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO3Sets4[GBPCHF_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_4__Time out_OCO3");
		                        Base.GBPCHF_UP_S2_OCO3Sets4.Clear();
		                        GBPCHF_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO3S5_UP_S2 = 0;
		                for (; GBPCHF_OCO3S5_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets5.Count; GBPCHF_OCO3S5_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO3Sets5[GBPCHF_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO3Sets5[GBPCHF_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_5__Time out_OCO3");
		                        Base.GBPCHF_UP_S2_OCO3Sets5.Clear();
		                        GBPCHF_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO3S6_UP_S2 = 0;
		                for (; GBPCHF_OCO3S6_UP_S2 < Base.GBPCHF_UP_S2_OCO3Sets6.Count; GBPCHF_OCO3S6_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO3Sets6[GBPCHF_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO3Sets6[GBPCHF_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_6__Time out_OCO3");
		                        Base.GBPCHF_UP_S2_OCO3Sets6.Clear();
		                        GBPCHF_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPCHF_OCO4_EO1_UP_S2)
            		Base.GBPCHF_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPCHF_OCO4_EO2_UP_S2)
	                Base.GBPCHF_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO4_EO3_UP_S2)
	                Base.GBPCHF_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO4_EO4_UP_S2)
	                Base.GBPCHF_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO4_EO5_UP_S2)
	                Base.GBPCHF_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPCHF_OCO4_EO6_UP_S2)
	                Base.GBPCHF_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCHF_OCO4S1_UP_S2 = 0;
		                for (; GBPCHF_OCO4S1_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets1.Count; GBPCHF_OCO4S1_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO4Sets1[GBPCHF_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO4Sets1[GBPCHF_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_1__Time out_OCO4");
		                        Base.GBPCHF_UP_S2_OCO4Sets1.Clear();
		                        GBPCHF_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCHF_OCO4S2_UP_S2 = 0;
		                for (; GBPCHF_OCO4S2_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets2.Count; GBPCHF_OCO4S2_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO4Sets2[GBPCHF_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO4Sets2[GBPCHF_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_2__Time out_OCO4");
		                        Base.GBPCHF_UP_S2_OCO4Sets2.Clear();
		                        GBPCHF_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO4S3_UP_S2 = 0;
		                for (; GBPCHF_OCO4S3_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets3.Count; GBPCHF_OCO4S3_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO4Sets3[GBPCHF_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO4Sets3[GBPCHF_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_3__Time out_OCO4");
		                        Base.GBPCHF_UP_S2_OCO4Sets3.Clear();
		                        GBPCHF_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCHF_OCO4S4_UP_S2 = 0;
		                for (; GBPCHF_OCO4S4_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets4.Count; GBPCHF_OCO4S4_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO4Sets4[GBPCHF_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO4Sets4[GBPCHF_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_4__Time out_OCO4");
		                        Base.GBPCHF_UP_S2_OCO4Sets4.Clear();
		                        GBPCHF_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO4S5_UP_S2 = 0;
		                for (; GBPCHF_OCO4S5_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets5.Count; GBPCHF_OCO4S5_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO4Sets5[GBPCHF_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO4Sets5[GBPCHF_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_5__Time out_OCO4");
		                        Base.GBPCHF_UP_S2_OCO4Sets5.Clear();
		                        GBPCHF_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCHF_OCO4S6_UP_S2 = 0;
		                for (; GBPCHF_OCO4S6_UP_S2 < Base.GBPCHF_UP_S2_OCO4Sets6.Count; GBPCHF_OCO4S6_UP_S2++)
		                    if (Base.GBPCHF_UP_S2_OCO4Sets6[GBPCHF_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCHF_UP_S2_OCO4Sets6[GBPCHF_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCHF", order.Quantity, false, "GBPCHF_UP_S2_Entry_6__Time out_OCO4");
		                        Base.GBPCHF_UP_S2_OCO4Sets6.Clear();
		                        GBPCHF_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_GBPCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPCHF_UP_S2 = DOWM_GBPCHF_UP_S2 || DOWT_GBPCHF_UP_S2 || DOWW_GBPCHF_UP_S2 || DOWTH_GBPCHF_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPCHF"))
	            	{
	            		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.GBPCHF_OCO1_UP_S2_IsReady == false ||
	                    	Base.GBPCHF_OCO2_UP_S2_IsReady == false ||
	                    	Base.GBPCHF_OCO3_UP_S2_IsReady == false ||
	                    	Base.GBPCHF_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.GBPCHF_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPCHF_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPCHF_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPCHF_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPCHF_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.GBPCHF_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.GBPCHF_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.GBPCHF_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	GBPCHF_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.382m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.382m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
		                										
		                										)
		                							
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	GBPCHF_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.5m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.5m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	GBPCHF_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.618m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*2.618m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (GBPCHF_Signal_Condition_UP_1)
	                	{
	                    	GBPCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPCHF_Signal_Condition_UP_2)
	                	{
	                    	GBPCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPCHF_Signal_Condition_UP_3)
	                	{
	                    	GBPCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (GBPCHF_Signal_Condition_UP_1)
	                	{
	                    	GBPCHF_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (GBPCHF_Signal_Condition_UP_2)
	                	{
	                    	GBPCHF_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (GBPCHF_Signal_Condition_UP_3)
	                	{
	                    	GBPCHF_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    GBPCHF_UP_S2_TP2 =  GBPCHF_UP_S2_SL * 0;
	                    GBPCHF_UP_S2_TP3 =  GBPCHF_UP_S2_SL * 0;
	                    GBPCHF_UP_S2_TP4 =  GBPCHF_UP_S2_SL * 0;
	                    GBPCHF_UP_S2_TP5 =  GBPCHF_UP_S2_SL * 0;
	                    GBPCHF_UP_S2_TP6 =  GBPCHF_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPCHF_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPCHF_quantity_SL_UP_S2 = GBPCHF_quantity_UP_S2;
	                    GBPCHF_quantity_TP1_UP_S2 = (int)Math.Floor(GBPCHF_quantity_UP_S2 * 1m);
	                    GBPCHF_quantity_TP2_UP_S2 = (int)Math.Floor(GBPCHF_quantity_TP1_UP_S2 * 0m);
	                    GBPCHF_quantity_TP3_UP_S2 = (int)Math.Floor(GBPCHF_quantity_TP2_UP_S2 * 0m);
	                    GBPCHF_quantity_TP4_UP_S2 = (int)Math.Floor(GBPCHF_quantity_TP3_UP_S2 * 0m);
	                    GBPCHF_quantity_TP5_UP_S2 = (int)Math.Floor(GBPCHF_quantity_TP4_UP_S2 * 0m);
	                    GBPCHF_quantity_TP6_UP_S2 = (int)Math.Floor(GBPCHF_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((GBPCHF_Signal_Condition_UP_1 || GBPCHF_Signal_Condition_UP_2 || GBPCHF_Signal_Condition_UP_3)  && 
	                    DOWR_GBPCHF_UP_S2 && 
	                    Base.GBPCHF_OCO1_UP_S2_IsReady == true &&
	                    Base.GBPCHF_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCHF_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP1_UP_S2, false,"GBPCHF_UP_S2_Entry_TP1_OCO1");
	                         Base.GBPCHF_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.GBPCHF_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP2_UP_S2, false,"GBPCHF_UP_S2_Entry_TP2_OCO1");
	                         Base.GBPCHF_OCO1_EO2_UP_S2 = false;
	
	                         Base.GBPCHF_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP3_UP_S2, false,"GBPCHF_UP_S2_Entry_TP3_OCO1");
	                         Base.GBPCHF_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.GBPCHF_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP4_UP_S2, false,"GBPCHF_UP_S2_Entry_TP4_OCO1");
	                         Base.GBPCHF_OCO1_EO4_UP_S2 = false;

							Base.GBPCHF_OCO1_UP_S2_IsReady = false;
							
							if (Base.GBPCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((GBPCHF_Signal_Condition_UP_1 || GBPCHF_Signal_Condition_UP_2 || GBPCHF_Signal_Condition_UP_3)  && 
	                    DOWR_GBPCHF_UP_S2 && 
	                    Base.GBPCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPCHF_OCO2_UP_S2_IsReady == true &&
	                    Base.GBPCHF_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCHF_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP1_UP_S2, false,"GBPCHF_UP_S2_Entry_TP1_OCO2");
	                         Base.GBPCHF_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.GBPCHF_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP2_UP_S2, false,"GBPCHF_UP_S2_Entry_TP2_OCO2");
	                         Base.GBPCHF_OCO2_EO2_UP_S2 = false;
	
	                         Base.GBPCHF_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP3_UP_S2, false,"GBPCHF_UP_S2_Entry_TP3_OCO2");
	                         Base.GBPCHF_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.GBPCHF_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP4_UP_S2, false,"GBPCHF_UP_S2_Entry_TP4_OCO2");
	                         Base.GBPCHF_OCO2_EO4_UP_S2 = false;

							Base.GBPCHF_OCO2_UP_S2_IsReady = false;
							
							if (Base.GBPCHF_OCO2_UP_S2_IsReady == false && Base.GBPCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((GBPCHF_Signal_Condition_UP_1 || GBPCHF_Signal_Condition_UP_2 || GBPCHF_Signal_Condition_UP_3)  && 
	                    DOWR_GBPCHF_UP_S2 &&
	                    Base.GBPCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPCHF_OCO3_UP_S2_IsReady == true &&
	                    Base.GBPCHF_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCHF_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP1_UP_S2, false,"GBPCHF_UP_S2_Entry_TP1_OCO3");
	                         Base.GBPCHF_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.GBPCHF_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP2_UP_S2, false,"GBPCHF_UP_S2_Entry_TP2_OCO3");
	                         Base.GBPCHF_OCO3_EO2_UP_S2 = false;
	
	                         Base.GBPCHF_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP3_UP_S2, false,"GBPCHF_UP_S2_Entry_TP3_OCO3");
	                         Base.GBPCHF_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.GBPCHF_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP4_UP_S2, false,"GBPCHF_UP_S2_Entry_TP4_OCO3");
	                         Base.GBPCHF_OCO3_EO4_UP_S2 = false;

							Base.GBPCHF_OCO3_UP_S2_IsReady = false;
							
							if (Base.GBPCHF_OCO3_UP_S2_IsReady == false && Base.GBPCHF_OCO2_UP_S2_IsReady == false && Base.GBPCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((GBPCHF_Signal_Condition_UP_1 || GBPCHF_Signal_Condition_UP_2 || GBPCHF_Signal_Condition_UP_3)  && 
	                    DOWR_GBPCHF_UP_S2 && 
	                    Base.GBPCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPCHF_OCO3_UP_S2_IsReady == false &&
	                    Base.GBPCHF_OCO4_UP_S2_IsReady == true &&
	                    Base.GBPCHF_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCHF_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP1_UP_S2, false,"GBPCHF_UP_S2_Entry_TP1_OCO4");
	                         Base.GBPCHF_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.GBPCHF_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP2_UP_S2, false,"GBPCHF_UP_S2_Entry_TP2_OCO4");
	                         Base.GBPCHF_OCO4_EO2_UP_S2 = false;
	
	                         Base.GBPCHF_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP3_UP_S2, false,"GBPCHF_UP_S2_Entry_TP3_OCO4");
	                         Base.GBPCHF_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.GBPCHF_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCHF_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCHF_quantity_TP4_UP_S2, false,"GBPCHF_UP_S2_Entry_TP4_OCO4");
	                         Base.GBPCHF_OCO4_EO4_UP_S2 = false;

							Base.GBPCHF_OCO4_UP_S2_IsReady = false;
							
							if (Base.GBPCHF_OCO4_UP_S2_IsReady == false && Base.GBPCHF_OCO3_UP_S2_IsReady == false && Base.GBPCHF_OCO2_UP_S2_IsReady == false && Base.GBPCHF_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.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 EURCHF_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURCHF_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("EURCHF OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCHF OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCHF OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURCHF OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURCHF OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURCHF OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURCHF S2");
		        	}
		        }
		        
				if (Base.EURCHF_OCO1_EO1_DOWN_S2)
	                Base.EURCHF_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURCHF_OCO1_EO2_DOWN_S2)
	                Base.EURCHF_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO1_EO3_DOWN_S2)
	                Base.EURCHF_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO1_EO4_DOWN_S2)
	                Base.EURCHF_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCHF_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.EURCHF_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP1_EURCHF_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP1,"TP1_EURCHF_DOWN_S2_OCO1"));
		                 };
		                Base.EURCHF_DOWN_S2_OCO1Sets1.Add( Base.EURCHF_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCHF_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP2_EURCHF_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP2,"TP2_EURCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO1Sets2.Add( Base.EURCHF_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP3_EURCHF_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP3,"TP3_EURCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO1Sets3.Add( Base.EURCHF_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP4_EURCHF_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP4,"TP4_EURCHF_DOWN_S2_OCO1"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO1Sets4.Add( Base.EURCHF_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURCHF_OCO1S1_DOWN_S2 = 0;
	                for (; EURCHF_OCO1S1_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets1.Count; EURCHF_OCO1S1_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO1Sets1[EURCHF_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO1Sets1[EURCHF_OCO1S1_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO1Sets1.RemoveAt(EURCHF_OCO1S1_DOWN_S2);
	                        EURCHF_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURCHF_OCO1S2_DOWN_S2 = 0;
	                for (; EURCHF_OCO1S2_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets2.Count; EURCHF_OCO1S2_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO1Sets2[EURCHF_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO1Sets2[EURCHF_OCO1S2_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO1Sets2.RemoveAt(EURCHF_OCO1S2_DOWN_S2);
	                        EURCHF_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO1S3_DOWN_S2 = 0;
	                for (; EURCHF_OCO1S3_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets3.Count; EURCHF_OCO1S3_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO1Sets3[EURCHF_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO1Sets3[EURCHF_OCO1S3_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO1Sets3.RemoveAt(EURCHF_OCO1S3_DOWN_S2);
	                        EURCHF_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO1S4_DOWN_S2 = 0;
	                for (; EURCHF_OCO1S4_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets4.Count; EURCHF_OCO1S4_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO1Sets4[EURCHF_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO1Sets4[EURCHF_OCO1S4_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO1Sets4.RemoveAt(EURCHF_OCO1S4_DOWN_S2);
	                        EURCHF_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCHF_OCO2_EO1_DOWN_S2)
	                Base.EURCHF_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURCHF_OCO2_EO2_DOWN_S2)
	                Base.EURCHF_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO2_EO3_DOWN_S2)
	                Base.EURCHF_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO2_EO4_DOWN_S2)
	                Base.EURCHF_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCHF_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.EURCHF_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP1_EURCHF_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP1,"TP1_EURCHF_DOWN_S2_OCO2"));
		                 };
		                Base.EURCHF_DOWN_S2_OCO2Sets1.Add( Base.EURCHF_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCHF_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP2_EURCHF_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP2,"TP2_EURCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO2Sets2.Add( Base.EURCHF_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP3_EURCHF_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP3,"TP3_EURCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO2Sets3.Add( Base.EURCHF_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP4_EURCHF_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP4,"TP4_EURCHF_DOWN_S2_OCO2"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO2Sets4.Add( Base.EURCHF_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURCHF_OCO2S1_DOWN_S2 = 0;
	                for (; EURCHF_OCO2S1_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets1.Count; EURCHF_OCO2S1_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO2Sets1[EURCHF_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO2Sets1[EURCHF_OCO2S1_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO2Sets1.RemoveAt(EURCHF_OCO2S1_DOWN_S2);
	                        EURCHF_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURCHF_OCO2S2_DOWN_S2 = 0;
	                for (; EURCHF_OCO2S2_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets2.Count; EURCHF_OCO2S2_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO2Sets2[EURCHF_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO2Sets2[EURCHF_OCO2S2_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO2Sets2.RemoveAt(EURCHF_OCO2S2_DOWN_S2);
	                        EURCHF_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO2S3_DOWN_S2 = 0;
	                for (; EURCHF_OCO2S3_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets3.Count; EURCHF_OCO2S3_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO2Sets3[EURCHF_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO2Sets3[EURCHF_OCO2S3_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO2Sets3.RemoveAt(EURCHF_OCO2S3_DOWN_S2);
	                        EURCHF_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO2S4_DOWN_S2 = 0;
	                for (; EURCHF_OCO2S4_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets4.Count; EURCHF_OCO2S4_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO2Sets4[EURCHF_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO2Sets4[EURCHF_OCO2S4_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO2Sets4.RemoveAt(EURCHF_OCO2S4_DOWN_S2);
	                        EURCHF_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCHF_OCO3_EO1_DOWN_S2)
	                Base.EURCHF_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURCHF_OCO3_EO2_DOWN_S2)
	                Base.EURCHF_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO3_EO3_DOWN_S2)
	                Base.EURCHF_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO3_EO4_DOWN_S2)
	                Base.EURCHF_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCHF_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.EURCHF_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP1_EURCHF_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP1,"TP1_EURCHF_DOWN_S2_OCO3"));
		                 };
		                Base.EURCHF_DOWN_S2_OCO3Sets1.Add( Base.EURCHF_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCHF_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP2_EURCHF_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP2,"TP2_EURCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO3Sets2.Add( Base.EURCHF_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP3_EURCHF_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP3,"TP3_EURCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO3Sets3.Add( Base.EURCHF_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP4_EURCHF_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP4,"TP4_EURCHF_DOWN_S2_OCO3"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO3Sets4.Add( Base.EURCHF_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURCHF_OCO3S1_DOWN_S2 = 0;
	                for (; EURCHF_OCO3S1_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets1.Count; EURCHF_OCO3S1_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO3Sets1[EURCHF_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO3Sets1[EURCHF_OCO3S1_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO3Sets1.RemoveAt(EURCHF_OCO3S1_DOWN_S2);
	                        EURCHF_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURCHF_OCO3S2_DOWN_S2 = 0;
	                for (; EURCHF_OCO3S2_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets2.Count; EURCHF_OCO3S2_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO3Sets2[EURCHF_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO3Sets2[EURCHF_OCO3S2_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO3Sets2.RemoveAt(EURCHF_OCO3S2_DOWN_S2);
	                        EURCHF_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO3S3_DOWN_S2 = 0;
	                for (; EURCHF_OCO3S3_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets3.Count; EURCHF_OCO3S3_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO3Sets3[EURCHF_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO3Sets3[EURCHF_OCO3S3_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO3Sets3.RemoveAt(EURCHF_OCO3S3_DOWN_S2);
	                        EURCHF_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO3S4_DOWN_S2 = 0;
	                for (; EURCHF_OCO3S4_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets4.Count; EURCHF_OCO3S4_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO3Sets4[EURCHF_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO3Sets4[EURCHF_OCO3S4_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO3Sets4.RemoveAt(EURCHF_OCO3S4_DOWN_S2);
	                        EURCHF_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURCHF_OCO4_EO1_DOWN_S2)
	                Base.EURCHF_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURCHF_OCO4_EO2_DOWN_S2)
	                Base.EURCHF_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO4_EO3_DOWN_S2)
	                Base.EURCHF_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURCHF_OCO4_EO4_DOWN_S2)
	                Base.EURCHF_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURCHF_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.EURCHF_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP1_EURCHF_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP1,"TP1_EURCHF_DOWN_S2_OCO4"));
		                 };
		                Base.EURCHF_DOWN_S2_OCO4Sets1.Add( Base.EURCHF_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURCHF_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP2_EURCHF_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP2,"TP2_EURCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO4Sets2.Add( Base.EURCHF_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP3_EURCHF_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP3,"TP3_EURCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO4Sets3.Add( Base.EURCHF_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURCHF_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURCHF_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURCHF_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURCHF_DOWN_S2_SL,"SL_TP4_EURCHF_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURCHF_DOWN_S2_TP4,"TP4_EURCHF_DOWN_S2_OCO4"));
		                 };
	                    Base.EURCHF_DOWN_S2_OCO4Sets4.Add( Base.EURCHF_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURCHF_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURCHF_OCO4S1_DOWN_S2 = 0;
	                for (; EURCHF_OCO4S1_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets1.Count; EURCHF_OCO4S1_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO4Sets1[EURCHF_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO4Sets1[EURCHF_OCO4S1_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO4Sets1.RemoveAt(EURCHF_OCO4S1_DOWN_S2);
	                        EURCHF_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURCHF_OCO4S2_DOWN_S2 = 0;
	                for (; EURCHF_OCO4S2_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets2.Count; EURCHF_OCO4S2_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO4Sets2[EURCHF_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO4Sets2[EURCHF_OCO4S2_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO4Sets2.RemoveAt(EURCHF_OCO4S2_DOWN_S2);
	                        EURCHF_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO4S3_DOWN_S2 = 0;
	                for (; EURCHF_OCO4S3_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets3.Count; EURCHF_OCO4S3_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO4Sets3[EURCHF_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO4Sets3[EURCHF_OCO4S3_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO4Sets3.RemoveAt(EURCHF_OCO4S3_DOWN_S2);
	                        EURCHF_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURCHF_OCO4S4_DOWN_S2 = 0;
	                for (; EURCHF_OCO4S4_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets4.Count; EURCHF_OCO4S4_DOWN_S2++)
	                    if (Base.EURCHF_DOWN_S2_OCO4Sets4[EURCHF_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURCHF_DOWN_S2_OCO4Sets4[EURCHF_OCO4S4_DOWN_S2].Filled();
	                        Base.EURCHF_DOWN_S2_OCO4Sets4.RemoveAt(EURCHF_OCO4S4_DOWN_S2);
	                        EURCHF_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct EURCAD_OCO1_DOWN_S2
    {
        public EURCAD_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 =="TP1_EURCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD 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 =="TP1_EURCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURCAD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD 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 EURCAD_OCO1_UP_S2
    {
        public EURCAD_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 =="TP1_EURCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD 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 =="TP1_EURCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURCAD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURCAD 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 EURCAD_OCO2_DOWN_S2
    {
        public EURCAD_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 =="TP1_EURCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD 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 =="TP1_EURCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURCAD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD 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 EURCAD_OCO2_UP_S2
    {
        public EURCAD_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 =="TP1_EURCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD 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 =="TP1_EURCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURCAD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURCAD 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 EURCAD_OCO3_DOWN_S2
    {
        public EURCAD_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 =="TP1_EURCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD 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 =="TP1_EURCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURCAD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD 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 EURCAD_OCO3_UP_S2
    {
        public EURCAD_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 =="TP1_EURCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD 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 =="TP1_EURCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURCAD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURCAD 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 EURCAD_OCO4_DOWN_S2
    {
        public EURCAD_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 =="TP1_EURCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD 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 =="TP1_EURCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURCAD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD 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 EURCAD_OCO4_UP_S2
    {
        public EURCAD_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 =="TP1_EURCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD 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 =="TP1_EURCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURCAD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURCAD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURCAD 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.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 _EURNZD;
		
    	///oco1 up
    	public static OrderTicket EURNZD_OCO1_MO1_UP_S2;
    	public static OrderTicket EURNZD_OCO1_MO2_UP_S2;
    	public static OrderTicket EURNZD_OCO1_MO3_UP_S2;
    	public static OrderTicket EURNZD_OCO1_MO4_UP_S2;
    	public static OrderTicket EURNZD_OCO1_MO5_UP_S2;
    	public static OrderTicket EURNZD_OCO1_MO6_UP_S2;
    	
    	public static int EURNZD_OCO1_EO1_UP_S2_ID ;
        public static int EURNZD_OCO1_EO2_UP_S2_ID ;
        public static int EURNZD_OCO1_EO3_UP_S2_ID ;
        public static int EURNZD_OCO1_EO4_UP_S2_ID ;
        public static int EURNZD_OCO1_EO5_UP_S2_ID ;
        public static int EURNZD_OCO1_EO6_UP_S2_ID ;
        
        public static bool EURNZD_OCO1_EO1_UP_S2 ;
        public static bool EURNZD_OCO1_EO2_UP_S2 ;
        public static bool EURNZD_OCO1_EO3_UP_S2 ;
        public static bool EURNZD_OCO1_EO4_UP_S2 ;
        public static bool EURNZD_OCO1_EO5_UP_S2 ;
        public static bool EURNZD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_UP_S2> EURNZD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_UP_S2> EURNZD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_UP_S2> EURNZD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_UP_S2> EURNZD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_UP_S2> EURNZD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_UP_S2> EURNZD_OOFE_OCO1_UP_S2_6 ;
        
        public static EURNZD_OCO1_UP_S2 EURNZD_PFO_OCO1_UP_S2_1 ;
        public static EURNZD_OCO1_UP_S2 EURNZD_PFO_OCO1_UP_S2_2 ;
        public static EURNZD_OCO1_UP_S2 EURNZD_PFO_OCO1_UP_S2_3 ;
        public static EURNZD_OCO1_UP_S2 EURNZD_PFO_OCO1_UP_S2_4 ;
        public static EURNZD_OCO1_UP_S2 EURNZD_PFO_OCO1_UP_S2_5 ;
        public static EURNZD_OCO1_UP_S2 EURNZD_PFO_OCO1_UP_S2_6 ;
        
        public static List<EURNZD_OCO1_UP_S2> EURNZD_UP_S2_OCO1Sets1 = new List<EURNZD_OCO1_UP_S2>();
        public static List<EURNZD_OCO1_UP_S2> EURNZD_UP_S2_OCO1Sets2 = new List<EURNZD_OCO1_UP_S2>();
        public static List<EURNZD_OCO1_UP_S2> EURNZD_UP_S2_OCO1Sets3 = new List<EURNZD_OCO1_UP_S2>();
        public static List<EURNZD_OCO1_UP_S2> EURNZD_UP_S2_OCO1Sets4 = new List<EURNZD_OCO1_UP_S2>();
        public static List<EURNZD_OCO1_UP_S2> EURNZD_UP_S2_OCO1Sets5 = new List<EURNZD_OCO1_UP_S2>();
        public static List<EURNZD_OCO1_UP_S2> EURNZD_UP_S2_OCO1Sets6 = new List<EURNZD_OCO1_UP_S2>();
        
        public static bool EURNZD_OCO1_UP_S2_IsReady = true;
        public static bool EURNZD_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket EURNZD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int EURNZD_OCO1_EO1_DOWN_S2_ID ;
        public static int EURNZD_OCO1_EO2_DOWN_S2_ID ;
        public static int EURNZD_OCO1_EO3_DOWN_S2_ID ;
        public static int EURNZD_OCO1_EO4_DOWN_S2_ID ;
        public static int EURNZD_OCO1_EO5_DOWN_S2_ID ;
        public static int EURNZD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool EURNZD_OCO1_EO1_DOWN_S2 ;
        public static bool EURNZD_OCO1_EO2_DOWN_S2 ;
        public static bool EURNZD_OCO1_EO3_DOWN_S2 ;
        public static bool EURNZD_OCO1_EO4_DOWN_S2 ;
        public static bool EURNZD_OCO1_EO5_DOWN_S2 ;
        public static bool EURNZD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_DOWN_S2> EURNZD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_DOWN_S2> EURNZD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_DOWN_S2> EURNZD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_DOWN_S2> EURNZD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_DOWN_S2> EURNZD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO1_DOWN_S2> EURNZD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static EURNZD_OCO1_DOWN_S2 EURNZD_PFO_OCO1_DOWN_S2_1 ;
        public static EURNZD_OCO1_DOWN_S2 EURNZD_PFO_OCO1_DOWN_S2_2 ;
        public static EURNZD_OCO1_DOWN_S2 EURNZD_PFO_OCO1_DOWN_S2_3 ;
        public static EURNZD_OCO1_DOWN_S2 EURNZD_PFO_OCO1_DOWN_S2_4 ;
        public static EURNZD_OCO1_DOWN_S2 EURNZD_PFO_OCO1_DOWN_S2_5 ;
        public static EURNZD_OCO1_DOWN_S2 EURNZD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<EURNZD_OCO1_DOWN_S2> EURNZD_DOWN_S2_OCO1Sets1 = new List<EURNZD_OCO1_DOWN_S2>();
        public static List<EURNZD_OCO1_DOWN_S2> EURNZD_DOWN_S2_OCO1Sets2 = new List<EURNZD_OCO1_DOWN_S2>();
        public static List<EURNZD_OCO1_DOWN_S2> EURNZD_DOWN_S2_OCO1Sets3 = new List<EURNZD_OCO1_DOWN_S2>();
        public static List<EURNZD_OCO1_DOWN_S2> EURNZD_DOWN_S2_OCO1Sets4 = new List<EURNZD_OCO1_DOWN_S2>();
        public static List<EURNZD_OCO1_DOWN_S2> EURNZD_DOWN_S2_OCO1Sets5 = new List<EURNZD_OCO1_DOWN_S2>();
        public static List<EURNZD_OCO1_DOWN_S2> EURNZD_DOWN_S2_OCO1Sets6 = new List<EURNZD_OCO1_DOWN_S2>();
        
        public static bool EURNZD_OCO1_DOWN_S2_IsReady = true;
        public static bool EURNZD_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket EURNZD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO6_UP_S2 ;
    	
    	public static int EURNZD_OCO2_EO1_UP_S2_ID ;
        public static int EURNZD_OCO2_EO2_UP_S2_ID ;
        public static int EURNZD_OCO2_EO3_UP_S2_ID ;
        public static int EURNZD_OCO2_EO4_UP_S2_ID ;
        public static int EURNZD_OCO2_EO5_UP_S2_ID ;
        public static int EURNZD_OCO2_EO6_UP_S2_ID ;
        
        public static bool EURNZD_OCO2_EO1_UP_S2 ;
        public static bool EURNZD_OCO2_EO2_UP_S2 ;
        public static bool EURNZD_OCO2_EO3_UP_S2 ;
        public static bool EURNZD_OCO2_EO4_UP_S2 ;
        public static bool EURNZD_OCO2_EO5_UP_S2 ;
        public static bool EURNZD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_UP_S2> EURNZD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_UP_S2> EURNZD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_UP_S2> EURNZD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_UP_S2> EURNZD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_UP_S2> EURNZD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_UP_S2> EURNZD_OOFE_OCO2_UP_S2_6 ;
        
        public static EURNZD_OCO2_UP_S2 EURNZD_PFO_OCO2_UP_S2_1 ;
        public static EURNZD_OCO2_UP_S2 EURNZD_PFO_OCO2_UP_S2_2 ;
        public static EURNZD_OCO2_UP_S2 EURNZD_PFO_OCO2_UP_S2_3 ;
        public static EURNZD_OCO2_UP_S2 EURNZD_PFO_OCO2_UP_S2_4 ;
        public static EURNZD_OCO2_UP_S2 EURNZD_PFO_OCO2_UP_S2_5 ;
        public static EURNZD_OCO2_UP_S2 EURNZD_PFO_OCO2_UP_S2_6 ;
        
        public static List<EURNZD_OCO2_UP_S2> EURNZD_UP_S2_OCO2Sets1 = new List<EURNZD_OCO2_UP_S2>();
        public static List<EURNZD_OCO2_UP_S2> EURNZD_UP_S2_OCO2Sets2 = new List<EURNZD_OCO2_UP_S2>();
        public static List<EURNZD_OCO2_UP_S2> EURNZD_UP_S2_OCO2Sets3 = new List<EURNZD_OCO2_UP_S2>();
        public static List<EURNZD_OCO2_UP_S2> EURNZD_UP_S2_OCO2Sets4 = new List<EURNZD_OCO2_UP_S2>();
        public static List<EURNZD_OCO2_UP_S2> EURNZD_UP_S2_OCO2Sets5 = new List<EURNZD_OCO2_UP_S2>();
        public static List<EURNZD_OCO2_UP_S2> EURNZD_UP_S2_OCO2Sets6 = new List<EURNZD_OCO2_UP_S2>();
        
        public static bool EURNZD_OCO2_UP_S2_IsReady = true;
        public static bool EURNZD_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket EURNZD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int EURNZD_OCO2_EO1_DOWN_S2_ID ;
        public static int EURNZD_OCO2_EO2_DOWN_S2_ID ;
        public static int EURNZD_OCO2_EO3_DOWN_S2_ID ;
        public static int EURNZD_OCO2_EO4_DOWN_S2_ID ;
        public static int EURNZD_OCO2_EO5_DOWN_S2_ID ;
        public static int EURNZD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool EURNZD_OCO2_EO1_DOWN_S2 ;
        public static bool EURNZD_OCO2_EO2_DOWN_S2 ;
        public static bool EURNZD_OCO2_EO3_DOWN_S2 ;
        public static bool EURNZD_OCO2_EO4_DOWN_S2 ;
        public static bool EURNZD_OCO2_EO5_DOWN_S2 ;
        public static bool EURNZD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_DOWN_S2> EURNZD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_DOWN_S2> EURNZD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_DOWN_S2> EURNZD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_DOWN_S2> EURNZD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_DOWN_S2> EURNZD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO2_DOWN_S2> EURNZD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static EURNZD_OCO2_DOWN_S2 EURNZD_PFO_OCO2_DOWN_S2_1 ;
        public static EURNZD_OCO2_DOWN_S2 EURNZD_PFO_OCO2_DOWN_S2_2 ;
        public static EURNZD_OCO2_DOWN_S2 EURNZD_PFO_OCO2_DOWN_S2_3 ;
        public static EURNZD_OCO2_DOWN_S2 EURNZD_PFO_OCO2_DOWN_S2_4 ;
        public static EURNZD_OCO2_DOWN_S2 EURNZD_PFO_OCO2_DOWN_S2_5 ;
        public static EURNZD_OCO2_DOWN_S2 EURNZD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<EURNZD_OCO2_DOWN_S2> EURNZD_DOWN_S2_OCO2Sets1 = new List<EURNZD_OCO2_DOWN_S2>();
        public static List<EURNZD_OCO2_DOWN_S2> EURNZD_DOWN_S2_OCO2Sets2 = new List<EURNZD_OCO2_DOWN_S2>();
        public static List<EURNZD_OCO2_DOWN_S2> EURNZD_DOWN_S2_OCO2Sets3 = new List<EURNZD_OCO2_DOWN_S2>();
        public static List<EURNZD_OCO2_DOWN_S2> EURNZD_DOWN_S2_OCO2Sets4 = new List<EURNZD_OCO2_DOWN_S2>();
        public static List<EURNZD_OCO2_DOWN_S2> EURNZD_DOWN_S2_OCO2Sets5 = new List<EURNZD_OCO2_DOWN_S2>();
        public static List<EURNZD_OCO2_DOWN_S2> EURNZD_DOWN_S2_OCO2Sets6 = new List<EURNZD_OCO2_DOWN_S2>();
        
        public static bool EURNZD_OCO2_DOWN_S2_IsReady = true;
        public static bool EURNZD_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket EURNZD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO6_UP_S2 ;
    	
    	public static int EURNZD_OCO3_EO1_UP_S2_ID ;
        public static int EURNZD_OCO3_EO2_UP_S2_ID ;
        public static int EURNZD_OCO3_EO3_UP_S2_ID ;
        public static int EURNZD_OCO3_EO4_UP_S2_ID ;
        public static int EURNZD_OCO3_EO5_UP_S2_ID ;
        public static int EURNZD_OCO3_EO6_UP_S2_ID ;
        
        public static bool EURNZD_OCO3_EO1_UP_S2 ;
        public static bool EURNZD_OCO3_EO2_UP_S2 ;
        public static bool EURNZD_OCO3_EO3_UP_S2 ;
        public static bool EURNZD_OCO3_EO4_UP_S2 ;
        public static bool EURNZD_OCO3_EO5_UP_S2 ;
        public static bool EURNZD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_UP_S2> EURNZD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_UP_S2> EURNZD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_UP_S2> EURNZD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_UP_S2> EURNZD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_UP_S2> EURNZD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_UP_S2> EURNZD_OOFE_OCO3_UP_S2_6 ;
        
        public static EURNZD_OCO3_UP_S2 EURNZD_PFO_OCO3_UP_S2_1 ;
        public static EURNZD_OCO3_UP_S2 EURNZD_PFO_OCO3_UP_S2_2 ;
        public static EURNZD_OCO3_UP_S2 EURNZD_PFO_OCO3_UP_S2_3 ;
        public static EURNZD_OCO3_UP_S2 EURNZD_PFO_OCO3_UP_S2_4 ;
        public static EURNZD_OCO3_UP_S2 EURNZD_PFO_OCO3_UP_S2_5 ;
        public static EURNZD_OCO3_UP_S2 EURNZD_PFO_OCO3_UP_S2_6 ;
        
        public static List<EURNZD_OCO3_UP_S2> EURNZD_UP_S2_OCO3Sets1 = new List<EURNZD_OCO3_UP_S2>();
        public static List<EURNZD_OCO3_UP_S2> EURNZD_UP_S2_OCO3Sets2 = new List<EURNZD_OCO3_UP_S2>();
        public static List<EURNZD_OCO3_UP_S2> EURNZD_UP_S2_OCO3Sets3 = new List<EURNZD_OCO3_UP_S2>();
        public static List<EURNZD_OCO3_UP_S2> EURNZD_UP_S2_OCO3Sets4 = new List<EURNZD_OCO3_UP_S2>();
        public static List<EURNZD_OCO3_UP_S2> EURNZD_UP_S2_OCO3Sets5 = new List<EURNZD_OCO3_UP_S2>();
        public static List<EURNZD_OCO3_UP_S2> EURNZD_UP_S2_OCO3Sets6 = new List<EURNZD_OCO3_UP_S2>();
        
        public static bool EURNZD_OCO3_UP_S2_IsReady = true;
        public static bool EURNZD_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket EURNZD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int EURNZD_OCO3_EO1_DOWN_S2_ID ;
        public static int EURNZD_OCO3_EO2_DOWN_S2_ID ;
        public static int EURNZD_OCO3_EO3_DOWN_S2_ID ;
        public static int EURNZD_OCO3_EO4_DOWN_S2_ID ;
        public static int EURNZD_OCO3_EO5_DOWN_S2_ID ;
        public static int EURNZD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool EURNZD_OCO3_EO1_DOWN_S2 ;
        public static bool EURNZD_OCO3_EO2_DOWN_S2 ;
        public static bool EURNZD_OCO3_EO3_DOWN_S2 ;
        public static bool EURNZD_OCO3_EO4_DOWN_S2 ;
        public static bool EURNZD_OCO3_EO5_DOWN_S2 ;
        public static bool EURNZD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_DOWN_S2> EURNZD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_DOWN_S2> EURNZD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_DOWN_S2> EURNZD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_DOWN_S2> EURNZD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_DOWN_S2> EURNZD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO3_DOWN_S2> EURNZD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static EURNZD_OCO3_DOWN_S2 EURNZD_PFO_OCO3_DOWN_S2_1 ;
        public static EURNZD_OCO3_DOWN_S2 EURNZD_PFO_OCO3_DOWN_S2_2 ;
        public static EURNZD_OCO3_DOWN_S2 EURNZD_PFO_OCO3_DOWN_S2_3 ;
        public static EURNZD_OCO3_DOWN_S2 EURNZD_PFO_OCO3_DOWN_S2_4 ;
        public static EURNZD_OCO3_DOWN_S2 EURNZD_PFO_OCO3_DOWN_S2_5 ;
        public static EURNZD_OCO3_DOWN_S2 EURNZD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<EURNZD_OCO3_DOWN_S2> EURNZD_DOWN_S2_OCO3Sets1 = new List<EURNZD_OCO3_DOWN_S2>();
        public static List<EURNZD_OCO3_DOWN_S2> EURNZD_DOWN_S2_OCO3Sets2 = new List<EURNZD_OCO3_DOWN_S2>();
        public static List<EURNZD_OCO3_DOWN_S2> EURNZD_DOWN_S2_OCO3Sets3 = new List<EURNZD_OCO3_DOWN_S2>();
        public static List<EURNZD_OCO3_DOWN_S2> EURNZD_DOWN_S2_OCO3Sets4 = new List<EURNZD_OCO3_DOWN_S2>();
        public static List<EURNZD_OCO3_DOWN_S2> EURNZD_DOWN_S2_OCO3Sets5 = new List<EURNZD_OCO3_DOWN_S2>();
        public static List<EURNZD_OCO3_DOWN_S2> EURNZD_DOWN_S2_OCO3Sets6 = new List<EURNZD_OCO3_DOWN_S2>();
        
        public static bool EURNZD_OCO3_DOWN_S2_IsReady = true;
        public static bool EURNZD_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket EURNZD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO6_UP_S2 ;
    	
    	public static int EURNZD_OCO4_EO1_UP_S2_ID ;
        public static int EURNZD_OCO4_EO2_UP_S2_ID ;
        public static int EURNZD_OCO4_EO3_UP_S2_ID ;
        public static int EURNZD_OCO4_EO4_UP_S2_ID ;
        public static int EURNZD_OCO4_EO5_UP_S2_ID ;
        public static int EURNZD_OCO4_EO6_UP_S2_ID ;
        
        public static bool EURNZD_OCO4_EO1_UP_S2 ;
        public static bool EURNZD_OCO4_EO2_UP_S2 ;
        public static bool EURNZD_OCO4_EO3_UP_S2 ;
        public static bool EURNZD_OCO4_EO4_UP_S2 ;
        public static bool EURNZD_OCO4_EO5_UP_S2 ;
        public static bool EURNZD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_UP_S2> EURNZD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_UP_S2> EURNZD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_UP_S2> EURNZD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_UP_S2> EURNZD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_UP_S2> EURNZD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_UP_S2> EURNZD_OOFE_OCO4_UP_S2_6 ;
        
        public static EURNZD_OCO4_UP_S2 EURNZD_PFO_OCO4_UP_S2_1 ;
        public static EURNZD_OCO4_UP_S2 EURNZD_PFO_OCO4_UP_S2_2 ;
        public static EURNZD_OCO4_UP_S2 EURNZD_PFO_OCO4_UP_S2_3 ;
        public static EURNZD_OCO4_UP_S2 EURNZD_PFO_OCO4_UP_S2_4 ;
        public static EURNZD_OCO4_UP_S2 EURNZD_PFO_OCO4_UP_S2_5 ;
        public static EURNZD_OCO4_UP_S2 EURNZD_PFO_OCO4_UP_S2_6 ;
        
        public static List<EURNZD_OCO4_UP_S2> EURNZD_UP_S2_OCO4Sets1 = new List<EURNZD_OCO4_UP_S2>();
        public static List<EURNZD_OCO4_UP_S2> EURNZD_UP_S2_OCO4Sets2 = new List<EURNZD_OCO4_UP_S2>();
        public static List<EURNZD_OCO4_UP_S2> EURNZD_UP_S2_OCO4Sets3 = new List<EURNZD_OCO4_UP_S2>();
        public static List<EURNZD_OCO4_UP_S2> EURNZD_UP_S2_OCO4Sets4 = new List<EURNZD_OCO4_UP_S2>();
        public static List<EURNZD_OCO4_UP_S2> EURNZD_UP_S2_OCO4Sets5 = new List<EURNZD_OCO4_UP_S2>();
        public static List<EURNZD_OCO4_UP_S2> EURNZD_UP_S2_OCO4Sets6 = new List<EURNZD_OCO4_UP_S2>();
        
        public static bool EURNZD_OCO4_UP_S2_IsReady = true;
        public static bool EURNZD_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket EURNZD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket EURNZD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int EURNZD_OCO4_EO1_DOWN_S2_ID ;
        public static int EURNZD_OCO4_EO2_DOWN_S2_ID ;
        public static int EURNZD_OCO4_EO3_DOWN_S2_ID ;
        public static int EURNZD_OCO4_EO4_DOWN_S2_ID ;
        public static int EURNZD_OCO4_EO5_DOWN_S2_ID ;
        public static int EURNZD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool EURNZD_OCO4_EO1_DOWN_S2 ;
        public static bool EURNZD_OCO4_EO2_DOWN_S2 ;
        public static bool EURNZD_OCO4_EO3_DOWN_S2 ;
        public static bool EURNZD_OCO4_EO4_DOWN_S2 ;
        public static bool EURNZD_OCO4_EO5_DOWN_S2 ;
        public static bool EURNZD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_DOWN_S2> EURNZD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_DOWN_S2> EURNZD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_DOWN_S2> EURNZD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_DOWN_S2> EURNZD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_DOWN_S2> EURNZD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURNZD_OCO4_DOWN_S2> EURNZD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static EURNZD_OCO4_DOWN_S2 EURNZD_PFO_OCO4_DOWN_S2_1 ;
        public static EURNZD_OCO4_DOWN_S2 EURNZD_PFO_OCO4_DOWN_S2_2 ;
        public static EURNZD_OCO4_DOWN_S2 EURNZD_PFO_OCO4_DOWN_S2_3 ;
        public static EURNZD_OCO4_DOWN_S2 EURNZD_PFO_OCO4_DOWN_S2_4 ;
        public static EURNZD_OCO4_DOWN_S2 EURNZD_PFO_OCO4_DOWN_S2_5 ;
        public static EURNZD_OCO4_DOWN_S2 EURNZD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<EURNZD_OCO4_DOWN_S2> EURNZD_DOWN_S2_OCO4Sets1 = new List<EURNZD_OCO4_DOWN_S2>();
        public static List<EURNZD_OCO4_DOWN_S2> EURNZD_DOWN_S2_OCO4Sets2 = new List<EURNZD_OCO4_DOWN_S2>();
        public static List<EURNZD_OCO4_DOWN_S2> EURNZD_DOWN_S2_OCO4Sets3 = new List<EURNZD_OCO4_DOWN_S2>();
        public static List<EURNZD_OCO4_DOWN_S2> EURNZD_DOWN_S2_OCO4Sets4 = new List<EURNZD_OCO4_DOWN_S2>();
        public static List<EURNZD_OCO4_DOWN_S2> EURNZD_DOWN_S2_OCO4Sets5 = new List<EURNZD_OCO4_DOWN_S2>();
        public static List<EURNZD_OCO4_DOWN_S2> EURNZD_DOWN_S2_OCO4Sets6 = new List<EURNZD_OCO4_DOWN_S2>();
        
        public static bool EURNZD_OCO4_DOWN_S2_IsReady = true;
        public static bool EURNZD_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal EURNZD_UP_S2_SL {get; set;}
		public static decimal EURNZD_UP_S2_TP1 {get; set;}
		public static decimal EURNZD_UP_S2_TP2 {get; set;}
		public static decimal EURNZD_UP_S2_TP3 {get; set;}
		public static decimal EURNZD_UP_S2_TP4 {get; set;}
		public static decimal EURNZD_UP_S2_TP5 {get; set;}
		public static decimal EURNZD_UP_S2_TP6 {get; set;}
		
		public static decimal EURNZD_DOWN_S2_SL {get; set;}
		public static decimal EURNZD_DOWN_S2_TP1 {get; set;}
		public static decimal EURNZD_DOWN_S2_TP2 {get; set;}
		public static decimal EURNZD_DOWN_S2_TP3 {get; set;}
		public static decimal EURNZD_DOWN_S2_TP4 {get; set;}
		public static decimal EURNZD_DOWN_S2_TP5 {get; set;}
		public static decimal EURNZD_DOWN_S2_TP6 {get; set;}

        public static bool EURNZD_Signal_Condition_UP_1 ;
        public static bool EURNZD_Signal_Condition_UP_2 ;
        public static bool EURNZD_Signal_Condition_UP_3 ;
        public static bool EURNZD_Signal_Condition_DOWN_S2 ;
        
        public static int EURNZD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int EURNZD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int EURNZD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int EURNZD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int EURNZD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int EURNZD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int EURNZD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int EURNZD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int EURNZD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int EURNZD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_EURNZD_UP_S2 ;
        public static bool DOWM_EURNZD_UP_S2 ;
        public static bool DOWT_EURNZD_UP_S2 ;
        public static bool DOWW_EURNZD_UP_S2 ;
        public static bool DOWTH_EURNZD_UP_S2 ;
        
		public static bool DOWR_EURNZD_DOWN_S2 ;
        public static bool DOWM_EURNZD_DOWN_S2 ;
        public static bool DOWT_EURNZD_DOWN_S2 ;
        public static bool DOWW_EURNZD_DOWN_S2 ;
        public static bool DOWTH_EURNZD_DOWN_S2 ;
        
        
		public static int EURNZD_quantity_UP_S2 ;
		public static int EURNZD_quantity_SL_UP_S2 ;
		public static int EURNZD_quantity_TP1_UP_S2 ;
		public static int EURNZD_quantity_TP2_UP_S2 ;
		public static int EURNZD_quantity_TP3_UP_S2 ;
		public static int EURNZD_quantity_TP4_UP_S2 ;
		public static int EURNZD_quantity_TP5_UP_S2;
		public static int EURNZD_quantity_TP6_UP_S2 ;
		
		public static int EURNZD_quantity_DOWN_S2 ;
		public static int EURNZD_quantity_SL_DOWN_S2 ;
		public static int EURNZD_quantity_TP1_DOWN_S2 ;
		public static int EURNZD_quantity_TP2_DOWN_S2 ;
		public static int EURNZD_quantity_TP3_DOWN_S2 ;
		public static int EURNZD_quantity_TP4_DOWN_S2 ;
		public static int EURNZD_quantity_TP5_DOWN_S2;
		public static int EURNZD_quantity_TP6_DOWN_S2 ;
    }
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct EURAUD_OCO1_DOWN_S2
    {
        public EURAUD_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 =="TP1_EURAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD 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 =="TP1_EURAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURAUD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD 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 EURAUD_OCO1_UP_S2
    {
        public EURAUD_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 =="TP1_EURAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD 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 =="TP1_EURAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURAUD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURAUD 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 EURAUD_OCO2_DOWN_S2
    {
        public EURAUD_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 =="TP1_EURAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD 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 =="TP1_EURAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURAUD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD 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 EURAUD_OCO2_UP_S2
    {
        public EURAUD_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 =="TP1_EURAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD 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 =="TP1_EURAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURAUD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURAUD 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 EURAUD_OCO3_DOWN_S2
    {
        public EURAUD_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 =="TP1_EURAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD 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 =="TP1_EURAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURAUD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD 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 EURAUD_OCO3_UP_S2
    {
        public EURAUD_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 =="TP1_EURAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD 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 =="TP1_EURAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURAUD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURAUD 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 EURAUD_OCO4_DOWN_S2
    {
        public EURAUD_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 =="TP1_EURAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD 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 =="TP1_EURAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURAUD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD 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 EURAUD_OCO4_UP_S2
    {
        public EURAUD_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 =="TP1_EURAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD 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 =="TP1_EURAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURAUD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURAUD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURAUD 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 EURNZD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURNZD_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("EURNZD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURNZD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURNZD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURNZD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURNZD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURNZD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURNZD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        }
		        
				if (Base.EURNZD_OCO1_EO1_UP_S2)
	                Base.EURNZD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURNZD_OCO1_EO2_UP_S2)
	                Base.EURNZD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO1_EO3_UP_S2)
	                Base.EURNZD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO1_EO4_UP_S2)
	                Base.EURNZD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO1_EO5_UP_S2)
	                Base.EURNZD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO1_EO6_UP_S2)
	                Base.EURNZD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURNZD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.EURNZD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP1,"TP1_EURNZD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP1_EURNZD_UP_S2_OCO1"));
		                 };
		                Base.EURNZD_UP_S2_OCO1Sets1.Add( Base.EURNZD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURNZD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP2,"TP2_EURNZD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP2_EURNZD_UP_S2_OCO1"));
		                 };
	                    Base.EURNZD_UP_S2_OCO1Sets2.Add( Base.EURNZD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP3,"TP3_EURNZD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP3_EURNZD_UP_S2_OCO1"));
		                 };
	                    Base.EURNZD_UP_S2_OCO1Sets3.Add( Base.EURNZD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP4,"TP4_EURNZD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP4_EURNZD_UP_S2_OCO1"));
		                 };
	                    Base.EURNZD_UP_S2_OCO1Sets4.Add( Base.EURNZD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP5,"TP5_EURNZD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP5_EURNZD_UP_S2_OCO1"));
		                 };
	                    Base.EURNZD_UP_S2_OCO1Sets5.Add( Base.EURNZD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP6,"TP6_EURNZD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP6_EURNZD_UP_S2_OCO1"));
		                 };
	                    Base.EURNZD_UP_S2_OCO1Sets6.Add( Base.EURNZD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURNZD_OCO1S1_UP_S2 = 0;
	                for (; EURNZD_OCO1S1_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets1.Count; EURNZD_OCO1S1_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO1Sets1[EURNZD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO1Sets1[EURNZD_OCO1S1_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO1Sets1.RemoveAt(EURNZD_OCO1S1_UP_S2);
	                        EURNZD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURNZD_OCO1S2_UP_S2 = 0;
	                for (; EURNZD_OCO1S2_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets2.Count; EURNZD_OCO1S2_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO1Sets2[EURNZD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO1Sets2[EURNZD_OCO1S2_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO1Sets2.RemoveAt(EURNZD_OCO1S2_UP_S2);
	                        EURNZD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO1S3_UP_S2 = 0;
	                for (; EURNZD_OCO1S3_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets3.Count; EURNZD_OCO1S3_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO1Sets3[EURNZD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO1Sets3[EURNZD_OCO1S3_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO1Sets3.RemoveAt(EURNZD_OCO1S3_UP_S2);
	                        EURNZD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO1S4_UP_S2 = 0;
	                for (; EURNZD_OCO1S4_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets4.Count; EURNZD_OCO1S4_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO1Sets4[EURNZD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO1Sets4[EURNZD_OCO1S4_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO1Sets4.RemoveAt(EURNZD_OCO1S4_UP_S2);
	                        EURNZD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURNZD_OCO1S5_UP_S2 = 0;
	                for (; EURNZD_OCO1S5_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets5.Count; EURNZD_OCO1S5_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO1Sets5[EURNZD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO1Sets5[EURNZD_OCO1S5_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO1Sets5.RemoveAt(EURNZD_OCO1S5_UP_S2);
	                        EURNZD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURNZD_OCO1S6_UP_S2 = 0;
	                for (; EURNZD_OCO1S6_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets6.Count; EURNZD_OCO1S6_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO1Sets6[EURNZD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO1Sets6[EURNZD_OCO1S6_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO1Sets6.RemoveAt(EURNZD_OCO1S6_UP_S2);
	                        EURNZD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.EURNZD_OCO2_EO1_UP_S2)
	                Base.EURNZD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURNZD_OCO2_EO2_UP_S2)
	                Base.EURNZD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO2_EO3_UP_S2)
	                Base.EURNZD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO2_EO4_UP_S2)
	                Base.EURNZD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO2_EO5_UP_S2)
	                Base.EURNZD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO2_EO6_UP_S2)
	                Base.EURNZD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURNZD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.EURNZD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP1,"TP1_EURNZD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP1_EURNZD_UP_S2_OCO2"));
		                 };
		                Base.EURNZD_UP_S2_OCO2Sets1.Add( Base.EURNZD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURNZD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP2,"TP2_EURNZD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP2_EURNZD_UP_S2_OCO2"));
		                 };
	                    Base.EURNZD_UP_S2_OCO2Sets2.Add( Base.EURNZD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP3,"TP3_EURNZD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP3_EURNZD_UP_S2_OCO2"));
		                 };
	                    Base.EURNZD_UP_S2_OCO2Sets3.Add( Base.EURNZD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP4,"TP4_EURNZD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP4_EURNZD_UP_S2_OCO2"));
		                 };
	                    Base.EURNZD_UP_S2_OCO2Sets4.Add( Base.EURNZD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP5,"TP5_EURNZD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP5_EURNZD_UP_S2_OCO2"));
		                 };
	                    Base.EURNZD_UP_S2_OCO2Sets5.Add( Base.EURNZD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP6,"TP6_EURNZD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP6_EURNZD_UP_S2_OCO2"));
		                 };
	                    Base.EURNZD_UP_S2_OCO2Sets6.Add( Base.EURNZD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURNZD_OCO2S1_UP_S2 = 0;
	                for (; EURNZD_OCO2S1_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets1.Count; EURNZD_OCO2S1_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO2Sets1[EURNZD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO2Sets1[EURNZD_OCO2S1_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO2Sets1.RemoveAt(EURNZD_OCO2S1_UP_S2);
	                        EURNZD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURNZD_OCO2S2_UP_S2 = 0;
	                for (; EURNZD_OCO2S2_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets2.Count; EURNZD_OCO2S2_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO2Sets2[EURNZD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO2Sets2[EURNZD_OCO2S2_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO2Sets2.RemoveAt(EURNZD_OCO2S2_UP_S2);
	                        EURNZD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO2S3_UP_S2 = 0;
	                for (; EURNZD_OCO2S3_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets3.Count; EURNZD_OCO2S3_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO2Sets3[EURNZD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO2Sets3[EURNZD_OCO2S3_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO2Sets3.RemoveAt(EURNZD_OCO2S3_UP_S2);
	                        EURNZD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO2S4_UP_S2 = 0;
	                for (; EURNZD_OCO2S4_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets4.Count; EURNZD_OCO2S4_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO2Sets4[EURNZD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO2Sets4[EURNZD_OCO2S4_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO2Sets4.RemoveAt(EURNZD_OCO2S4_UP_S2);
	                        EURNZD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURNZD_OCO2S5_UP_S2 = 0;
	                for (; EURNZD_OCO2S5_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets5.Count; EURNZD_OCO2S5_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO2Sets5[EURNZD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO2Sets5[EURNZD_OCO2S5_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO2Sets5.RemoveAt(EURNZD_OCO2S5_UP_S2);
	                        EURNZD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURNZD_OCO2S6_UP_S2 = 0;
	                for (; EURNZD_OCO2S6_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets6.Count; EURNZD_OCO2S6_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO2Sets6[EURNZD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO2Sets6[EURNZD_OCO2S6_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO2Sets6.RemoveAt(EURNZD_OCO2S6_UP_S2);
	                        EURNZD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURNZD_OCO3_EO1_UP_S2)
	                Base.EURNZD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURNZD_OCO3_EO2_UP_S2)
	                Base.EURNZD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO3_EO3_UP_S2)
	                Base.EURNZD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO3_EO4_UP_S2)
	                Base.EURNZD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO3_EO5_UP_S2)
	                Base.EURNZD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO3_EO6_UP_S2)
	                Base.EURNZD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURNZD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.EURNZD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP1,"TP1_EURNZD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP1_EURNZD_UP_S2_OCO3"));
		                 };
		                Base.EURNZD_UP_S2_OCO3Sets1.Add( Base.EURNZD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURNZD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP2,"TP2_EURNZD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP2_EURNZD_UP_S2_OCO3"));
		                 };
	                    Base.EURNZD_UP_S2_OCO3Sets2.Add( Base.EURNZD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP3,"TP3_EURNZD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP3_EURNZD_UP_S2_OCO3"));
		                 };
	                    Base.EURNZD_UP_S2_OCO3Sets3.Add( Base.EURNZD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP4,"TP4_EURNZD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP4_EURNZD_UP_S2_OCO3"));
		                 };
	                    Base.EURNZD_UP_S2_OCO3Sets4.Add( Base.EURNZD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP5,"TP5_EURNZD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP5_EURNZD_UP_S2_OCO3"));
		                 };
	                    Base.EURNZD_UP_S2_OCO3Sets5.Add( Base.EURNZD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP6,"TP6_EURNZD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP6_EURNZD_UP_S2_OCO3"));
		                 };
	                    Base.EURNZD_UP_S2_OCO3Sets6.Add( Base.EURNZD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURNZD_OCO3S1_UP_S2 = 0;
	                for (; EURNZD_OCO3S1_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets1.Count; EURNZD_OCO3S1_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO3Sets1[EURNZD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO3Sets1[EURNZD_OCO3S1_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO3Sets1.RemoveAt(EURNZD_OCO3S1_UP_S2);
	                        EURNZD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURNZD_OCO3S2_UP_S2 = 0;
	                for (; EURNZD_OCO3S2_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets2.Count; EURNZD_OCO3S2_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO3Sets2[EURNZD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO3Sets2[EURNZD_OCO3S2_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO3Sets2.RemoveAt(EURNZD_OCO3S2_UP_S2);
	                        EURNZD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO3S3_UP_S2 = 0;
	                for (; EURNZD_OCO3S3_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets3.Count; EURNZD_OCO3S3_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO3Sets3[EURNZD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO3Sets3[EURNZD_OCO3S3_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO3Sets3.RemoveAt(EURNZD_OCO3S3_UP_S2);
	                        EURNZD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO3S4_UP_S2 = 0;
	                for (; EURNZD_OCO3S4_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets4.Count; EURNZD_OCO3S4_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO3Sets4[EURNZD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO3Sets4[EURNZD_OCO3S4_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO3Sets4.RemoveAt(EURNZD_OCO3S4_UP_S2);
	                        EURNZD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURNZD_OCO3S5_UP_S2 = 0;
	                for (; EURNZD_OCO3S5_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets5.Count; EURNZD_OCO3S5_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO3Sets5[EURNZD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO3Sets5[EURNZD_OCO3S5_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO3Sets5.RemoveAt(EURNZD_OCO3S5_UP_S2);
	                        EURNZD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURNZD_OCO3S6_UP_S2 = 0;
	                for (; EURNZD_OCO3S6_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets6.Count; EURNZD_OCO3S6_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO3Sets6[EURNZD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO3Sets6[EURNZD_OCO3S6_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO3Sets6.RemoveAt(EURNZD_OCO3S6_UP_S2);
	                        EURNZD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURNZD_OCO4_EO1_UP_S2)
	                Base.EURNZD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURNZD_OCO4_EO2_UP_S2)
	                Base.EURNZD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO4_EO3_UP_S2)
	                Base.EURNZD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO4_EO4_UP_S2)
	                Base.EURNZD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO4_EO5_UP_S2)
	                Base.EURNZD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO4_EO6_UP_S2)
	                Base.EURNZD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURNZD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.EURNZD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP1,"TP1_EURNZD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP1_EURNZD_UP_S2_OCO4"));
		                 };
		                Base.EURNZD_UP_S2_OCO4Sets1.Add( Base.EURNZD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURNZD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP2,"TP2_EURNZD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP2_EURNZD_UP_S2_OCO4"));
		                 };
	                    Base.EURNZD_UP_S2_OCO4Sets2.Add( Base.EURNZD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP3,"TP3_EURNZD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP3_EURNZD_UP_S2_OCO4"));
		                 };
	                    Base.EURNZD_UP_S2_OCO4Sets3.Add( Base.EURNZD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP4,"TP4_EURNZD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP4_EURNZD_UP_S2_OCO4"));
		                 };
	                    Base.EURNZD_UP_S2_OCO4Sets4.Add( Base.EURNZD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP5,"TP5_EURNZD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP5_EURNZD_UP_S2_OCO4"));
		                 };
	                    Base.EURNZD_UP_S2_OCO4Sets5.Add( Base.EURNZD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_UP_S2_TP6,"TP6_EURNZD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_UP_S2_SL,"SL_TP6_EURNZD_UP_S2_OCO4"));
		                 };
	                    Base.EURNZD_UP_S2_OCO4Sets6.Add( Base.EURNZD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURNZD_OCO4S1_UP_S2 = 0;
	                for (; EURNZD_OCO4S1_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets1.Count; EURNZD_OCO4S1_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO4Sets1[EURNZD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO4Sets1[EURNZD_OCO4S1_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO4Sets1.RemoveAt(EURNZD_OCO4S1_UP_S2);
	                        EURNZD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURNZD_OCO4S2_UP_S2 = 0;
	                for (; EURNZD_OCO4S2_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets2.Count; EURNZD_OCO4S2_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO4Sets2[EURNZD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO4Sets2[EURNZD_OCO4S2_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO4Sets2.RemoveAt(EURNZD_OCO4S2_UP_S2);
	                        EURNZD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO4S3_UP_S2 = 0;
	                for (; EURNZD_OCO4S3_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets3.Count; EURNZD_OCO4S3_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO4Sets3[EURNZD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO4Sets3[EURNZD_OCO4S3_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO4Sets3.RemoveAt(EURNZD_OCO4S3_UP_S2);
	                        EURNZD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO4S4_UP_S2 = 0;
	                for (; EURNZD_OCO4S4_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets4.Count; EURNZD_OCO4S4_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO4Sets4[EURNZD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO4Sets4[EURNZD_OCO4S4_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO4Sets4.RemoveAt(EURNZD_OCO4S4_UP_S2);
	                        EURNZD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURNZD_OCO4S5_UP_S2 = 0;
	                for (; EURNZD_OCO4S5_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets5.Count; EURNZD_OCO4S5_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO4Sets5[EURNZD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO4Sets5[EURNZD_OCO4S5_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO4Sets5.RemoveAt(EURNZD_OCO4S5_UP_S2);
	                        EURNZD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURNZD_OCO4S6_UP_S2 = 0;
	                for (; EURNZD_OCO4S6_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets6.Count; EURNZD_OCO4S6_UP_S2++)
	                    if (Base.EURNZD_UP_S2_OCO4Sets6[EURNZD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_UP_S2_OCO4Sets6[EURNZD_OCO4S6_UP_S2].Filled();
	                        Base.EURNZD_UP_S2_OCO4Sets6.RemoveAt(EURNZD_OCO4S6_UP_S2);
	                        EURNZD_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURAUD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURAUD_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(x=>x.Tag.Contains("EURAUD_UP_S2_OCO1")))
			{
				Base.EURAUD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURAUD_UP_S2_OCO2")))
			{
				Base.EURAUD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURAUD_UP_S2_OCO3")))
			{
				Base.EURAUD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURAUD_UP_S2_OCO4")))
			{
				Base.EURAUD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURAUD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.EURAUD_OCO1_EO1_UP_S2)
	                Base.EURAUD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.EURAUD_OCO1_EO2_UP_S2)
	                Base.EURAUD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO1_EO3_UP_S2)
	                Base.EURAUD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO1_EO4_UP_S2)
	                Base.EURAUD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO1_EO5_UP_S2)
	                Base.EURAUD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO1_EO6_UP_S2)
	                Base.EURAUD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURAUD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURAUD_OCO1S1_UP_S2 = 0;
		                for (; EURAUD_OCO1S1_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets1.Count; EURAUD_OCO1S1_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO1Sets1[EURAUD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO1Sets1[EURAUD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.EURAUD_UP_S2_OCO1Sets1.Clear();
		                        EURAUD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURAUD_OCO1S2_UP_S2 = 0;
		                for (; EURAUD_OCO1S2_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets2.Count; EURAUD_OCO1S2_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO1Sets2[EURAUD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO1Sets2[EURAUD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.EURAUD_UP_S2_OCO1Sets2.Clear();
		                        EURAUD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO1S3_UP_S2 = 0;
		                for (; EURAUD_OCO1S3_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets3.Count; EURAUD_OCO1S3_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO1Sets3[EURAUD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO1Sets3[EURAUD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.EURAUD_UP_S2_OCO1Sets3.Clear();
		                        EURAUD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO1S4_UP_S2 = 0;
		                for (; EURAUD_OCO1S4_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets4.Count; EURAUD_OCO1S4_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO1Sets4[EURAUD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO1Sets4[EURAUD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.EURAUD_UP_S2_OCO1Sets4.Clear();
		                        EURAUD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO1S5_UP_S2 = 0;
		                for (; EURAUD_OCO1S5_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets5.Count; EURAUD_OCO1S5_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO1Sets5[EURAUD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO1Sets5[EURAUD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.EURAUD_UP_S2_OCO1Sets5.Clear();
		                        EURAUD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO1S6_UP_S2 = 0;
		                for (; EURAUD_OCO1S6_UP_S2 < Base.EURAUD_UP_S2_OCO1Sets6.Count; EURAUD_OCO1S6_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO1Sets6[EURAUD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO1Sets6[EURAUD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.EURAUD_UP_S2_OCO1Sets6.Clear();
		                        EURAUD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURAUD_OCO2_EO1_UP_S2)
                	Base.EURAUD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.EURAUD_OCO2_EO2_UP_S2)
	                Base.EURAUD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO2_EO3_UP_S2)
	                Base.EURAUD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO2_EO4_UP_S2)
	                Base.EURAUD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO2_EO5_UP_S2)
	                Base.EURAUD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO2_EO6_UP_S2)
	                Base.EURAUD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURAUD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURAUD_OCO2S1_UP_S2 = 0;
		                for (; EURAUD_OCO2S1_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets1.Count; EURAUD_OCO2S1_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO2Sets1[EURAUD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO2Sets1[EURAUD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.EURAUD_UP_S2_OCO2Sets1.Clear();
		                        EURAUD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURAUD_OCO2S2_UP_S2 = 0;
		                for (; EURAUD_OCO2S2_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets2.Count; EURAUD_OCO2S2_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO2Sets2[EURAUD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO2Sets2[EURAUD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.EURAUD_UP_S2_OCO2Sets2.Clear();
		                        EURAUD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO2S3_UP_S2 = 0;
		                for (; EURAUD_OCO2S3_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets3.Count; EURAUD_OCO2S3_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO2Sets3[EURAUD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO2Sets3[EURAUD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.EURAUD_UP_S2_OCO2Sets3.Clear();
		                        EURAUD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO2S4_UP_S2 = 0;
		                for (; EURAUD_OCO2S4_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets4.Count; EURAUD_OCO2S4_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO2Sets4[EURAUD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO2Sets4[EURAUD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.EURAUD_UP_S2_OCO2Sets4.Clear();
		                        EURAUD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO2S5_UP_S2 = 0;
		                for (; EURAUD_OCO2S5_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets5.Count; EURAUD_OCO2S5_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO2Sets5[EURAUD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO2Sets5[EURAUD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.EURAUD_UP_S2_OCO2Sets5.Clear();
		                        EURAUD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO2S6_UP_S2 = 0;
		                for (; EURAUD_OCO2S6_UP_S2 < Base.EURAUD_UP_S2_OCO2Sets6.Count; EURAUD_OCO2S6_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO2Sets6[EURAUD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO2Sets6[EURAUD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.EURAUD_UP_S2_OCO2Sets6.Clear();
		                        EURAUD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURAUD_OCO3_EO1_UP_S2)
            		Base.EURAUD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.EURAUD_OCO3_EO2_UP_S2)
	                Base.EURAUD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO3_EO3_UP_S2)
	                Base.EURAUD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO3_EO4_UP_S2)
	                Base.EURAUD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO3_EO5_UP_S2)
	                Base.EURAUD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO3_EO6_UP_S2)
	                Base.EURAUD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURAUD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURAUD_OCO3S1_UP_S2 = 0;
		                for (; EURAUD_OCO3S1_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets1.Count; EURAUD_OCO3S1_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO3Sets1[EURAUD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO3Sets1[EURAUD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.EURAUD_UP_S2_OCO3Sets1.Clear();
		                        EURAUD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURAUD_OCO3S2_UP_S2 = 0;
		                for (; EURAUD_OCO3S2_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets2.Count; EURAUD_OCO3S2_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO3Sets2[EURAUD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO3Sets2[EURAUD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.EURAUD_UP_S2_OCO3Sets2.Clear();
		                        EURAUD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO3S3_UP_S2 = 0;
		                for (; EURAUD_OCO3S3_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets3.Count; EURAUD_OCO3S3_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO3Sets3[EURAUD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO3Sets3[EURAUD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.EURAUD_UP_S2_OCO3Sets3.Clear();
		                        EURAUD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO3S4_UP_S2 = 0;
		                for (; EURAUD_OCO3S4_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets4.Count; EURAUD_OCO3S4_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO3Sets4[EURAUD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO3Sets4[EURAUD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.EURAUD_UP_S2_OCO3Sets4.Clear();
		                        EURAUD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO3S5_UP_S2 = 0;
		                for (; EURAUD_OCO3S5_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets5.Count; EURAUD_OCO3S5_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO3Sets5[EURAUD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO3Sets5[EURAUD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.EURAUD_UP_S2_OCO3Sets5.Clear();
		                        EURAUD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO3S6_UP_S2 = 0;
		                for (; EURAUD_OCO3S6_UP_S2 < Base.EURAUD_UP_S2_OCO3Sets6.Count; EURAUD_OCO3S6_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO3Sets6[EURAUD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO3Sets6[EURAUD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.EURAUD_UP_S2_OCO3Sets6.Clear();
		                        EURAUD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURAUD_OCO4_EO1_UP_S2)
            		Base.EURAUD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.EURAUD_OCO4_EO2_UP_S2)
	                Base.EURAUD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO4_EO3_UP_S2)
	                Base.EURAUD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO4_EO4_UP_S2)
	                Base.EURAUD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO4_EO5_UP_S2)
	                Base.EURAUD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO4_EO6_UP_S2)
	                Base.EURAUD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURAUD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURAUD_OCO4S1_UP_S2 = 0;
		                for (; EURAUD_OCO4S1_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets1.Count; EURAUD_OCO4S1_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO4Sets1[EURAUD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO4Sets1[EURAUD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.EURAUD_UP_S2_OCO4Sets1.Clear();
		                        EURAUD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURAUD_OCO4S2_UP_S2 = 0;
		                for (; EURAUD_OCO4S2_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets2.Count; EURAUD_OCO4S2_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO4Sets2[EURAUD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO4Sets2[EURAUD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.EURAUD_UP_S2_OCO4Sets2.Clear();
		                        EURAUD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO4S3_UP_S2 = 0;
		                for (; EURAUD_OCO4S3_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets3.Count; EURAUD_OCO4S3_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO4Sets3[EURAUD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO4Sets3[EURAUD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.EURAUD_UP_S2_OCO4Sets3.Clear();
		                        EURAUD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO4S4_UP_S2 = 0;
		                for (; EURAUD_OCO4S4_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets4.Count; EURAUD_OCO4S4_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO4Sets4[EURAUD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO4Sets4[EURAUD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.EURAUD_UP_S2_OCO4Sets4.Clear();
		                        EURAUD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO4S5_UP_S2 = 0;
		                for (; EURAUD_OCO4S5_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets5.Count; EURAUD_OCO4S5_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO4Sets5[EURAUD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO4Sets5[EURAUD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.EURAUD_UP_S2_OCO4Sets5.Clear();
		                        EURAUD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO4S6_UP_S2 = 0;
		                for (; EURAUD_OCO4S6_UP_S2 < Base.EURAUD_UP_S2_OCO4Sets6.Count; EURAUD_OCO4S6_UP_S2++)
		                    if (Base.EURAUD_UP_S2_OCO4Sets6[EURAUD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_UP_S2_OCO4Sets6[EURAUD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.EURAUD_UP_S2_OCO4Sets6.Clear();
		                        EURAUD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_EURAUD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURAUD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURAUD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURAUD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURAUD_UP_S2 = DOWM_EURAUD_UP_S2 || DOWT_EURAUD_UP_S2 || DOWW_EURAUD_UP_S2 || DOWTH_EURAUD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURAUD"))
	            	{
	            		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.EURAUD_OCO1_UP_S2_IsReady == false ||
	                    	Base.EURAUD_OCO2_UP_S2_IsReady == false ||
	                    	Base.EURAUD_OCO3_UP_S2_IsReady == false ||
	                    	Base.EURAUD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.EURAUD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.EURAUD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.EURAUD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.EURAUD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURAUD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.EURAUD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.EURAUD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.EURAUD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	EURAUD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                	EURAUD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                									
	                	EURAUD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[0] < pricesM_BID_Low[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 (EURAUD_Signal_Condition_UP_1)
	                	{
	                    	EURAUD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURAUD_Signal_Condition_UP_2)
	                	{
	                    	EURAUD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURAUD_Signal_Condition_UP_3)
	                	{
	                    	EURAUD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (EURAUD_Signal_Condition_UP_1)
	                	{
	                    	EURAUD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (EURAUD_Signal_Condition_UP_2)
	                	{
	                    	EURAUD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (EURAUD_Signal_Condition_UP_3)
	                	{
	                    	EURAUD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    EURAUD_UP_S2_TP2 =  EURAUD_UP_S2_SL * 0;
	                    EURAUD_UP_S2_TP3 =  EURAUD_UP_S2_SL * 0;
	                    EURAUD_UP_S2_TP4 =  EURAUD_UP_S2_SL * 0;
	                    EURAUD_UP_S2_TP5 =  EURAUD_UP_S2_SL * 0;
	                    EURAUD_UP_S2_TP6 =  EURAUD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURAUD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURAUD_quantity_SL_UP_S2 = EURAUD_quantity_UP_S2;
	                    EURAUD_quantity_TP1_UP_S2 = (int)Math.Floor(EURAUD_quantity_UP_S2 * 1m);
	                    EURAUD_quantity_TP2_UP_S2 = (int)Math.Floor(EURAUD_quantity_TP1_UP_S2 * 0m);
	                    EURAUD_quantity_TP3_UP_S2 = (int)Math.Floor(EURAUD_quantity_TP2_UP_S2 * 0m);
	                    EURAUD_quantity_TP4_UP_S2 = (int)Math.Floor(EURAUD_quantity_TP3_UP_S2 * 0m);
	                    EURAUD_quantity_TP5_UP_S2 = (int)Math.Floor(EURAUD_quantity_TP4_UP_S2 * 0m);
	                    EURAUD_quantity_TP6_UP_S2 = (int)Math.Floor(EURAUD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((EURAUD_Signal_Condition_UP_1 || EURAUD_Signal_Condition_UP_2 || EURAUD_Signal_Condition_UP_3)  && 
	                    DOWR_EURAUD_UP_S2 && 
	                    Base.EURAUD_OCO1_UP_S2_IsReady == true &&
	                    Base.EURAUD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURAUD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP1_UP_S2, false,"EURAUD_UP_S2_Entry_TP1_OCO1");
	                         Base.EURAUD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.EURAUD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP2_UP_S2, false,"EURAUD_UP_S2_Entry_TP2_OCO1");
	                         Base.EURAUD_OCO1_EO2_UP_S2 = false;
	
	                         Base.EURAUD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP3_UP_S2, false,"EURAUD_UP_S2_Entry_TP3_OCO1");
	                         Base.EURAUD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.EURAUD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP4_UP_S2, false,"EURAUD_UP_S2_Entry_TP4_OCO1");
	                         Base.EURAUD_OCO1_EO4_UP_S2 = false;

							Base.EURAUD_OCO1_UP_S2_IsReady = false;
							
							if (Base.EURAUD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((EURAUD_Signal_Condition_UP_1 || EURAUD_Signal_Condition_UP_2 || EURAUD_Signal_Condition_UP_3)  && 
	                    DOWR_EURAUD_UP_S2 && 
	                    Base.EURAUD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURAUD_OCO2_UP_S2_IsReady == true &&
	                    Base.EURAUD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURAUD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP1_UP_S2, false,"EURAUD_UP_S2_Entry_TP1_OCO2");
	                         Base.EURAUD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.EURAUD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP2_UP_S2, false,"EURAUD_UP_S2_Entry_TP2_OCO2");
	                         Base.EURAUD_OCO2_EO2_UP_S2 = false;
	
	                         Base.EURAUD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP3_UP_S2, false,"EURAUD_UP_S2_Entry_TP3_OCO2");
	                         Base.EURAUD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.EURAUD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP4_UP_S2, false,"EURAUD_UP_S2_Entry_TP4_OCO2");
	                         Base.EURAUD_OCO2_EO4_UP_S2 = false;

							Base.EURAUD_OCO2_UP_S2_IsReady = false;
							
							if (Base.EURAUD_OCO2_UP_S2_IsReady == false && Base.EURAUD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((EURAUD_Signal_Condition_UP_1 || EURAUD_Signal_Condition_UP_2 || EURAUD_Signal_Condition_UP_3)  && 
	                    DOWR_EURAUD_UP_S2 &&
	                    Base.EURAUD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURAUD_OCO2_UP_S2_IsReady == false &&
	                    Base.EURAUD_OCO3_UP_S2_IsReady == true &&
	                    Base.EURAUD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURAUD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP1_UP_S2, false,"EURAUD_UP_S2_Entry_TP1_OCO3");
	                         Base.EURAUD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.EURAUD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP2_UP_S2, false,"EURAUD_UP_S2_Entry_TP2_OCO3");
	                         Base.EURAUD_OCO3_EO2_UP_S2 = false;
	
	                         Base.EURAUD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP3_UP_S2, false,"EURAUD_UP_S2_Entry_TP3_OCO3");
	                         Base.EURAUD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.EURAUD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP4_UP_S2, false,"EURAUD_UP_S2_Entry_TP4_OCO3");
	                         Base.EURAUD_OCO3_EO4_UP_S2 = false;

							Base.EURAUD_OCO3_UP_S2_IsReady = false;
							
							if (Base.EURAUD_OCO3_UP_S2_IsReady == false && Base.EURAUD_OCO2_UP_S2_IsReady == false && Base.EURAUD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((EURAUD_Signal_Condition_UP_1 || EURAUD_Signal_Condition_UP_2 || EURAUD_Signal_Condition_UP_3)  && 
	                    DOWR_EURAUD_UP_S2 && 
	                    Base.EURAUD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURAUD_OCO2_UP_S2_IsReady == false &&
	                    Base.EURAUD_OCO3_UP_S2_IsReady == false &&
	                    Base.EURAUD_OCO4_UP_S2_IsReady == true &&
	                    Base.EURAUD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURAUD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP1_UP_S2, false,"EURAUD_UP_S2_Entry_TP1_OCO4");
	                         Base.EURAUD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.EURAUD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP2_UP_S2, false,"EURAUD_UP_S2_Entry_TP2_OCO4");
	                         Base.EURAUD_OCO4_EO2_UP_S2 = false;
	
	                         Base.EURAUD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP3_UP_S2, false,"EURAUD_UP_S2_Entry_TP3_OCO4");
	                         Base.EURAUD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.EURAUD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURAUD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP4_UP_S2, false,"EURAUD_UP_S2_Entry_TP4_OCO4");
	                         Base.EURAUD_OCO4_EO4_UP_S2 = false;

							Base.EURAUD_OCO4_UP_S2_IsReady = false;
							
							if (Base.EURAUD_OCO4_UP_S2_IsReady == false && Base.EURAUD_OCO3_UP_S2_IsReady == false && Base.EURAUD_OCO2_UP_S2_IsReady == false && Base.EURAUD_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURAUD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURAUD_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("EURAUD_DOWN_S2_OCO1")))
			{
				Base.EURAUD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURAUD_DOWN_S2_OCO2")))
			{
				Base.EURAUD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURAUD_DOWN_S2_OCO3")))
			{
				Base.EURAUD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURAUD_DOWN_S2_OCO4")))
			{
				Base.EURAUD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURAUD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.EURAUD_OCO1_EO1_DOWN_S2)
	                Base.EURAUD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURAUD_OCO1_EO2_DOWN_S2)
	                Base.EURAUD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO1_EO3_DOWN_S2)
	                Base.EURAUD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO1_EO4_DOWN_S2)
	                Base.EURAUD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO1_EO5_DOWN_S2)
	                Base.EURAUD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO1_EO6_DOWN_S2)
	                Base.EURAUD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURAUD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURAUD_OCO1S1_DOWN_S2 = 0;
		                for (; EURAUD_OCO1S1_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets1.Count; EURAUD_OCO1S1_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO1Sets1[EURAUD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO1Sets1[EURAUD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.EURAUD_DOWN_S2_OCO1Sets1.Clear();
		                        EURAUD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURAUD_OCO1S2_DOWN_S2 = 0;
		                for (; EURAUD_OCO1S2_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets2.Count; EURAUD_OCO1S2_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO1Sets2[EURAUD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO1Sets2[EURAUD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.EURAUD_DOWN_S2_OCO1Sets2.Clear();
		                        EURAUD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO1S3_DOWN_S2 = 0;
		                for (; EURAUD_OCO1S3_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets3.Count; EURAUD_OCO1S3_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO1Sets3[EURAUD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO1Sets3[EURAUD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.EURAUD_DOWN_S2_OCO1Sets3.Clear();
		                        EURAUD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO1S4_DOWN_S2 = 0;
		                for (; EURAUD_OCO1S4_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets4.Count; EURAUD_OCO1S4_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO1Sets4[EURAUD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO1Sets4[EURAUD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.EURAUD_DOWN_S2_OCO1Sets4.Clear();
		                        EURAUD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO1S5_DOWN_S2 = 0;
		                for (; EURAUD_OCO1S5_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets5.Count; EURAUD_OCO1S5_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO1Sets5[EURAUD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO1Sets5[EURAUD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.EURAUD_DOWN_S2_OCO1Sets5.Clear();
		                        EURAUD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO1S6_DOWN_S2 = 0;
		                for (; EURAUD_OCO1S6_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO1Sets6.Count; EURAUD_OCO1S6_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO1Sets6[EURAUD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO1Sets6[EURAUD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.EURAUD_DOWN_S2_OCO1Sets6.Clear();
		                        EURAUD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURAUD_OCO2_EO1_DOWN_S2)
	                Base.EURAUD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURAUD_OCO2_EO2_DOWN_S2)
	                Base.EURAUD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO2_EO3_DOWN_S2)
	                Base.EURAUD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO2_EO4_DOWN_S2)
	                Base.EURAUD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO2_EO5_DOWN_S2)
	                Base.EURAUD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO2_EO6_DOWN_S2)
	                Base.EURAUD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURAUD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURAUD_OCO2S1_DOWN_S2 = 0;
		                for (; EURAUD_OCO2S1_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets1.Count; EURAUD_OCO2S1_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO2Sets1[EURAUD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO2Sets1[EURAUD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.EURAUD_DOWN_S2_OCO2Sets1.Clear();
		                        EURAUD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURAUD_OCO2S2_DOWN_S2 = 0;
		                for (; EURAUD_OCO2S2_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets2.Count; EURAUD_OCO2S2_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO2Sets2[EURAUD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO2Sets2[EURAUD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.EURAUD_DOWN_S2_OCO2Sets2.Clear();
		                        EURAUD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO2S3_DOWN_S2 = 0;
		                for (; EURAUD_OCO2S3_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets3.Count; EURAUD_OCO2S3_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO2Sets3[EURAUD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO2Sets3[EURAUD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.EURAUD_DOWN_S2_OCO2Sets3.Clear();
		                        EURAUD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO2S4_DOWN_S2 = 0;
		                for (; EURAUD_OCO2S4_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets4.Count; EURAUD_OCO2S4_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO2Sets4[EURAUD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO2Sets4[EURAUD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.EURAUD_DOWN_S2_OCO2Sets4.Clear();
		                        EURAUD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO2S5_DOWN_S2 = 0;
		                for (; EURAUD_OCO2S5_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets5.Count; EURAUD_OCO2S5_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO2Sets5[EURAUD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO2Sets5[EURAUD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.EURAUD_DOWN_S2_OCO2Sets5.Clear();
		                        EURAUD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO2S6_DOWN_S2 = 0;
		                for (; EURAUD_OCO2S6_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO2Sets6.Count; EURAUD_OCO2S6_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO2Sets6[EURAUD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO2Sets6[EURAUD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.EURAUD_DOWN_S2_OCO2Sets6.Clear();
		                        EURAUD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURAUD_OCO3_EO1_DOWN_S2)
	                Base.EURAUD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURAUD_OCO3_EO2_DOWN_S2)
	                Base.EURAUD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO3_EO3_DOWN_S2)
	                Base.EURAUD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO3_EO4_DOWN_S2)
	                Base.EURAUD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO3_EO5_DOWN_S2)
	                Base.EURAUD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO3_EO6_DOWN_S2)
	                Base.EURAUD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURAUD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURAUD_OCO3S1_DOWN_S2 = 0;
		                for (; EURAUD_OCO3S1_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets1.Count; EURAUD_OCO3S1_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO3Sets1[EURAUD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO3Sets1[EURAUD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.EURAUD_DOWN_S2_OCO3Sets1.Clear();
		                        EURAUD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURAUD_OCO3S2_DOWN_S2 = 0;
		                for (; EURAUD_OCO3S2_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets2.Count; EURAUD_OCO3S2_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO3Sets2[EURAUD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO3Sets2[EURAUD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.EURAUD_DOWN_S2_OCO3Sets2.Clear();
		                        EURAUD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO3S3_DOWN_S2 = 0;
		                for (; EURAUD_OCO3S3_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets3.Count; EURAUD_OCO3S3_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO3Sets3[EURAUD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO3Sets3[EURAUD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.EURAUD_DOWN_S2_OCO3Sets3.Clear();
		                        EURAUD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO3S4_DOWN_S2 = 0;
		                for (; EURAUD_OCO3S4_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets4.Count; EURAUD_OCO3S4_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO3Sets4[EURAUD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO3Sets4[EURAUD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.EURAUD_DOWN_S2_OCO3Sets4.Clear();
		                        EURAUD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO3S5_DOWN_S2 = 0;
		                for (; EURAUD_OCO3S5_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets5.Count; EURAUD_OCO3S5_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO3Sets5[EURAUD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO3Sets5[EURAUD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.EURAUD_DOWN_S2_OCO3Sets5.Clear();
		                        EURAUD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO3S6_DOWN_S2 = 0;
		                for (; EURAUD_OCO3S6_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO3Sets6.Count; EURAUD_OCO3S6_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO3Sets6[EURAUD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO3Sets6[EURAUD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.EURAUD_DOWN_S2_OCO3Sets6.Clear();
		                        EURAUD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURAUD_OCO4_EO1_DOWN_S2)
	                Base.EURAUD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURAUD_OCO4_EO2_DOWN_S2)
	                Base.EURAUD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO4_EO3_DOWN_S2)
	                Base.EURAUD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO4_EO4_DOWN_S2)
	                Base.EURAUD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO4_EO5_DOWN_S2)
	                Base.EURAUD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURAUD_OCO4_EO6_DOWN_S2)
	                Base.EURAUD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURAUD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURAUD_OCO4S1_DOWN_S2 = 0;
		                for (; EURAUD_OCO4S1_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets1.Count; EURAUD_OCO4S1_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO4Sets1[EURAUD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO4Sets1[EURAUD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.EURAUD_DOWN_S2_OCO4Sets1.Clear();
		                        EURAUD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURAUD_OCO4S2_DOWN_S2 = 0;
		                for (; EURAUD_OCO4S2_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets2.Count; EURAUD_OCO4S2_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO4Sets2[EURAUD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO4Sets2[EURAUD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.EURAUD_DOWN_S2_OCO4Sets2.Clear();
		                        EURAUD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO4S3_DOWN_S2 = 0;
		                for (; EURAUD_OCO4S3_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets3.Count; EURAUD_OCO4S3_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO4Sets3[EURAUD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO4Sets3[EURAUD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.EURAUD_DOWN_S2_OCO4Sets3.Clear();
		                        EURAUD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURAUD_OCO4S4_DOWN_S2 = 0;
		                for (; EURAUD_OCO4S4_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets4.Count; EURAUD_OCO4S4_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO4Sets4[EURAUD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO4Sets4[EURAUD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.EURAUD_DOWN_S2_OCO4Sets4.Clear();
		                        EURAUD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO4S5_DOWN_S2 = 0;
		                for (; EURAUD_OCO4S5_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets5.Count; EURAUD_OCO4S5_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO4Sets5[EURAUD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO4Sets5[EURAUD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.EURAUD_DOWN_S2_OCO4Sets5.Clear();
		                        EURAUD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURAUD_OCO4S6_DOWN_S2 = 0;
		                for (; EURAUD_OCO4S6_DOWN_S2 < Base.EURAUD_DOWN_S2_OCO4Sets6.Count; EURAUD_OCO4S6_DOWN_S2++)
		                    if (Base.EURAUD_DOWN_S2_OCO4Sets6[EURAUD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURAUD_DOWN_S2_OCO4Sets6[EURAUD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURAUD", order.Quantity, false, "EURAUD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.EURAUD_DOWN_S2_OCO4Sets6.Clear();
		                        EURAUD_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();
	            	}
	            	
					DOWM_EURAUD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURAUD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURAUD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURAUD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURAUD_DOWN_S2 = DOWM_EURAUD_DOWN_S2 || DOWT_EURAUD_DOWN_S2 || DOWW_EURAUD_DOWN_S2 || DOWTH_EURAUD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURAUD"))
	            	{
	            		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.EURAUD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.EURAUD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.EURAUD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.EURAUD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.EURAUD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURAUD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURAUD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURAUD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURAUD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURAUD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURAUD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURAUD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	EURAUD_Signal_Condition_DOWN_S2 =  
	                									(
	                								/*		//pricesM_ASK_OpenpricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_OpenpricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.04m &&
	                										
	                										//pricesM_ASK_Openprices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//pricesM_ASK_Openprices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										prices_ASK_High[0] - pricesM_BID_High[0] > prices_ASK_Close[0] * 0.03m &&

	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 && //yuhukj
	                										
	                										//prices_BID_Close[0] - prices_ASK_Open[0] > 0 &&
 	                										
	                										//prices_BID_Close[0] > pricesM_ASK_High[0] && 
	                										//prices_ASK_High[0] > pricesM_ASK_High[0] && 
	                										
	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										//pricesM_BID_Open[1] - pricesM_ASK_Close[1] > 0 &&
	                										
	                										//pricesM_BID_High[0] - pricesM_ASK_Open[0] > pricesM_BID_High[1] - pricesM_ASK_Open[1] &&
	                										
	                										//pricesM_BID_High[0] > pricesM_BID_High[1] &&
	                										
	                										//prices_BID_Close[0] > prices_ASK_Close[0]
	                										
	                										//prices_BID_Close[0] - prices_ASK_Open[0] > prices_ASK_Open[0] * 0.00001m &&
	                										
	                										//prices_ASK_High[0] > pricesM_ASK_High[0] &&
	                										//prices_BID_Close[0] < pricesM_BID_High[0] &&
	                										
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.001m    */
															
															pricesM_BID_High[0] - pricesM_BID_Open[0] > prices_BID_Close[0] * 0.005m &&
	                										pricesM_BID_High[1] - pricesM_BID_Open[1] > prices_BID_Close[0] * 0.00001m &&
	                										
	                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > prices_BID_Close[0] * 0.0001m &&
	                										pricesM_ASK_Open[1] - pricesM_BID_Close[1] > prices_BID_Close[0] * 0.0001m &&

	                										//prices_ASK_High[0] > pricesM_ASK_High[0] &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.001m
	                									);
	                									
	                    EURAUD_DOWN_S2_SL  =  0.02m;
	                    EURAUD_DOWN_S2_TP1 =  0.001m;
	             /*       EURAUD_DOWN_S2_SL  =  0.03m;
	                    EURAUD_DOWN_S2_TP1 =  0.01m;       */
	                    EURAUD_DOWN_S2_TP2 =  EURAUD_DOWN_S2_SL * 0;
	                    EURAUD_DOWN_S2_TP3 =  EURAUD_DOWN_S2_SL * 0;
	                    EURAUD_DOWN_S2_TP4 =  EURAUD_DOWN_S2_SL * 0;
	                    EURAUD_DOWN_S2_TP5 =  EURAUD_DOWN_S2_SL * 0;
	                    EURAUD_DOWN_S2_TP6 =  EURAUD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURAUD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURAUD_quantity_SL_DOWN_S2 = EURAUD_quantity_DOWN_S2;
	                    EURAUD_quantity_TP1_DOWN_S2 = (int)Math.Floor(EURAUD_quantity_DOWN_S2 * 1m);
	                    EURAUD_quantity_TP2_DOWN_S2 = (int)Math.Floor(EURAUD_quantity_TP1_DOWN_S2 * 0m);
	                    EURAUD_quantity_TP3_DOWN_S2 = (int)Math.Floor(EURAUD_quantity_TP2_DOWN_S2 * 0m);
	                    EURAUD_quantity_TP4_DOWN_S2 = (int)Math.Floor(EURAUD_quantity_TP3_DOWN_S2 * 0m);
	                    EURAUD_quantity_TP5_DOWN_S2 = (int)Math.Floor(EURAUD_quantity_TP4_DOWN_S2 * 0m);
	                    EURAUD_quantity_TP6_DOWN_S2 = (int)Math.Floor(EURAUD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (EURAUD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURAUD_DOWN_S2 && 
	                    Base.EURAUD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.EURAUD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURAUD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP1_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.EURAUD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.EURAUD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP2_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.EURAUD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.EURAUD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP3_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.EURAUD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.EURAUD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP4_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.EURAUD_OCO1_EO4_DOWN_S2 = false;

							Base.EURAUD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.EURAUD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (EURAUD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURAUD_DOWN_S2 && 
	                    Base.EURAUD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.EURAUD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURAUD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURAUD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP1_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.EURAUD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.EURAUD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP2_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.EURAUD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.EURAUD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP3_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.EURAUD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.EURAUD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP4_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.EURAUD_OCO2_EO4_DOWN_S2 = false;

							Base.EURAUD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.EURAUD_OCO2_DOWN_S2_IsReady == false && Base.EURAUD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (EURAUD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURAUD_DOWN_S2 &&
	                    Base.EURAUD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.EURAUD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURAUD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURAUD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURAUD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP1_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.EURAUD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.EURAUD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP2_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.EURAUD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.EURAUD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP3_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.EURAUD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.EURAUD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP4_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.EURAUD_OCO3_EO4_DOWN_S2 = false;

							Base.EURAUD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.EURAUD_OCO3_DOWN_S2_IsReady == false && Base.EURAUD_OCO2_DOWN_S2_IsReady == false && Base.EURAUD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (EURAUD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURAUD_DOWN_S2 && 
	                    Base.EURAUD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.EURAUD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURAUD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURAUD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.EURAUD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURAUD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP1_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.EURAUD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.EURAUD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP2_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.EURAUD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.EURAUD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP3_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.EURAUD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.EURAUD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURAUD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURAUD_quantity_TP4_DOWN_S2, false,"EURAUD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.EURAUD_OCO4_EO4_DOWN_S2 = false;

							Base.EURAUD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.EURAUD_OCO4_DOWN_S2_IsReady == false && Base.EURAUD_OCO3_DOWN_S2_IsReady == false && Base.EURAUD_OCO2_DOWN_S2_IsReady == false && Base.EURAUD_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.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 EURNZD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURNZD_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("EURNZD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURNZD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURNZD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURNZD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURNZD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURNZD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURNZD S2");
		        	}
		        }
		        
				if (Base.EURNZD_OCO1_EO1_DOWN_S2)
	                Base.EURNZD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURNZD_OCO1_EO2_DOWN_S2)
	                Base.EURNZD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO1_EO3_DOWN_S2)
	                Base.EURNZD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO1_EO4_DOWN_S2)
	                Base.EURNZD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURNZD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.EURNZD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP1_EURNZD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP1,"TP1_EURNZD_DOWN_S2_OCO1"));
		                 };
		                Base.EURNZD_DOWN_S2_OCO1Sets1.Add( Base.EURNZD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURNZD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP2_EURNZD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP2,"TP2_EURNZD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO1Sets2.Add( Base.EURNZD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP3_EURNZD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP3,"TP3_EURNZD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO1Sets3.Add( Base.EURNZD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP4_EURNZD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP4,"TP4_EURNZD_DOWN_S2_OCO1"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO1Sets4.Add( Base.EURNZD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURNZD_OCO1S1_DOWN_S2 = 0;
	                for (; EURNZD_OCO1S1_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets1.Count; EURNZD_OCO1S1_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO1Sets1[EURNZD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO1Sets1[EURNZD_OCO1S1_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO1Sets1.RemoveAt(EURNZD_OCO1S1_DOWN_S2);
	                        EURNZD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURNZD_OCO1S2_DOWN_S2 = 0;
	                for (; EURNZD_OCO1S2_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets2.Count; EURNZD_OCO1S2_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO1Sets2[EURNZD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO1Sets2[EURNZD_OCO1S2_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO1Sets2.RemoveAt(EURNZD_OCO1S2_DOWN_S2);
	                        EURNZD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO1S3_DOWN_S2 = 0;
	                for (; EURNZD_OCO1S3_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets3.Count; EURNZD_OCO1S3_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO1Sets3[EURNZD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO1Sets3[EURNZD_OCO1S3_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO1Sets3.RemoveAt(EURNZD_OCO1S3_DOWN_S2);
	                        EURNZD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO1S4_DOWN_S2 = 0;
	                for (; EURNZD_OCO1S4_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO1Sets4.Count; EURNZD_OCO1S4_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO1Sets4[EURNZD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO1Sets4[EURNZD_OCO1S4_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO1Sets4.RemoveAt(EURNZD_OCO1S4_DOWN_S2);
	                        EURNZD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURNZD_OCO2_EO1_DOWN_S2)
	                Base.EURNZD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURNZD_OCO2_EO2_DOWN_S2)
	                Base.EURNZD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO2_EO3_DOWN_S2)
	                Base.EURNZD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO2_EO4_DOWN_S2)
	                Base.EURNZD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURNZD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.EURNZD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP1_EURNZD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP1,"TP1_EURNZD_DOWN_S2_OCO2"));
		                 };
		                Base.EURNZD_DOWN_S2_OCO2Sets1.Add( Base.EURNZD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURNZD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP2_EURNZD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP2,"TP2_EURNZD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO2Sets2.Add( Base.EURNZD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP3_EURNZD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP3,"TP3_EURNZD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO2Sets3.Add( Base.EURNZD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP4_EURNZD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP4,"TP4_EURNZD_DOWN_S2_OCO2"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO2Sets4.Add( Base.EURNZD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURNZD_OCO2S1_DOWN_S2 = 0;
	                for (; EURNZD_OCO2S1_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets1.Count; EURNZD_OCO2S1_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO2Sets1[EURNZD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO2Sets1[EURNZD_OCO2S1_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO2Sets1.RemoveAt(EURNZD_OCO2S1_DOWN_S2);
	                        EURNZD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURNZD_OCO2S2_DOWN_S2 = 0;
	                for (; EURNZD_OCO2S2_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets2.Count; EURNZD_OCO2S2_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO2Sets2[EURNZD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO2Sets2[EURNZD_OCO2S2_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO2Sets2.RemoveAt(EURNZD_OCO2S2_DOWN_S2);
	                        EURNZD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO2S3_DOWN_S2 = 0;
	                for (; EURNZD_OCO2S3_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets3.Count; EURNZD_OCO2S3_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO2Sets3[EURNZD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO2Sets3[EURNZD_OCO2S3_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO2Sets3.RemoveAt(EURNZD_OCO2S3_DOWN_S2);
	                        EURNZD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO2S4_DOWN_S2 = 0;
	                for (; EURNZD_OCO2S4_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO2Sets4.Count; EURNZD_OCO2S4_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO2Sets4[EURNZD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO2Sets4[EURNZD_OCO2S4_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO2Sets4.RemoveAt(EURNZD_OCO2S4_DOWN_S2);
	                        EURNZD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURNZD_OCO3_EO1_DOWN_S2)
	                Base.EURNZD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURNZD_OCO3_EO2_DOWN_S2)
	                Base.EURNZD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO3_EO3_DOWN_S2)
	                Base.EURNZD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO3_EO4_DOWN_S2)
	                Base.EURNZD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURNZD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.EURNZD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP1_EURNZD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP1,"TP1_EURNZD_DOWN_S2_OCO3"));
		                 };
		                Base.EURNZD_DOWN_S2_OCO3Sets1.Add( Base.EURNZD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURNZD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP2_EURNZD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP2,"TP2_EURNZD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO3Sets2.Add( Base.EURNZD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP3_EURNZD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP3,"TP3_EURNZD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO3Sets3.Add( Base.EURNZD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP4_EURNZD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP4,"TP4_EURNZD_DOWN_S2_OCO3"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO3Sets4.Add( Base.EURNZD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURNZD_OCO3S1_DOWN_S2 = 0;
	                for (; EURNZD_OCO3S1_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets1.Count; EURNZD_OCO3S1_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO3Sets1[EURNZD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO3Sets1[EURNZD_OCO3S1_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO3Sets1.RemoveAt(EURNZD_OCO3S1_DOWN_S2);
	                        EURNZD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURNZD_OCO3S2_DOWN_S2 = 0;
	                for (; EURNZD_OCO3S2_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets2.Count; EURNZD_OCO3S2_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO3Sets2[EURNZD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO3Sets2[EURNZD_OCO3S2_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO3Sets2.RemoveAt(EURNZD_OCO3S2_DOWN_S2);
	                        EURNZD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO3S3_DOWN_S2 = 0;
	                for (; EURNZD_OCO3S3_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets3.Count; EURNZD_OCO3S3_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO3Sets3[EURNZD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO3Sets3[EURNZD_OCO3S3_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO3Sets3.RemoveAt(EURNZD_OCO3S3_DOWN_S2);
	                        EURNZD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO3S4_DOWN_S2 = 0;
	                for (; EURNZD_OCO3S4_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO3Sets4.Count; EURNZD_OCO3S4_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO3Sets4[EURNZD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO3Sets4[EURNZD_OCO3S4_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO3Sets4.RemoveAt(EURNZD_OCO3S4_DOWN_S2);
	                        EURNZD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURNZD_OCO4_EO1_DOWN_S2)
	                Base.EURNZD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURNZD_OCO4_EO2_DOWN_S2)
	                Base.EURNZD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO4_EO3_DOWN_S2)
	                Base.EURNZD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURNZD_OCO4_EO4_DOWN_S2)
	                Base.EURNZD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURNZD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.EURNZD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP1_EURNZD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP1,"TP1_EURNZD_DOWN_S2_OCO4"));
		                 };
		                Base.EURNZD_DOWN_S2_OCO4Sets1.Add( Base.EURNZD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURNZD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP2_EURNZD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP2,"TP2_EURNZD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO4Sets2.Add( Base.EURNZD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP3_EURNZD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP3,"TP3_EURNZD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO4Sets3.Add( Base.EURNZD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURNZD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURNZD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURNZD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURNZD_DOWN_S2_SL,"SL_TP4_EURNZD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURNZD_DOWN_S2_TP4,"TP4_EURNZD_DOWN_S2_OCO4"));
		                 };
	                    Base.EURNZD_DOWN_S2_OCO4Sets4.Add( Base.EURNZD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURNZD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURNZD_OCO4S1_DOWN_S2 = 0;
	                for (; EURNZD_OCO4S1_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets1.Count; EURNZD_OCO4S1_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO4Sets1[EURNZD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO4Sets1[EURNZD_OCO4S1_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO4Sets1.RemoveAt(EURNZD_OCO4S1_DOWN_S2);
	                        EURNZD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURNZD_OCO4S2_DOWN_S2 = 0;
	                for (; EURNZD_OCO4S2_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets2.Count; EURNZD_OCO4S2_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO4Sets2[EURNZD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO4Sets2[EURNZD_OCO4S2_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO4Sets2.RemoveAt(EURNZD_OCO4S2_DOWN_S2);
	                        EURNZD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO4S3_DOWN_S2 = 0;
	                for (; EURNZD_OCO4S3_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets3.Count; EURNZD_OCO4S3_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO4Sets3[EURNZD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO4Sets3[EURNZD_OCO4S3_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO4Sets3.RemoveAt(EURNZD_OCO4S3_DOWN_S2);
	                        EURNZD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURNZD_OCO4S4_DOWN_S2 = 0;
	                for (; EURNZD_OCO4S4_DOWN_S2 < Base.EURNZD_DOWN_S2_OCO4Sets4.Count; EURNZD_OCO4S4_DOWN_S2++)
	                    if (Base.EURNZD_DOWN_S2_OCO4Sets4[EURNZD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURNZD_DOWN_S2_OCO4Sets4[EURNZD_OCO4S4_DOWN_S2].Filled();
	                        Base.EURNZD_DOWN_S2_OCO4Sets4.RemoveAt(EURNZD_OCO4S4_DOWN_S2);
	                        EURNZD_OCO4S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURCHF_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURCHF_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("EURCHF_DOWN_S2_OCO1")))
			{
				Base.EURCHF_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCHF_DOWN_S2_OCO2")))
			{
				Base.EURCHF_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCHF_DOWN_S2_OCO3")))
			{
				Base.EURCHF_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCHF_DOWN_S2_OCO4")))
			{
				Base.EURCHF_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURCHF_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.EURCHF_OCO1_EO1_DOWN_S2)
	                Base.EURCHF_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURCHF_OCO1_EO2_DOWN_S2)
	                Base.EURCHF_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO1_EO3_DOWN_S2)
	                Base.EURCHF_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO1_EO4_DOWN_S2)
	                Base.EURCHF_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO1_EO5_DOWN_S2)
	                Base.EURCHF_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO1_EO6_DOWN_S2)
	                Base.EURCHF_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCHF_OCO1S1_DOWN_S2 = 0;
		                for (; EURCHF_OCO1S1_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets1.Count; EURCHF_OCO1S1_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO1Sets1[EURCHF_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO1Sets1[EURCHF_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.EURCHF_DOWN_S2_OCO1Sets1.Clear();
		                        EURCHF_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURCHF_OCO1S2_DOWN_S2 = 0;
		                for (; EURCHF_OCO1S2_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets2.Count; EURCHF_OCO1S2_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO1Sets2[EURCHF_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO1Sets2[EURCHF_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.EURCHF_DOWN_S2_OCO1Sets2.Clear();
		                        EURCHF_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO1S3_DOWN_S2 = 0;
		                for (; EURCHF_OCO1S3_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets3.Count; EURCHF_OCO1S3_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO1Sets3[EURCHF_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO1Sets3[EURCHF_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.EURCHF_DOWN_S2_OCO1Sets3.Clear();
		                        EURCHF_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO1S4_DOWN_S2 = 0;
		                for (; EURCHF_OCO1S4_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets4.Count; EURCHF_OCO1S4_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO1Sets4[EURCHF_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO1Sets4[EURCHF_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.EURCHF_DOWN_S2_OCO1Sets4.Clear();
		                        EURCHF_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO1S5_DOWN_S2 = 0;
		                for (; EURCHF_OCO1S5_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets5.Count; EURCHF_OCO1S5_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO1Sets5[EURCHF_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO1Sets5[EURCHF_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.EURCHF_DOWN_S2_OCO1Sets5.Clear();
		                        EURCHF_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO1S6_DOWN_S2 = 0;
		                for (; EURCHF_OCO1S6_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO1Sets6.Count; EURCHF_OCO1S6_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO1Sets6[EURCHF_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO1Sets6[EURCHF_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.EURCHF_DOWN_S2_OCO1Sets6.Clear();
		                        EURCHF_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURCHF_OCO2_EO1_DOWN_S2)
	                Base.EURCHF_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURCHF_OCO2_EO2_DOWN_S2)
	                Base.EURCHF_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO2_EO3_DOWN_S2)
	                Base.EURCHF_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO2_EO4_DOWN_S2)
	                Base.EURCHF_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO2_EO5_DOWN_S2)
	                Base.EURCHF_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO2_EO6_DOWN_S2)
	                Base.EURCHF_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCHF_OCO2S1_DOWN_S2 = 0;
		                for (; EURCHF_OCO2S1_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets1.Count; EURCHF_OCO2S1_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO2Sets1[EURCHF_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO2Sets1[EURCHF_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.EURCHF_DOWN_S2_OCO2Sets1.Clear();
		                        EURCHF_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURCHF_OCO2S2_DOWN_S2 = 0;
		                for (; EURCHF_OCO2S2_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets2.Count; EURCHF_OCO2S2_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO2Sets2[EURCHF_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO2Sets2[EURCHF_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.EURCHF_DOWN_S2_OCO2Sets2.Clear();
		                        EURCHF_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO2S3_DOWN_S2 = 0;
		                for (; EURCHF_OCO2S3_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets3.Count; EURCHF_OCO2S3_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO2Sets3[EURCHF_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO2Sets3[EURCHF_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.EURCHF_DOWN_S2_OCO2Sets3.Clear();
		                        EURCHF_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO2S4_DOWN_S2 = 0;
		                for (; EURCHF_OCO2S4_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets4.Count; EURCHF_OCO2S4_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO2Sets4[EURCHF_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO2Sets4[EURCHF_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.EURCHF_DOWN_S2_OCO2Sets4.Clear();
		                        EURCHF_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO2S5_DOWN_S2 = 0;
		                for (; EURCHF_OCO2S5_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets5.Count; EURCHF_OCO2S5_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO2Sets5[EURCHF_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO2Sets5[EURCHF_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.EURCHF_DOWN_S2_OCO2Sets5.Clear();
		                        EURCHF_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO2S6_DOWN_S2 = 0;
		                for (; EURCHF_OCO2S6_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO2Sets6.Count; EURCHF_OCO2S6_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO2Sets6[EURCHF_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO2Sets6[EURCHF_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.EURCHF_DOWN_S2_OCO2Sets6.Clear();
		                        EURCHF_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURCHF_OCO3_EO1_DOWN_S2)
	                Base.EURCHF_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURCHF_OCO3_EO2_DOWN_S2)
	                Base.EURCHF_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO3_EO3_DOWN_S2)
	                Base.EURCHF_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO3_EO4_DOWN_S2)
	                Base.EURCHF_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO3_EO5_DOWN_S2)
	                Base.EURCHF_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO3_EO6_DOWN_S2)
	                Base.EURCHF_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCHF_OCO3S1_DOWN_S2 = 0;
		                for (; EURCHF_OCO3S1_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets1.Count; EURCHF_OCO3S1_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO3Sets1[EURCHF_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO3Sets1[EURCHF_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.EURCHF_DOWN_S2_OCO3Sets1.Clear();
		                        EURCHF_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURCHF_OCO3S2_DOWN_S2 = 0;
		                for (; EURCHF_OCO3S2_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets2.Count; EURCHF_OCO3S2_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO3Sets2[EURCHF_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO3Sets2[EURCHF_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.EURCHF_DOWN_S2_OCO3Sets2.Clear();
		                        EURCHF_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO3S3_DOWN_S2 = 0;
		                for (; EURCHF_OCO3S3_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets3.Count; EURCHF_OCO3S3_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO3Sets3[EURCHF_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO3Sets3[EURCHF_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.EURCHF_DOWN_S2_OCO3Sets3.Clear();
		                        EURCHF_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO3S4_DOWN_S2 = 0;
		                for (; EURCHF_OCO3S4_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets4.Count; EURCHF_OCO3S4_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO3Sets4[EURCHF_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO3Sets4[EURCHF_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.EURCHF_DOWN_S2_OCO3Sets4.Clear();
		                        EURCHF_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO3S5_DOWN_S2 = 0;
		                for (; EURCHF_OCO3S5_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets5.Count; EURCHF_OCO3S5_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO3Sets5[EURCHF_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO3Sets5[EURCHF_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.EURCHF_DOWN_S2_OCO3Sets5.Clear();
		                        EURCHF_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO3S6_DOWN_S2 = 0;
		                for (; EURCHF_OCO3S6_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO3Sets6.Count; EURCHF_OCO3S6_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO3Sets6[EURCHF_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO3Sets6[EURCHF_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.EURCHF_DOWN_S2_OCO3Sets6.Clear();
		                        EURCHF_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURCHF_OCO4_EO1_DOWN_S2)
	                Base.EURCHF_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURCHF_OCO4_EO2_DOWN_S2)
	                Base.EURCHF_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO4_EO3_DOWN_S2)
	                Base.EURCHF_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO4_EO4_DOWN_S2)
	                Base.EURCHF_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO4_EO5_DOWN_S2)
	                Base.EURCHF_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO4_EO6_DOWN_S2)
	                Base.EURCHF_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCHF_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCHF_OCO4S1_DOWN_S2 = 0;
		                for (; EURCHF_OCO4S1_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets1.Count; EURCHF_OCO4S1_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO4Sets1[EURCHF_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO4Sets1[EURCHF_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.EURCHF_DOWN_S2_OCO4Sets1.Clear();
		                        EURCHF_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURCHF_OCO4S2_DOWN_S2 = 0;
		                for (; EURCHF_OCO4S2_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets2.Count; EURCHF_OCO4S2_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO4Sets2[EURCHF_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO4Sets2[EURCHF_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.EURCHF_DOWN_S2_OCO4Sets2.Clear();
		                        EURCHF_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO4S3_DOWN_S2 = 0;
		                for (; EURCHF_OCO4S3_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets3.Count; EURCHF_OCO4S3_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO4Sets3[EURCHF_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO4Sets3[EURCHF_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.EURCHF_DOWN_S2_OCO4Sets3.Clear();
		                        EURCHF_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO4S4_DOWN_S2 = 0;
		                for (; EURCHF_OCO4S4_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets4.Count; EURCHF_OCO4S4_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO4Sets4[EURCHF_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO4Sets4[EURCHF_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.EURCHF_DOWN_S2_OCO4Sets4.Clear();
		                        EURCHF_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO4S5_DOWN_S2 = 0;
		                for (; EURCHF_OCO4S5_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets5.Count; EURCHF_OCO4S5_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO4Sets5[EURCHF_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO4Sets5[EURCHF_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.EURCHF_DOWN_S2_OCO4Sets5.Clear();
		                        EURCHF_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO4S6_DOWN_S2 = 0;
		                for (; EURCHF_OCO4S6_DOWN_S2 < Base.EURCHF_DOWN_S2_OCO4Sets6.Count; EURCHF_OCO4S6_DOWN_S2++)
		                    if (Base.EURCHF_DOWN_S2_OCO4Sets6[EURCHF_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_DOWN_S2_OCO4Sets6[EURCHF_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.EURCHF_DOWN_S2_OCO4Sets6.Clear();
		                        EURCHF_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();
	            	}
	            	
					DOWM_EURCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURCHF_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURCHF_DOWN_S2 = DOWM_EURCHF_DOWN_S2 || DOWT_EURCHF_DOWN_S2 || DOWW_EURCHF_DOWN_S2 || DOWTH_EURCHF_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURCHF"))
	            	{
	            		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.EURCHF_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.EURCHF_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.EURCHF_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.EURCHF_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.EURCHF_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURCHF_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURCHF_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURCHF_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURCHF_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURCHF_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURCHF_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	EURCHF_Signal_Condition_DOWN_S2 =  
	  	                								(
																pricesM_BID_High[0] - pricesM_BID_Open[0] > prices_BID_Close[0] * 0.0075m &&
		                										pricesM_BID_High[1] - pricesM_BID_Open[1] > prices_BID_Close[0] * 0.00001m &&
		                										
		                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > prices_BID_Close[0] * 0.0001m &&
		                										pricesM_ASK_Open[1] - pricesM_BID_Close[1] > prices_BID_Close[0] * 0.0001m &&
	
		                										//prices_ASK_High[0] > pricesM_ASK_High[0] &&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < 0.0002m
	                									);
	                									
	                    EURCHF_DOWN_S2_SL  =  0.01m;
	                    EURCHF_DOWN_S2_TP1 =  0.002m;
	                    EURCHF_DOWN_S2_TP2 =  EURCHF_DOWN_S2_SL * 0;
	                    EURCHF_DOWN_S2_TP3 =  EURCHF_DOWN_S2_SL * 0;
	                    EURCHF_DOWN_S2_TP4 =  EURCHF_DOWN_S2_SL * 0;
	                    EURCHF_DOWN_S2_TP5 =  EURCHF_DOWN_S2_SL * 0;
	                    EURCHF_DOWN_S2_TP6 =  EURCHF_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURCHF_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURCHF_quantity_SL_DOWN_S2 = EURCHF_quantity_DOWN_S2;
	                    EURCHF_quantity_TP1_DOWN_S2 = (int)Math.Floor(EURCHF_quantity_DOWN_S2 * 1m);
	                    EURCHF_quantity_TP2_DOWN_S2 = (int)Math.Floor(EURCHF_quantity_TP1_DOWN_S2 * 0m);
	                    EURCHF_quantity_TP3_DOWN_S2 = (int)Math.Floor(EURCHF_quantity_TP2_DOWN_S2 * 0m);
	                    EURCHF_quantity_TP4_DOWN_S2 = (int)Math.Floor(EURCHF_quantity_TP3_DOWN_S2 * 0m);
	                    EURCHF_quantity_TP5_DOWN_S2 = (int)Math.Floor(EURCHF_quantity_TP4_DOWN_S2 * 0m);
	                    EURCHF_quantity_TP6_DOWN_S2 = (int)Math.Floor(EURCHF_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (EURCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURCHF_DOWN_S2 && 
	                    Base.EURCHF_OCO1_DOWN_S2_IsReady == true &&
	                    Base.EURCHF_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCHF_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP1_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP1_OCO1");
	                         Base.EURCHF_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.EURCHF_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP2_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP2_OCO1");
	                         Base.EURCHF_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.EURCHF_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP3_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP3_OCO1");
	                         Base.EURCHF_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.EURCHF_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP4_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP4_OCO1");
	                         Base.EURCHF_OCO1_EO4_DOWN_S2 = false;

							Base.EURCHF_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.EURCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (EURCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURCHF_DOWN_S2 && 
	                    Base.EURCHF_OCO2_DOWN_S2_IsReady == true &&
	                    Base.EURCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURCHF_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCHF_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP1_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP1_OCO2");
	                         Base.EURCHF_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.EURCHF_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP2_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP2_OCO2");
	                         Base.EURCHF_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.EURCHF_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP3_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP3_OCO2");
	                         Base.EURCHF_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.EURCHF_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP4_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP4_OCO2");
	                         Base.EURCHF_OCO2_EO4_DOWN_S2 = false;

							Base.EURCHF_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.EURCHF_OCO2_DOWN_S2_IsReady == false && Base.EURCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (EURCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURCHF_DOWN_S2 &&
	                    Base.EURCHF_OCO3_DOWN_S2_IsReady == true &&
	                    Base.EURCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURCHF_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCHF_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP1_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP1_OCO3");
	                         Base.EURCHF_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.EURCHF_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP2_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP2_OCO3");
	                         Base.EURCHF_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.EURCHF_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP3_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP3_OCO3");
	                         Base.EURCHF_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.EURCHF_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP4_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP4_OCO3");
	                         Base.EURCHF_OCO3_EO4_DOWN_S2 = false;

							Base.EURCHF_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.EURCHF_OCO3_DOWN_S2_IsReady == false && Base.EURCHF_OCO2_DOWN_S2_IsReady == false && Base.EURCHF_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (EURCHF_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURCHF_DOWN_S2 && 
	                    Base.EURCHF_OCO4_DOWN_S2_IsReady == true &&
	                    Base.EURCHF_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURCHF_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURCHF_OCO3_DOWN_S2_IsReady == false &&
	                    Base.EURCHF_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCHF_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP1_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP1_OCO4");
	                         Base.EURCHF_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.EURCHF_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP2_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP2_OCO4");
	                         Base.EURCHF_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.EURCHF_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP3_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP3_OCO4");
	                         Base.EURCHF_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.EURCHF_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURCHF_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP4_DOWN_S2, false,"EURCHF_DOWN_S2_Entry_TP4_OCO4");
	                         Base.EURCHF_OCO4_EO4_DOWN_S2 = false;

							Base.EURCHF_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.EURCHF_OCO4_DOWN_S2_IsReady == false && Base.EURCHF_OCO3_DOWN_S2_IsReady == false && Base.EURCHF_OCO2_DOWN_S2_IsReady == false && Base.EURCHF_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct EURNZD_OCO1_DOWN_S2
    {
        public EURNZD_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 =="TP1_EURNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD 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 =="TP1_EURNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURNZD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD 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 EURNZD_OCO1_UP_S2
    {
        public EURNZD_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 =="TP1_EURNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD 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 =="TP1_EURNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURNZD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURNZD 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 EURNZD_OCO2_DOWN_S2
    {
        public EURNZD_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 =="TP1_EURNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD 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 =="TP1_EURNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURNZD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD 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 EURNZD_OCO2_UP_S2
    {
        public EURNZD_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 =="TP1_EURNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD 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 =="TP1_EURNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURNZD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURNZD 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 EURNZD_OCO3_DOWN_S2
    {
        public EURNZD_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 =="TP1_EURNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD 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 =="TP1_EURNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURNZD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD 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 EURNZD_OCO3_UP_S2
    {
        public EURNZD_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 =="TP1_EURNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD 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 =="TP1_EURNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURNZD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURNZD 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 EURNZD_OCO4_DOWN_S2
    {
        public EURNZD_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 =="TP1_EURNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD 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 =="TP1_EURNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURNZD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD 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 EURNZD_OCO4_UP_S2
    {
        public EURNZD_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 =="TP1_EURNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD 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 =="TP1_EURNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURNZD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURNZD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURNZD 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURCHF_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURCHF_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(x=>x.Tag.Contains("EURCHF_UP_S2_OCO1")))
			{
				Base.EURCHF_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCHF_UP_S2_OCO2")))
			{
				Base.EURCHF_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCHF_UP_S2_OCO3")))
			{
				Base.EURCHF_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURCHF_UP_S2_OCO4")))
			{
				Base.EURCHF_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURCHF_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.EURCHF_OCO1_EO1_UP_S2)
	                Base.EURCHF_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.EURCHF_OCO1_EO2_UP_S2)
	                Base.EURCHF_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO1_EO3_UP_S2)
	                Base.EURCHF_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO1_EO4_UP_S2)
	                Base.EURCHF_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO1_EO5_UP_S2)
	                Base.EURCHF_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO1_EO6_UP_S2)
	                Base.EURCHF_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCHF_OCO1S1_UP_S2 = 0;
		                for (; EURCHF_OCO1S1_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets1.Count; EURCHF_OCO1S1_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO1Sets1[EURCHF_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO1Sets1[EURCHF_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_1__Time out_OCO1");
		                        Base.EURCHF_UP_S2_OCO1Sets1.Clear();
		                        EURCHF_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURCHF_OCO1S2_UP_S2 = 0;
		                for (; EURCHF_OCO1S2_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets2.Count; EURCHF_OCO1S2_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO1Sets2[EURCHF_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO1Sets2[EURCHF_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_2__Time out_OCO1");
		                        Base.EURCHF_UP_S2_OCO1Sets2.Clear();
		                        EURCHF_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO1S3_UP_S2 = 0;
		                for (; EURCHF_OCO1S3_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets3.Count; EURCHF_OCO1S3_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO1Sets3[EURCHF_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO1Sets3[EURCHF_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_3__Time out_OCO1");
		                        Base.EURCHF_UP_S2_OCO1Sets3.Clear();
		                        EURCHF_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO1S4_UP_S2 = 0;
		                for (; EURCHF_OCO1S4_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets4.Count; EURCHF_OCO1S4_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO1Sets4[EURCHF_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO1Sets4[EURCHF_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_4__Time out_OCO1");
		                        Base.EURCHF_UP_S2_OCO1Sets4.Clear();
		                        EURCHF_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO1S5_UP_S2 = 0;
		                for (; EURCHF_OCO1S5_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets5.Count; EURCHF_OCO1S5_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO1Sets5[EURCHF_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO1Sets5[EURCHF_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_5__Time out_OCO1");
		                        Base.EURCHF_UP_S2_OCO1Sets5.Clear();
		                        EURCHF_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO1S6_UP_S2 = 0;
		                for (; EURCHF_OCO1S6_UP_S2 < Base.EURCHF_UP_S2_OCO1Sets6.Count; EURCHF_OCO1S6_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO1Sets6[EURCHF_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO1Sets6[EURCHF_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_6__Time out_OCO1");
		                        Base.EURCHF_UP_S2_OCO1Sets6.Clear();
		                        EURCHF_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURCHF_OCO2_EO1_UP_S2)
                	Base.EURCHF_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.EURCHF_OCO2_EO2_UP_S2)
	                Base.EURCHF_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO2_EO3_UP_S2)
	                Base.EURCHF_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO2_EO4_UP_S2)
	                Base.EURCHF_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO2_EO5_UP_S2)
	                Base.EURCHF_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO2_EO6_UP_S2)
	                Base.EURCHF_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCHF_OCO2S1_UP_S2 = 0;
		                for (; EURCHF_OCO2S1_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets1.Count; EURCHF_OCO2S1_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO2Sets1[EURCHF_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO2Sets1[EURCHF_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_1__Time out_OCO2");
		                        Base.EURCHF_UP_S2_OCO2Sets1.Clear();
		                        EURCHF_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURCHF_OCO2S2_UP_S2 = 0;
		                for (; EURCHF_OCO2S2_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets2.Count; EURCHF_OCO2S2_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO2Sets2[EURCHF_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO2Sets2[EURCHF_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_2__Time out_OCO2");
		                        Base.EURCHF_UP_S2_OCO2Sets2.Clear();
		                        EURCHF_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO2S3_UP_S2 = 0;
		                for (; EURCHF_OCO2S3_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets3.Count; EURCHF_OCO2S3_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO2Sets3[EURCHF_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO2Sets3[EURCHF_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_3__Time out_OCO2");
		                        Base.EURCHF_UP_S2_OCO2Sets3.Clear();
		                        EURCHF_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO2S4_UP_S2 = 0;
		                for (; EURCHF_OCO2S4_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets4.Count; EURCHF_OCO2S4_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO2Sets4[EURCHF_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO2Sets4[EURCHF_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_4__Time out_OCO2");
		                        Base.EURCHF_UP_S2_OCO2Sets4.Clear();
		                        EURCHF_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO2S5_UP_S2 = 0;
		                for (; EURCHF_OCO2S5_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets5.Count; EURCHF_OCO2S5_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO2Sets5[EURCHF_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO2Sets5[EURCHF_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_5__Time out_OCO2");
		                        Base.EURCHF_UP_S2_OCO2Sets5.Clear();
		                        EURCHF_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO2S6_UP_S2 = 0;
		                for (; EURCHF_OCO2S6_UP_S2 < Base.EURCHF_UP_S2_OCO2Sets6.Count; EURCHF_OCO2S6_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO2Sets6[EURCHF_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO2Sets6[EURCHF_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_6__Time out_OCO2");
		                        Base.EURCHF_UP_S2_OCO2Sets6.Clear();
		                        EURCHF_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURCHF_OCO3_EO1_UP_S2)
            		Base.EURCHF_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.EURCHF_OCO3_EO2_UP_S2)
	                Base.EURCHF_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO3_EO3_UP_S2)
	                Base.EURCHF_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO3_EO4_UP_S2)
	                Base.EURCHF_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO3_EO5_UP_S2)
	                Base.EURCHF_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO3_EO6_UP_S2)
	                Base.EURCHF_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCHF_OCO3S1_UP_S2 = 0;
		                for (; EURCHF_OCO3S1_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets1.Count; EURCHF_OCO3S1_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO3Sets1[EURCHF_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO3Sets1[EURCHF_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_1__Time out_OCO3");
		                        Base.EURCHF_UP_S2_OCO3Sets1.Clear();
		                        EURCHF_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURCHF_OCO3S2_UP_S2 = 0;
		                for (; EURCHF_OCO3S2_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets2.Count; EURCHF_OCO3S2_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO3Sets2[EURCHF_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO3Sets2[EURCHF_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_2__Time out_OCO3");
		                        Base.EURCHF_UP_S2_OCO3Sets2.Clear();
		                        EURCHF_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO3S3_UP_S2 = 0;
		                for (; EURCHF_OCO3S3_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets3.Count; EURCHF_OCO3S3_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO3Sets3[EURCHF_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO3Sets3[EURCHF_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_3__Time out_OCO3");
		                        Base.EURCHF_UP_S2_OCO3Sets3.Clear();
		                        EURCHF_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO3S4_UP_S2 = 0;
		                for (; EURCHF_OCO3S4_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets4.Count; EURCHF_OCO3S4_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO3Sets4[EURCHF_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO3Sets4[EURCHF_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_4__Time out_OCO3");
		                        Base.EURCHF_UP_S2_OCO3Sets4.Clear();
		                        EURCHF_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO3S5_UP_S2 = 0;
		                for (; EURCHF_OCO3S5_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets5.Count; EURCHF_OCO3S5_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO3Sets5[EURCHF_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO3Sets5[EURCHF_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_5__Time out_OCO3");
		                        Base.EURCHF_UP_S2_OCO3Sets5.Clear();
		                        EURCHF_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO3S6_UP_S2 = 0;
		                for (; EURCHF_OCO3S6_UP_S2 < Base.EURCHF_UP_S2_OCO3Sets6.Count; EURCHF_OCO3S6_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO3Sets6[EURCHF_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO3Sets6[EURCHF_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_6__Time out_OCO3");
		                        Base.EURCHF_UP_S2_OCO3Sets6.Clear();
		                        EURCHF_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURCHF_OCO4_EO1_UP_S2)
            		Base.EURCHF_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.EURCHF_OCO4_EO2_UP_S2)
	                Base.EURCHF_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO4_EO3_UP_S2)
	                Base.EURCHF_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO4_EO4_UP_S2)
	                Base.EURCHF_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO4_EO5_UP_S2)
	                Base.EURCHF_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURCHF_OCO4_EO6_UP_S2)
	                Base.EURCHF_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURCHF_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURCHF_OCO4S1_UP_S2 = 0;
		                for (; EURCHF_OCO4S1_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets1.Count; EURCHF_OCO4S1_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO4Sets1[EURCHF_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO4Sets1[EURCHF_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_1__Time out_OCO4");
		                        Base.EURCHF_UP_S2_OCO4Sets1.Clear();
		                        EURCHF_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURCHF_OCO4S2_UP_S2 = 0;
		                for (; EURCHF_OCO4S2_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets2.Count; EURCHF_OCO4S2_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO4Sets2[EURCHF_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO4Sets2[EURCHF_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_2__Time out_OCO4");
		                        Base.EURCHF_UP_S2_OCO4Sets2.Clear();
		                        EURCHF_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO4S3_UP_S2 = 0;
		                for (; EURCHF_OCO4S3_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets3.Count; EURCHF_OCO4S3_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO4Sets3[EURCHF_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO4Sets3[EURCHF_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_3__Time out_OCO4");
		                        Base.EURCHF_UP_S2_OCO4Sets3.Clear();
		                        EURCHF_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURCHF_OCO4S4_UP_S2 = 0;
		                for (; EURCHF_OCO4S4_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets4.Count; EURCHF_OCO4S4_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO4Sets4[EURCHF_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO4Sets4[EURCHF_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_4__Time out_OCO4");
		                        Base.EURCHF_UP_S2_OCO4Sets4.Clear();
		                        EURCHF_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO4S5_UP_S2 = 0;
		                for (; EURCHF_OCO4S5_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets5.Count; EURCHF_OCO4S5_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO4Sets5[EURCHF_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO4Sets5[EURCHF_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_5__Time out_OCO4");
		                        Base.EURCHF_UP_S2_OCO4Sets5.Clear();
		                        EURCHF_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURCHF_OCO4S6_UP_S2 = 0;
		                for (; EURCHF_OCO4S6_UP_S2 < Base.EURCHF_UP_S2_OCO4Sets6.Count; EURCHF_OCO4S6_UP_S2++)
		                    if (Base.EURCHF_UP_S2_OCO4Sets6[EURCHF_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURCHF_UP_S2_OCO4Sets6[EURCHF_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURCHF", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURCHF", order.Quantity, false, "EURCHF_UP_S2_Entry_6__Time out_OCO4");
		                        Base.EURCHF_UP_S2_OCO4Sets6.Clear();
		                        EURCHF_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_EURCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURCHF_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURCHF_UP_S2 = DOWM_EURCHF_UP_S2 || DOWT_EURCHF_UP_S2 || DOWW_EURCHF_UP_S2 || DOWTH_EURCHF_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURCHF"))
	            	{
	            		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.EURCHF_OCO1_UP_S2_IsReady == false ||
	                    	Base.EURCHF_OCO2_UP_S2_IsReady == false ||
	                    	Base.EURCHF_OCO3_UP_S2_IsReady == false ||
	                    	Base.EURCHF_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.EURCHF_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.EURCHF_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.EURCHF_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.EURCHF_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURCHF_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.EURCHF_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.EURCHF_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.EURCHF_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	EURCHF_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											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.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                							
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	EURCHF_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	EURCHF_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
		
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (EURCHF_Signal_Condition_UP_1)
	                	{
	                    	EURCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURCHF_Signal_Condition_UP_2)
	                	{
	                    	EURCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURCHF_Signal_Condition_UP_3)
	                	{
	                    	EURCHF_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (EURCHF_Signal_Condition_UP_1)
	                	{
	                    	EURCHF_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (EURCHF_Signal_Condition_UP_2)
	                	{
	                    	EURCHF_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (EURCHF_Signal_Condition_UP_3)
	                	{
	                    	EURCHF_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    EURCHF_UP_S2_TP2 =  EURCHF_UP_S2_SL * 0;
	                    EURCHF_UP_S2_TP3 =  EURCHF_UP_S2_SL * 0;
	                    EURCHF_UP_S2_TP4 =  EURCHF_UP_S2_SL * 0;
	                    EURCHF_UP_S2_TP5 =  EURCHF_UP_S2_SL * 0;
	                    EURCHF_UP_S2_TP6 =  EURCHF_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURCHF_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURCHF_quantity_SL_UP_S2 = EURCHF_quantity_UP_S2;
	                    EURCHF_quantity_TP1_UP_S2 = (int)Math.Floor(EURCHF_quantity_UP_S2 * 1m);
	                    EURCHF_quantity_TP2_UP_S2 = (int)Math.Floor(EURCHF_quantity_TP1_UP_S2 * 0m);
	                    EURCHF_quantity_TP3_UP_S2 = (int)Math.Floor(EURCHF_quantity_TP2_UP_S2 * 0m);
	                    EURCHF_quantity_TP4_UP_S2 = (int)Math.Floor(EURCHF_quantity_TP3_UP_S2 * 0m);
	                    EURCHF_quantity_TP5_UP_S2 = (int)Math.Floor(EURCHF_quantity_TP4_UP_S2 * 0m);
	                    EURCHF_quantity_TP6_UP_S2 = (int)Math.Floor(EURCHF_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((EURCHF_Signal_Condition_UP_1 || EURCHF_Signal_Condition_UP_2 || EURCHF_Signal_Condition_UP_3)  && 
	                    DOWR_EURCHF_UP_S2 && 
	                    Base.EURCHF_OCO1_UP_S2_IsReady == true &&
	                    Base.EURCHF_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCHF_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP1_UP_S2, false,"EURCHF_UP_S2_Entry_TP1_OCO1");
	                         Base.EURCHF_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.EURCHF_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP2_UP_S2, false,"EURCHF_UP_S2_Entry_TP2_OCO1");
	                         Base.EURCHF_OCO1_EO2_UP_S2 = false;
	
	                         Base.EURCHF_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP3_UP_S2, false,"EURCHF_UP_S2_Entry_TP3_OCO1");
	                         Base.EURCHF_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.EURCHF_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP4_UP_S2, false,"EURCHF_UP_S2_Entry_TP4_OCO1");
	                         Base.EURCHF_OCO1_EO4_UP_S2 = false;

							Base.EURCHF_OCO1_UP_S2_IsReady = false;
							
							if (Base.EURCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((EURCHF_Signal_Condition_UP_1 || EURCHF_Signal_Condition_UP_2 || EURCHF_Signal_Condition_UP_3)  && 
	                    DOWR_EURCHF_UP_S2 && 
	                    Base.EURCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.EURCHF_OCO2_UP_S2_IsReady == true &&
	                    Base.EURCHF_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCHF_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP1_UP_S2, false,"EURCHF_UP_S2_Entry_TP1_OCO2");
	                         Base.EURCHF_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.EURCHF_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP2_UP_S2, false,"EURCHF_UP_S2_Entry_TP2_OCO2");
	                         Base.EURCHF_OCO2_EO2_UP_S2 = false;
	
	                         Base.EURCHF_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP3_UP_S2, false,"EURCHF_UP_S2_Entry_TP3_OCO2");
	                         Base.EURCHF_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.EURCHF_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP4_UP_S2, false,"EURCHF_UP_S2_Entry_TP4_OCO2");
	                         Base.EURCHF_OCO2_EO4_UP_S2 = false;

							Base.EURCHF_OCO2_UP_S2_IsReady = false;
							
							if (Base.EURCHF_OCO2_UP_S2_IsReady == false && Base.EURCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((EURCHF_Signal_Condition_UP_1 || EURCHF_Signal_Condition_UP_2 || EURCHF_Signal_Condition_UP_3)  && 
	                    DOWR_EURCHF_UP_S2 &&
	                    Base.EURCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.EURCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.EURCHF_OCO3_UP_S2_IsReady == true &&
	                    Base.EURCHF_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCHF_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP1_UP_S2, false,"EURCHF_UP_S2_Entry_TP1_OCO3");
	                         Base.EURCHF_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.EURCHF_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP2_UP_S2, false,"EURCHF_UP_S2_Entry_TP2_OCO3");
	                         Base.EURCHF_OCO3_EO2_UP_S2 = false;
	
	                         Base.EURCHF_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP3_UP_S2, false,"EURCHF_UP_S2_Entry_TP3_OCO3");
	                         Base.EURCHF_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.EURCHF_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP4_UP_S2, false,"EURCHF_UP_S2_Entry_TP4_OCO3");
	                         Base.EURCHF_OCO3_EO4_UP_S2 = false;

							Base.EURCHF_OCO3_UP_S2_IsReady = false;
							
							if (Base.EURCHF_OCO3_UP_S2_IsReady == false && Base.EURCHF_OCO2_UP_S2_IsReady == false && Base.EURCHF_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((EURCHF_Signal_Condition_UP_1 || EURCHF_Signal_Condition_UP_2 || EURCHF_Signal_Condition_UP_3)  && 
	                    DOWR_EURCHF_UP_S2 && 
	                    Base.EURCHF_OCO1_UP_S2_IsReady == false &&
	                    Base.EURCHF_OCO2_UP_S2_IsReady == false &&
	                    Base.EURCHF_OCO3_UP_S2_IsReady == false &&
	                    Base.EURCHF_OCO4_UP_S2_IsReady == true &&
	                    Base.EURCHF_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURCHF_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP1_UP_S2, false,"EURCHF_UP_S2_Entry_TP1_OCO4");
	                         Base.EURCHF_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.EURCHF_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP2_UP_S2, false,"EURCHF_UP_S2_Entry_TP2_OCO4");
	                         Base.EURCHF_OCO4_EO2_UP_S2 = false;
	
	                         Base.EURCHF_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP3_UP_S2, false,"EURCHF_UP_S2_Entry_TP3_OCO4");
	                         Base.EURCHF_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.EURCHF_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURCHF_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURCHF_quantity_TP4_UP_S2, false,"EURCHF_UP_S2_Entry_TP4_OCO4");
	                         Base.EURCHF_OCO4_EO4_UP_S2 = false;

							Base.EURCHF_OCO4_UP_S2_IsReady = false;
							
							if (Base.EURCHF_OCO4_UP_S2_IsReady == false && Base.EURCHF_OCO3_UP_S2_IsReady == false && Base.EURCHF_OCO2_UP_S2_IsReady == false && Base.EURCHF_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 _USDCHF;
		
    	///oco1 up
    	public static OrderTicket USDCHF_OCO1_MO1_UP_S2;
    	public static OrderTicket USDCHF_OCO1_MO2_UP_S2;
    	public static OrderTicket USDCHF_OCO1_MO3_UP_S2;
    	public static OrderTicket USDCHF_OCO1_MO4_UP_S2;
    	public static OrderTicket USDCHF_OCO1_MO5_UP_S2;
    	public static OrderTicket USDCHF_OCO1_MO6_UP_S2;
    	
    	public static int USDCHF_OCO1_EO1_UP_S2_ID ;
        public static int USDCHF_OCO1_EO2_UP_S2_ID ;
        public static int USDCHF_OCO1_EO3_UP_S2_ID ;
        public static int USDCHF_OCO1_EO4_UP_S2_ID ;
        public static int USDCHF_OCO1_EO5_UP_S2_ID ;
        public static int USDCHF_OCO1_EO6_UP_S2_ID ;
        
        public static bool USDCHF_OCO1_EO1_UP_S2 ;
        public static bool USDCHF_OCO1_EO2_UP_S2 ;
        public static bool USDCHF_OCO1_EO3_UP_S2 ;
        public static bool USDCHF_OCO1_EO4_UP_S2 ;
        public static bool USDCHF_OCO1_EO5_UP_S2 ;
        public static bool USDCHF_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_UP_S2> USDCHF_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_UP_S2> USDCHF_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_UP_S2> USDCHF_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_UP_S2> USDCHF_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_UP_S2> USDCHF_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_UP_S2> USDCHF_OOFE_OCO1_UP_S2_6 ;
        
        public static USDCHF_OCO1_UP_S2 USDCHF_PFO_OCO1_UP_S2_1 ;
        public static USDCHF_OCO1_UP_S2 USDCHF_PFO_OCO1_UP_S2_2 ;
        public static USDCHF_OCO1_UP_S2 USDCHF_PFO_OCO1_UP_S2_3 ;
        public static USDCHF_OCO1_UP_S2 USDCHF_PFO_OCO1_UP_S2_4 ;
        public static USDCHF_OCO1_UP_S2 USDCHF_PFO_OCO1_UP_S2_5 ;
        public static USDCHF_OCO1_UP_S2 USDCHF_PFO_OCO1_UP_S2_6 ;
        
        public static List<USDCHF_OCO1_UP_S2> USDCHF_UP_S2_OCO1Sets1 = new List<USDCHF_OCO1_UP_S2>();
        public static List<USDCHF_OCO1_UP_S2> USDCHF_UP_S2_OCO1Sets2 = new List<USDCHF_OCO1_UP_S2>();
        public static List<USDCHF_OCO1_UP_S2> USDCHF_UP_S2_OCO1Sets3 = new List<USDCHF_OCO1_UP_S2>();
        public static List<USDCHF_OCO1_UP_S2> USDCHF_UP_S2_OCO1Sets4 = new List<USDCHF_OCO1_UP_S2>();
        public static List<USDCHF_OCO1_UP_S2> USDCHF_UP_S2_OCO1Sets5 = new List<USDCHF_OCO1_UP_S2>();
        public static List<USDCHF_OCO1_UP_S2> USDCHF_UP_S2_OCO1Sets6 = new List<USDCHF_OCO1_UP_S2>();
        
        public static bool USDCHF_OCO1_UP_S2_IsReady = true;
        public static bool USDCHF_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket USDCHF_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO1_MO6_DOWN_S2 ;
    	
    	public static int USDCHF_OCO1_EO1_DOWN_S2_ID ;
        public static int USDCHF_OCO1_EO2_DOWN_S2_ID ;
        public static int USDCHF_OCO1_EO3_DOWN_S2_ID ;
        public static int USDCHF_OCO1_EO4_DOWN_S2_ID ;
        public static int USDCHF_OCO1_EO5_DOWN_S2_ID ;
        public static int USDCHF_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool USDCHF_OCO1_EO1_DOWN_S2 ;
        public static bool USDCHF_OCO1_EO2_DOWN_S2 ;
        public static bool USDCHF_OCO1_EO3_DOWN_S2 ;
        public static bool USDCHF_OCO1_EO4_DOWN_S2 ;
        public static bool USDCHF_OCO1_EO5_DOWN_S2 ;
        public static bool USDCHF_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_DOWN_S2> USDCHF_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_DOWN_S2> USDCHF_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_DOWN_S2> USDCHF_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_DOWN_S2> USDCHF_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_DOWN_S2> USDCHF_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO1_DOWN_S2> USDCHF_OOFE_OCO1_DOWN_S2_6 ;
        
        public static USDCHF_OCO1_DOWN_S2 USDCHF_PFO_OCO1_DOWN_S2_1 ;
        public static USDCHF_OCO1_DOWN_S2 USDCHF_PFO_OCO1_DOWN_S2_2 ;
        public static USDCHF_OCO1_DOWN_S2 USDCHF_PFO_OCO1_DOWN_S2_3 ;
        public static USDCHF_OCO1_DOWN_S2 USDCHF_PFO_OCO1_DOWN_S2_4 ;
        public static USDCHF_OCO1_DOWN_S2 USDCHF_PFO_OCO1_DOWN_S2_5 ;
        public static USDCHF_OCO1_DOWN_S2 USDCHF_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<USDCHF_OCO1_DOWN_S2> USDCHF_DOWN_S2_OCO1Sets1 = new List<USDCHF_OCO1_DOWN_S2>();
        public static List<USDCHF_OCO1_DOWN_S2> USDCHF_DOWN_S2_OCO1Sets2 = new List<USDCHF_OCO1_DOWN_S2>();
        public static List<USDCHF_OCO1_DOWN_S2> USDCHF_DOWN_S2_OCO1Sets3 = new List<USDCHF_OCO1_DOWN_S2>();
        public static List<USDCHF_OCO1_DOWN_S2> USDCHF_DOWN_S2_OCO1Sets4 = new List<USDCHF_OCO1_DOWN_S2>();
        public static List<USDCHF_OCO1_DOWN_S2> USDCHF_DOWN_S2_OCO1Sets5 = new List<USDCHF_OCO1_DOWN_S2>();
        public static List<USDCHF_OCO1_DOWN_S2> USDCHF_DOWN_S2_OCO1Sets6 = new List<USDCHF_OCO1_DOWN_S2>();
        
        public static bool USDCHF_OCO1_DOWN_S2_IsReady = true;
        public static bool USDCHF_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket USDCHF_OCO2_MO1_UP_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO2_UP_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO3_UP_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO4_UP_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO5_UP_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO6_UP_S2 ;
    	
    	public static int USDCHF_OCO2_EO1_UP_S2_ID ;
        public static int USDCHF_OCO2_EO2_UP_S2_ID ;
        public static int USDCHF_OCO2_EO3_UP_S2_ID ;
        public static int USDCHF_OCO2_EO4_UP_S2_ID ;
        public static int USDCHF_OCO2_EO5_UP_S2_ID ;
        public static int USDCHF_OCO2_EO6_UP_S2_ID ;
        
        public static bool USDCHF_OCO2_EO1_UP_S2 ;
        public static bool USDCHF_OCO2_EO2_UP_S2 ;
        public static bool USDCHF_OCO2_EO3_UP_S2 ;
        public static bool USDCHF_OCO2_EO4_UP_S2 ;
        public static bool USDCHF_OCO2_EO5_UP_S2 ;
        public static bool USDCHF_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_UP_S2> USDCHF_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_UP_S2> USDCHF_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_UP_S2> USDCHF_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_UP_S2> USDCHF_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_UP_S2> USDCHF_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_UP_S2> USDCHF_OOFE_OCO2_UP_S2_6 ;
        
        public static USDCHF_OCO2_UP_S2 USDCHF_PFO_OCO2_UP_S2_1 ;
        public static USDCHF_OCO2_UP_S2 USDCHF_PFO_OCO2_UP_S2_2 ;
        public static USDCHF_OCO2_UP_S2 USDCHF_PFO_OCO2_UP_S2_3 ;
        public static USDCHF_OCO2_UP_S2 USDCHF_PFO_OCO2_UP_S2_4 ;
        public static USDCHF_OCO2_UP_S2 USDCHF_PFO_OCO2_UP_S2_5 ;
        public static USDCHF_OCO2_UP_S2 USDCHF_PFO_OCO2_UP_S2_6 ;
        
        public static List<USDCHF_OCO2_UP_S2> USDCHF_UP_S2_OCO2Sets1 = new List<USDCHF_OCO2_UP_S2>();
        public static List<USDCHF_OCO2_UP_S2> USDCHF_UP_S2_OCO2Sets2 = new List<USDCHF_OCO2_UP_S2>();
        public static List<USDCHF_OCO2_UP_S2> USDCHF_UP_S2_OCO2Sets3 = new List<USDCHF_OCO2_UP_S2>();
        public static List<USDCHF_OCO2_UP_S2> USDCHF_UP_S2_OCO2Sets4 = new List<USDCHF_OCO2_UP_S2>();
        public static List<USDCHF_OCO2_UP_S2> USDCHF_UP_S2_OCO2Sets5 = new List<USDCHF_OCO2_UP_S2>();
        public static List<USDCHF_OCO2_UP_S2> USDCHF_UP_S2_OCO2Sets6 = new List<USDCHF_OCO2_UP_S2>();
        
        public static bool USDCHF_OCO2_UP_S2_IsReady = true;
        public static bool USDCHF_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket USDCHF_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO2_MO6_DOWN_S2 ;
    	
    	public static int USDCHF_OCO2_EO1_DOWN_S2_ID ;
        public static int USDCHF_OCO2_EO2_DOWN_S2_ID ;
        public static int USDCHF_OCO2_EO3_DOWN_S2_ID ;
        public static int USDCHF_OCO2_EO4_DOWN_S2_ID ;
        public static int USDCHF_OCO2_EO5_DOWN_S2_ID ;
        public static int USDCHF_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool USDCHF_OCO2_EO1_DOWN_S2 ;
        public static bool USDCHF_OCO2_EO2_DOWN_S2 ;
        public static bool USDCHF_OCO2_EO3_DOWN_S2 ;
        public static bool USDCHF_OCO2_EO4_DOWN_S2 ;
        public static bool USDCHF_OCO2_EO5_DOWN_S2 ;
        public static bool USDCHF_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_DOWN_S2> USDCHF_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_DOWN_S2> USDCHF_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_DOWN_S2> USDCHF_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_DOWN_S2> USDCHF_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_DOWN_S2> USDCHF_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO2_DOWN_S2> USDCHF_OOFE_OCO2_DOWN_S2_6 ;
        
        public static USDCHF_OCO2_DOWN_S2 USDCHF_PFO_OCO2_DOWN_S2_1 ;
        public static USDCHF_OCO2_DOWN_S2 USDCHF_PFO_OCO2_DOWN_S2_2 ;
        public static USDCHF_OCO2_DOWN_S2 USDCHF_PFO_OCO2_DOWN_S2_3 ;
        public static USDCHF_OCO2_DOWN_S2 USDCHF_PFO_OCO2_DOWN_S2_4 ;
        public static USDCHF_OCO2_DOWN_S2 USDCHF_PFO_OCO2_DOWN_S2_5 ;
        public static USDCHF_OCO2_DOWN_S2 USDCHF_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<USDCHF_OCO2_DOWN_S2> USDCHF_DOWN_S2_OCO2Sets1 = new List<USDCHF_OCO2_DOWN_S2>();
        public static List<USDCHF_OCO2_DOWN_S2> USDCHF_DOWN_S2_OCO2Sets2 = new List<USDCHF_OCO2_DOWN_S2>();
        public static List<USDCHF_OCO2_DOWN_S2> USDCHF_DOWN_S2_OCO2Sets3 = new List<USDCHF_OCO2_DOWN_S2>();
        public static List<USDCHF_OCO2_DOWN_S2> USDCHF_DOWN_S2_OCO2Sets4 = new List<USDCHF_OCO2_DOWN_S2>();
        public static List<USDCHF_OCO2_DOWN_S2> USDCHF_DOWN_S2_OCO2Sets5 = new List<USDCHF_OCO2_DOWN_S2>();
        public static List<USDCHF_OCO2_DOWN_S2> USDCHF_DOWN_S2_OCO2Sets6 = new List<USDCHF_OCO2_DOWN_S2>();
        
        public static bool USDCHF_OCO2_DOWN_S2_IsReady = true;
        public static bool USDCHF_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket USDCHF_OCO3_MO1_UP_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO2_UP_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO3_UP_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO4_UP_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO5_UP_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO6_UP_S2 ;
    	
    	public static int USDCHF_OCO3_EO1_UP_S2_ID ;
        public static int USDCHF_OCO3_EO2_UP_S2_ID ;
        public static int USDCHF_OCO3_EO3_UP_S2_ID ;
        public static int USDCHF_OCO3_EO4_UP_S2_ID ;
        public static int USDCHF_OCO3_EO5_UP_S2_ID ;
        public static int USDCHF_OCO3_EO6_UP_S2_ID ;
        
        public static bool USDCHF_OCO3_EO1_UP_S2 ;
        public static bool USDCHF_OCO3_EO2_UP_S2 ;
        public static bool USDCHF_OCO3_EO3_UP_S2 ;
        public static bool USDCHF_OCO3_EO4_UP_S2 ;
        public static bool USDCHF_OCO3_EO5_UP_S2 ;
        public static bool USDCHF_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_UP_S2> USDCHF_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_UP_S2> USDCHF_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_UP_S2> USDCHF_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_UP_S2> USDCHF_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_UP_S2> USDCHF_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_UP_S2> USDCHF_OOFE_OCO3_UP_S2_6 ;
        
        public static USDCHF_OCO3_UP_S2 USDCHF_PFO_OCO3_UP_S2_1 ;
        public static USDCHF_OCO3_UP_S2 USDCHF_PFO_OCO3_UP_S2_2 ;
        public static USDCHF_OCO3_UP_S2 USDCHF_PFO_OCO3_UP_S2_3 ;
        public static USDCHF_OCO3_UP_S2 USDCHF_PFO_OCO3_UP_S2_4 ;
        public static USDCHF_OCO3_UP_S2 USDCHF_PFO_OCO3_UP_S2_5 ;
        public static USDCHF_OCO3_UP_S2 USDCHF_PFO_OCO3_UP_S2_6 ;
        
        public static List<USDCHF_OCO3_UP_S2> USDCHF_UP_S2_OCO3Sets1 = new List<USDCHF_OCO3_UP_S2>();
        public static List<USDCHF_OCO3_UP_S2> USDCHF_UP_S2_OCO3Sets2 = new List<USDCHF_OCO3_UP_S2>();
        public static List<USDCHF_OCO3_UP_S2> USDCHF_UP_S2_OCO3Sets3 = new List<USDCHF_OCO3_UP_S2>();
        public static List<USDCHF_OCO3_UP_S2> USDCHF_UP_S2_OCO3Sets4 = new List<USDCHF_OCO3_UP_S2>();
        public static List<USDCHF_OCO3_UP_S2> USDCHF_UP_S2_OCO3Sets5 = new List<USDCHF_OCO3_UP_S2>();
        public static List<USDCHF_OCO3_UP_S2> USDCHF_UP_S2_OCO3Sets6 = new List<USDCHF_OCO3_UP_S2>();
        
        public static bool USDCHF_OCO3_UP_S2_IsReady = true;
        public static bool USDCHF_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket USDCHF_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO3_MO6_DOWN_S2 ;
    	
    	public static int USDCHF_OCO3_EO1_DOWN_S2_ID ;
        public static int USDCHF_OCO3_EO2_DOWN_S2_ID ;
        public static int USDCHF_OCO3_EO3_DOWN_S2_ID ;
        public static int USDCHF_OCO3_EO4_DOWN_S2_ID ;
        public static int USDCHF_OCO3_EO5_DOWN_S2_ID ;
        public static int USDCHF_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool USDCHF_OCO3_EO1_DOWN_S2 ;
        public static bool USDCHF_OCO3_EO2_DOWN_S2 ;
        public static bool USDCHF_OCO3_EO3_DOWN_S2 ;
        public static bool USDCHF_OCO3_EO4_DOWN_S2 ;
        public static bool USDCHF_OCO3_EO5_DOWN_S2 ;
        public static bool USDCHF_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_DOWN_S2> USDCHF_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_DOWN_S2> USDCHF_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_DOWN_S2> USDCHF_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_DOWN_S2> USDCHF_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_DOWN_S2> USDCHF_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO3_DOWN_S2> USDCHF_OOFE_OCO3_DOWN_S2_6 ;
        
        public static USDCHF_OCO3_DOWN_S2 USDCHF_PFO_OCO3_DOWN_S2_1 ;
        public static USDCHF_OCO3_DOWN_S2 USDCHF_PFO_OCO3_DOWN_S2_2 ;
        public static USDCHF_OCO3_DOWN_S2 USDCHF_PFO_OCO3_DOWN_S2_3 ;
        public static USDCHF_OCO3_DOWN_S2 USDCHF_PFO_OCO3_DOWN_S2_4 ;
        public static USDCHF_OCO3_DOWN_S2 USDCHF_PFO_OCO3_DOWN_S2_5 ;
        public static USDCHF_OCO3_DOWN_S2 USDCHF_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<USDCHF_OCO3_DOWN_S2> USDCHF_DOWN_S2_OCO3Sets1 = new List<USDCHF_OCO3_DOWN_S2>();
        public static List<USDCHF_OCO3_DOWN_S2> USDCHF_DOWN_S2_OCO3Sets2 = new List<USDCHF_OCO3_DOWN_S2>();
        public static List<USDCHF_OCO3_DOWN_S2> USDCHF_DOWN_S2_OCO3Sets3 = new List<USDCHF_OCO3_DOWN_S2>();
        public static List<USDCHF_OCO3_DOWN_S2> USDCHF_DOWN_S2_OCO3Sets4 = new List<USDCHF_OCO3_DOWN_S2>();
        public static List<USDCHF_OCO3_DOWN_S2> USDCHF_DOWN_S2_OCO3Sets5 = new List<USDCHF_OCO3_DOWN_S2>();
        public static List<USDCHF_OCO3_DOWN_S2> USDCHF_DOWN_S2_OCO3Sets6 = new List<USDCHF_OCO3_DOWN_S2>();
        
        public static bool USDCHF_OCO3_DOWN_S2_IsReady = true;
        public static bool USDCHF_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket USDCHF_OCO4_MO1_UP_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO2_UP_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO3_UP_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO4_UP_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO5_UP_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO6_UP_S2 ;
    	
    	public static int USDCHF_OCO4_EO1_UP_S2_ID ;
        public static int USDCHF_OCO4_EO2_UP_S2_ID ;
        public static int USDCHF_OCO4_EO3_UP_S2_ID ;
        public static int USDCHF_OCO4_EO4_UP_S2_ID ;
        public static int USDCHF_OCO4_EO5_UP_S2_ID ;
        public static int USDCHF_OCO4_EO6_UP_S2_ID ;
        
        public static bool USDCHF_OCO4_EO1_UP_S2 ;
        public static bool USDCHF_OCO4_EO2_UP_S2 ;
        public static bool USDCHF_OCO4_EO3_UP_S2 ;
        public static bool USDCHF_OCO4_EO4_UP_S2 ;
        public static bool USDCHF_OCO4_EO5_UP_S2 ;
        public static bool USDCHF_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_UP_S2> USDCHF_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_UP_S2> USDCHF_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_UP_S2> USDCHF_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_UP_S2> USDCHF_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_UP_S2> USDCHF_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_UP_S2> USDCHF_OOFE_OCO4_UP_S2_6 ;
        
        public static USDCHF_OCO4_UP_S2 USDCHF_PFO_OCO4_UP_S2_1 ;
        public static USDCHF_OCO4_UP_S2 USDCHF_PFO_OCO4_UP_S2_2 ;
        public static USDCHF_OCO4_UP_S2 USDCHF_PFO_OCO4_UP_S2_3 ;
        public static USDCHF_OCO4_UP_S2 USDCHF_PFO_OCO4_UP_S2_4 ;
        public static USDCHF_OCO4_UP_S2 USDCHF_PFO_OCO4_UP_S2_5 ;
        public static USDCHF_OCO4_UP_S2 USDCHF_PFO_OCO4_UP_S2_6 ;
        
        public static List<USDCHF_OCO4_UP_S2> USDCHF_UP_S2_OCO4Sets1 = new List<USDCHF_OCO4_UP_S2>();
        public static List<USDCHF_OCO4_UP_S2> USDCHF_UP_S2_OCO4Sets2 = new List<USDCHF_OCO4_UP_S2>();
        public static List<USDCHF_OCO4_UP_S2> USDCHF_UP_S2_OCO4Sets3 = new List<USDCHF_OCO4_UP_S2>();
        public static List<USDCHF_OCO4_UP_S2> USDCHF_UP_S2_OCO4Sets4 = new List<USDCHF_OCO4_UP_S2>();
        public static List<USDCHF_OCO4_UP_S2> USDCHF_UP_S2_OCO4Sets5 = new List<USDCHF_OCO4_UP_S2>();
        public static List<USDCHF_OCO4_UP_S2> USDCHF_UP_S2_OCO4Sets6 = new List<USDCHF_OCO4_UP_S2>();
        
        public static bool USDCHF_OCO4_UP_S2_IsReady = true;
        public static bool USDCHF_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket USDCHF_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket USDCHF_OCO4_MO6_DOWN_S2 ;
    	
    	public static int USDCHF_OCO4_EO1_DOWN_S2_ID ;
        public static int USDCHF_OCO4_EO2_DOWN_S2_ID ;
        public static int USDCHF_OCO4_EO3_DOWN_S2_ID ;
        public static int USDCHF_OCO4_EO4_DOWN_S2_ID ;
        public static int USDCHF_OCO4_EO5_DOWN_S2_ID ;
        public static int USDCHF_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool USDCHF_OCO4_EO1_DOWN_S2 ;
        public static bool USDCHF_OCO4_EO2_DOWN_S2 ;
        public static bool USDCHF_OCO4_EO3_DOWN_S2 ;
        public static bool USDCHF_OCO4_EO4_DOWN_S2 ;
        public static bool USDCHF_OCO4_EO5_DOWN_S2 ;
        public static bool USDCHF_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_DOWN_S2> USDCHF_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_DOWN_S2> USDCHF_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_DOWN_S2> USDCHF_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_DOWN_S2> USDCHF_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_DOWN_S2> USDCHF_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDCHF_OCO4_DOWN_S2> USDCHF_OOFE_OCO4_DOWN_S2_6 ;
        
        public static USDCHF_OCO4_DOWN_S2 USDCHF_PFO_OCO4_DOWN_S2_1 ;
        public static USDCHF_OCO4_DOWN_S2 USDCHF_PFO_OCO4_DOWN_S2_2 ;
        public static USDCHF_OCO4_DOWN_S2 USDCHF_PFO_OCO4_DOWN_S2_3 ;
        public static USDCHF_OCO4_DOWN_S2 USDCHF_PFO_OCO4_DOWN_S2_4 ;
        public static USDCHF_OCO4_DOWN_S2 USDCHF_PFO_OCO4_DOWN_S2_5 ;
        public static USDCHF_OCO4_DOWN_S2 USDCHF_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<USDCHF_OCO4_DOWN_S2> USDCHF_DOWN_S2_OCO4Sets1 = new List<USDCHF_OCO4_DOWN_S2>();
        public static List<USDCHF_OCO4_DOWN_S2> USDCHF_DOWN_S2_OCO4Sets2 = new List<USDCHF_OCO4_DOWN_S2>();
        public static List<USDCHF_OCO4_DOWN_S2> USDCHF_DOWN_S2_OCO4Sets3 = new List<USDCHF_OCO4_DOWN_S2>();
        public static List<USDCHF_OCO4_DOWN_S2> USDCHF_DOWN_S2_OCO4Sets4 = new List<USDCHF_OCO4_DOWN_S2>();
        public static List<USDCHF_OCO4_DOWN_S2> USDCHF_DOWN_S2_OCO4Sets5 = new List<USDCHF_OCO4_DOWN_S2>();
        public static List<USDCHF_OCO4_DOWN_S2> USDCHF_DOWN_S2_OCO4Sets6 = new List<USDCHF_OCO4_DOWN_S2>();
        
        public static bool USDCHF_OCO4_DOWN_S2_IsReady = true;
        public static bool USDCHF_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal USDCHF_UP_S2_SL {get; set;}
		public static decimal USDCHF_UP_S2_TP1 {get; set;}
		public static decimal USDCHF_UP_S2_TP2 {get; set;}
		public static decimal USDCHF_UP_S2_TP3 {get; set;}
		public static decimal USDCHF_UP_S2_TP4 {get; set;}
		public static decimal USDCHF_UP_S2_TP5 {get; set;}
		public static decimal USDCHF_UP_S2_TP6 {get; set;}
		
		public static decimal USDCHF_DOWN_S2_SL {get; set;}
		public static decimal USDCHF_DOWN_S2_TP1 {get; set;}
		public static decimal USDCHF_DOWN_S2_TP2 {get; set;}
		public static decimal USDCHF_DOWN_S2_TP3 {get; set;}
		public static decimal USDCHF_DOWN_S2_TP4 {get; set;}
		public static decimal USDCHF_DOWN_S2_TP5 {get; set;}
		public static decimal USDCHF_DOWN_S2_TP6 {get; set;}

        public static bool USDCHF_Signal_Condition_UP_1 ;
        public static bool USDCHF_Signal_Condition_UP_2 ;
        public static bool USDCHF_Signal_Condition_UP_3 ;
        
        public static bool USDCHF_Signal_Condition_DOWN_S2 ;
        
        public static int USDCHF_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int USDCHF_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int USDCHF_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int USDCHF_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int USDCHF_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int USDCHF_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int USDCHF_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int USDCHF_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int USDCHF_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int USDCHF_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_USDCHF_UP_S2 ;
        public static bool DOWM_USDCHF_UP_S2 ;
        public static bool DOWT_USDCHF_UP_S2 ;
        public static bool DOWW_USDCHF_UP_S2 ;
        public static bool DOWTH_USDCHF_UP_S2 ;
        
		public static bool DOWR_USDCHF_DOWN_S2 ;
        public static bool DOWM_USDCHF_DOWN_S2 ;
        public static bool DOWT_USDCHF_DOWN_S2 ;
        public static bool DOWW_USDCHF_DOWN_S2 ;
        public static bool DOWTH_USDCHF_DOWN_S2 ;
        
        
		public static int USDCHF_quantity_UP_S2 ;
		public static int USDCHF_quantity_SL_UP_S2 ;
		public static int USDCHF_quantity_TP1_UP_S2 ;
		public static int USDCHF_quantity_TP2_UP_S2 ;
		public static int USDCHF_quantity_TP3_UP_S2 ;
		public static int USDCHF_quantity_TP4_UP_S2 ;
		public static int USDCHF_quantity_TP5_UP_S2;
		public static int USDCHF_quantity_TP6_UP_S2 ;
		
		public static int USDCHF_quantity_DOWN_S2 ;
		public static int USDCHF_quantity_SL_DOWN_S2 ;
		public static int USDCHF_quantity_TP1_DOWN_S2 ;
		public static int USDCHF_quantity_TP2_DOWN_S2 ;
		public static int USDCHF_quantity_TP3_DOWN_S2 ;
		public static int USDCHF_quantity_TP4_DOWN_S2 ;
		public static int USDCHF_quantity_TP5_DOWN_S2;
		public static int USDCHF_quantity_TP6_DOWN_S2 ;
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURUSD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURUSD_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("EURUSD_DOWN_S2_OCO1")))
			{
				Base.EURUSD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURUSD_DOWN_S2_OCO2")))
			{
				Base.EURUSD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURUSD_DOWN_S2_OCO3")))
			{
				Base.EURUSD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURUSD_DOWN_S2_OCO4")))
			{
				Base.EURUSD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURUSD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.EURUSD_OCO1_EO1_DOWN_S2)
	                Base.EURUSD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURUSD_OCO1_EO2_DOWN_S2)
	                Base.EURUSD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO1_EO3_DOWN_S2)
	                Base.EURUSD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO1_EO4_DOWN_S2)
	                Base.EURUSD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO1_EO5_DOWN_S2)
	                Base.EURUSD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO1_EO6_DOWN_S2)
	                Base.EURUSD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURUSD_OCO1S1_DOWN_S2 = 0;
		                for (; EURUSD_OCO1S1_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets1.Count; EURUSD_OCO1S1_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO1Sets1[EURUSD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO1Sets1[EURUSD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.EURUSD_DOWN_S2_OCO1Sets1.Clear();
		                        EURUSD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURUSD_OCO1S2_DOWN_S2 = 0;
		                for (; EURUSD_OCO1S2_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets2.Count; EURUSD_OCO1S2_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO1Sets2[EURUSD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO1Sets2[EURUSD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.EURUSD_DOWN_S2_OCO1Sets2.Clear();
		                        EURUSD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO1S3_DOWN_S2 = 0;
		                for (; EURUSD_OCO1S3_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets3.Count; EURUSD_OCO1S3_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO1Sets3[EURUSD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO1Sets3[EURUSD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.EURUSD_DOWN_S2_OCO1Sets3.Clear();
		                        EURUSD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO1S4_DOWN_S2 = 0;
		                for (; EURUSD_OCO1S4_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets4.Count; EURUSD_OCO1S4_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO1Sets4[EURUSD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO1Sets4[EURUSD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.EURUSD_DOWN_S2_OCO1Sets4.Clear();
		                        EURUSD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO1S5_DOWN_S2 = 0;
		                for (; EURUSD_OCO1S5_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets5.Count; EURUSD_OCO1S5_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO1Sets5[EURUSD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO1Sets5[EURUSD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.EURUSD_DOWN_S2_OCO1Sets5.Clear();
		                        EURUSD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO1S6_DOWN_S2 = 0;
		                for (; EURUSD_OCO1S6_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO1Sets6.Count; EURUSD_OCO1S6_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO1Sets6[EURUSD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO1Sets6[EURUSD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.EURUSD_DOWN_S2_OCO1Sets6.Clear();
		                        EURUSD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURUSD_OCO2_EO1_DOWN_S2)
	                Base.EURUSD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURUSD_OCO2_EO2_DOWN_S2)
	                Base.EURUSD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO2_EO3_DOWN_S2)
	                Base.EURUSD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO2_EO4_DOWN_S2)
	                Base.EURUSD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO2_EO5_DOWN_S2)
	                Base.EURUSD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO2_EO6_DOWN_S2)
	                Base.EURUSD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURUSD_OCO2S1_DOWN_S2 = 0;
		                for (; EURUSD_OCO2S1_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets1.Count; EURUSD_OCO2S1_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO2Sets1[EURUSD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO2Sets1[EURUSD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.EURUSD_DOWN_S2_OCO2Sets1.Clear();
		                        EURUSD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURUSD_OCO2S2_DOWN_S2 = 0;
		                for (; EURUSD_OCO2S2_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets2.Count; EURUSD_OCO2S2_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO2Sets2[EURUSD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO2Sets2[EURUSD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.EURUSD_DOWN_S2_OCO2Sets2.Clear();
		                        EURUSD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO2S3_DOWN_S2 = 0;
		                for (; EURUSD_OCO2S3_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets3.Count; EURUSD_OCO2S3_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO2Sets3[EURUSD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO2Sets3[EURUSD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.EURUSD_DOWN_S2_OCO2Sets3.Clear();
		                        EURUSD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO2S4_DOWN_S2 = 0;
		                for (; EURUSD_OCO2S4_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets4.Count; EURUSD_OCO2S4_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO2Sets4[EURUSD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO2Sets4[EURUSD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.EURUSD_DOWN_S2_OCO2Sets4.Clear();
		                        EURUSD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO2S5_DOWN_S2 = 0;
		                for (; EURUSD_OCO2S5_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets5.Count; EURUSD_OCO2S5_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO2Sets5[EURUSD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO2Sets5[EURUSD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.EURUSD_DOWN_S2_OCO2Sets5.Clear();
		                        EURUSD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO2S6_DOWN_S2 = 0;
		                for (; EURUSD_OCO2S6_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO2Sets6.Count; EURUSD_OCO2S6_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO2Sets6[EURUSD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO2Sets6[EURUSD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.EURUSD_DOWN_S2_OCO2Sets6.Clear();
		                        EURUSD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURUSD_OCO3_EO1_DOWN_S2)
	                Base.EURUSD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURUSD_OCO3_EO2_DOWN_S2)
	                Base.EURUSD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO3_EO3_DOWN_S2)
	                Base.EURUSD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO3_EO4_DOWN_S2)
	                Base.EURUSD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO3_EO5_DOWN_S2)
	                Base.EURUSD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO3_EO6_DOWN_S2)
	                Base.EURUSD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURUSD_OCO3S1_DOWN_S2 = 0;
		                for (; EURUSD_OCO3S1_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets1.Count; EURUSD_OCO3S1_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO3Sets1[EURUSD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO3Sets1[EURUSD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.EURUSD_DOWN_S2_OCO3Sets1.Clear();
		                        EURUSD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURUSD_OCO3S2_DOWN_S2 = 0;
		                for (; EURUSD_OCO3S2_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets2.Count; EURUSD_OCO3S2_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO3Sets2[EURUSD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO3Sets2[EURUSD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.EURUSD_DOWN_S2_OCO3Sets2.Clear();
		                        EURUSD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO3S3_DOWN_S2 = 0;
		                for (; EURUSD_OCO3S3_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets3.Count; EURUSD_OCO3S3_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO3Sets3[EURUSD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO3Sets3[EURUSD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.EURUSD_DOWN_S2_OCO3Sets3.Clear();
		                        EURUSD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO3S4_DOWN_S2 = 0;
		                for (; EURUSD_OCO3S4_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets4.Count; EURUSD_OCO3S4_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO3Sets4[EURUSD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO3Sets4[EURUSD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.EURUSD_DOWN_S2_OCO3Sets4.Clear();
		                        EURUSD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO3S5_DOWN_S2 = 0;
		                for (; EURUSD_OCO3S5_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets5.Count; EURUSD_OCO3S5_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO3Sets5[EURUSD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO3Sets5[EURUSD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.EURUSD_DOWN_S2_OCO3Sets5.Clear();
		                        EURUSD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO3S6_DOWN_S2 = 0;
		                for (; EURUSD_OCO3S6_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO3Sets6.Count; EURUSD_OCO3S6_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO3Sets6[EURUSD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO3Sets6[EURUSD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.EURUSD_DOWN_S2_OCO3Sets6.Clear();
		                        EURUSD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURUSD_OCO4_EO1_DOWN_S2)
	                Base.EURUSD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURUSD_OCO4_EO2_DOWN_S2)
	                Base.EURUSD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO4_EO3_DOWN_S2)
	                Base.EURUSD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO4_EO4_DOWN_S2)
	                Base.EURUSD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO4_EO5_DOWN_S2)
	                Base.EURUSD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURUSD_OCO4_EO6_DOWN_S2)
	                Base.EURUSD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURUSD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURUSD_OCO4S1_DOWN_S2 = 0;
		                for (; EURUSD_OCO4S1_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets1.Count; EURUSD_OCO4S1_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO4Sets1[EURUSD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO4Sets1[EURUSD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.EURUSD_DOWN_S2_OCO4Sets1.Clear();
		                        EURUSD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURUSD_OCO4S2_DOWN_S2 = 0;
		                for (; EURUSD_OCO4S2_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets2.Count; EURUSD_OCO4S2_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO4Sets2[EURUSD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO4Sets2[EURUSD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.EURUSD_DOWN_S2_OCO4Sets2.Clear();
		                        EURUSD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO4S3_DOWN_S2 = 0;
		                for (; EURUSD_OCO4S3_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets3.Count; EURUSD_OCO4S3_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO4Sets3[EURUSD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO4Sets3[EURUSD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.EURUSD_DOWN_S2_OCO4Sets3.Clear();
		                        EURUSD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURUSD_OCO4S4_DOWN_S2 = 0;
		                for (; EURUSD_OCO4S4_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets4.Count; EURUSD_OCO4S4_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO4Sets4[EURUSD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO4Sets4[EURUSD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.EURUSD_DOWN_S2_OCO4Sets4.Clear();
		                        EURUSD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO4S5_DOWN_S2 = 0;
		                for (; EURUSD_OCO4S5_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets5.Count; EURUSD_OCO4S5_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO4Sets5[EURUSD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO4Sets5[EURUSD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.EURUSD_DOWN_S2_OCO4Sets5.Clear();
		                        EURUSD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURUSD_OCO4S6_DOWN_S2 = 0;
		                for (; EURUSD_OCO4S6_DOWN_S2 < Base.EURUSD_DOWN_S2_OCO4Sets6.Count; EURUSD_OCO4S6_DOWN_S2++)
		                    if (Base.EURUSD_DOWN_S2_OCO4Sets6[EURUSD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURUSD_DOWN_S2_OCO4Sets6[EURUSD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURUSD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURUSD", order.Quantity, false, "EURUSD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.EURUSD_DOWN_S2_OCO4Sets6.Clear();
		                        EURUSD_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();
	            	}
	            	
					DOWM_EURUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURUSD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURUSD_DOWN_S2 = DOWM_EURUSD_DOWN_S2 || DOWT_EURUSD_DOWN_S2 || DOWW_EURUSD_DOWN_S2 || DOWTH_EURUSD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURUSD"))
	            	{
	            		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.EURUSD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.EURUSD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.EURUSD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.EURUSD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.EURUSD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURUSD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURUSD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURUSD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURUSD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURUSD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURUSD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURUSD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	EURUSD_Signal_Condition_DOWN_S2 =  
	                									(
																	pricesM_ASK_Open[0] - pricesM_BID_Close[0] > 0.01m &&
		                										
		                										prices_ASK_High[0] > pricesM_ASK_High[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])/2) &&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < 0.001m
	                									);
	                									
	                    EURUSD_DOWN_S2_SL  =  0.015m;
	                    EURUSD_DOWN_S2_TP1 =  0.0005m;
	                    EURUSD_DOWN_S2_TP2 =  EURUSD_DOWN_S2_SL * 0;
	                    EURUSD_DOWN_S2_TP3 =  EURUSD_DOWN_S2_SL * 0;
	                    EURUSD_DOWN_S2_TP4 =  EURUSD_DOWN_S2_SL * 0;
	                    EURUSD_DOWN_S2_TP5 =  EURUSD_DOWN_S2_SL * 0;
	                    EURUSD_DOWN_S2_TP6 =  EURUSD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURUSD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURUSD_quantity_SL_DOWN_S2 = EURUSD_quantity_DOWN_S2;
	                    EURUSD_quantity_TP1_DOWN_S2 = (int)Math.Floor(EURUSD_quantity_DOWN_S2 * 1m);
	                    EURUSD_quantity_TP2_DOWN_S2 = (int)Math.Floor(EURUSD_quantity_TP1_DOWN_S2 * 0m);
	                    EURUSD_quantity_TP3_DOWN_S2 = (int)Math.Floor(EURUSD_quantity_TP2_DOWN_S2 * 0m);
	                    EURUSD_quantity_TP4_DOWN_S2 = (int)Math.Floor(EURUSD_quantity_TP3_DOWN_S2 * 0m);
	                    EURUSD_quantity_TP5_DOWN_S2 = (int)Math.Floor(EURUSD_quantity_TP4_DOWN_S2 * 0m);
	                    EURUSD_quantity_TP6_DOWN_S2 = (int)Math.Floor(EURUSD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (EURUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURUSD_DOWN_S2 && 
	                    Base.EURUSD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.EURUSD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURUSD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP1_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.EURUSD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.EURUSD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP2_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.EURUSD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.EURUSD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP3_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.EURUSD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.EURUSD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP4_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.EURUSD_OCO1_EO4_DOWN_S2 = false;

							Base.EURUSD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.EURUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (EURUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURUSD_DOWN_S2 && 
	                    Base.EURUSD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.EURUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURUSD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURUSD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP1_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.EURUSD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.EURUSD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP2_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.EURUSD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.EURUSD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP3_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.EURUSD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.EURUSD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP4_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.EURUSD_OCO2_EO4_DOWN_S2 = false;

							Base.EURUSD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.EURUSD_OCO2_DOWN_S2_IsReady == false && Base.EURUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (EURUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURUSD_DOWN_S2 &&
	                    Base.EURUSD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.EURUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURUSD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURUSD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURUSD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP1_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.EURUSD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.EURUSD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP2_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.EURUSD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.EURUSD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP3_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.EURUSD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.EURUSD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP4_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.EURUSD_OCO3_EO4_DOWN_S2 = false;

							Base.EURUSD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.EURUSD_OCO3_DOWN_S2_IsReady == false && Base.EURUSD_OCO2_DOWN_S2_IsReady == false && Base.EURUSD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (EURUSD_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURUSD_DOWN_S2 && 
	                    Base.EURUSD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.EURUSD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURUSD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURUSD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.EURUSD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURUSD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP1_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.EURUSD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.EURUSD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP2_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.EURUSD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.EURUSD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP3_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.EURUSD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.EURUSD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURUSD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURUSD_quantity_TP4_DOWN_S2, false,"EURUSD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.EURUSD_OCO4_EO4_DOWN_S2 = false;

							Base.EURUSD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.EURUSD_OCO4_DOWN_S2_IsReady == false && Base.EURUSD_OCO3_DOWN_S2_IsReady == false && Base.EURUSD_OCO2_DOWN_S2_IsReady == false && Base.EURUSD_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPCAD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPCAD_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("GBPCAD_DOWN_S2_OCO1")))
			{
				Base.GBPCAD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCAD_DOWN_S2_OCO2")))
			{
				Base.GBPCAD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCAD_DOWN_S2_OCO3")))
			{
				Base.GBPCAD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCAD_DOWN_S2_OCO4")))
			{
				Base.GBPCAD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPCAD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.GBPCAD_OCO1_EO1_DOWN_S2)
	                Base.GBPCAD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPCAD_OCO1_EO2_DOWN_S2)
	                Base.GBPCAD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO1_EO3_DOWN_S2)
	                Base.GBPCAD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO1_EO4_DOWN_S2)
	                Base.GBPCAD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO1_EO5_DOWN_S2)
	                Base.GBPCAD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO1_EO6_DOWN_S2)
	                Base.GBPCAD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCAD_OCO1S1_DOWN_S2 = 0;
		                for (; GBPCAD_OCO1S1_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets1.Count; GBPCAD_OCO1S1_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO1Sets1[GBPCAD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO1Sets1[GBPCAD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.GBPCAD_DOWN_S2_OCO1Sets1.Clear();
		                        GBPCAD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCAD_OCO1S2_DOWN_S2 = 0;
		                for (; GBPCAD_OCO1S2_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets2.Count; GBPCAD_OCO1S2_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO1Sets2[GBPCAD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO1Sets2[GBPCAD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.GBPCAD_DOWN_S2_OCO1Sets2.Clear();
		                        GBPCAD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO1S3_DOWN_S2 = 0;
		                for (; GBPCAD_OCO1S3_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets3.Count; GBPCAD_OCO1S3_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO1Sets3[GBPCAD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO1Sets3[GBPCAD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.GBPCAD_DOWN_S2_OCO1Sets3.Clear();
		                        GBPCAD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO1S4_DOWN_S2 = 0;
		                for (; GBPCAD_OCO1S4_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets4.Count; GBPCAD_OCO1S4_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO1Sets4[GBPCAD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO1Sets4[GBPCAD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.GBPCAD_DOWN_S2_OCO1Sets4.Clear();
		                        GBPCAD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO1S5_DOWN_S2 = 0;
		                for (; GBPCAD_OCO1S5_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets5.Count; GBPCAD_OCO1S5_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO1Sets5[GBPCAD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO1Sets5[GBPCAD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.GBPCAD_DOWN_S2_OCO1Sets5.Clear();
		                        GBPCAD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO1S6_DOWN_S2 = 0;
		                for (; GBPCAD_OCO1S6_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO1Sets6.Count; GBPCAD_OCO1S6_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO1Sets6[GBPCAD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO1Sets6[GBPCAD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.GBPCAD_DOWN_S2_OCO1Sets6.Clear();
		                        GBPCAD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPCAD_OCO2_EO1_DOWN_S2)
	                Base.GBPCAD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPCAD_OCO2_EO2_DOWN_S2)
	                Base.GBPCAD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO2_EO3_DOWN_S2)
	                Base.GBPCAD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO2_EO4_DOWN_S2)
	                Base.GBPCAD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO2_EO5_DOWN_S2)
	                Base.GBPCAD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO2_EO6_DOWN_S2)
	                Base.GBPCAD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCAD_OCO2S1_DOWN_S2 = 0;
		                for (; GBPCAD_OCO2S1_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets1.Count; GBPCAD_OCO2S1_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO2Sets1[GBPCAD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO2Sets1[GBPCAD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.GBPCAD_DOWN_S2_OCO2Sets1.Clear();
		                        GBPCAD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCAD_OCO2S2_DOWN_S2 = 0;
		                for (; GBPCAD_OCO2S2_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets2.Count; GBPCAD_OCO2S2_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO2Sets2[GBPCAD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO2Sets2[GBPCAD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.GBPCAD_DOWN_S2_OCO2Sets2.Clear();
		                        GBPCAD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO2S3_DOWN_S2 = 0;
		                for (; GBPCAD_OCO2S3_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets3.Count; GBPCAD_OCO2S3_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO2Sets3[GBPCAD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO2Sets3[GBPCAD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.GBPCAD_DOWN_S2_OCO2Sets3.Clear();
		                        GBPCAD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO2S4_DOWN_S2 = 0;
		                for (; GBPCAD_OCO2S4_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets4.Count; GBPCAD_OCO2S4_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO2Sets4[GBPCAD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO2Sets4[GBPCAD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.GBPCAD_DOWN_S2_OCO2Sets4.Clear();
		                        GBPCAD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO2S5_DOWN_S2 = 0;
		                for (; GBPCAD_OCO2S5_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets5.Count; GBPCAD_OCO2S5_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO2Sets5[GBPCAD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO2Sets5[GBPCAD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.GBPCAD_DOWN_S2_OCO2Sets5.Clear();
		                        GBPCAD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO2S6_DOWN_S2 = 0;
		                for (; GBPCAD_OCO2S6_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO2Sets6.Count; GBPCAD_OCO2S6_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO2Sets6[GBPCAD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO2Sets6[GBPCAD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.GBPCAD_DOWN_S2_OCO2Sets6.Clear();
		                        GBPCAD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPCAD_OCO3_EO1_DOWN_S2)
	                Base.GBPCAD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPCAD_OCO3_EO2_DOWN_S2)
	                Base.GBPCAD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO3_EO3_DOWN_S2)
	                Base.GBPCAD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO3_EO4_DOWN_S2)
	                Base.GBPCAD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO3_EO5_DOWN_S2)
	                Base.GBPCAD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO3_EO6_DOWN_S2)
	                Base.GBPCAD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCAD_OCO3S1_DOWN_S2 = 0;
		                for (; GBPCAD_OCO3S1_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets1.Count; GBPCAD_OCO3S1_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO3Sets1[GBPCAD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO3Sets1[GBPCAD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.GBPCAD_DOWN_S2_OCO3Sets1.Clear();
		                        GBPCAD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCAD_OCO3S2_DOWN_S2 = 0;
		                for (; GBPCAD_OCO3S2_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets2.Count; GBPCAD_OCO3S2_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO3Sets2[GBPCAD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO3Sets2[GBPCAD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.GBPCAD_DOWN_S2_OCO3Sets2.Clear();
		                        GBPCAD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO3S3_DOWN_S2 = 0;
		                for (; GBPCAD_OCO3S3_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets3.Count; GBPCAD_OCO3S3_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO3Sets3[GBPCAD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO3Sets3[GBPCAD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.GBPCAD_DOWN_S2_OCO3Sets3.Clear();
		                        GBPCAD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO3S4_DOWN_S2 = 0;
		                for (; GBPCAD_OCO3S4_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets4.Count; GBPCAD_OCO3S4_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO3Sets4[GBPCAD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO3Sets4[GBPCAD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.GBPCAD_DOWN_S2_OCO3Sets4.Clear();
		                        GBPCAD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO3S5_DOWN_S2 = 0;
		                for (; GBPCAD_OCO3S5_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets5.Count; GBPCAD_OCO3S5_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO3Sets5[GBPCAD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO3Sets5[GBPCAD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.GBPCAD_DOWN_S2_OCO3Sets5.Clear();
		                        GBPCAD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO3S6_DOWN_S2 = 0;
		                for (; GBPCAD_OCO3S6_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO3Sets6.Count; GBPCAD_OCO3S6_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO3Sets6[GBPCAD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO3Sets6[GBPCAD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.GBPCAD_DOWN_S2_OCO3Sets6.Clear();
		                        GBPCAD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPCAD_OCO4_EO1_DOWN_S2)
	                Base.GBPCAD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPCAD_OCO4_EO2_DOWN_S2)
	                Base.GBPCAD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO4_EO3_DOWN_S2)
	                Base.GBPCAD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO4_EO4_DOWN_S2)
	                Base.GBPCAD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO4_EO5_DOWN_S2)
	                Base.GBPCAD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO4_EO6_DOWN_S2)
	                Base.GBPCAD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCAD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCAD_OCO4S1_DOWN_S2 = 0;
		                for (; GBPCAD_OCO4S1_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets1.Count; GBPCAD_OCO4S1_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO4Sets1[GBPCAD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO4Sets1[GBPCAD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.GBPCAD_DOWN_S2_OCO4Sets1.Clear();
		                        GBPCAD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCAD_OCO4S2_DOWN_S2 = 0;
		                for (; GBPCAD_OCO4S2_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets2.Count; GBPCAD_OCO4S2_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO4Sets2[GBPCAD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO4Sets2[GBPCAD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.GBPCAD_DOWN_S2_OCO4Sets2.Clear();
		                        GBPCAD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO4S3_DOWN_S2 = 0;
		                for (; GBPCAD_OCO4S3_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets3.Count; GBPCAD_OCO4S3_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO4Sets3[GBPCAD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO4Sets3[GBPCAD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.GBPCAD_DOWN_S2_OCO4Sets3.Clear();
		                        GBPCAD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO4S4_DOWN_S2 = 0;
		                for (; GBPCAD_OCO4S4_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets4.Count; GBPCAD_OCO4S4_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO4Sets4[GBPCAD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO4Sets4[GBPCAD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.GBPCAD_DOWN_S2_OCO4Sets4.Clear();
		                        GBPCAD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO4S5_DOWN_S2 = 0;
		                for (; GBPCAD_OCO4S5_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets5.Count; GBPCAD_OCO4S5_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO4Sets5[GBPCAD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO4Sets5[GBPCAD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.GBPCAD_DOWN_S2_OCO4Sets5.Clear();
		                        GBPCAD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO4S6_DOWN_S2 = 0;
		                for (; GBPCAD_OCO4S6_DOWN_S2 < Base.GBPCAD_DOWN_S2_OCO4Sets6.Count; GBPCAD_OCO4S6_DOWN_S2++)
		                    if (Base.GBPCAD_DOWN_S2_OCO4Sets6[GBPCAD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_DOWN_S2_OCO4Sets6[GBPCAD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.GBPCAD_DOWN_S2_OCO4Sets6.Clear();
		                        GBPCAD_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();
	            	}
	            	
					DOWM_GBPCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPCAD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPCAD_DOWN_S2 = DOWM_GBPCAD_DOWN_S2 || DOWT_GBPCAD_DOWN_S2 || DOWW_GBPCAD_DOWN_S2 || DOWTH_GBPCAD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPCAD"))
	            	{
	            		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.GBPCAD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.GBPCAD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.GBPCAD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.GBPCAD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.GBPCAD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPCAD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPCAD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPCAD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPCAD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPCAD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPCAD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	GBPCAD_Signal_Condition_DOWN_S2 =  
	                									(
															prices_ASK_High[0] - pricesM_ASK_High[0] > prices_ASK_Close[0] * 0.01m &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.001m 
	                									);
	                									
	                    GBPCAD_DOWN_S2_SL  =  0.01m;
	                    GBPCAD_DOWN_S2_TP1 =  0.0005m;
	                    GBPCAD_DOWN_S2_TP2 =  GBPCAD_DOWN_S2_SL * 0;
	                    GBPCAD_DOWN_S2_TP3 =  GBPCAD_DOWN_S2_SL * 0;
	                    GBPCAD_DOWN_S2_TP4 =  GBPCAD_DOWN_S2_SL * 0;
	                    GBPCAD_DOWN_S2_TP5 =  GBPCAD_DOWN_S2_SL * 0;
	                    GBPCAD_DOWN_S2_TP6 =  GBPCAD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPCAD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPCAD_quantity_SL_DOWN_S2 = GBPCAD_quantity_DOWN_S2;
	                    GBPCAD_quantity_TP1_DOWN_S2 = (int)Math.Floor(GBPCAD_quantity_DOWN_S2 * 1m);
	                    GBPCAD_quantity_TP2_DOWN_S2 = (int)Math.Floor(GBPCAD_quantity_TP1_DOWN_S2 * 0m);
	                    GBPCAD_quantity_TP3_DOWN_S2 = (int)Math.Floor(GBPCAD_quantity_TP2_DOWN_S2 * 0m);
	                    GBPCAD_quantity_TP4_DOWN_S2 = (int)Math.Floor(GBPCAD_quantity_TP3_DOWN_S2 * 0m);
	                    GBPCAD_quantity_TP5_DOWN_S2 = (int)Math.Floor(GBPCAD_quantity_TP4_DOWN_S2 * 0m);
	                    GBPCAD_quantity_TP6_DOWN_S2 = (int)Math.Floor(GBPCAD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (GBPCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPCAD_DOWN_S2 && 
	                    Base.GBPCAD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.GBPCAD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCAD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP1_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.GBPCAD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPCAD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP2_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.GBPCAD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.GBPCAD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP3_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.GBPCAD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPCAD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP4_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.GBPCAD_OCO1_EO4_DOWN_S2 = false;

							Base.GBPCAD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.GBPCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (GBPCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPCAD_DOWN_S2 && 
	                    Base.GBPCAD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.GBPCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPCAD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCAD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP1_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.GBPCAD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPCAD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP2_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.GBPCAD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.GBPCAD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP3_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.GBPCAD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPCAD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP4_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.GBPCAD_OCO2_EO4_DOWN_S2 = false;

							Base.GBPCAD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.GBPCAD_OCO2_DOWN_S2_IsReady == false && Base.GBPCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (GBPCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPCAD_DOWN_S2 &&
	                    Base.GBPCAD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.GBPCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPCAD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCAD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP1_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.GBPCAD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPCAD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP2_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.GBPCAD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.GBPCAD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP3_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.GBPCAD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPCAD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP4_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.GBPCAD_OCO3_EO4_DOWN_S2 = false;

							Base.GBPCAD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.GBPCAD_OCO3_DOWN_S2_IsReady == false && Base.GBPCAD_OCO2_DOWN_S2_IsReady == false && Base.GBPCAD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (GBPCAD_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPCAD_DOWN_S2 && 
	                    Base.GBPCAD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.GBPCAD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPCAD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPCAD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.GBPCAD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCAD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP1_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.GBPCAD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPCAD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP2_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.GBPCAD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.GBPCAD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP3_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.GBPCAD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPCAD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPCAD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP4_DOWN_S2, false,"GBPCAD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.GBPCAD_OCO4_EO4_DOWN_S2 = false;

							Base.GBPCAD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.GBPCAD_OCO4_DOWN_S2_IsReady == false && Base.GBPCAD_OCO3_DOWN_S2_IsReady == false && Base.GBPCAD_OCO2_DOWN_S2_IsReady == false && Base.GBPCAD_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.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 AUDCAD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDCAD_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("AUDCAD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCAD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCAD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCAD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCAD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCAD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCAD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        }
		        
				if (Base.AUDCAD_OCO1_EO1_UP_S2)
	                Base.AUDCAD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCAD_OCO1_EO2_UP_S2)
	                Base.AUDCAD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO1_EO3_UP_S2)
	                Base.AUDCAD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO1_EO4_UP_S2)
	                Base.AUDCAD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO1_EO5_UP_S2)
	                Base.AUDCAD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO1_EO6_UP_S2)
	                Base.AUDCAD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.AUDCAD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP1,"TP1_AUDCAD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP1_AUDCAD_UP_S2_OCO1"));
		                 };
		                Base.AUDCAD_UP_S2_OCO1Sets1.Add( Base.AUDCAD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP2,"TP2_AUDCAD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP2_AUDCAD_UP_S2_OCO1"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO1Sets2.Add( Base.AUDCAD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP3,"TP3_AUDCAD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP3_AUDCAD_UP_S2_OCO1"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO1Sets3.Add( Base.AUDCAD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP4,"TP4_AUDCAD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP4_AUDCAD_UP_S2_OCO1"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO1Sets4.Add( Base.AUDCAD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP5,"TP5_AUDCAD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP5_AUDCAD_UP_S2_OCO1"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO1Sets5.Add( Base.AUDCAD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP6,"TP6_AUDCAD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP6_AUDCAD_UP_S2_OCO1"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO1Sets6.Add( Base.AUDCAD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDCAD_OCO1S1_UP_S2 = 0;
	                for (; AUDCAD_OCO1S1_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets1.Count; AUDCAD_OCO1S1_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO1Sets1[AUDCAD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO1Sets1[AUDCAD_OCO1S1_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO1Sets1.RemoveAt(AUDCAD_OCO1S1_UP_S2);
	                        AUDCAD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCAD_OCO1S2_UP_S2 = 0;
	                for (; AUDCAD_OCO1S2_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets2.Count; AUDCAD_OCO1S2_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO1Sets2[AUDCAD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO1Sets2[AUDCAD_OCO1S2_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO1Sets2.RemoveAt(AUDCAD_OCO1S2_UP_S2);
	                        AUDCAD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO1S3_UP_S2 = 0;
	                for (; AUDCAD_OCO1S3_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets3.Count; AUDCAD_OCO1S3_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO1Sets3[AUDCAD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO1Sets3[AUDCAD_OCO1S3_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO1Sets3.RemoveAt(AUDCAD_OCO1S3_UP_S2);
	                        AUDCAD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO1S4_UP_S2 = 0;
	                for (; AUDCAD_OCO1S4_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets4.Count; AUDCAD_OCO1S4_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO1Sets4[AUDCAD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO1Sets4[AUDCAD_OCO1S4_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO1Sets4.RemoveAt(AUDCAD_OCO1S4_UP_S2);
	                        AUDCAD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCAD_OCO1S5_UP_S2 = 0;
	                for (; AUDCAD_OCO1S5_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets5.Count; AUDCAD_OCO1S5_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO1Sets5[AUDCAD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO1Sets5[AUDCAD_OCO1S5_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO1Sets5.RemoveAt(AUDCAD_OCO1S5_UP_S2);
	                        AUDCAD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCAD_OCO1S6_UP_S2 = 0;
	                for (; AUDCAD_OCO1S6_UP_S2 < Base.AUDCAD_UP_S2_OCO1Sets6.Count; AUDCAD_OCO1S6_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO1Sets6[AUDCAD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO1Sets6[AUDCAD_OCO1S6_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO1Sets6.RemoveAt(AUDCAD_OCO1S6_UP_S2);
	                        AUDCAD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.AUDCAD_OCO2_EO1_UP_S2)
	                Base.AUDCAD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCAD_OCO2_EO2_UP_S2)
	                Base.AUDCAD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO2_EO3_UP_S2)
	                Base.AUDCAD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO2_EO4_UP_S2)
	                Base.AUDCAD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO2_EO5_UP_S2)
	                Base.AUDCAD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO2_EO6_UP_S2)
	                Base.AUDCAD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.AUDCAD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP1,"TP1_AUDCAD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP1_AUDCAD_UP_S2_OCO2"));
		                 };
		                Base.AUDCAD_UP_S2_OCO2Sets1.Add( Base.AUDCAD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP2,"TP2_AUDCAD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP2_AUDCAD_UP_S2_OCO2"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO2Sets2.Add( Base.AUDCAD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP3,"TP3_AUDCAD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP3_AUDCAD_UP_S2_OCO2"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO2Sets3.Add( Base.AUDCAD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP4,"TP4_AUDCAD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP4_AUDCAD_UP_S2_OCO2"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO2Sets4.Add( Base.AUDCAD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP5,"TP5_AUDCAD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP5_AUDCAD_UP_S2_OCO2"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO2Sets5.Add( Base.AUDCAD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP6,"TP6_AUDCAD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP6_AUDCAD_UP_S2_OCO2"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO2Sets6.Add( Base.AUDCAD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDCAD_OCO2S1_UP_S2 = 0;
	                for (; AUDCAD_OCO2S1_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets1.Count; AUDCAD_OCO2S1_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO2Sets1[AUDCAD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO2Sets1[AUDCAD_OCO2S1_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO2Sets1.RemoveAt(AUDCAD_OCO2S1_UP_S2);
	                        AUDCAD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCAD_OCO2S2_UP_S2 = 0;
	                for (; AUDCAD_OCO2S2_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets2.Count; AUDCAD_OCO2S2_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO2Sets2[AUDCAD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO2Sets2[AUDCAD_OCO2S2_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO2Sets2.RemoveAt(AUDCAD_OCO2S2_UP_S2);
	                        AUDCAD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO2S3_UP_S2 = 0;
	                for (; AUDCAD_OCO2S3_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets3.Count; AUDCAD_OCO2S3_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO2Sets3[AUDCAD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO2Sets3[AUDCAD_OCO2S3_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO2Sets3.RemoveAt(AUDCAD_OCO2S3_UP_S2);
	                        AUDCAD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO2S4_UP_S2 = 0;
	                for (; AUDCAD_OCO2S4_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets4.Count; AUDCAD_OCO2S4_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO2Sets4[AUDCAD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO2Sets4[AUDCAD_OCO2S4_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO2Sets4.RemoveAt(AUDCAD_OCO2S4_UP_S2);
	                        AUDCAD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCAD_OCO2S5_UP_S2 = 0;
	                for (; AUDCAD_OCO2S5_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets5.Count; AUDCAD_OCO2S5_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO2Sets5[AUDCAD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO2Sets5[AUDCAD_OCO2S5_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO2Sets5.RemoveAt(AUDCAD_OCO2S5_UP_S2);
	                        AUDCAD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCAD_OCO2S6_UP_S2 = 0;
	                for (; AUDCAD_OCO2S6_UP_S2 < Base.AUDCAD_UP_S2_OCO2Sets6.Count; AUDCAD_OCO2S6_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO2Sets6[AUDCAD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO2Sets6[AUDCAD_OCO2S6_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO2Sets6.RemoveAt(AUDCAD_OCO2S6_UP_S2);
	                        AUDCAD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCAD_OCO3_EO1_UP_S2)
	                Base.AUDCAD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCAD_OCO3_EO2_UP_S2)
	                Base.AUDCAD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO3_EO3_UP_S2)
	                Base.AUDCAD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO3_EO4_UP_S2)
	                Base.AUDCAD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO3_EO5_UP_S2)
	                Base.AUDCAD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO3_EO6_UP_S2)
	                Base.AUDCAD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.AUDCAD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP1,"TP1_AUDCAD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP1_AUDCAD_UP_S2_OCO3"));
		                 };
		                Base.AUDCAD_UP_S2_OCO3Sets1.Add( Base.AUDCAD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP2,"TP2_AUDCAD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP2_AUDCAD_UP_S2_OCO3"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO3Sets2.Add( Base.AUDCAD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP3,"TP3_AUDCAD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP3_AUDCAD_UP_S2_OCO3"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO3Sets3.Add( Base.AUDCAD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP4,"TP4_AUDCAD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP4_AUDCAD_UP_S2_OCO3"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO3Sets4.Add( Base.AUDCAD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP5,"TP5_AUDCAD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP5_AUDCAD_UP_S2_OCO3"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO3Sets5.Add( Base.AUDCAD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP6,"TP6_AUDCAD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP6_AUDCAD_UP_S2_OCO3"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO3Sets6.Add( Base.AUDCAD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDCAD_OCO3S1_UP_S2 = 0;
	                for (; AUDCAD_OCO3S1_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets1.Count; AUDCAD_OCO3S1_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO3Sets1[AUDCAD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO3Sets1[AUDCAD_OCO3S1_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO3Sets1.RemoveAt(AUDCAD_OCO3S1_UP_S2);
	                        AUDCAD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCAD_OCO3S2_UP_S2 = 0;
	                for (; AUDCAD_OCO3S2_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets2.Count; AUDCAD_OCO3S2_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO3Sets2[AUDCAD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO3Sets2[AUDCAD_OCO3S2_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO3Sets2.RemoveAt(AUDCAD_OCO3S2_UP_S2);
	                        AUDCAD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO3S3_UP_S2 = 0;
	                for (; AUDCAD_OCO3S3_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets3.Count; AUDCAD_OCO3S3_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO3Sets3[AUDCAD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO3Sets3[AUDCAD_OCO3S3_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO3Sets3.RemoveAt(AUDCAD_OCO3S3_UP_S2);
	                        AUDCAD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO3S4_UP_S2 = 0;
	                for (; AUDCAD_OCO3S4_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets4.Count; AUDCAD_OCO3S4_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO3Sets4[AUDCAD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO3Sets4[AUDCAD_OCO3S4_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO3Sets4.RemoveAt(AUDCAD_OCO3S4_UP_S2);
	                        AUDCAD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCAD_OCO3S5_UP_S2 = 0;
	                for (; AUDCAD_OCO3S5_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets5.Count; AUDCAD_OCO3S5_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO3Sets5[AUDCAD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO3Sets5[AUDCAD_OCO3S5_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO3Sets5.RemoveAt(AUDCAD_OCO3S5_UP_S2);
	                        AUDCAD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCAD_OCO3S6_UP_S2 = 0;
	                for (; AUDCAD_OCO3S6_UP_S2 < Base.AUDCAD_UP_S2_OCO3Sets6.Count; AUDCAD_OCO3S6_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO3Sets6[AUDCAD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO3Sets6[AUDCAD_OCO3S6_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO3Sets6.RemoveAt(AUDCAD_OCO3S6_UP_S2);
	                        AUDCAD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCAD_OCO4_EO1_UP_S2)
	                Base.AUDCAD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCAD_OCO4_EO2_UP_S2)
	                Base.AUDCAD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO4_EO3_UP_S2)
	                Base.AUDCAD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO4_EO4_UP_S2)
	                Base.AUDCAD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO4_EO5_UP_S2)
	                Base.AUDCAD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO4_EO6_UP_S2)
	                Base.AUDCAD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.AUDCAD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP1,"TP1_AUDCAD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP1_AUDCAD_UP_S2_OCO4"));
		                 };
		                Base.AUDCAD_UP_S2_OCO4Sets1.Add( Base.AUDCAD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP2,"TP2_AUDCAD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP2_AUDCAD_UP_S2_OCO4"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO4Sets2.Add( Base.AUDCAD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP3,"TP3_AUDCAD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP3_AUDCAD_UP_S2_OCO4"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO4Sets3.Add( Base.AUDCAD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP4,"TP4_AUDCAD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP4_AUDCAD_UP_S2_OCO4"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO4Sets4.Add( Base.AUDCAD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP5,"TP5_AUDCAD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP5_AUDCAD_UP_S2_OCO4"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO4Sets5.Add( Base.AUDCAD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_UP_S2_TP6,"TP6_AUDCAD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_UP_S2_SL,"SL_TP6_AUDCAD_UP_S2_OCO4"));
		                 };
	                    Base.AUDCAD_UP_S2_OCO4Sets6.Add( Base.AUDCAD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDCAD_OCO4S1_UP_S2 = 0;
	                for (; AUDCAD_OCO4S1_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets1.Count; AUDCAD_OCO4S1_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO4Sets1[AUDCAD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO4Sets1[AUDCAD_OCO4S1_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO4Sets1.RemoveAt(AUDCAD_OCO4S1_UP_S2);
	                        AUDCAD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCAD_OCO4S2_UP_S2 = 0;
	                for (; AUDCAD_OCO4S2_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets2.Count; AUDCAD_OCO4S2_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO4Sets2[AUDCAD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO4Sets2[AUDCAD_OCO4S2_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO4Sets2.RemoveAt(AUDCAD_OCO4S2_UP_S2);
	                        AUDCAD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO4S3_UP_S2 = 0;
	                for (; AUDCAD_OCO4S3_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets3.Count; AUDCAD_OCO4S3_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO4Sets3[AUDCAD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO4Sets3[AUDCAD_OCO4S3_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO4Sets3.RemoveAt(AUDCAD_OCO4S3_UP_S2);
	                        AUDCAD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO4S4_UP_S2 = 0;
	                for (; AUDCAD_OCO4S4_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets4.Count; AUDCAD_OCO4S4_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO4Sets4[AUDCAD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO4Sets4[AUDCAD_OCO4S4_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO4Sets4.RemoveAt(AUDCAD_OCO4S4_UP_S2);
	                        AUDCAD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCAD_OCO4S5_UP_S2 = 0;
	                for (; AUDCAD_OCO4S5_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets5.Count; AUDCAD_OCO4S5_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO4Sets5[AUDCAD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO4Sets5[AUDCAD_OCO4S5_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO4Sets5.RemoveAt(AUDCAD_OCO4S5_UP_S2);
	                        AUDCAD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCAD_OCO4S6_UP_S2 = 0;
	                for (; AUDCAD_OCO4S6_UP_S2 < Base.AUDCAD_UP_S2_OCO4Sets6.Count; AUDCAD_OCO4S6_UP_S2++)
	                    if (Base.AUDCAD_UP_S2_OCO4Sets6[AUDCAD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_UP_S2_OCO4Sets6[AUDCAD_OCO4S6_UP_S2].Filled();
	                        Base.AUDCAD_UP_S2_OCO4Sets6.RemoveAt(AUDCAD_OCO4S6_UP_S2);
	                        AUDCAD_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_CHFJPY_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_CHFJPY_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(x=>x.Tag.Contains("CHFJPY_UP_S2_OCO1")))
			{
				Base.CHFJPY_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CHFJPY_UP_S2_OCO2")))
			{
				Base.CHFJPY_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CHFJPY_UP_S2_OCO3")))
			{
				Base.CHFJPY_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("CHFJPY_UP_S2_OCO4")))
			{
				Base.CHFJPY_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("CHFJPY_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.CHFJPY_OCO1_EO1_UP_S2)
	                Base.CHFJPY_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.CHFJPY_OCO1_EO2_UP_S2)
	                Base.CHFJPY_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO1_EO3_UP_S2)
	                Base.CHFJPY_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO1_EO4_UP_S2)
	                Base.CHFJPY_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO1_EO5_UP_S2)
	                Base.CHFJPY_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO1_EO6_UP_S2)
	                Base.CHFJPY_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CHFJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int CHFJPY_OCO1S1_UP_S2 = 0;
		                for (; CHFJPY_OCO1S1_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets1.Count; CHFJPY_OCO1S1_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO1Sets1[CHFJPY_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO1Sets1[CHFJPY_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_1__Time out_OCO1");
		                        Base.CHFJPY_UP_S2_OCO1Sets1.Clear();
		                        CHFJPY_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int CHFJPY_OCO1S2_UP_S2 = 0;
		                for (; CHFJPY_OCO1S2_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets2.Count; CHFJPY_OCO1S2_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO1Sets2[CHFJPY_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO1Sets2[CHFJPY_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_2__Time out_OCO1");
		                        Base.CHFJPY_UP_S2_OCO1Sets2.Clear();
		                        CHFJPY_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO1S3_UP_S2 = 0;
		                for (; CHFJPY_OCO1S3_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets3.Count; CHFJPY_OCO1S3_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO1Sets3[CHFJPY_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO1Sets3[CHFJPY_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_3__Time out_OCO1");
		                        Base.CHFJPY_UP_S2_OCO1Sets3.Clear();
		                        CHFJPY_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO1S4_UP_S2 = 0;
		                for (; CHFJPY_OCO1S4_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets4.Count; CHFJPY_OCO1S4_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO1Sets4[CHFJPY_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO1Sets4[CHFJPY_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_4__Time out_OCO1");
		                        Base.CHFJPY_UP_S2_OCO1Sets4.Clear();
		                        CHFJPY_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO1S5_UP_S2 = 0;
		                for (; CHFJPY_OCO1S5_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets5.Count; CHFJPY_OCO1S5_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO1Sets5[CHFJPY_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO1Sets5[CHFJPY_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_5__Time out_OCO1");
		                        Base.CHFJPY_UP_S2_OCO1Sets5.Clear();
		                        CHFJPY_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO1S6_UP_S2 = 0;
		                for (; CHFJPY_OCO1S6_UP_S2 < Base.CHFJPY_UP_S2_OCO1Sets6.Count; CHFJPY_OCO1S6_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO1Sets6[CHFJPY_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO1Sets6[CHFJPY_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_6__Time out_OCO1");
		                        Base.CHFJPY_UP_S2_OCO1Sets6.Clear();
		                        CHFJPY_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.CHFJPY_OCO2_EO1_UP_S2)
                	Base.CHFJPY_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.CHFJPY_OCO2_EO2_UP_S2)
	                Base.CHFJPY_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO2_EO3_UP_S2)
	                Base.CHFJPY_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO2_EO4_UP_S2)
	                Base.CHFJPY_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO2_EO5_UP_S2)
	                Base.CHFJPY_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO2_EO6_UP_S2)
	                Base.CHFJPY_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CHFJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int CHFJPY_OCO2S1_UP_S2 = 0;
		                for (; CHFJPY_OCO2S1_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets1.Count; CHFJPY_OCO2S1_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO2Sets1[CHFJPY_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO2Sets1[CHFJPY_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_1__Time out_OCO2");
		                        Base.CHFJPY_UP_S2_OCO2Sets1.Clear();
		                        CHFJPY_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int CHFJPY_OCO2S2_UP_S2 = 0;
		                for (; CHFJPY_OCO2S2_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets2.Count; CHFJPY_OCO2S2_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO2Sets2[CHFJPY_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO2Sets2[CHFJPY_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_2__Time out_OCO2");
		                        Base.CHFJPY_UP_S2_OCO2Sets2.Clear();
		                        CHFJPY_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO2S3_UP_S2 = 0;
		                for (; CHFJPY_OCO2S3_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets3.Count; CHFJPY_OCO2S3_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO2Sets3[CHFJPY_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO2Sets3[CHFJPY_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_3__Time out_OCO2");
		                        Base.CHFJPY_UP_S2_OCO2Sets3.Clear();
		                        CHFJPY_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO2S4_UP_S2 = 0;
		                for (; CHFJPY_OCO2S4_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets4.Count; CHFJPY_OCO2S4_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO2Sets4[CHFJPY_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO2Sets4[CHFJPY_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_4__Time out_OCO2");
		                        Base.CHFJPY_UP_S2_OCO2Sets4.Clear();
		                        CHFJPY_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO2S5_UP_S2 = 0;
		                for (; CHFJPY_OCO2S5_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets5.Count; CHFJPY_OCO2S5_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO2Sets5[CHFJPY_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO2Sets5[CHFJPY_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_5__Time out_OCO2");
		                        Base.CHFJPY_UP_S2_OCO2Sets5.Clear();
		                        CHFJPY_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO2S6_UP_S2 = 0;
		                for (; CHFJPY_OCO2S6_UP_S2 < Base.CHFJPY_UP_S2_OCO2Sets6.Count; CHFJPY_OCO2S6_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO2Sets6[CHFJPY_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO2Sets6[CHFJPY_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_6__Time out_OCO2");
		                        Base.CHFJPY_UP_S2_OCO2Sets6.Clear();
		                        CHFJPY_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.CHFJPY_OCO3_EO1_UP_S2)
            		Base.CHFJPY_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.CHFJPY_OCO3_EO2_UP_S2)
	                Base.CHFJPY_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO3_EO3_UP_S2)
	                Base.CHFJPY_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO3_EO4_UP_S2)
	                Base.CHFJPY_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO3_EO5_UP_S2)
	                Base.CHFJPY_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO3_EO6_UP_S2)
	                Base.CHFJPY_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CHFJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int CHFJPY_OCO3S1_UP_S2 = 0;
		                for (; CHFJPY_OCO3S1_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets1.Count; CHFJPY_OCO3S1_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO3Sets1[CHFJPY_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO3Sets1[CHFJPY_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_1__Time out_OCO3");
		                        Base.CHFJPY_UP_S2_OCO3Sets1.Clear();
		                        CHFJPY_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int CHFJPY_OCO3S2_UP_S2 = 0;
		                for (; CHFJPY_OCO3S2_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets2.Count; CHFJPY_OCO3S2_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO3Sets2[CHFJPY_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO3Sets2[CHFJPY_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_2__Time out_OCO3");
		                        Base.CHFJPY_UP_S2_OCO3Sets2.Clear();
		                        CHFJPY_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO3S3_UP_S2 = 0;
		                for (; CHFJPY_OCO3S3_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets3.Count; CHFJPY_OCO3S3_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO3Sets3[CHFJPY_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO3Sets3[CHFJPY_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_3__Time out_OCO3");
		                        Base.CHFJPY_UP_S2_OCO3Sets3.Clear();
		                        CHFJPY_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO3S4_UP_S2 = 0;
		                for (; CHFJPY_OCO3S4_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets4.Count; CHFJPY_OCO3S4_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO3Sets4[CHFJPY_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO3Sets4[CHFJPY_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_4__Time out_OCO3");
		                        Base.CHFJPY_UP_S2_OCO3Sets4.Clear();
		                        CHFJPY_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO3S5_UP_S2 = 0;
		                for (; CHFJPY_OCO3S5_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets5.Count; CHFJPY_OCO3S5_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO3Sets5[CHFJPY_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO3Sets5[CHFJPY_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_5__Time out_OCO3");
		                        Base.CHFJPY_UP_S2_OCO3Sets5.Clear();
		                        CHFJPY_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO3S6_UP_S2 = 0;
		                for (; CHFJPY_OCO3S6_UP_S2 < Base.CHFJPY_UP_S2_OCO3Sets6.Count; CHFJPY_OCO3S6_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO3Sets6[CHFJPY_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO3Sets6[CHFJPY_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_6__Time out_OCO3");
		                        Base.CHFJPY_UP_S2_OCO3Sets6.Clear();
		                        CHFJPY_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.CHFJPY_OCO4_EO1_UP_S2)
            		Base.CHFJPY_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.CHFJPY_OCO4_EO2_UP_S2)
	                Base.CHFJPY_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO4_EO3_UP_S2)
	                Base.CHFJPY_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO4_EO4_UP_S2)
	                Base.CHFJPY_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO4_EO5_UP_S2)
	                Base.CHFJPY_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.CHFJPY_OCO4_EO6_UP_S2)
	                Base.CHFJPY_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.CHFJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int CHFJPY_OCO4S1_UP_S2 = 0;
		                for (; CHFJPY_OCO4S1_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets1.Count; CHFJPY_OCO4S1_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO4Sets1[CHFJPY_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO4Sets1[CHFJPY_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_1__Time out_OCO4");
		                        Base.CHFJPY_UP_S2_OCO4Sets1.Clear();
		                        CHFJPY_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int CHFJPY_OCO4S2_UP_S2 = 0;
		                for (; CHFJPY_OCO4S2_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets2.Count; CHFJPY_OCO4S2_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO4Sets2[CHFJPY_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO4Sets2[CHFJPY_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_2__Time out_OCO4");
		                        Base.CHFJPY_UP_S2_OCO4Sets2.Clear();
		                        CHFJPY_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO4S3_UP_S2 = 0;
		                for (; CHFJPY_OCO4S3_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets3.Count; CHFJPY_OCO4S3_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO4Sets3[CHFJPY_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO4Sets3[CHFJPY_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_3__Time out_OCO4");
		                        Base.CHFJPY_UP_S2_OCO4Sets3.Clear();
		                        CHFJPY_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int CHFJPY_OCO4S4_UP_S2 = 0;
		                for (; CHFJPY_OCO4S4_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets4.Count; CHFJPY_OCO4S4_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO4Sets4[CHFJPY_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO4Sets4[CHFJPY_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_4__Time out_OCO4");
		                        Base.CHFJPY_UP_S2_OCO4Sets4.Clear();
		                        CHFJPY_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO4S5_UP_S2 = 0;
		                for (; CHFJPY_OCO4S5_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets5.Count; CHFJPY_OCO4S5_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO4Sets5[CHFJPY_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO4Sets5[CHFJPY_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_5__Time out_OCO4");
		                        Base.CHFJPY_UP_S2_OCO4Sets5.Clear();
		                        CHFJPY_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int CHFJPY_OCO4S6_UP_S2 = 0;
		                for (; CHFJPY_OCO4S6_UP_S2 < Base.CHFJPY_UP_S2_OCO4Sets6.Count; CHFJPY_OCO4S6_UP_S2++)
		                    if (Base.CHFJPY_UP_S2_OCO4Sets6[CHFJPY_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.CHFJPY_UP_S2_OCO4Sets6[CHFJPY_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("CHFJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("CHFJPY", order.Quantity, false, "CHFJPY_UP_S2_Entry_6__Time out_OCO4");
		                        Base.CHFJPY_UP_S2_OCO4Sets6.Clear();
		                        CHFJPY_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_CHFJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_CHFJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_CHFJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_CHFJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_CHFJPY_UP_S2 = DOWM_CHFJPY_UP_S2 || DOWT_CHFJPY_UP_S2 || DOWW_CHFJPY_UP_S2 || DOWTH_CHFJPY_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("CHFJPY") && SY1D.Symbol.ID.Market == Market.FXCM)
	            	{
	            		if(SY1D.BQ[0].Open != 0)
	            		{
	            			algorithm.Debug("ID : " + SY1D.Symbol.ID.Market);
	            		}
	            		
	            		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.CHFJPY_OCO1_UP_S2_IsReady == false ||
	                    	Base.CHFJPY_OCO2_UP_S2_IsReady == false ||
	                    	Base.CHFJPY_OCO3_UP_S2_IsReady == false ||
	                    	Base.CHFJPY_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.CHFJPY_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.CHFJPY_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.CHFJPY_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.CHFJPY_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.CHFJPY_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.CHFJPY_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.CHFJPY_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.CHFJPY_OCO4_UP_S2_Monthly_IsReady = true;
                    	}

	                	CHFJPY_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										&&
		                										(
		                											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.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										)
		                										&&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                	CHFJPY_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										&&
		                										(
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										)
		                										&&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                									
	                	CHFJPY_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										&&
		                										(
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										)
		                										&&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                	if (CHFJPY_Signal_Condition_UP_1)
	                	{
	                    	CHFJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (CHFJPY_Signal_Condition_UP_2)
	                	{
	                    	CHFJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (CHFJPY_Signal_Condition_UP_3)
	                	{
	                    	CHFJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (CHFJPY_Signal_Condition_UP_1)
	                	{
	                    	CHFJPY_UP_S2_TP1  =  Base.Yen_TP_1 ;
	                	}
	                	
	                	if (CHFJPY_Signal_Condition_UP_2)
	                	{
	                    	CHFJPY_UP_S2_TP1  =  Base.Yen_TP_2 ;
	                	}
	                	
	                	if (CHFJPY_Signal_Condition_UP_3)
	                	{
	                    	CHFJPY_UP_S2_TP1  =  Base.Yen_TP_3 ;
	                	}

	                    CHFJPY_UP_S2_TP2 =  CHFJPY_UP_S2_SL * 0;
	                    CHFJPY_UP_S2_TP3 =  CHFJPY_UP_S2_SL * 0;
	                    CHFJPY_UP_S2_TP4 =  CHFJPY_UP_S2_SL * 0;
	                    CHFJPY_UP_S2_TP5 =  CHFJPY_UP_S2_SL * 0;
	                    CHFJPY_UP_S2_TP6 =  CHFJPY_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    CHFJPY_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    CHFJPY_quantity_SL_UP_S2 = CHFJPY_quantity_UP_S2;
	                    CHFJPY_quantity_TP1_UP_S2 = (int)Math.Floor(CHFJPY_quantity_UP_S2 * 1m);
	                    CHFJPY_quantity_TP2_UP_S2 = (int)Math.Floor(CHFJPY_quantity_TP1_UP_S2 * 0m);
	                    CHFJPY_quantity_TP3_UP_S2 = (int)Math.Floor(CHFJPY_quantity_TP2_UP_S2 * 0m);
	                    CHFJPY_quantity_TP4_UP_S2 = (int)Math.Floor(CHFJPY_quantity_TP3_UP_S2 * 0m);
	                    CHFJPY_quantity_TP5_UP_S2 = (int)Math.Floor(CHFJPY_quantity_TP4_UP_S2 * 0m);
	                    CHFJPY_quantity_TP6_UP_S2 = (int)Math.Floor(CHFJPY_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((CHFJPY_Signal_Condition_UP_1 || CHFJPY_Signal_Condition_UP_2 || CHFJPY_Signal_Condition_UP_3)  && 
	                    DOWR_CHFJPY_UP_S2 && 
	                    Base.CHFJPY_OCO1_UP_S2_IsReady == true &&
	                    Base.CHFJPY_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.CHFJPY_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP1_UP_S2, false,"CHFJPY_UP_S2_Entry_TP1_OCO1");
	                         Base.CHFJPY_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.CHFJPY_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP2_UP_S2, false,"CHFJPY_UP_S2_Entry_TP2_OCO1");
	                         Base.CHFJPY_OCO1_EO2_UP_S2 = false;
	
	                         Base.CHFJPY_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP3_UP_S2, false,"CHFJPY_UP_S2_Entry_TP3_OCO1");
	                         Base.CHFJPY_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.CHFJPY_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP4_UP_S2, false,"CHFJPY_UP_S2_Entry_TP4_OCO1");
	                         Base.CHFJPY_OCO1_EO4_UP_S2 = false;

							Base.CHFJPY_OCO1_UP_S2_IsReady = false;
							
							if (Base.CHFJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco2:
	                    if ((CHFJPY_Signal_Condition_UP_1 || CHFJPY_Signal_Condition_UP_2 || CHFJPY_Signal_Condition_UP_3)  && 
	                    DOWR_CHFJPY_UP_S2 && 
	                    Base.CHFJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.CHFJPY_OCO2_UP_S2_IsReady == true &&
	                    Base.CHFJPY_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.CHFJPY_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP1_UP_S2, false,"CHFJPY_UP_S2_Entry_TP1_OCO2");
	                         Base.CHFJPY_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.CHFJPY_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP2_UP_S2, false,"CHFJPY_UP_S2_Entry_TP2_OCO2");
	                         Base.CHFJPY_OCO2_EO2_UP_S2 = false;
	
	                         Base.CHFJPY_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP3_UP_S2, false,"CHFJPY_UP_S2_Entry_TP3_OCO2");
	                         Base.CHFJPY_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.CHFJPY_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP4_UP_S2, false,"CHFJPY_UP_S2_Entry_TP4_OCO2");
	                         Base.CHFJPY_OCO2_EO4_UP_S2 = false;

							Base.CHFJPY_OCO2_UP_S2_IsReady = false;
							
							if (Base.CHFJPY_OCO2_UP_S2_IsReady == false && Base.CHFJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco3:
	                    if ((CHFJPY_Signal_Condition_UP_1 || CHFJPY_Signal_Condition_UP_2 || CHFJPY_Signal_Condition_UP_3)  && 
	                    DOWR_CHFJPY_UP_S2 &&
	                    Base.CHFJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.CHFJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.CHFJPY_OCO3_UP_S2_IsReady == true &&
	                    Base.CHFJPY_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.CHFJPY_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP1_UP_S2, false,"CHFJPY_UP_S2_Entry_TP1_OCO3");
	                         Base.CHFJPY_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.CHFJPY_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP2_UP_S2, false,"CHFJPY_UP_S2_Entry_TP2_OCO3");
	                         Base.CHFJPY_OCO3_EO2_UP_S2 = false;
	
	                         Base.CHFJPY_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP3_UP_S2, false,"CHFJPY_UP_S2_Entry_TP3_OCO3");
	                         Base.CHFJPY_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.CHFJPY_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP4_UP_S2, false,"CHFJPY_UP_S2_Entry_TP4_OCO3");
	                         Base.CHFJPY_OCO3_EO4_UP_S2 = false;

							Base.CHFJPY_OCO3_UP_S2_IsReady = false;
							
							if (Base.CHFJPY_OCO3_UP_S2_IsReady == false && Base.CHFJPY_OCO2_UP_S2_IsReady == false && Base.CHFJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco4:
	                    if ((CHFJPY_Signal_Condition_UP_1 || CHFJPY_Signal_Condition_UP_2 || CHFJPY_Signal_Condition_UP_3)  && 
	                    DOWR_CHFJPY_UP_S2 && 
	                    Base.CHFJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.CHFJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.CHFJPY_OCO3_UP_S2_IsReady == false &&
	                    Base.CHFJPY_OCO4_UP_S2_IsReady == true &&
	                    Base.CHFJPY_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.CHFJPY_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP1_UP_S2, false,"CHFJPY_UP_S2_Entry_TP1_OCO4");
	                         Base.CHFJPY_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.CHFJPY_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP2_UP_S2, false,"CHFJPY_UP_S2_Entry_TP2_OCO4");
	                         Base.CHFJPY_OCO4_EO2_UP_S2 = false;
	
	                         Base.CHFJPY_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP3_UP_S2, false,"CHFJPY_UP_S2_Entry_TP3_OCO4");
	                         Base.CHFJPY_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.CHFJPY_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         CHFJPY_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, CHFJPY_quantity_TP4_UP_S2, false,"CHFJPY_UP_S2_Entry_TP4_OCO4");
	                         Base.CHFJPY_OCO4_EO4_UP_S2 = false;

							Base.CHFJPY_OCO4_UP_S2_IsReady = false;
							
							if (Base.CHFJPY_OCO4_UP_S2_IsReady == false && Base.CHFJPY_OCO3_UP_S2_IsReady == false && Base.CHFJPY_OCO2_UP_S2_IsReady == false && Base.CHFJPY_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.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 EURGBP_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURGBP_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("EURGBP OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURGBP OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURGBP OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURGBP OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURGBP OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURGBP OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURGBP OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        }
		        
				if (Base.EURGBP_OCO1_EO1_UP_S2)
	                Base.EURGBP_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURGBP_OCO1_EO2_UP_S2)
	                Base.EURGBP_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO1_EO3_UP_S2)
	                Base.EURGBP_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO1_EO4_UP_S2)
	                Base.EURGBP_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO1_EO5_UP_S2)
	                Base.EURGBP_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO1_EO6_UP_S2)
	                Base.EURGBP_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURGBP_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.EURGBP_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP1,"TP1_EURGBP_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP1_EURGBP_UP_S2_OCO1"));
		                 };
		                Base.EURGBP_UP_S2_OCO1Sets1.Add( Base.EURGBP_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURGBP_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP2,"TP2_EURGBP_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP2_EURGBP_UP_S2_OCO1"));
		                 };
	                    Base.EURGBP_UP_S2_OCO1Sets2.Add( Base.EURGBP_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP3,"TP3_EURGBP_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP3_EURGBP_UP_S2_OCO1"));
		                 };
	                    Base.EURGBP_UP_S2_OCO1Sets3.Add( Base.EURGBP_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP4,"TP4_EURGBP_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP4_EURGBP_UP_S2_OCO1"));
		                 };
	                    Base.EURGBP_UP_S2_OCO1Sets4.Add( Base.EURGBP_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP5,"TP5_EURGBP_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP5_EURGBP_UP_S2_OCO1"));
		                 };
	                    Base.EURGBP_UP_S2_OCO1Sets5.Add( Base.EURGBP_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP6,"TP6_EURGBP_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP6_EURGBP_UP_S2_OCO1"));
		                 };
	                    Base.EURGBP_UP_S2_OCO1Sets6.Add( Base.EURGBP_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURGBP_OCO1S1_UP_S2 = 0;
	                for (; EURGBP_OCO1S1_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets1.Count; EURGBP_OCO1S1_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO1Sets1[EURGBP_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO1Sets1[EURGBP_OCO1S1_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO1Sets1.RemoveAt(EURGBP_OCO1S1_UP_S2);
	                        EURGBP_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURGBP_OCO1S2_UP_S2 = 0;
	                for (; EURGBP_OCO1S2_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets2.Count; EURGBP_OCO1S2_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO1Sets2[EURGBP_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO1Sets2[EURGBP_OCO1S2_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO1Sets2.RemoveAt(EURGBP_OCO1S2_UP_S2);
	                        EURGBP_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO1S3_UP_S2 = 0;
	                for (; EURGBP_OCO1S3_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets3.Count; EURGBP_OCO1S3_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO1Sets3[EURGBP_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO1Sets3[EURGBP_OCO1S3_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO1Sets3.RemoveAt(EURGBP_OCO1S3_UP_S2);
	                        EURGBP_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO1S4_UP_S2 = 0;
	                for (; EURGBP_OCO1S4_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets4.Count; EURGBP_OCO1S4_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO1Sets4[EURGBP_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO1Sets4[EURGBP_OCO1S4_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO1Sets4.RemoveAt(EURGBP_OCO1S4_UP_S2);
	                        EURGBP_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURGBP_OCO1S5_UP_S2 = 0;
	                for (; EURGBP_OCO1S5_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets5.Count; EURGBP_OCO1S5_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO1Sets5[EURGBP_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO1Sets5[EURGBP_OCO1S5_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO1Sets5.RemoveAt(EURGBP_OCO1S5_UP_S2);
	                        EURGBP_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURGBP_OCO1S6_UP_S2 = 0;
	                for (; EURGBP_OCO1S6_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets6.Count; EURGBP_OCO1S6_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO1Sets6[EURGBP_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO1Sets6[EURGBP_OCO1S6_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO1Sets6.RemoveAt(EURGBP_OCO1S6_UP_S2);
	                        EURGBP_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.EURGBP_OCO2_EO1_UP_S2)
	                Base.EURGBP_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURGBP_OCO2_EO2_UP_S2)
	                Base.EURGBP_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO2_EO3_UP_S2)
	                Base.EURGBP_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO2_EO4_UP_S2)
	                Base.EURGBP_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO2_EO5_UP_S2)
	                Base.EURGBP_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO2_EO6_UP_S2)
	                Base.EURGBP_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURGBP_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.EURGBP_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP1,"TP1_EURGBP_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP1_EURGBP_UP_S2_OCO2"));
		                 };
		                Base.EURGBP_UP_S2_OCO2Sets1.Add( Base.EURGBP_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURGBP_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP2,"TP2_EURGBP_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP2_EURGBP_UP_S2_OCO2"));
		                 };
	                    Base.EURGBP_UP_S2_OCO2Sets2.Add( Base.EURGBP_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP3,"TP3_EURGBP_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP3_EURGBP_UP_S2_OCO2"));
		                 };
	                    Base.EURGBP_UP_S2_OCO2Sets3.Add( Base.EURGBP_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP4,"TP4_EURGBP_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP4_EURGBP_UP_S2_OCO2"));
		                 };
	                    Base.EURGBP_UP_S2_OCO2Sets4.Add( Base.EURGBP_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP5,"TP5_EURGBP_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP5_EURGBP_UP_S2_OCO2"));
		                 };
	                    Base.EURGBP_UP_S2_OCO2Sets5.Add( Base.EURGBP_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP6,"TP6_EURGBP_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP6_EURGBP_UP_S2_OCO2"));
		                 };
	                    Base.EURGBP_UP_S2_OCO2Sets6.Add( Base.EURGBP_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURGBP_OCO2S1_UP_S2 = 0;
	                for (; EURGBP_OCO2S1_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets1.Count; EURGBP_OCO2S1_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO2Sets1[EURGBP_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO2Sets1[EURGBP_OCO2S1_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO2Sets1.RemoveAt(EURGBP_OCO2S1_UP_S2);
	                        EURGBP_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURGBP_OCO2S2_UP_S2 = 0;
	                for (; EURGBP_OCO2S2_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets2.Count; EURGBP_OCO2S2_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO2Sets2[EURGBP_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO2Sets2[EURGBP_OCO2S2_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO2Sets2.RemoveAt(EURGBP_OCO2S2_UP_S2);
	                        EURGBP_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO2S3_UP_S2 = 0;
	                for (; EURGBP_OCO2S3_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets3.Count; EURGBP_OCO2S3_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO2Sets3[EURGBP_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO2Sets3[EURGBP_OCO2S3_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO2Sets3.RemoveAt(EURGBP_OCO2S3_UP_S2);
	                        EURGBP_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO2S4_UP_S2 = 0;
	                for (; EURGBP_OCO2S4_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets4.Count; EURGBP_OCO2S4_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO2Sets4[EURGBP_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO2Sets4[EURGBP_OCO2S4_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO2Sets4.RemoveAt(EURGBP_OCO2S4_UP_S2);
	                        EURGBP_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURGBP_OCO2S5_UP_S2 = 0;
	                for (; EURGBP_OCO2S5_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets5.Count; EURGBP_OCO2S5_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO2Sets5[EURGBP_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO2Sets5[EURGBP_OCO2S5_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO2Sets5.RemoveAt(EURGBP_OCO2S5_UP_S2);
	                        EURGBP_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURGBP_OCO2S6_UP_S2 = 0;
	                for (; EURGBP_OCO2S6_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets6.Count; EURGBP_OCO2S6_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO2Sets6[EURGBP_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO2Sets6[EURGBP_OCO2S6_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO2Sets6.RemoveAt(EURGBP_OCO2S6_UP_S2);
	                        EURGBP_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURGBP_OCO3_EO1_UP_S2)
	                Base.EURGBP_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURGBP_OCO3_EO2_UP_S2)
	                Base.EURGBP_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO3_EO3_UP_S2)
	                Base.EURGBP_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO3_EO4_UP_S2)
	                Base.EURGBP_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO3_EO5_UP_S2)
	                Base.EURGBP_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO3_EO6_UP_S2)
	                Base.EURGBP_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURGBP_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.EURGBP_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP1,"TP1_EURGBP_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP1_EURGBP_UP_S2_OCO3"));
		                 };
		                Base.EURGBP_UP_S2_OCO3Sets1.Add( Base.EURGBP_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURGBP_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP2,"TP2_EURGBP_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP2_EURGBP_UP_S2_OCO3"));
		                 };
	                    Base.EURGBP_UP_S2_OCO3Sets2.Add( Base.EURGBP_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP3,"TP3_EURGBP_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP3_EURGBP_UP_S2_OCO3"));
		                 };
	                    Base.EURGBP_UP_S2_OCO3Sets3.Add( Base.EURGBP_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP4,"TP4_EURGBP_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP4_EURGBP_UP_S2_OCO3"));
		                 };
	                    Base.EURGBP_UP_S2_OCO3Sets4.Add( Base.EURGBP_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP5,"TP5_EURGBP_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP5_EURGBP_UP_S2_OCO3"));
		                 };
	                    Base.EURGBP_UP_S2_OCO3Sets5.Add( Base.EURGBP_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP6,"TP6_EURGBP_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP6_EURGBP_UP_S2_OCO3"));
		                 };
	                    Base.EURGBP_UP_S2_OCO3Sets6.Add( Base.EURGBP_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURGBP_OCO3S1_UP_S2 = 0;
	                for (; EURGBP_OCO3S1_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets1.Count; EURGBP_OCO3S1_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO3Sets1[EURGBP_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO3Sets1[EURGBP_OCO3S1_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO3Sets1.RemoveAt(EURGBP_OCO3S1_UP_S2);
	                        EURGBP_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURGBP_OCO3S2_UP_S2 = 0;
	                for (; EURGBP_OCO3S2_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets2.Count; EURGBP_OCO3S2_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO3Sets2[EURGBP_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO3Sets2[EURGBP_OCO3S2_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO3Sets2.RemoveAt(EURGBP_OCO3S2_UP_S2);
	                        EURGBP_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO3S3_UP_S2 = 0;
	                for (; EURGBP_OCO3S3_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets3.Count; EURGBP_OCO3S3_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO3Sets3[EURGBP_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO3Sets3[EURGBP_OCO3S3_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO3Sets3.RemoveAt(EURGBP_OCO3S3_UP_S2);
	                        EURGBP_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO3S4_UP_S2 = 0;
	                for (; EURGBP_OCO3S4_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets4.Count; EURGBP_OCO3S4_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO3Sets4[EURGBP_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO3Sets4[EURGBP_OCO3S4_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO3Sets4.RemoveAt(EURGBP_OCO3S4_UP_S2);
	                        EURGBP_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURGBP_OCO3S5_UP_S2 = 0;
	                for (; EURGBP_OCO3S5_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets5.Count; EURGBP_OCO3S5_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO3Sets5[EURGBP_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO3Sets5[EURGBP_OCO3S5_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO3Sets5.RemoveAt(EURGBP_OCO3S5_UP_S2);
	                        EURGBP_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURGBP_OCO3S6_UP_S2 = 0;
	                for (; EURGBP_OCO3S6_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets6.Count; EURGBP_OCO3S6_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO3Sets6[EURGBP_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO3Sets6[EURGBP_OCO3S6_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO3Sets6.RemoveAt(EURGBP_OCO3S6_UP_S2);
	                        EURGBP_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURGBP_OCO4_EO1_UP_S2)
	                Base.EURGBP_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURGBP_OCO4_EO2_UP_S2)
	                Base.EURGBP_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO4_EO3_UP_S2)
	                Base.EURGBP_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO4_EO4_UP_S2)
	                Base.EURGBP_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO4_EO5_UP_S2)
	                Base.EURGBP_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO4_EO6_UP_S2)
	                Base.EURGBP_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURGBP_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.EURGBP_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP1,"TP1_EURGBP_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP1_EURGBP_UP_S2_OCO4"));
		                 };
		                Base.EURGBP_UP_S2_OCO4Sets1.Add( Base.EURGBP_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURGBP_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP2,"TP2_EURGBP_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP2_EURGBP_UP_S2_OCO4"));
		                 };
	                    Base.EURGBP_UP_S2_OCO4Sets2.Add( Base.EURGBP_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP3,"TP3_EURGBP_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP3_EURGBP_UP_S2_OCO4"));
		                 };
	                    Base.EURGBP_UP_S2_OCO4Sets3.Add( Base.EURGBP_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP4,"TP4_EURGBP_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP4_EURGBP_UP_S2_OCO4"));
		                 };
	                    Base.EURGBP_UP_S2_OCO4Sets4.Add( Base.EURGBP_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP5,"TP5_EURGBP_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP5_EURGBP_UP_S2_OCO4"));
		                 };
	                    Base.EURGBP_UP_S2_OCO4Sets5.Add( Base.EURGBP_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_UP_S2_TP6,"TP6_EURGBP_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_UP_S2_SL,"SL_TP6_EURGBP_UP_S2_OCO4"));
		                 };
	                    Base.EURGBP_UP_S2_OCO4Sets6.Add( Base.EURGBP_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURGBP_OCO4S1_UP_S2 = 0;
	                for (; EURGBP_OCO4S1_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets1.Count; EURGBP_OCO4S1_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO4Sets1[EURGBP_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO4Sets1[EURGBP_OCO4S1_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO4Sets1.RemoveAt(EURGBP_OCO4S1_UP_S2);
	                        EURGBP_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURGBP_OCO4S2_UP_S2 = 0;
	                for (; EURGBP_OCO4S2_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets2.Count; EURGBP_OCO4S2_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO4Sets2[EURGBP_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO4Sets2[EURGBP_OCO4S2_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO4Sets2.RemoveAt(EURGBP_OCO4S2_UP_S2);
	                        EURGBP_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO4S3_UP_S2 = 0;
	                for (; EURGBP_OCO4S3_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets3.Count; EURGBP_OCO4S3_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO4Sets3[EURGBP_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO4Sets3[EURGBP_OCO4S3_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO4Sets3.RemoveAt(EURGBP_OCO4S3_UP_S2);
	                        EURGBP_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO4S4_UP_S2 = 0;
	                for (; EURGBP_OCO4S4_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets4.Count; EURGBP_OCO4S4_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO4Sets4[EURGBP_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO4Sets4[EURGBP_OCO4S4_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO4Sets4.RemoveAt(EURGBP_OCO4S4_UP_S2);
	                        EURGBP_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURGBP_OCO4S5_UP_S2 = 0;
	                for (; EURGBP_OCO4S5_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets5.Count; EURGBP_OCO4S5_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO4Sets5[EURGBP_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO4Sets5[EURGBP_OCO4S5_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO4Sets5.RemoveAt(EURGBP_OCO4S5_UP_S2);
	                        EURGBP_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURGBP_OCO4S6_UP_S2 = 0;
	                for (; EURGBP_OCO4S6_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets6.Count; EURGBP_OCO4S6_UP_S2++)
	                    if (Base.EURGBP_UP_S2_OCO4Sets6[EURGBP_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_UP_S2_OCO4Sets6[EURGBP_OCO4S6_UP_S2].Filled();
	                        Base.EURGBP_UP_S2_OCO4Sets6.RemoveAt(EURGBP_OCO4S6_UP_S2);
	                        EURGBP_OCO4S6_UP_S2 = 0;
	                        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.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 CHFJPY_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public CHFJPY_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("CHFJPY OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CHFJPY OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CHFJPY OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("CHFJPY OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("CHFJPY OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("CHFJPY OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue CHFJPY S2");
		        	}
		        }
		        
				if (Base.CHFJPY_OCO1_EO1_DOWN_S2)
	                Base.CHFJPY_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.CHFJPY_OCO1_EO2_DOWN_S2)
	                Base.CHFJPY_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO1_EO3_DOWN_S2)
	                Base.CHFJPY_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO1_EO4_DOWN_S2)
	                Base.CHFJPY_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.CHFJPY_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP1_CHFJPY_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP1,"TP1_CHFJPY_DOWN_S2_OCO1"));
		                 };
		                Base.CHFJPY_DOWN_S2_OCO1Sets1.Add( Base.CHFJPY_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP2_CHFJPY_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP2,"TP2_CHFJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO1Sets2.Add( Base.CHFJPY_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP3_CHFJPY_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP3,"TP3_CHFJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO1Sets3.Add( Base.CHFJPY_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP4_CHFJPY_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP4,"TP4_CHFJPY_DOWN_S2_OCO1"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO1Sets4.Add( Base.CHFJPY_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int CHFJPY_OCO1S1_DOWN_S2 = 0;
	                for (; CHFJPY_OCO1S1_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets1.Count; CHFJPY_OCO1S1_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO1Sets1[CHFJPY_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO1Sets1[CHFJPY_OCO1S1_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO1Sets1.RemoveAt(CHFJPY_OCO1S1_DOWN_S2);
	                        CHFJPY_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int CHFJPY_OCO1S2_DOWN_S2 = 0;
	                for (; CHFJPY_OCO1S2_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets2.Count; CHFJPY_OCO1S2_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO1Sets2[CHFJPY_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO1Sets2[CHFJPY_OCO1S2_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO1Sets2.RemoveAt(CHFJPY_OCO1S2_DOWN_S2);
	                        CHFJPY_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO1S3_DOWN_S2 = 0;
	                for (; CHFJPY_OCO1S3_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets3.Count; CHFJPY_OCO1S3_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO1Sets3[CHFJPY_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO1Sets3[CHFJPY_OCO1S3_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO1Sets3.RemoveAt(CHFJPY_OCO1S3_DOWN_S2);
	                        CHFJPY_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO1S4_DOWN_S2 = 0;
	                for (; CHFJPY_OCO1S4_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO1Sets4.Count; CHFJPY_OCO1S4_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO1Sets4[CHFJPY_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO1Sets4[CHFJPY_OCO1S4_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO1Sets4.RemoveAt(CHFJPY_OCO1S4_DOWN_S2);
	                        CHFJPY_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CHFJPY_OCO2_EO1_DOWN_S2)
	                Base.CHFJPY_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.CHFJPY_OCO2_EO2_DOWN_S2)
	                Base.CHFJPY_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO2_EO3_DOWN_S2)
	                Base.CHFJPY_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO2_EO4_DOWN_S2)
	                Base.CHFJPY_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.CHFJPY_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP1_CHFJPY_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP1,"TP1_CHFJPY_DOWN_S2_OCO2"));
		                 };
		                Base.CHFJPY_DOWN_S2_OCO2Sets1.Add( Base.CHFJPY_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP2_CHFJPY_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP2,"TP2_CHFJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO2Sets2.Add( Base.CHFJPY_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP3_CHFJPY_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP3,"TP3_CHFJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO2Sets3.Add( Base.CHFJPY_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP4_CHFJPY_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP4,"TP4_CHFJPY_DOWN_S2_OCO2"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO2Sets4.Add( Base.CHFJPY_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int CHFJPY_OCO2S1_DOWN_S2 = 0;
	                for (; CHFJPY_OCO2S1_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets1.Count; CHFJPY_OCO2S1_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO2Sets1[CHFJPY_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO2Sets1[CHFJPY_OCO2S1_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO2Sets1.RemoveAt(CHFJPY_OCO2S1_DOWN_S2);
	                        CHFJPY_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int CHFJPY_OCO2S2_DOWN_S2 = 0;
	                for (; CHFJPY_OCO2S2_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets2.Count; CHFJPY_OCO2S2_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO2Sets2[CHFJPY_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO2Sets2[CHFJPY_OCO2S2_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO2Sets2.RemoveAt(CHFJPY_OCO2S2_DOWN_S2);
	                        CHFJPY_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO2S3_DOWN_S2 = 0;
	                for (; CHFJPY_OCO2S3_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets3.Count; CHFJPY_OCO2S3_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO2Sets3[CHFJPY_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO2Sets3[CHFJPY_OCO2S3_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO2Sets3.RemoveAt(CHFJPY_OCO2S3_DOWN_S2);
	                        CHFJPY_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO2S4_DOWN_S2 = 0;
	                for (; CHFJPY_OCO2S4_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO2Sets4.Count; CHFJPY_OCO2S4_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO2Sets4[CHFJPY_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO2Sets4[CHFJPY_OCO2S4_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO2Sets4.RemoveAt(CHFJPY_OCO2S4_DOWN_S2);
	                        CHFJPY_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CHFJPY_OCO3_EO1_DOWN_S2)
	                Base.CHFJPY_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.CHFJPY_OCO3_EO2_DOWN_S2)
	                Base.CHFJPY_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO3_EO3_DOWN_S2)
	                Base.CHFJPY_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO3_EO4_DOWN_S2)
	                Base.CHFJPY_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.CHFJPY_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP1_CHFJPY_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP1,"TP1_CHFJPY_DOWN_S2_OCO3"));
		                 };
		                Base.CHFJPY_DOWN_S2_OCO3Sets1.Add( Base.CHFJPY_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP2_CHFJPY_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP2,"TP2_CHFJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO3Sets2.Add( Base.CHFJPY_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP3_CHFJPY_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP3,"TP3_CHFJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO3Sets3.Add( Base.CHFJPY_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP4_CHFJPY_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP4,"TP4_CHFJPY_DOWN_S2_OCO3"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO3Sets4.Add( Base.CHFJPY_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int CHFJPY_OCO3S1_DOWN_S2 = 0;
	                for (; CHFJPY_OCO3S1_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets1.Count; CHFJPY_OCO3S1_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO3Sets1[CHFJPY_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO3Sets1[CHFJPY_OCO3S1_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO3Sets1.RemoveAt(CHFJPY_OCO3S1_DOWN_S2);
	                        CHFJPY_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int CHFJPY_OCO3S2_DOWN_S2 = 0;
	                for (; CHFJPY_OCO3S2_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets2.Count; CHFJPY_OCO3S2_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO3Sets2[CHFJPY_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO3Sets2[CHFJPY_OCO3S2_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO3Sets2.RemoveAt(CHFJPY_OCO3S2_DOWN_S2);
	                        CHFJPY_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO3S3_DOWN_S2 = 0;
	                for (; CHFJPY_OCO3S3_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets3.Count; CHFJPY_OCO3S3_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO3Sets3[CHFJPY_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO3Sets3[CHFJPY_OCO3S3_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO3Sets3.RemoveAt(CHFJPY_OCO3S3_DOWN_S2);
	                        CHFJPY_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO3S4_DOWN_S2 = 0;
	                for (; CHFJPY_OCO3S4_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO3Sets4.Count; CHFJPY_OCO3S4_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO3Sets4[CHFJPY_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO3Sets4[CHFJPY_OCO3S4_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO3Sets4.RemoveAt(CHFJPY_OCO3S4_DOWN_S2);
	                        CHFJPY_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.CHFJPY_OCO4_EO1_DOWN_S2)
	                Base.CHFJPY_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.CHFJPY_OCO4_EO2_DOWN_S2)
	                Base.CHFJPY_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO4_EO3_DOWN_S2)
	                Base.CHFJPY_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.CHFJPY_OCO4_EO4_DOWN_S2)
	                Base.CHFJPY_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.CHFJPY_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP1_CHFJPY_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP1,"TP1_CHFJPY_DOWN_S2_OCO4"));
		                 };
		                Base.CHFJPY_DOWN_S2_OCO4Sets1.Add( Base.CHFJPY_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP2_CHFJPY_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP2,"TP2_CHFJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO4Sets2.Add( Base.CHFJPY_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP3_CHFJPY_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP3,"TP3_CHFJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO4Sets3.Add( Base.CHFJPY_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.CHFJPY_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.CHFJPY_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new CHFJPY_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.CHFJPY_DOWN_S2_SL,"SL_TP4_CHFJPY_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.CHFJPY_DOWN_S2_TP4,"TP4_CHFJPY_DOWN_S2_OCO4"));
		                 };
	                    Base.CHFJPY_DOWN_S2_OCO4Sets4.Add( Base.CHFJPY_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.CHFJPY_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int CHFJPY_OCO4S1_DOWN_S2 = 0;
	                for (; CHFJPY_OCO4S1_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets1.Count; CHFJPY_OCO4S1_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO4Sets1[CHFJPY_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO4Sets1[CHFJPY_OCO4S1_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO4Sets1.RemoveAt(CHFJPY_OCO4S1_DOWN_S2);
	                        CHFJPY_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int CHFJPY_OCO4S2_DOWN_S2 = 0;
	                for (; CHFJPY_OCO4S2_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets2.Count; CHFJPY_OCO4S2_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO4Sets2[CHFJPY_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO4Sets2[CHFJPY_OCO4S2_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO4Sets2.RemoveAt(CHFJPY_OCO4S2_DOWN_S2);
	                        CHFJPY_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO4S3_DOWN_S2 = 0;
	                for (; CHFJPY_OCO4S3_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets3.Count; CHFJPY_OCO4S3_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO4Sets3[CHFJPY_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO4Sets3[CHFJPY_OCO4S3_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO4Sets3.RemoveAt(CHFJPY_OCO4S3_DOWN_S2);
	                        CHFJPY_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int CHFJPY_OCO4S4_DOWN_S2 = 0;
	                for (; CHFJPY_OCO4S4_DOWN_S2 < Base.CHFJPY_DOWN_S2_OCO4Sets4.Count; CHFJPY_OCO4S4_DOWN_S2++)
	                    if (Base.CHFJPY_DOWN_S2_OCO4Sets4[CHFJPY_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.CHFJPY_DOWN_S2_OCO4Sets4[CHFJPY_OCO4S4_DOWN_S2].Filled();
	                        Base.CHFJPY_DOWN_S2_OCO4Sets4.RemoveAt(CHFJPY_OCO4S4_DOWN_S2);
	                        CHFJPY_OCO4S4_DOWN_S2 = 0;
	                        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.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 EURGBP_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURGBP_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("EURGBP OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURGBP OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURGBP OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURGBP OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("EURGBP OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("EURGBP OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue EURGBP S2");
		        	}
		        }
		        
				if (Base.EURGBP_OCO1_EO1_DOWN_S2)
	                Base.EURGBP_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURGBP_OCO1_EO2_DOWN_S2)
	                Base.EURGBP_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO1_EO3_DOWN_S2)
	                Base.EURGBP_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO1_EO4_DOWN_S2)
	                Base.EURGBP_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURGBP_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.EURGBP_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP1_EURGBP_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP1,"TP1_EURGBP_DOWN_S2_OCO1"));
		                 };
		                Base.EURGBP_DOWN_S2_OCO1Sets1.Add( Base.EURGBP_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURGBP_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP2_EURGBP_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP2,"TP2_EURGBP_DOWN_S2_OCO1"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO1Sets2.Add( Base.EURGBP_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP3_EURGBP_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP3,"TP3_EURGBP_DOWN_S2_OCO1"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO1Sets3.Add( Base.EURGBP_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP4_EURGBP_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP4,"TP4_EURGBP_DOWN_S2_OCO1"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO1Sets4.Add( Base.EURGBP_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURGBP_OCO1S1_DOWN_S2 = 0;
	                for (; EURGBP_OCO1S1_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets1.Count; EURGBP_OCO1S1_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO1Sets1[EURGBP_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO1Sets1[EURGBP_OCO1S1_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO1Sets1.RemoveAt(EURGBP_OCO1S1_DOWN_S2);
	                        EURGBP_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURGBP_OCO1S2_DOWN_S2 = 0;
	                for (; EURGBP_OCO1S2_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets2.Count; EURGBP_OCO1S2_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO1Sets2[EURGBP_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO1Sets2[EURGBP_OCO1S2_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO1Sets2.RemoveAt(EURGBP_OCO1S2_DOWN_S2);
	                        EURGBP_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO1S3_DOWN_S2 = 0;
	                for (; EURGBP_OCO1S3_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets3.Count; EURGBP_OCO1S3_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO1Sets3[EURGBP_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO1Sets3[EURGBP_OCO1S3_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO1Sets3.RemoveAt(EURGBP_OCO1S3_DOWN_S2);
	                        EURGBP_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO1S4_DOWN_S2 = 0;
	                for (; EURGBP_OCO1S4_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets4.Count; EURGBP_OCO1S4_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO1Sets4[EURGBP_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO1Sets4[EURGBP_OCO1S4_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO1Sets4.RemoveAt(EURGBP_OCO1S4_DOWN_S2);
	                        EURGBP_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURGBP_OCO2_EO1_DOWN_S2)
	                Base.EURGBP_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURGBP_OCO2_EO2_DOWN_S2)
	                Base.EURGBP_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO2_EO3_DOWN_S2)
	                Base.EURGBP_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO2_EO4_DOWN_S2)
	                Base.EURGBP_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURGBP_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.EURGBP_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP1_EURGBP_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP1,"TP1_EURGBP_DOWN_S2_OCO2"));
		                 };
		                Base.EURGBP_DOWN_S2_OCO2Sets1.Add( Base.EURGBP_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURGBP_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP2_EURGBP_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP2,"TP2_EURGBP_DOWN_S2_OCO2"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO2Sets2.Add( Base.EURGBP_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP3_EURGBP_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP3,"TP3_EURGBP_DOWN_S2_OCO2"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO2Sets3.Add( Base.EURGBP_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP4_EURGBP_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP4,"TP4_EURGBP_DOWN_S2_OCO2"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO2Sets4.Add( Base.EURGBP_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int EURGBP_OCO2S1_DOWN_S2 = 0;
	                for (; EURGBP_OCO2S1_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets1.Count; EURGBP_OCO2S1_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO2Sets1[EURGBP_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO2Sets1[EURGBP_OCO2S1_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO2Sets1.RemoveAt(EURGBP_OCO2S1_DOWN_S2);
	                        EURGBP_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURGBP_OCO2S2_DOWN_S2 = 0;
	                for (; EURGBP_OCO2S2_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets2.Count; EURGBP_OCO2S2_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO2Sets2[EURGBP_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO2Sets2[EURGBP_OCO2S2_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO2Sets2.RemoveAt(EURGBP_OCO2S2_DOWN_S2);
	                        EURGBP_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO2S3_DOWN_S2 = 0;
	                for (; EURGBP_OCO2S3_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets3.Count; EURGBP_OCO2S3_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO2Sets3[EURGBP_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO2Sets3[EURGBP_OCO2S3_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO2Sets3.RemoveAt(EURGBP_OCO2S3_DOWN_S2);
	                        EURGBP_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO2S4_DOWN_S2 = 0;
	                for (; EURGBP_OCO2S4_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets4.Count; EURGBP_OCO2S4_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO2Sets4[EURGBP_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO2Sets4[EURGBP_OCO2S4_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO2Sets4.RemoveAt(EURGBP_OCO2S4_DOWN_S2);
	                        EURGBP_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURGBP_OCO3_EO1_DOWN_S2)
	                Base.EURGBP_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURGBP_OCO3_EO2_DOWN_S2)
	                Base.EURGBP_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO3_EO3_DOWN_S2)
	                Base.EURGBP_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO3_EO4_DOWN_S2)
	                Base.EURGBP_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURGBP_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.EURGBP_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP1_EURGBP_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP1,"TP1_EURGBP_DOWN_S2_OCO3"));
		                 };
		                Base.EURGBP_DOWN_S2_OCO3Sets1.Add( Base.EURGBP_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURGBP_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP2_EURGBP_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP2,"TP2_EURGBP_DOWN_S2_OCO3"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO3Sets2.Add( Base.EURGBP_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP3_EURGBP_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP3,"TP3_EURGBP_DOWN_S2_OCO3"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO3Sets3.Add( Base.EURGBP_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP4_EURGBP_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP4,"TP4_EURGBP_DOWN_S2_OCO3"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO3Sets4.Add( Base.EURGBP_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURGBP_OCO3S1_DOWN_S2 = 0;
	                for (; EURGBP_OCO3S1_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets1.Count; EURGBP_OCO3S1_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO3Sets1[EURGBP_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO3Sets1[EURGBP_OCO3S1_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO3Sets1.RemoveAt(EURGBP_OCO3S1_DOWN_S2);
	                        EURGBP_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURGBP_OCO3S2_DOWN_S2 = 0;
	                for (; EURGBP_OCO3S2_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets2.Count; EURGBP_OCO3S2_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO3Sets2[EURGBP_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO3Sets2[EURGBP_OCO3S2_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO3Sets2.RemoveAt(EURGBP_OCO3S2_DOWN_S2);
	                        EURGBP_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO3S3_DOWN_S2 = 0;
	                for (; EURGBP_OCO3S3_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets3.Count; EURGBP_OCO3S3_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO3Sets3[EURGBP_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO3Sets3[EURGBP_OCO3S3_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO3Sets3.RemoveAt(EURGBP_OCO3S3_DOWN_S2);
	                        EURGBP_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO3S4_DOWN_S2 = 0;
	                for (; EURGBP_OCO3S4_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets4.Count; EURGBP_OCO3S4_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO3Sets4[EURGBP_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO3Sets4[EURGBP_OCO3S4_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO3Sets4.RemoveAt(EURGBP_OCO3S4_DOWN_S2);
	                        EURGBP_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURGBP_OCO4_EO1_DOWN_S2)
	                Base.EURGBP_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.EURGBP_OCO4_EO2_DOWN_S2)
	                Base.EURGBP_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO4_EO3_DOWN_S2)
	                Base.EURGBP_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.EURGBP_OCO4_EO4_DOWN_S2)
	                Base.EURGBP_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURGBP_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.EURGBP_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP1_EURGBP_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP1,"TP1_EURGBP_DOWN_S2_OCO4"));
		                 };
		                Base.EURGBP_DOWN_S2_OCO4Sets1.Add( Base.EURGBP_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURGBP_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP2_EURGBP_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP2,"TP2_EURGBP_DOWN_S2_OCO4"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO4Sets2.Add( Base.EURGBP_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP3_EURGBP_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP3,"TP3_EURGBP_DOWN_S2_OCO4"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO4Sets3.Add( Base.EURGBP_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURGBP_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.EURGBP_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURGBP_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURGBP_DOWN_S2_SL,"SL_TP4_EURGBP_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURGBP_DOWN_S2_TP4,"TP4_EURGBP_DOWN_S2_OCO4"));
		                 };
	                    Base.EURGBP_DOWN_S2_OCO4Sets4.Add( Base.EURGBP_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURGBP_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int EURGBP_OCO4S1_DOWN_S2 = 0;
	                for (; EURGBP_OCO4S1_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets1.Count; EURGBP_OCO4S1_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO4Sets1[EURGBP_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO4Sets1[EURGBP_OCO4S1_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO4Sets1.RemoveAt(EURGBP_OCO4S1_DOWN_S2);
	                        EURGBP_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int EURGBP_OCO4S2_DOWN_S2 = 0;
	                for (; EURGBP_OCO4S2_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets2.Count; EURGBP_OCO4S2_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO4Sets2[EURGBP_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO4Sets2[EURGBP_OCO4S2_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO4Sets2.RemoveAt(EURGBP_OCO4S2_DOWN_S2);
	                        EURGBP_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO4S3_DOWN_S2 = 0;
	                for (; EURGBP_OCO4S3_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets3.Count; EURGBP_OCO4S3_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO4Sets3[EURGBP_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO4Sets3[EURGBP_OCO4S3_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO4Sets3.RemoveAt(EURGBP_OCO4S3_DOWN_S2);
	                        EURGBP_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int EURGBP_OCO4S4_DOWN_S2 = 0;
	                for (; EURGBP_OCO4S4_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets4.Count; EURGBP_OCO4S4_DOWN_S2++)
	                    if (Base.EURGBP_DOWN_S2_OCO4Sets4[EURGBP_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURGBP_DOWN_S2_OCO4Sets4[EURGBP_OCO4S4_DOWN_S2].Filled();
	                        Base.EURGBP_DOWN_S2_OCO4Sets4.RemoveAt(EURGBP_OCO4S4_DOWN_S2);
	                        EURGBP_OCO4S4_DOWN_S2 = 0;
	                        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.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 AUDCAD_DOWN_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDCAD_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("AUDCAD OCO1 CANCEL 1 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 1 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 1 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCAD OCO1 CANCEL 2 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 2 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 2 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCAD OCO1 CANCEL 3 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 3 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 3 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCAD OCO1 CANCEL 4 DOWN S2") || 
		        		OrderID.Tag.StartsWith("AUDCAD OCO2 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO3 CANCEL 4 DOWN S2") ||
		        		OrderID.Tag.StartsWith("AUDCAD OCO4 CANCEL 4 DOWN S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCAD S2");
		        	}
		        }
		        
				if (Base.AUDCAD_OCO1_EO1_DOWN_S2)
	                Base.AUDCAD_OCO1_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCAD_OCO1_EO2_DOWN_S2)
	                Base.AUDCAD_OCO1_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO1_EO3_DOWN_S2)
	                Base.AUDCAD_OCO1_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO1_EO4_DOWN_S2)
	                Base.AUDCAD_OCO1_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDCAD_OOFE_OCO1_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP1_AUDCAD_DOWN_S2_OCO1"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP1,"TP1_AUDCAD_DOWN_S2_OCO1"));
		                 };
		                Base.AUDCAD_DOWN_S2_OCO1Sets1.Add( Base.AUDCAD_OOFE_OCO1_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO1_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP2_AUDCAD_DOWN_S2_OCO1"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP2,"TP2_AUDCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO1Sets2.Add( Base.AUDCAD_OOFE_OCO1_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO1_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP3_AUDCAD_DOWN_S2_OCO1"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP3,"TP3_AUDCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO1Sets3.Add( Base.AUDCAD_OOFE_OCO1_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO1_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO1_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO1_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP4_AUDCAD_DOWN_S2_OCO1"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP4,"TP4_AUDCAD_DOWN_S2_OCO1"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO1Sets4.Add( Base.AUDCAD_OOFE_OCO1_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO1_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDCAD_OCO1S1_DOWN_S2 = 0;
	                for (; AUDCAD_OCO1S1_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets1.Count; AUDCAD_OCO1S1_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO1Sets1[AUDCAD_OCO1S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO1Sets1[AUDCAD_OCO1S1_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO1Sets1.RemoveAt(AUDCAD_OCO1S1_DOWN_S2);
	                        AUDCAD_OCO1S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCAD_OCO1S2_DOWN_S2 = 0;
	                for (; AUDCAD_OCO1S2_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets2.Count; AUDCAD_OCO1S2_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO1Sets2[AUDCAD_OCO1S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO1Sets2[AUDCAD_OCO1S2_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO1Sets2.RemoveAt(AUDCAD_OCO1S2_DOWN_S2);
	                        AUDCAD_OCO1S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO1S3_DOWN_S2 = 0;
	                for (; AUDCAD_OCO1S3_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets3.Count; AUDCAD_OCO1S3_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO1Sets3[AUDCAD_OCO1S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO1Sets3[AUDCAD_OCO1S3_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO1Sets3.RemoveAt(AUDCAD_OCO1S3_DOWN_S2);
	                        AUDCAD_OCO1S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO1S4_DOWN_S2 = 0;
	                for (; AUDCAD_OCO1S4_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO1Sets4.Count; AUDCAD_OCO1S4_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO1Sets4[AUDCAD_OCO1S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO1Sets4[AUDCAD_OCO1S4_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO1Sets4.RemoveAt(AUDCAD_OCO1S4_DOWN_S2);
	                        AUDCAD_OCO1S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCAD_OCO2_EO1_DOWN_S2)
	                Base.AUDCAD_OCO2_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCAD_OCO2_EO2_DOWN_S2)
	                Base.AUDCAD_OCO2_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO2_EO3_DOWN_S2)
	                Base.AUDCAD_OCO2_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO2_EO4_DOWN_S2)
	                Base.AUDCAD_OCO2_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDCAD_OOFE_OCO2_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP1_AUDCAD_DOWN_S2_OCO2"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP1,"TP1_AUDCAD_DOWN_S2_OCO2"));
		                 };
		                Base.AUDCAD_DOWN_S2_OCO2Sets1.Add( Base.AUDCAD_OOFE_OCO2_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO2_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP2_AUDCAD_DOWN_S2_OCO2"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP2,"TP2_AUDCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO2Sets2.Add( Base.AUDCAD_OOFE_OCO2_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO2_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP3_AUDCAD_DOWN_S2_OCO2"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP3,"TP3_AUDCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO2Sets3.Add( Base.AUDCAD_OOFE_OCO2_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO2_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO2_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO2_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP4_AUDCAD_DOWN_S2_OCO2"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP4,"TP4_AUDCAD_DOWN_S2_OCO2"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO2Sets4.Add( Base.AUDCAD_OOFE_OCO2_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO2_EO4_DOWN_S2_ID = -1;
	                }
	                
	                int AUDCAD_OCO2S1_DOWN_S2 = 0;
	                for (; AUDCAD_OCO2S1_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets1.Count; AUDCAD_OCO2S1_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO2Sets1[AUDCAD_OCO2S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO2Sets1[AUDCAD_OCO2S1_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO2Sets1.RemoveAt(AUDCAD_OCO2S1_DOWN_S2);
	                        AUDCAD_OCO2S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCAD_OCO2S2_DOWN_S2 = 0;
	                for (; AUDCAD_OCO2S2_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets2.Count; AUDCAD_OCO2S2_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO2Sets2[AUDCAD_OCO2S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO2Sets2[AUDCAD_OCO2S2_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO2Sets2.RemoveAt(AUDCAD_OCO2S2_DOWN_S2);
	                        AUDCAD_OCO2S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO2S3_DOWN_S2 = 0;
	                for (; AUDCAD_OCO2S3_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets3.Count; AUDCAD_OCO2S3_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO2Sets3[AUDCAD_OCO2S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO2Sets3[AUDCAD_OCO2S3_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO2Sets3.RemoveAt(AUDCAD_OCO2S3_DOWN_S2);
	                        AUDCAD_OCO2S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO2S4_DOWN_S2 = 0;
	                for (; AUDCAD_OCO2S4_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO2Sets4.Count; AUDCAD_OCO2S4_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO2Sets4[AUDCAD_OCO2S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO2Sets4[AUDCAD_OCO2S4_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO2Sets4.RemoveAt(AUDCAD_OCO2S4_DOWN_S2);
	                        AUDCAD_OCO2S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCAD_OCO3_EO1_DOWN_S2)
	                Base.AUDCAD_OCO3_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCAD_OCO3_EO2_DOWN_S2)
	                Base.AUDCAD_OCO3_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO3_EO3_DOWN_S2)
	                Base.AUDCAD_OCO3_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO3_EO4_DOWN_S2)
	                Base.AUDCAD_OCO3_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDCAD_OOFE_OCO3_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP1_AUDCAD_DOWN_S2_OCO3"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP1,"TP1_AUDCAD_DOWN_S2_OCO3"));
		                 };
		                Base.AUDCAD_DOWN_S2_OCO3Sets1.Add( Base.AUDCAD_OOFE_OCO3_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO3_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP2_AUDCAD_DOWN_S2_OCO3"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP2,"TP2_AUDCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO3Sets2.Add( Base.AUDCAD_OOFE_OCO3_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO3_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP3_AUDCAD_DOWN_S2_OCO3"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP3,"TP3_AUDCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO3Sets3.Add( Base.AUDCAD_OOFE_OCO3_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO3_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO3_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO3_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP4_AUDCAD_DOWN_S2_OCO3"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP4,"TP4_AUDCAD_DOWN_S2_OCO3"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO3Sets4.Add( Base.AUDCAD_OOFE_OCO3_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO3_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDCAD_OCO3S1_DOWN_S2 = 0;
	                for (; AUDCAD_OCO3S1_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets1.Count; AUDCAD_OCO3S1_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO3Sets1[AUDCAD_OCO3S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO3Sets1[AUDCAD_OCO3S1_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO3Sets1.RemoveAt(AUDCAD_OCO3S1_DOWN_S2);
	                        AUDCAD_OCO3S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCAD_OCO3S2_DOWN_S2 = 0;
	                for (; AUDCAD_OCO3S2_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets2.Count; AUDCAD_OCO3S2_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO3Sets2[AUDCAD_OCO3S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO3Sets2[AUDCAD_OCO3S2_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO3Sets2.RemoveAt(AUDCAD_OCO3S2_DOWN_S2);
	                        AUDCAD_OCO3S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO3S3_DOWN_S2 = 0;
	                for (; AUDCAD_OCO3S3_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets3.Count; AUDCAD_OCO3S3_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO3Sets3[AUDCAD_OCO3S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO3Sets3[AUDCAD_OCO3S3_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO3Sets3.RemoveAt(AUDCAD_OCO3S3_DOWN_S2);
	                        AUDCAD_OCO3S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO3S4_DOWN_S2 = 0;
	                for (; AUDCAD_OCO3S4_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO3Sets4.Count; AUDCAD_OCO3S4_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO3Sets4[AUDCAD_OCO3S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO3Sets4[AUDCAD_OCO3S4_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO3Sets4.RemoveAt(AUDCAD_OCO3S4_DOWN_S2);
	                        AUDCAD_OCO3S4_DOWN_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCAD_OCO4_EO1_DOWN_S2)
	                Base.AUDCAD_OCO4_EO1_DOWN_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCAD_OCO4_EO2_DOWN_S2)
	                Base.AUDCAD_OCO4_EO2_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO4_EO3_DOWN_S2)
	                Base.AUDCAD_OCO4_EO3_DOWN_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCAD_OCO4_EO4_DOWN_S2)
	                Base.AUDCAD_OCO4_EO4_DOWN_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO1_DOWN_S2_ID)
	                {
	                	Base.AUDCAD_OOFE_OCO4_DOWN_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_DOWN_S2(
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP1_AUDCAD_DOWN_S2_OCO4"),
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP1,"TP1_AUDCAD_DOWN_S2_OCO4"));
		                 };
		                Base.AUDCAD_DOWN_S2_OCO4Sets1.Add( Base.AUDCAD_OOFE_OCO4_DOWN_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO1_DOWN_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO2_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO4_DOWN_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_DOWN_S2(
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP2_AUDCAD_DOWN_S2_OCO4"),
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP2,"TP2_AUDCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO4Sets2.Add( Base.AUDCAD_OOFE_OCO4_DOWN_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO2_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO3_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO4_DOWN_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_DOWN_S2(
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP3_AUDCAD_DOWN_S2_OCO4"),
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP3,"TP3_AUDCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO4Sets3.Add( Base.AUDCAD_OOFE_OCO4_DOWN_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO3_DOWN_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCAD_OCO4_EO4_DOWN_S2_ID) 
	                {
	                	Base.AUDCAD_OOFE_OCO4_DOWN_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCAD_OCO4_DOWN_S2(
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCAD_DOWN_S2_SL,"SL_TP4_AUDCAD_DOWN_S2_OCO4"),
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCAD_DOWN_S2_TP4,"TP4_AUDCAD_DOWN_S2_OCO4"));
		                 };
	                    Base.AUDCAD_DOWN_S2_OCO4Sets4.Add( Base.AUDCAD_OOFE_OCO4_DOWN_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCAD_OCO4_EO4_DOWN_S2_ID = -1;
	                }

	                
	                int AUDCAD_OCO4S1_DOWN_S2 = 0;
	                for (; AUDCAD_OCO4S1_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets1.Count; AUDCAD_OCO4S1_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO4Sets1[AUDCAD_OCO4S1_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO4Sets1[AUDCAD_OCO4S1_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO4Sets1.RemoveAt(AUDCAD_OCO4S1_DOWN_S2);
	                        AUDCAD_OCO4S1_DOWN_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCAD_OCO4S2_DOWN_S2 = 0;
	                for (; AUDCAD_OCO4S2_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets2.Count; AUDCAD_OCO4S2_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO4Sets2[AUDCAD_OCO4S2_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO4Sets2[AUDCAD_OCO4S2_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO4Sets2.RemoveAt(AUDCAD_OCO4S2_DOWN_S2);
	                        AUDCAD_OCO4S2_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO4S3_DOWN_S2 = 0;
	                for (; AUDCAD_OCO4S3_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets3.Count; AUDCAD_OCO4S3_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO4Sets3[AUDCAD_OCO4S3_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO4Sets3[AUDCAD_OCO4S3_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO4Sets3.RemoveAt(AUDCAD_OCO4S3_DOWN_S2);
	                        AUDCAD_OCO4S3_DOWN_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCAD_OCO4S4_DOWN_S2 = 0;
	                for (; AUDCAD_OCO4S4_DOWN_S2 < Base.AUDCAD_DOWN_S2_OCO4Sets4.Count; AUDCAD_OCO4S4_DOWN_S2++)
	                    if (Base.AUDCAD_DOWN_S2_OCO4Sets4[AUDCAD_OCO4S4_DOWN_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCAD_DOWN_S2_OCO4Sets4[AUDCAD_OCO4S4_DOWN_S2].Filled();
	                        Base.AUDCAD_DOWN_S2_OCO4Sets4.RemoveAt(AUDCAD_OCO4S4_DOWN_S2);
	                        AUDCAD_OCO4S4_DOWN_S2 = 0;
	                        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 _EURUSD;
		
    	///oco1 up
    	public static OrderTicket EURUSD_OCO1_MO1_UP_S2;
    	public static OrderTicket EURUSD_OCO1_MO2_UP_S2;
    	public static OrderTicket EURUSD_OCO1_MO3_UP_S2;
    	public static OrderTicket EURUSD_OCO1_MO4_UP_S2;
    	public static OrderTicket EURUSD_OCO1_MO5_UP_S2;
    	public static OrderTicket EURUSD_OCO1_MO6_UP_S2;
    	
    	public static int EURUSD_OCO1_EO1_UP_S2_ID ;
        public static int EURUSD_OCO1_EO2_UP_S2_ID ;
        public static int EURUSD_OCO1_EO3_UP_S2_ID ;
        public static int EURUSD_OCO1_EO4_UP_S2_ID ;
        public static int EURUSD_OCO1_EO5_UP_S2_ID ;
        public static int EURUSD_OCO1_EO6_UP_S2_ID ;
        
        public static bool EURUSD_OCO1_EO1_UP_S2 ;
        public static bool EURUSD_OCO1_EO2_UP_S2 ;
        public static bool EURUSD_OCO1_EO3_UP_S2 ;
        public static bool EURUSD_OCO1_EO4_UP_S2 ;
        public static bool EURUSD_OCO1_EO5_UP_S2 ;
        public static bool EURUSD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_UP_S2> EURUSD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_UP_S2> EURUSD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_UP_S2> EURUSD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_UP_S2> EURUSD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_UP_S2> EURUSD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_UP_S2> EURUSD_OOFE_OCO1_UP_S2_6 ;
        
        public static EURUSD_OCO1_UP_S2 EURUSD_PFO_OCO1_UP_S2_1 ;
        public static EURUSD_OCO1_UP_S2 EURUSD_PFO_OCO1_UP_S2_2 ;
        public static EURUSD_OCO1_UP_S2 EURUSD_PFO_OCO1_UP_S2_3 ;
        public static EURUSD_OCO1_UP_S2 EURUSD_PFO_OCO1_UP_S2_4 ;
        public static EURUSD_OCO1_UP_S2 EURUSD_PFO_OCO1_UP_S2_5 ;
        public static EURUSD_OCO1_UP_S2 EURUSD_PFO_OCO1_UP_S2_6 ;
        
        public static List<EURUSD_OCO1_UP_S2> EURUSD_UP_S2_OCO1Sets1 = new List<EURUSD_OCO1_UP_S2>();
        public static List<EURUSD_OCO1_UP_S2> EURUSD_UP_S2_OCO1Sets2 = new List<EURUSD_OCO1_UP_S2>();
        public static List<EURUSD_OCO1_UP_S2> EURUSD_UP_S2_OCO1Sets3 = new List<EURUSD_OCO1_UP_S2>();
        public static List<EURUSD_OCO1_UP_S2> EURUSD_UP_S2_OCO1Sets4 = new List<EURUSD_OCO1_UP_S2>();
        public static List<EURUSD_OCO1_UP_S2> EURUSD_UP_S2_OCO1Sets5 = new List<EURUSD_OCO1_UP_S2>();
        public static List<EURUSD_OCO1_UP_S2> EURUSD_UP_S2_OCO1Sets6 = new List<EURUSD_OCO1_UP_S2>();
        
        public static bool EURUSD_OCO1_UP_S2_IsReady = true;
        public static bool EURUSD_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket EURUSD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int EURUSD_OCO1_EO1_DOWN_S2_ID ;
        public static int EURUSD_OCO1_EO2_DOWN_S2_ID ;
        public static int EURUSD_OCO1_EO3_DOWN_S2_ID ;
        public static int EURUSD_OCO1_EO4_DOWN_S2_ID ;
        public static int EURUSD_OCO1_EO5_DOWN_S2_ID ;
        public static int EURUSD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool EURUSD_OCO1_EO1_DOWN_S2 ;
        public static bool EURUSD_OCO1_EO2_DOWN_S2 ;
        public static bool EURUSD_OCO1_EO3_DOWN_S2 ;
        public static bool EURUSD_OCO1_EO4_DOWN_S2 ;
        public static bool EURUSD_OCO1_EO5_DOWN_S2 ;
        public static bool EURUSD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_DOWN_S2> EURUSD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_DOWN_S2> EURUSD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_DOWN_S2> EURUSD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_DOWN_S2> EURUSD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_DOWN_S2> EURUSD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO1_DOWN_S2> EURUSD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static EURUSD_OCO1_DOWN_S2 EURUSD_PFO_OCO1_DOWN_S2_1 ;
        public static EURUSD_OCO1_DOWN_S2 EURUSD_PFO_OCO1_DOWN_S2_2 ;
        public static EURUSD_OCO1_DOWN_S2 EURUSD_PFO_OCO1_DOWN_S2_3 ;
        public static EURUSD_OCO1_DOWN_S2 EURUSD_PFO_OCO1_DOWN_S2_4 ;
        public static EURUSD_OCO1_DOWN_S2 EURUSD_PFO_OCO1_DOWN_S2_5 ;
        public static EURUSD_OCO1_DOWN_S2 EURUSD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<EURUSD_OCO1_DOWN_S2> EURUSD_DOWN_S2_OCO1Sets1 = new List<EURUSD_OCO1_DOWN_S2>();
        public static List<EURUSD_OCO1_DOWN_S2> EURUSD_DOWN_S2_OCO1Sets2 = new List<EURUSD_OCO1_DOWN_S2>();
        public static List<EURUSD_OCO1_DOWN_S2> EURUSD_DOWN_S2_OCO1Sets3 = new List<EURUSD_OCO1_DOWN_S2>();
        public static List<EURUSD_OCO1_DOWN_S2> EURUSD_DOWN_S2_OCO1Sets4 = new List<EURUSD_OCO1_DOWN_S2>();
        public static List<EURUSD_OCO1_DOWN_S2> EURUSD_DOWN_S2_OCO1Sets5 = new List<EURUSD_OCO1_DOWN_S2>();
        public static List<EURUSD_OCO1_DOWN_S2> EURUSD_DOWN_S2_OCO1Sets6 = new List<EURUSD_OCO1_DOWN_S2>();
        
        public static bool EURUSD_OCO1_DOWN_S2_IsReady = true;
        public static bool EURUSD_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket EURUSD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO6_UP_S2 ;
    	
    	public static int EURUSD_OCO2_EO1_UP_S2_ID ;
        public static int EURUSD_OCO2_EO2_UP_S2_ID ;
        public static int EURUSD_OCO2_EO3_UP_S2_ID ;
        public static int EURUSD_OCO2_EO4_UP_S2_ID ;
        public static int EURUSD_OCO2_EO5_UP_S2_ID ;
        public static int EURUSD_OCO2_EO6_UP_S2_ID ;
        
        public static bool EURUSD_OCO2_EO1_UP_S2 ;
        public static bool EURUSD_OCO2_EO2_UP_S2 ;
        public static bool EURUSD_OCO2_EO3_UP_S2 ;
        public static bool EURUSD_OCO2_EO4_UP_S2 ;
        public static bool EURUSD_OCO2_EO5_UP_S2 ;
        public static bool EURUSD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_UP_S2> EURUSD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_UP_S2> EURUSD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_UP_S2> EURUSD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_UP_S2> EURUSD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_UP_S2> EURUSD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_UP_S2> EURUSD_OOFE_OCO2_UP_S2_6 ;
        
        public static EURUSD_OCO2_UP_S2 EURUSD_PFO_OCO2_UP_S2_1 ;
        public static EURUSD_OCO2_UP_S2 EURUSD_PFO_OCO2_UP_S2_2 ;
        public static EURUSD_OCO2_UP_S2 EURUSD_PFO_OCO2_UP_S2_3 ;
        public static EURUSD_OCO2_UP_S2 EURUSD_PFO_OCO2_UP_S2_4 ;
        public static EURUSD_OCO2_UP_S2 EURUSD_PFO_OCO2_UP_S2_5 ;
        public static EURUSD_OCO2_UP_S2 EURUSD_PFO_OCO2_UP_S2_6 ;
        
        public static List<EURUSD_OCO2_UP_S2> EURUSD_UP_S2_OCO2Sets1 = new List<EURUSD_OCO2_UP_S2>();
        public static List<EURUSD_OCO2_UP_S2> EURUSD_UP_S2_OCO2Sets2 = new List<EURUSD_OCO2_UP_S2>();
        public static List<EURUSD_OCO2_UP_S2> EURUSD_UP_S2_OCO2Sets3 = new List<EURUSD_OCO2_UP_S2>();
        public static List<EURUSD_OCO2_UP_S2> EURUSD_UP_S2_OCO2Sets4 = new List<EURUSD_OCO2_UP_S2>();
        public static List<EURUSD_OCO2_UP_S2> EURUSD_UP_S2_OCO2Sets5 = new List<EURUSD_OCO2_UP_S2>();
        public static List<EURUSD_OCO2_UP_S2> EURUSD_UP_S2_OCO2Sets6 = new List<EURUSD_OCO2_UP_S2>();
        
        public static bool EURUSD_OCO2_UP_S2_IsReady = true;
        public static bool EURUSD_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket EURUSD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int EURUSD_OCO2_EO1_DOWN_S2_ID ;
        public static int EURUSD_OCO2_EO2_DOWN_S2_ID ;
        public static int EURUSD_OCO2_EO3_DOWN_S2_ID ;
        public static int EURUSD_OCO2_EO4_DOWN_S2_ID ;
        public static int EURUSD_OCO2_EO5_DOWN_S2_ID ;
        public static int EURUSD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool EURUSD_OCO2_EO1_DOWN_S2 ;
        public static bool EURUSD_OCO2_EO2_DOWN_S2 ;
        public static bool EURUSD_OCO2_EO3_DOWN_S2 ;
        public static bool EURUSD_OCO2_EO4_DOWN_S2 ;
        public static bool EURUSD_OCO2_EO5_DOWN_S2 ;
        public static bool EURUSD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_DOWN_S2> EURUSD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_DOWN_S2> EURUSD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_DOWN_S2> EURUSD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_DOWN_S2> EURUSD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_DOWN_S2> EURUSD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO2_DOWN_S2> EURUSD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static EURUSD_OCO2_DOWN_S2 EURUSD_PFO_OCO2_DOWN_S2_1 ;
        public static EURUSD_OCO2_DOWN_S2 EURUSD_PFO_OCO2_DOWN_S2_2 ;
        public static EURUSD_OCO2_DOWN_S2 EURUSD_PFO_OCO2_DOWN_S2_3 ;
        public static EURUSD_OCO2_DOWN_S2 EURUSD_PFO_OCO2_DOWN_S2_4 ;
        public static EURUSD_OCO2_DOWN_S2 EURUSD_PFO_OCO2_DOWN_S2_5 ;
        public static EURUSD_OCO2_DOWN_S2 EURUSD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<EURUSD_OCO2_DOWN_S2> EURUSD_DOWN_S2_OCO2Sets1 = new List<EURUSD_OCO2_DOWN_S2>();
        public static List<EURUSD_OCO2_DOWN_S2> EURUSD_DOWN_S2_OCO2Sets2 = new List<EURUSD_OCO2_DOWN_S2>();
        public static List<EURUSD_OCO2_DOWN_S2> EURUSD_DOWN_S2_OCO2Sets3 = new List<EURUSD_OCO2_DOWN_S2>();
        public static List<EURUSD_OCO2_DOWN_S2> EURUSD_DOWN_S2_OCO2Sets4 = new List<EURUSD_OCO2_DOWN_S2>();
        public static List<EURUSD_OCO2_DOWN_S2> EURUSD_DOWN_S2_OCO2Sets5 = new List<EURUSD_OCO2_DOWN_S2>();
        public static List<EURUSD_OCO2_DOWN_S2> EURUSD_DOWN_S2_OCO2Sets6 = new List<EURUSD_OCO2_DOWN_S2>();
        
        public static bool EURUSD_OCO2_DOWN_S2_IsReady = true;
        public static bool EURUSD_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket EURUSD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO6_UP_S2 ;
    	
    	public static int EURUSD_OCO3_EO1_UP_S2_ID ;
        public static int EURUSD_OCO3_EO2_UP_S2_ID ;
        public static int EURUSD_OCO3_EO3_UP_S2_ID ;
        public static int EURUSD_OCO3_EO4_UP_S2_ID ;
        public static int EURUSD_OCO3_EO5_UP_S2_ID ;
        public static int EURUSD_OCO3_EO6_UP_S2_ID ;
        
        public static bool EURUSD_OCO3_EO1_UP_S2 ;
        public static bool EURUSD_OCO3_EO2_UP_S2 ;
        public static bool EURUSD_OCO3_EO3_UP_S2 ;
        public static bool EURUSD_OCO3_EO4_UP_S2 ;
        public static bool EURUSD_OCO3_EO5_UP_S2 ;
        public static bool EURUSD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_UP_S2> EURUSD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_UP_S2> EURUSD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_UP_S2> EURUSD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_UP_S2> EURUSD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_UP_S2> EURUSD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_UP_S2> EURUSD_OOFE_OCO3_UP_S2_6 ;
        
        public static EURUSD_OCO3_UP_S2 EURUSD_PFO_OCO3_UP_S2_1 ;
        public static EURUSD_OCO3_UP_S2 EURUSD_PFO_OCO3_UP_S2_2 ;
        public static EURUSD_OCO3_UP_S2 EURUSD_PFO_OCO3_UP_S2_3 ;
        public static EURUSD_OCO3_UP_S2 EURUSD_PFO_OCO3_UP_S2_4 ;
        public static EURUSD_OCO3_UP_S2 EURUSD_PFO_OCO3_UP_S2_5 ;
        public static EURUSD_OCO3_UP_S2 EURUSD_PFO_OCO3_UP_S2_6 ;
        
        public static List<EURUSD_OCO3_UP_S2> EURUSD_UP_S2_OCO3Sets1 = new List<EURUSD_OCO3_UP_S2>();
        public static List<EURUSD_OCO3_UP_S2> EURUSD_UP_S2_OCO3Sets2 = new List<EURUSD_OCO3_UP_S2>();
        public static List<EURUSD_OCO3_UP_S2> EURUSD_UP_S2_OCO3Sets3 = new List<EURUSD_OCO3_UP_S2>();
        public static List<EURUSD_OCO3_UP_S2> EURUSD_UP_S2_OCO3Sets4 = new List<EURUSD_OCO3_UP_S2>();
        public static List<EURUSD_OCO3_UP_S2> EURUSD_UP_S2_OCO3Sets5 = new List<EURUSD_OCO3_UP_S2>();
        public static List<EURUSD_OCO3_UP_S2> EURUSD_UP_S2_OCO3Sets6 = new List<EURUSD_OCO3_UP_S2>();
        
        public static bool EURUSD_OCO3_UP_S2_IsReady = true;
        public static bool EURUSD_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket EURUSD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int EURUSD_OCO3_EO1_DOWN_S2_ID ;
        public static int EURUSD_OCO3_EO2_DOWN_S2_ID ;
        public static int EURUSD_OCO3_EO3_DOWN_S2_ID ;
        public static int EURUSD_OCO3_EO4_DOWN_S2_ID ;
        public static int EURUSD_OCO3_EO5_DOWN_S2_ID ;
        public static int EURUSD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool EURUSD_OCO3_EO1_DOWN_S2 ;
        public static bool EURUSD_OCO3_EO2_DOWN_S2 ;
        public static bool EURUSD_OCO3_EO3_DOWN_S2 ;
        public static bool EURUSD_OCO3_EO4_DOWN_S2 ;
        public static bool EURUSD_OCO3_EO5_DOWN_S2 ;
        public static bool EURUSD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_DOWN_S2> EURUSD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_DOWN_S2> EURUSD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_DOWN_S2> EURUSD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_DOWN_S2> EURUSD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_DOWN_S2> EURUSD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO3_DOWN_S2> EURUSD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static EURUSD_OCO3_DOWN_S2 EURUSD_PFO_OCO3_DOWN_S2_1 ;
        public static EURUSD_OCO3_DOWN_S2 EURUSD_PFO_OCO3_DOWN_S2_2 ;
        public static EURUSD_OCO3_DOWN_S2 EURUSD_PFO_OCO3_DOWN_S2_3 ;
        public static EURUSD_OCO3_DOWN_S2 EURUSD_PFO_OCO3_DOWN_S2_4 ;
        public static EURUSD_OCO3_DOWN_S2 EURUSD_PFO_OCO3_DOWN_S2_5 ;
        public static EURUSD_OCO3_DOWN_S2 EURUSD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<EURUSD_OCO3_DOWN_S2> EURUSD_DOWN_S2_OCO3Sets1 = new List<EURUSD_OCO3_DOWN_S2>();
        public static List<EURUSD_OCO3_DOWN_S2> EURUSD_DOWN_S2_OCO3Sets2 = new List<EURUSD_OCO3_DOWN_S2>();
        public static List<EURUSD_OCO3_DOWN_S2> EURUSD_DOWN_S2_OCO3Sets3 = new List<EURUSD_OCO3_DOWN_S2>();
        public static List<EURUSD_OCO3_DOWN_S2> EURUSD_DOWN_S2_OCO3Sets4 = new List<EURUSD_OCO3_DOWN_S2>();
        public static List<EURUSD_OCO3_DOWN_S2> EURUSD_DOWN_S2_OCO3Sets5 = new List<EURUSD_OCO3_DOWN_S2>();
        public static List<EURUSD_OCO3_DOWN_S2> EURUSD_DOWN_S2_OCO3Sets6 = new List<EURUSD_OCO3_DOWN_S2>();
        
        public static bool EURUSD_OCO3_DOWN_S2_IsReady = true;
        public static bool EURUSD_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket EURUSD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO6_UP_S2 ;
    	
    	public static int EURUSD_OCO4_EO1_UP_S2_ID ;
        public static int EURUSD_OCO4_EO2_UP_S2_ID ;
        public static int EURUSD_OCO4_EO3_UP_S2_ID ;
        public static int EURUSD_OCO4_EO4_UP_S2_ID ;
        public static int EURUSD_OCO4_EO5_UP_S2_ID ;
        public static int EURUSD_OCO4_EO6_UP_S2_ID ;
        
        public static bool EURUSD_OCO4_EO1_UP_S2 ;
        public static bool EURUSD_OCO4_EO2_UP_S2 ;
        public static bool EURUSD_OCO4_EO3_UP_S2 ;
        public static bool EURUSD_OCO4_EO4_UP_S2 ;
        public static bool EURUSD_OCO4_EO5_UP_S2 ;
        public static bool EURUSD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_UP_S2> EURUSD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_UP_S2> EURUSD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_UP_S2> EURUSD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_UP_S2> EURUSD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_UP_S2> EURUSD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_UP_S2> EURUSD_OOFE_OCO4_UP_S2_6 ;
        
        public static EURUSD_OCO4_UP_S2 EURUSD_PFO_OCO4_UP_S2_1 ;
        public static EURUSD_OCO4_UP_S2 EURUSD_PFO_OCO4_UP_S2_2 ;
        public static EURUSD_OCO4_UP_S2 EURUSD_PFO_OCO4_UP_S2_3 ;
        public static EURUSD_OCO4_UP_S2 EURUSD_PFO_OCO4_UP_S2_4 ;
        public static EURUSD_OCO4_UP_S2 EURUSD_PFO_OCO4_UP_S2_5 ;
        public static EURUSD_OCO4_UP_S2 EURUSD_PFO_OCO4_UP_S2_6 ;
        
        public static List<EURUSD_OCO4_UP_S2> EURUSD_UP_S2_OCO4Sets1 = new List<EURUSD_OCO4_UP_S2>();
        public static List<EURUSD_OCO4_UP_S2> EURUSD_UP_S2_OCO4Sets2 = new List<EURUSD_OCO4_UP_S2>();
        public static List<EURUSD_OCO4_UP_S2> EURUSD_UP_S2_OCO4Sets3 = new List<EURUSD_OCO4_UP_S2>();
        public static List<EURUSD_OCO4_UP_S2> EURUSD_UP_S2_OCO4Sets4 = new List<EURUSD_OCO4_UP_S2>();
        public static List<EURUSD_OCO4_UP_S2> EURUSD_UP_S2_OCO4Sets5 = new List<EURUSD_OCO4_UP_S2>();
        public static List<EURUSD_OCO4_UP_S2> EURUSD_UP_S2_OCO4Sets6 = new List<EURUSD_OCO4_UP_S2>();
        
        public static bool EURUSD_OCO4_UP_S2_IsReady = true;
        public static bool EURUSD_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket EURUSD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket EURUSD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int EURUSD_OCO4_EO1_DOWN_S2_ID ;
        public static int EURUSD_OCO4_EO2_DOWN_S2_ID ;
        public static int EURUSD_OCO4_EO3_DOWN_S2_ID ;
        public static int EURUSD_OCO4_EO4_DOWN_S2_ID ;
        public static int EURUSD_OCO4_EO5_DOWN_S2_ID ;
        public static int EURUSD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool EURUSD_OCO4_EO1_DOWN_S2 ;
        public static bool EURUSD_OCO4_EO2_DOWN_S2 ;
        public static bool EURUSD_OCO4_EO3_DOWN_S2 ;
        public static bool EURUSD_OCO4_EO4_DOWN_S2 ;
        public static bool EURUSD_OCO4_EO5_DOWN_S2 ;
        public static bool EURUSD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_DOWN_S2> EURUSD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_DOWN_S2> EURUSD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_DOWN_S2> EURUSD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_DOWN_S2> EURUSD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_DOWN_S2> EURUSD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURUSD_OCO4_DOWN_S2> EURUSD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static EURUSD_OCO4_DOWN_S2 EURUSD_PFO_OCO4_DOWN_S2_1 ;
        public static EURUSD_OCO4_DOWN_S2 EURUSD_PFO_OCO4_DOWN_S2_2 ;
        public static EURUSD_OCO4_DOWN_S2 EURUSD_PFO_OCO4_DOWN_S2_3 ;
        public static EURUSD_OCO4_DOWN_S2 EURUSD_PFO_OCO4_DOWN_S2_4 ;
        public static EURUSD_OCO4_DOWN_S2 EURUSD_PFO_OCO4_DOWN_S2_5 ;
        public static EURUSD_OCO4_DOWN_S2 EURUSD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<EURUSD_OCO4_DOWN_S2> EURUSD_DOWN_S2_OCO4Sets1 = new List<EURUSD_OCO4_DOWN_S2>();
        public static List<EURUSD_OCO4_DOWN_S2> EURUSD_DOWN_S2_OCO4Sets2 = new List<EURUSD_OCO4_DOWN_S2>();
        public static List<EURUSD_OCO4_DOWN_S2> EURUSD_DOWN_S2_OCO4Sets3 = new List<EURUSD_OCO4_DOWN_S2>();
        public static List<EURUSD_OCO4_DOWN_S2> EURUSD_DOWN_S2_OCO4Sets4 = new List<EURUSD_OCO4_DOWN_S2>();
        public static List<EURUSD_OCO4_DOWN_S2> EURUSD_DOWN_S2_OCO4Sets5 = new List<EURUSD_OCO4_DOWN_S2>();
        public static List<EURUSD_OCO4_DOWN_S2> EURUSD_DOWN_S2_OCO4Sets6 = new List<EURUSD_OCO4_DOWN_S2>();
        
        public static bool EURUSD_OCO4_DOWN_S2_IsReady = true;
        public static bool EURUSD_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal EURUSD_UP_S2_SL {get; set;}
		public static decimal EURUSD_UP_S2_TP1 {get; set;}
		public static decimal EURUSD_UP_S2_TP2 {get; set;}
		public static decimal EURUSD_UP_S2_TP3 {get; set;}
		public static decimal EURUSD_UP_S2_TP4 {get; set;}
		public static decimal EURUSD_UP_S2_TP5 {get; set;}
		public static decimal EURUSD_UP_S2_TP6 {get; set;}
		
		public static decimal EURUSD_DOWN_S2_SL {get; set;}
		public static decimal EURUSD_DOWN_S2_TP1 {get; set;}
		public static decimal EURUSD_DOWN_S2_TP2 {get; set;}
		public static decimal EURUSD_DOWN_S2_TP3 {get; set;}
		public static decimal EURUSD_DOWN_S2_TP4 {get; set;}
		public static decimal EURUSD_DOWN_S2_TP5 {get; set;}
		public static decimal EURUSD_DOWN_S2_TP6 {get; set;}

        public static bool EURUSD_Signal_Condition_UP_1 ;
        public static bool EURUSD_Signal_Condition_UP_2 ;
        public static bool EURUSD_Signal_Condition_UP_3 ;
        public static bool EURUSD_Signal_Condition_DOWN_S2 ;
        
        public static int EURUSD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int EURUSD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int EURUSD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int EURUSD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int EURUSD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int EURUSD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int EURUSD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int EURUSD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int EURUSD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int EURUSD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_EURUSD_UP_S2 ;
        public static bool DOWM_EURUSD_UP_S2 ;
        public static bool DOWT_EURUSD_UP_S2 ;
        public static bool DOWW_EURUSD_UP_S2 ;
        public static bool DOWTH_EURUSD_UP_S2 ;
        
		public static bool DOWR_EURUSD_DOWN_S2 ;
        public static bool DOWM_EURUSD_DOWN_S2 ;
        public static bool DOWT_EURUSD_DOWN_S2 ;
        public static bool DOWW_EURUSD_DOWN_S2 ;
        public static bool DOWTH_EURUSD_DOWN_S2 ;
        
        
		public static int EURUSD_quantity_UP_S2 ;
		public static int EURUSD_quantity_SL_UP_S2 ;
		public static int EURUSD_quantity_TP1_UP_S2 ;
		public static int EURUSD_quantity_TP2_UP_S2 ;
		public static int EURUSD_quantity_TP3_UP_S2 ;
		public static int EURUSD_quantity_TP4_UP_S2 ;
		public static int EURUSD_quantity_TP5_UP_S2;
		public static int EURUSD_quantity_TP6_UP_S2 ;
		
		public static int EURUSD_quantity_DOWN_S2 ;
		public static int EURUSD_quantity_SL_DOWN_S2 ;
		public static int EURUSD_quantity_TP1_DOWN_S2 ;
		public static int EURUSD_quantity_TP2_DOWN_S2 ;
		public static int EURUSD_quantity_TP3_DOWN_S2 ;
		public static int EURUSD_quantity_TP4_DOWN_S2 ;
		public static int EURUSD_quantity_TP5_DOWN_S2;
		public static int EURUSD_quantity_TP6_DOWN_S2 ;
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPCAD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPCAD_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(x=>x.Tag.Contains("GBPCAD_UP_S2_OCO1")))
			{
				Base.GBPCAD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCAD_UP_S2_OCO2")))
			{
				Base.GBPCAD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCAD_UP_S2_OCO3")))
			{
				Base.GBPCAD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPCAD_UP_S2_OCO4")))
			{
				Base.GBPCAD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPCAD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.GBPCAD_OCO1_EO1_UP_S2)
	                Base.GBPCAD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPCAD_OCO1_EO2_UP_S2)
	                Base.GBPCAD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO1_EO3_UP_S2)
	                Base.GBPCAD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO1_EO4_UP_S2)
	                Base.GBPCAD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO1_EO5_UP_S2)
	                Base.GBPCAD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO1_EO6_UP_S2)
	                Base.GBPCAD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCAD_OCO1S1_UP_S2 = 0;
		                for (; GBPCAD_OCO1S1_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets1.Count; GBPCAD_OCO1S1_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO1Sets1[GBPCAD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO1Sets1[GBPCAD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.GBPCAD_UP_S2_OCO1Sets1.Clear();
		                        GBPCAD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCAD_OCO1S2_UP_S2 = 0;
		                for (; GBPCAD_OCO1S2_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets2.Count; GBPCAD_OCO1S2_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO1Sets2[GBPCAD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO1Sets2[GBPCAD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.GBPCAD_UP_S2_OCO1Sets2.Clear();
		                        GBPCAD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO1S3_UP_S2 = 0;
		                for (; GBPCAD_OCO1S3_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets3.Count; GBPCAD_OCO1S3_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO1Sets3[GBPCAD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO1Sets3[GBPCAD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.GBPCAD_UP_S2_OCO1Sets3.Clear();
		                        GBPCAD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO1S4_UP_S2 = 0;
		                for (; GBPCAD_OCO1S4_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets4.Count; GBPCAD_OCO1S4_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO1Sets4[GBPCAD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO1Sets4[GBPCAD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.GBPCAD_UP_S2_OCO1Sets4.Clear();
		                        GBPCAD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO1S5_UP_S2 = 0;
		                for (; GBPCAD_OCO1S5_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets5.Count; GBPCAD_OCO1S5_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO1Sets5[GBPCAD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO1Sets5[GBPCAD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.GBPCAD_UP_S2_OCO1Sets5.Clear();
		                        GBPCAD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO1S6_UP_S2 = 0;
		                for (; GBPCAD_OCO1S6_UP_S2 < Base.GBPCAD_UP_S2_OCO1Sets6.Count; GBPCAD_OCO1S6_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO1Sets6[GBPCAD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO1Sets6[GBPCAD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.GBPCAD_UP_S2_OCO1Sets6.Clear();
		                        GBPCAD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPCAD_OCO2_EO1_UP_S2)
                	Base.GBPCAD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPCAD_OCO2_EO2_UP_S2)
	                Base.GBPCAD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO2_EO3_UP_S2)
	                Base.GBPCAD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO2_EO4_UP_S2)
	                Base.GBPCAD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO2_EO5_UP_S2)
	                Base.GBPCAD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO2_EO6_UP_S2)
	                Base.GBPCAD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCAD_OCO2S1_UP_S2 = 0;
		                for (; GBPCAD_OCO2S1_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets1.Count; GBPCAD_OCO2S1_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO2Sets1[GBPCAD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO2Sets1[GBPCAD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.GBPCAD_UP_S2_OCO2Sets1.Clear();
		                        GBPCAD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCAD_OCO2S2_UP_S2 = 0;
		                for (; GBPCAD_OCO2S2_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets2.Count; GBPCAD_OCO2S2_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO2Sets2[GBPCAD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO2Sets2[GBPCAD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.GBPCAD_UP_S2_OCO2Sets2.Clear();
		                        GBPCAD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO2S3_UP_S2 = 0;
		                for (; GBPCAD_OCO2S3_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets3.Count; GBPCAD_OCO2S3_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO2Sets3[GBPCAD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO2Sets3[GBPCAD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.GBPCAD_UP_S2_OCO2Sets3.Clear();
		                        GBPCAD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO2S4_UP_S2 = 0;
		                for (; GBPCAD_OCO2S4_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets4.Count; GBPCAD_OCO2S4_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO2Sets4[GBPCAD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO2Sets4[GBPCAD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.GBPCAD_UP_S2_OCO2Sets4.Clear();
		                        GBPCAD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO2S5_UP_S2 = 0;
		                for (; GBPCAD_OCO2S5_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets5.Count; GBPCAD_OCO2S5_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO2Sets5[GBPCAD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO2Sets5[GBPCAD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.GBPCAD_UP_S2_OCO2Sets5.Clear();
		                        GBPCAD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO2S6_UP_S2 = 0;
		                for (; GBPCAD_OCO2S6_UP_S2 < Base.GBPCAD_UP_S2_OCO2Sets6.Count; GBPCAD_OCO2S6_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO2Sets6[GBPCAD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO2Sets6[GBPCAD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.GBPCAD_UP_S2_OCO2Sets6.Clear();
		                        GBPCAD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPCAD_OCO3_EO1_UP_S2)
            		Base.GBPCAD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPCAD_OCO3_EO2_UP_S2)
	                Base.GBPCAD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO3_EO3_UP_S2)
	                Base.GBPCAD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO3_EO4_UP_S2)
	                Base.GBPCAD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO3_EO5_UP_S2)
	                Base.GBPCAD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO3_EO6_UP_S2)
	                Base.GBPCAD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCAD_OCO3S1_UP_S2 = 0;
		                for (; GBPCAD_OCO3S1_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets1.Count; GBPCAD_OCO3S1_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO3Sets1[GBPCAD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO3Sets1[GBPCAD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.GBPCAD_UP_S2_OCO3Sets1.Clear();
		                        GBPCAD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCAD_OCO3S2_UP_S2 = 0;
		                for (; GBPCAD_OCO3S2_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets2.Count; GBPCAD_OCO3S2_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO3Sets2[GBPCAD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO3Sets2[GBPCAD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.GBPCAD_UP_S2_OCO3Sets2.Clear();
		                        GBPCAD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO3S3_UP_S2 = 0;
		                for (; GBPCAD_OCO3S3_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets3.Count; GBPCAD_OCO3S3_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO3Sets3[GBPCAD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO3Sets3[GBPCAD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.GBPCAD_UP_S2_OCO3Sets3.Clear();
		                        GBPCAD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO3S4_UP_S2 = 0;
		                for (; GBPCAD_OCO3S4_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets4.Count; GBPCAD_OCO3S4_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO3Sets4[GBPCAD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO3Sets4[GBPCAD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.GBPCAD_UP_S2_OCO3Sets4.Clear();
		                        GBPCAD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO3S5_UP_S2 = 0;
		                for (; GBPCAD_OCO3S5_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets5.Count; GBPCAD_OCO3S5_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO3Sets5[GBPCAD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO3Sets5[GBPCAD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.GBPCAD_UP_S2_OCO3Sets5.Clear();
		                        GBPCAD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO3S6_UP_S2 = 0;
		                for (; GBPCAD_OCO3S6_UP_S2 < Base.GBPCAD_UP_S2_OCO3Sets6.Count; GBPCAD_OCO3S6_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO3Sets6[GBPCAD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO3Sets6[GBPCAD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.GBPCAD_UP_S2_OCO3Sets6.Clear();
		                        GBPCAD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPCAD_OCO4_EO1_UP_S2)
            		Base.GBPCAD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPCAD_OCO4_EO2_UP_S2)
	                Base.GBPCAD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO4_EO3_UP_S2)
	                Base.GBPCAD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO4_EO4_UP_S2)
	                Base.GBPCAD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO4_EO5_UP_S2)
	                Base.GBPCAD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPCAD_OCO4_EO6_UP_S2)
	                Base.GBPCAD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPCAD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPCAD_OCO4S1_UP_S2 = 0;
		                for (; GBPCAD_OCO4S1_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets1.Count; GBPCAD_OCO4S1_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO4Sets1[GBPCAD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO4Sets1[GBPCAD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.GBPCAD_UP_S2_OCO4Sets1.Clear();
		                        GBPCAD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPCAD_OCO4S2_UP_S2 = 0;
		                for (; GBPCAD_OCO4S2_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets2.Count; GBPCAD_OCO4S2_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO4Sets2[GBPCAD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO4Sets2[GBPCAD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.GBPCAD_UP_S2_OCO4Sets2.Clear();
		                        GBPCAD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO4S3_UP_S2 = 0;
		                for (; GBPCAD_OCO4S3_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets3.Count; GBPCAD_OCO4S3_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO4Sets3[GBPCAD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO4Sets3[GBPCAD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.GBPCAD_UP_S2_OCO4Sets3.Clear();
		                        GBPCAD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPCAD_OCO4S4_UP_S2 = 0;
		                for (; GBPCAD_OCO4S4_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets4.Count; GBPCAD_OCO4S4_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO4Sets4[GBPCAD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO4Sets4[GBPCAD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.GBPCAD_UP_S2_OCO4Sets4.Clear();
		                        GBPCAD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO4S5_UP_S2 = 0;
		                for (; GBPCAD_OCO4S5_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets5.Count; GBPCAD_OCO4S5_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO4Sets5[GBPCAD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO4Sets5[GBPCAD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.GBPCAD_UP_S2_OCO4Sets5.Clear();
		                        GBPCAD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPCAD_OCO4S6_UP_S2 = 0;
		                for (; GBPCAD_OCO4S6_UP_S2 < Base.GBPCAD_UP_S2_OCO4Sets6.Count; GBPCAD_OCO4S6_UP_S2++)
		                    if (Base.GBPCAD_UP_S2_OCO4Sets6[GBPCAD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPCAD_UP_S2_OCO4Sets6[GBPCAD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPCAD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPCAD", order.Quantity, false, "GBPCAD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.GBPCAD_UP_S2_OCO4Sets6.Clear();
		                        GBPCAD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_GBPCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPCAD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPCAD_UP_S2 = DOWM_GBPCAD_UP_S2 || DOWT_GBPCAD_UP_S2 || DOWW_GBPCAD_UP_S2 || DOWTH_GBPCAD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPCAD"))
	            	{
	            		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.GBPCAD_OCO1_UP_S2_IsReady == false ||
	                    	Base.GBPCAD_OCO2_UP_S2_IsReady == false ||
	                    	Base.GBPCAD_OCO3_UP_S2_IsReady == false ||
	                    	Base.GBPCAD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.GBPCAD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPCAD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPCAD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPCAD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPCAD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.GBPCAD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.GBPCAD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.GBPCAD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	GBPCAD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											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.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                							
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	GBPCAD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
				                										
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	GBPCAD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
			                										&&
			                										
				                										(
		
				                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
				                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
				                										
				                										)
			                										
			                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (GBPCAD_Signal_Condition_UP_1)
	                	{
	                    	GBPCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPCAD_Signal_Condition_UP_2)
	                	{
	                    	GBPCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPCAD_Signal_Condition_UP_3)
	                	{
	                    	GBPCAD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (GBPCAD_Signal_Condition_UP_1)
	                	{
	                    	GBPCAD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (GBPCAD_Signal_Condition_UP_2)
	                	{
	                    	GBPCAD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (GBPCAD_Signal_Condition_UP_3)
	                	{
	                    	GBPCAD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    GBPCAD_UP_S2_TP2 =  GBPCAD_UP_S2_SL * 0;
	                    GBPCAD_UP_S2_TP3 =  GBPCAD_UP_S2_SL * 0;
	                    GBPCAD_UP_S2_TP4 =  GBPCAD_UP_S2_SL * 0;
	                    GBPCAD_UP_S2_TP5 =  GBPCAD_UP_S2_SL * 0;
	                    GBPCAD_UP_S2_TP6 =  GBPCAD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPCAD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPCAD_quantity_SL_UP_S2 = GBPCAD_quantity_UP_S2;
	                    GBPCAD_quantity_TP1_UP_S2 = (int)Math.Floor(GBPCAD_quantity_UP_S2 * 1m);
	                    GBPCAD_quantity_TP2_UP_S2 = (int)Math.Floor(GBPCAD_quantity_TP1_UP_S2 * 0m);
	                    GBPCAD_quantity_TP3_UP_S2 = (int)Math.Floor(GBPCAD_quantity_TP2_UP_S2 * 0m);
	                    GBPCAD_quantity_TP4_UP_S2 = (int)Math.Floor(GBPCAD_quantity_TP3_UP_S2 * 0m);
	                    GBPCAD_quantity_TP5_UP_S2 = (int)Math.Floor(GBPCAD_quantity_TP4_UP_S2 * 0m);
	                    GBPCAD_quantity_TP6_UP_S2 = (int)Math.Floor(GBPCAD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((GBPCAD_Signal_Condition_UP_1 || GBPCAD_Signal_Condition_UP_2 || GBPCAD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPCAD_UP_S2 && 
	                    Base.GBPCAD_OCO1_UP_S2_IsReady == true &&
	                    Base.GBPCAD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCAD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP1_UP_S2, false,"GBPCAD_UP_S2_Entry_TP1_OCO1");
	                         Base.GBPCAD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.GBPCAD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP2_UP_S2, false,"GBPCAD_UP_S2_Entry_TP2_OCO1");
	                         Base.GBPCAD_OCO1_EO2_UP_S2 = false;
	
	                         Base.GBPCAD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP3_UP_S2, false,"GBPCAD_UP_S2_Entry_TP3_OCO1");
	                         Base.GBPCAD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.GBPCAD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP4_UP_S2, false,"GBPCAD_UP_S2_Entry_TP4_OCO1");
	                         Base.GBPCAD_OCO1_EO4_UP_S2 = false;

							Base.GBPCAD_OCO1_UP_S2_IsReady = false;
							
							if (Base.GBPCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((GBPCAD_Signal_Condition_UP_1 || GBPCAD_Signal_Condition_UP_2 || GBPCAD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPCAD_UP_S2 && 
	                    Base.GBPCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPCAD_OCO2_UP_S2_IsReady == true &&
	                    Base.GBPCAD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCAD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP1_UP_S2, false,"GBPCAD_UP_S2_Entry_TP1_OCO2");
	                         Base.GBPCAD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.GBPCAD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP2_UP_S2, false,"GBPCAD_UP_S2_Entry_TP2_OCO2");
	                         Base.GBPCAD_OCO2_EO2_UP_S2 = false;
	
	                         Base.GBPCAD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP3_UP_S2, false,"GBPCAD_UP_S2_Entry_TP3_OCO2");
	                         Base.GBPCAD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.GBPCAD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP4_UP_S2, false,"GBPCAD_UP_S2_Entry_TP4_OCO2");
	                         Base.GBPCAD_OCO2_EO4_UP_S2 = false;

							Base.GBPCAD_OCO2_UP_S2_IsReady = false;
							
							if (Base.GBPCAD_OCO2_UP_S2_IsReady == false && Base.GBPCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((GBPCAD_Signal_Condition_UP_1 || GBPCAD_Signal_Condition_UP_2 || GBPCAD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPCAD_UP_S2 &&
	                    Base.GBPCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPCAD_OCO3_UP_S2_IsReady == true &&
	                    Base.GBPCAD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCAD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP1_UP_S2, false,"GBPCAD_UP_S2_Entry_TP1_OCO3");
	                         Base.GBPCAD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.GBPCAD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP2_UP_S2, false,"GBPCAD_UP_S2_Entry_TP2_OCO3");
	                         Base.GBPCAD_OCO3_EO2_UP_S2 = false;
	
	                         Base.GBPCAD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP3_UP_S2, false,"GBPCAD_UP_S2_Entry_TP3_OCO3");
	                         Base.GBPCAD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.GBPCAD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP4_UP_S2, false,"GBPCAD_UP_S2_Entry_TP4_OCO3");
	                         Base.GBPCAD_OCO3_EO4_UP_S2 = false;

							Base.GBPCAD_OCO3_UP_S2_IsReady = false;
							
							if (Base.GBPCAD_OCO3_UP_S2_IsReady == false && Base.GBPCAD_OCO2_UP_S2_IsReady == false && Base.GBPCAD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((GBPCAD_Signal_Condition_UP_1 || GBPCAD_Signal_Condition_UP_2 || GBPCAD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPCAD_UP_S2 && 
	                    Base.GBPCAD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPCAD_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPCAD_OCO3_UP_S2_IsReady == false &&
	                    Base.GBPCAD_OCO4_UP_S2_IsReady == true &&
	                    Base.GBPCAD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPCAD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP1_UP_S2, false,"GBPCAD_UP_S2_Entry_TP1_OCO4");
	                         Base.GBPCAD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.GBPCAD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP2_UP_S2, false,"GBPCAD_UP_S2_Entry_TP2_OCO4");
	                         Base.GBPCAD_OCO4_EO2_UP_S2 = false;
	
	                         Base.GBPCAD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP3_UP_S2, false,"GBPCAD_UP_S2_Entry_TP3_OCO4");
	                         Base.GBPCAD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.GBPCAD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPCAD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPCAD_quantity_TP4_UP_S2, false,"GBPCAD_UP_S2_Entry_TP4_OCO4");
	                         Base.GBPCAD_OCO4_EO4_UP_S2 = false;

							Base.GBPCAD_OCO4_UP_S2_IsReady = false;
							
							if (Base.GBPCAD_OCO4_UP_S2_IsReady == false && Base.GBPCAD_OCO3_UP_S2_IsReady == false && Base.GBPCAD_OCO2_UP_S2_IsReady == false && Base.GBPCAD_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            	}
	            }
	        }
        }
    }
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURGBP_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURGBP_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(x=>x.Tag.Contains("EURGBP_UP_S2_OCO1")))
			{
				Base.EURGBP_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURGBP_UP_S2_OCO2")))
			{
				Base.EURGBP_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURGBP_UP_S2_OCO3")))
			{
				Base.EURGBP_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURGBP_UP_S2_OCO4")))
			{
				Base.EURGBP_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURGBP_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.EURGBP_OCO1_EO1_UP_S2)
	                Base.EURGBP_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.EURGBP_OCO1_EO2_UP_S2)
	                Base.EURGBP_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO1_EO3_UP_S2)
	                Base.EURGBP_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO1_EO4_UP_S2)
	                Base.EURGBP_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO1_EO5_UP_S2)
	                Base.EURGBP_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO1_EO6_UP_S2)
	                Base.EURGBP_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURGBP_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURGBP_OCO1S1_UP_S2 = 0;
		                for (; EURGBP_OCO1S1_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets1.Count; EURGBP_OCO1S1_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO1Sets1[EURGBP_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO1Sets1[EURGBP_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_1__Time out_OCO1");
		                        Base.EURGBP_UP_S2_OCO1Sets1.Clear();
		                        EURGBP_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURGBP_OCO1S2_UP_S2 = 0;
		                for (; EURGBP_OCO1S2_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets2.Count; EURGBP_OCO1S2_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO1Sets2[EURGBP_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO1Sets2[EURGBP_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_2__Time out_OCO1");
		                        Base.EURGBP_UP_S2_OCO1Sets2.Clear();
		                        EURGBP_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO1S3_UP_S2 = 0;
		                for (; EURGBP_OCO1S3_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets3.Count; EURGBP_OCO1S3_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO1Sets3[EURGBP_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO1Sets3[EURGBP_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_3__Time out_OCO1");
		                        Base.EURGBP_UP_S2_OCO1Sets3.Clear();
		                        EURGBP_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO1S4_UP_S2 = 0;
		                for (; EURGBP_OCO1S4_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets4.Count; EURGBP_OCO1S4_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO1Sets4[EURGBP_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO1Sets4[EURGBP_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_4__Time out_OCO1");
		                        Base.EURGBP_UP_S2_OCO1Sets4.Clear();
		                        EURGBP_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO1S5_UP_S2 = 0;
		                for (; EURGBP_OCO1S5_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets5.Count; EURGBP_OCO1S5_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO1Sets5[EURGBP_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO1Sets5[EURGBP_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_5__Time out_OCO1");
		                        Base.EURGBP_UP_S2_OCO1Sets5.Clear();
		                        EURGBP_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO1S6_UP_S2 = 0;
		                for (; EURGBP_OCO1S6_UP_S2 < Base.EURGBP_UP_S2_OCO1Sets6.Count; EURGBP_OCO1S6_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO1Sets6[EURGBP_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO1Sets6[EURGBP_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_6__Time out_OCO1");
		                        Base.EURGBP_UP_S2_OCO1Sets6.Clear();
		                        EURGBP_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURGBP_OCO2_EO1_UP_S2)
                	Base.EURGBP_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.EURGBP_OCO2_EO2_UP_S2)
	                Base.EURGBP_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO2_EO3_UP_S2)
	                Base.EURGBP_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO2_EO4_UP_S2)
	                Base.EURGBP_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO2_EO5_UP_S2)
	                Base.EURGBP_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO2_EO6_UP_S2)
	                Base.EURGBP_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURGBP_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURGBP_OCO2S1_UP_S2 = 0;
		                for (; EURGBP_OCO2S1_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets1.Count; EURGBP_OCO2S1_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO2Sets1[EURGBP_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO2Sets1[EURGBP_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_1__Time out_OCO2");
		                        Base.EURGBP_UP_S2_OCO2Sets1.Clear();
		                        EURGBP_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURGBP_OCO2S2_UP_S2 = 0;
		                for (; EURGBP_OCO2S2_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets2.Count; EURGBP_OCO2S2_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO2Sets2[EURGBP_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO2Sets2[EURGBP_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_2__Time out_OCO2");
		                        Base.EURGBP_UP_S2_OCO2Sets2.Clear();
		                        EURGBP_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO2S3_UP_S2 = 0;
		                for (; EURGBP_OCO2S3_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets3.Count; EURGBP_OCO2S3_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO2Sets3[EURGBP_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO2Sets3[EURGBP_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_3__Time out_OCO2");
		                        Base.EURGBP_UP_S2_OCO2Sets3.Clear();
		                        EURGBP_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO2S4_UP_S2 = 0;
		                for (; EURGBP_OCO2S4_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets4.Count; EURGBP_OCO2S4_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO2Sets4[EURGBP_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO2Sets4[EURGBP_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_4__Time out_OCO2");
		                        Base.EURGBP_UP_S2_OCO2Sets4.Clear();
		                        EURGBP_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO2S5_UP_S2 = 0;
		                for (; EURGBP_OCO2S5_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets5.Count; EURGBP_OCO2S5_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO2Sets5[EURGBP_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO2Sets5[EURGBP_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_5__Time out_OCO2");
		                        Base.EURGBP_UP_S2_OCO2Sets5.Clear();
		                        EURGBP_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO2S6_UP_S2 = 0;
		                for (; EURGBP_OCO2S6_UP_S2 < Base.EURGBP_UP_S2_OCO2Sets6.Count; EURGBP_OCO2S6_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO2Sets6[EURGBP_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO2Sets6[EURGBP_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_6__Time out_OCO2");
		                        Base.EURGBP_UP_S2_OCO2Sets6.Clear();
		                        EURGBP_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURGBP_OCO3_EO1_UP_S2)
            		Base.EURGBP_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.EURGBP_OCO3_EO2_UP_S2)
	                Base.EURGBP_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO3_EO3_UP_S2)
	                Base.EURGBP_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO3_EO4_UP_S2)
	                Base.EURGBP_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO3_EO5_UP_S2)
	                Base.EURGBP_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO3_EO6_UP_S2)
	                Base.EURGBP_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURGBP_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURGBP_OCO3S1_UP_S2 = 0;
		                for (; EURGBP_OCO3S1_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets1.Count; EURGBP_OCO3S1_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO3Sets1[EURGBP_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO3Sets1[EURGBP_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_1__Time out_OCO3");
		                        Base.EURGBP_UP_S2_OCO3Sets1.Clear();
		                        EURGBP_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURGBP_OCO3S2_UP_S2 = 0;
		                for (; EURGBP_OCO3S2_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets2.Count; EURGBP_OCO3S2_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO3Sets2[EURGBP_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO3Sets2[EURGBP_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_2__Time out_OCO3");
		                        Base.EURGBP_UP_S2_OCO3Sets2.Clear();
		                        EURGBP_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO3S3_UP_S2 = 0;
		                for (; EURGBP_OCO3S3_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets3.Count; EURGBP_OCO3S3_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO3Sets3[EURGBP_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO3Sets3[EURGBP_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_3__Time out_OCO3");
		                        Base.EURGBP_UP_S2_OCO3Sets3.Clear();
		                        EURGBP_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO3S4_UP_S2 = 0;
		                for (; EURGBP_OCO3S4_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets4.Count; EURGBP_OCO3S4_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO3Sets4[EURGBP_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO3Sets4[EURGBP_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_4__Time out_OCO3");
		                        Base.EURGBP_UP_S2_OCO3Sets4.Clear();
		                        EURGBP_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO3S5_UP_S2 = 0;
		                for (; EURGBP_OCO3S5_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets5.Count; EURGBP_OCO3S5_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO3Sets5[EURGBP_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO3Sets5[EURGBP_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_5__Time out_OCO3");
		                        Base.EURGBP_UP_S2_OCO3Sets5.Clear();
		                        EURGBP_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO3S6_UP_S2 = 0;
		                for (; EURGBP_OCO3S6_UP_S2 < Base.EURGBP_UP_S2_OCO3Sets6.Count; EURGBP_OCO3S6_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO3Sets6[EURGBP_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO3Sets6[EURGBP_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_6__Time out_OCO3");
		                        Base.EURGBP_UP_S2_OCO3Sets6.Clear();
		                        EURGBP_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURGBP_OCO4_EO1_UP_S2)
            		Base.EURGBP_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.EURGBP_OCO4_EO2_UP_S2)
	                Base.EURGBP_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO4_EO3_UP_S2)
	                Base.EURGBP_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO4_EO4_UP_S2)
	                Base.EURGBP_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO4_EO5_UP_S2)
	                Base.EURGBP_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO4_EO6_UP_S2)
	                Base.EURGBP_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURGBP_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURGBP_OCO4S1_UP_S2 = 0;
		                for (; EURGBP_OCO4S1_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets1.Count; EURGBP_OCO4S1_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO4Sets1[EURGBP_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO4Sets1[EURGBP_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_1__Time out_OCO4");
		                        Base.EURGBP_UP_S2_OCO4Sets1.Clear();
		                        EURGBP_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURGBP_OCO4S2_UP_S2 = 0;
		                for (; EURGBP_OCO4S2_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets2.Count; EURGBP_OCO4S2_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO4Sets2[EURGBP_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO4Sets2[EURGBP_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_2__Time out_OCO4");
		                        Base.EURGBP_UP_S2_OCO4Sets2.Clear();
		                        EURGBP_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO4S3_UP_S2 = 0;
		                for (; EURGBP_OCO4S3_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets3.Count; EURGBP_OCO4S3_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO4Sets3[EURGBP_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO4Sets3[EURGBP_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_3__Time out_OCO4");
		                        Base.EURGBP_UP_S2_OCO4Sets3.Clear();
		                        EURGBP_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO4S4_UP_S2 = 0;
		                for (; EURGBP_OCO4S4_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets4.Count; EURGBP_OCO4S4_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO4Sets4[EURGBP_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO4Sets4[EURGBP_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_4__Time out_OCO4");
		                        Base.EURGBP_UP_S2_OCO4Sets4.Clear();
		                        EURGBP_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO4S5_UP_S2 = 0;
		                for (; EURGBP_OCO4S5_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets5.Count; EURGBP_OCO4S5_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO4Sets5[EURGBP_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO4Sets5[EURGBP_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_5__Time out_OCO4");
		                        Base.EURGBP_UP_S2_OCO4Sets5.Clear();
		                        EURGBP_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO4S6_UP_S2 = 0;
		                for (; EURGBP_OCO4S6_UP_S2 < Base.EURGBP_UP_S2_OCO4Sets6.Count; EURGBP_OCO4S6_UP_S2++)
		                    if (Base.EURGBP_UP_S2_OCO4Sets6[EURGBP_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_UP_S2_OCO4Sets6[EURGBP_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_UP_S2_Entry_6__Time out_OCO4");
		                        Base.EURGBP_UP_S2_OCO4Sets6.Clear();
		                        EURGBP_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_EURGBP_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURGBP_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURGBP_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURGBP_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURGBP_UP_S2 = DOWM_EURGBP_UP_S2 || DOWT_EURGBP_UP_S2 || DOWW_EURGBP_UP_S2 || DOWTH_EURGBP_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURGBP"))
	            	{
	            		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.EURGBP_OCO1_UP_S2_IsReady == false ||
	                    	Base.EURGBP_OCO2_UP_S2_IsReady == false ||
	                    	Base.EURGBP_OCO3_UP_S2_IsReady == false ||
	                    	Base.EURGBP_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.EURGBP_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.EURGBP_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.EURGBP_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.EURGBP_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURGBP_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.EURGBP_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.EURGBP_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.EURGBP_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	EURGBP_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                	EURGBP_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[0] < pricesM_BID_Low[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
	                									);
	                									
	                									
	                	EURGBP_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[0] < pricesM_BID_Low[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 (EURGBP_Signal_Condition_UP_1)
	                	{
	                    	EURGBP_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURGBP_Signal_Condition_UP_2)
	                	{
	                    	EURGBP_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURGBP_Signal_Condition_UP_3)
	                	{
	                    	EURGBP_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (EURGBP_Signal_Condition_UP_1)
	                	{
	                    	EURGBP_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (EURGBP_Signal_Condition_UP_2)
	                	{
	                    	EURGBP_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (EURGBP_Signal_Condition_UP_3)
	                	{
	                    	EURGBP_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    EURGBP_UP_S2_TP2 =  EURGBP_UP_S2_SL * 0;
	                    EURGBP_UP_S2_TP3 =  EURGBP_UP_S2_SL * 0;
	                    EURGBP_UP_S2_TP4 =  EURGBP_UP_S2_SL * 0;
	                    EURGBP_UP_S2_TP5 =  EURGBP_UP_S2_SL * 0;
	                    EURGBP_UP_S2_TP6 =  EURGBP_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURGBP_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURGBP_quantity_SL_UP_S2 = EURGBP_quantity_UP_S2;
	                    EURGBP_quantity_TP1_UP_S2 = (int)Math.Floor(EURGBP_quantity_UP_S2 * 1m);
	                    EURGBP_quantity_TP2_UP_S2 = (int)Math.Floor(EURGBP_quantity_TP1_UP_S2 * 0m);
	                    EURGBP_quantity_TP3_UP_S2 = (int)Math.Floor(EURGBP_quantity_TP2_UP_S2 * 0m);
	                    EURGBP_quantity_TP4_UP_S2 = (int)Math.Floor(EURGBP_quantity_TP3_UP_S2 * 0m);
	                    EURGBP_quantity_TP5_UP_S2 = (int)Math.Floor(EURGBP_quantity_TP4_UP_S2 * 0m);
	                    EURGBP_quantity_TP6_UP_S2 = (int)Math.Floor(EURGBP_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((EURGBP_Signal_Condition_UP_1 || EURGBP_Signal_Condition_UP_2 || EURGBP_Signal_Condition_UP_3)  && 
	                    DOWR_EURGBP_UP_S2 && 
	                    Base.EURGBP_OCO1_UP_S2_IsReady == true &&
	                    Base.EURGBP_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURGBP_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP1_UP_S2, false,"EURGBP_UP_S2_Entry_TP1_OCO1");
	                         Base.EURGBP_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.EURGBP_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP2_UP_S2, false,"EURGBP_UP_S2_Entry_TP2_OCO1");
	                         Base.EURGBP_OCO1_EO2_UP_S2 = false;
	
	                         Base.EURGBP_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP3_UP_S2, false,"EURGBP_UP_S2_Entry_TP3_OCO1");
	                         Base.EURGBP_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.EURGBP_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP4_UP_S2, false,"EURGBP_UP_S2_Entry_TP4_OCO1");
	                         Base.EURGBP_OCO1_EO4_UP_S2 = false;

							Base.EURGBP_OCO1_UP_S2_IsReady = false;
							
							if (Base.EURGBP_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((EURGBP_Signal_Condition_UP_1 || EURGBP_Signal_Condition_UP_2 || EURGBP_Signal_Condition_UP_3)  && 
	                    DOWR_EURGBP_UP_S2 && 
	                    Base.EURGBP_OCO1_UP_S2_IsReady == false &&
	                    Base.EURGBP_OCO2_UP_S2_IsReady == true &&
	                    Base.EURGBP_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURGBP_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP1_UP_S2, false,"EURGBP_UP_S2_Entry_TP1_OCO2");
	                         Base.EURGBP_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.EURGBP_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP2_UP_S2, false,"EURGBP_UP_S2_Entry_TP2_OCO2");
	                         Base.EURGBP_OCO2_EO2_UP_S2 = false;
	
	                         Base.EURGBP_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP3_UP_S2, false,"EURGBP_UP_S2_Entry_TP3_OCO2");
	                         Base.EURGBP_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.EURGBP_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP4_UP_S2, false,"EURGBP_UP_S2_Entry_TP4_OCO2");
	                         Base.EURGBP_OCO2_EO4_UP_S2 = false;

							Base.EURGBP_OCO2_UP_S2_IsReady = false;
							
							if (Base.EURGBP_OCO2_UP_S2_IsReady == false && Base.EURGBP_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((EURGBP_Signal_Condition_UP_1 || EURGBP_Signal_Condition_UP_2 || EURGBP_Signal_Condition_UP_3)  && 
	                    DOWR_EURGBP_UP_S2 &&
	                    Base.EURGBP_OCO1_UP_S2_IsReady == false &&
	                    Base.EURGBP_OCO2_UP_S2_IsReady == false &&
	                    Base.EURGBP_OCO3_UP_S2_IsReady == true &&
	                    Base.EURGBP_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURGBP_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP1_UP_S2, false,"EURGBP_UP_S2_Entry_TP1_OCO3");
	                         Base.EURGBP_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.EURGBP_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP2_UP_S2, false,"EURGBP_UP_S2_Entry_TP2_OCO3");
	                         Base.EURGBP_OCO3_EO2_UP_S2 = false;
	
	                         Base.EURGBP_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP3_UP_S2, false,"EURGBP_UP_S2_Entry_TP3_OCO3");
	                         Base.EURGBP_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.EURGBP_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP4_UP_S2, false,"EURGBP_UP_S2_Entry_TP4_OCO3");
	                         Base.EURGBP_OCO3_EO4_UP_S2 = false;

							Base.EURGBP_OCO3_UP_S2_IsReady = false;
							
							if (Base.EURGBP_OCO3_UP_S2_IsReady == false && Base.EURGBP_OCO2_UP_S2_IsReady == false && Base.EURGBP_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((EURGBP_Signal_Condition_UP_1 || EURGBP_Signal_Condition_UP_2 || EURGBP_Signal_Condition_UP_3)  && 
	                    DOWR_EURGBP_UP_S2 && 
	                    Base.EURGBP_OCO1_UP_S2_IsReady == false &&
	                    Base.EURGBP_OCO2_UP_S2_IsReady == false &&
	                    Base.EURGBP_OCO3_UP_S2_IsReady == false &&
	                    Base.EURGBP_OCO4_UP_S2_IsReady == true &&
	                    Base.EURGBP_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURGBP_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP1_UP_S2, false,"EURGBP_UP_S2_Entry_TP1_OCO4");
	                         Base.EURGBP_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.EURGBP_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP2_UP_S2, false,"EURGBP_UP_S2_Entry_TP2_OCO4");
	                         Base.EURGBP_OCO4_EO2_UP_S2 = false;
	
	                         Base.EURGBP_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP3_UP_S2, false,"EURGBP_UP_S2_Entry_TP3_OCO4");
	                         Base.EURGBP_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.EURGBP_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURGBP_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP4_UP_S2, false,"EURGBP_UP_S2_Entry_TP4_OCO4");
	                         Base.EURGBP_OCO4_EO4_UP_S2 = false;

							Base.EURGBP_OCO4_UP_S2_IsReady = false;
							
							if (Base.EURGBP_OCO4_UP_S2_IsReady == false && Base.EURGBP_OCO3_UP_S2_IsReady == false && Base.EURGBP_OCO2_UP_S2_IsReady == false && Base.EURGBP_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.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 EURUSD_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public EURUSD_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("EURUSD OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue eurusd S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURUSD OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue eurusd S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURUSD OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue eurusd S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURUSD OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue eurusd S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURUSD OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue eurusd S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURUSD OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue eurusd S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("EURUSD OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("EURUSD OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("EURUSD OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue eurusd S2");
		        	}
		        }
		        
				if (Base.EURUSD_OCO1_EO1_UP_S2)
	                Base.EURUSD_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURUSD_OCO1_EO2_UP_S2)
	                Base.EURUSD_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO1_EO3_UP_S2)
	                Base.EURUSD_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO1_EO4_UP_S2)
	                Base.EURUSD_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO1_EO5_UP_S2)
	                Base.EURUSD_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO1_EO6_UP_S2)
	                Base.EURUSD_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURUSD_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.EURUSD_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP1,"TP1_EURUSD_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP1_EURUSD_UP_S2_OCO1"));
		                 };
		                Base.EURUSD_UP_S2_OCO1Sets1.Add( Base.EURUSD_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURUSD_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP2,"TP2_EURUSD_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP2_EURUSD_UP_S2_OCO1"));
		                 };
	                    Base.EURUSD_UP_S2_OCO1Sets2.Add( Base.EURUSD_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP3,"TP3_EURUSD_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP3_EURUSD_UP_S2_OCO1"));
		                 };
	                    Base.EURUSD_UP_S2_OCO1Sets3.Add( Base.EURUSD_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP4,"TP4_EURUSD_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP4_EURUSD_UP_S2_OCO1"));
		                 };
	                    Base.EURUSD_UP_S2_OCO1Sets4.Add( Base.EURUSD_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP5,"TP5_EURUSD_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP5_EURUSD_UP_S2_OCO1"));
		                 };
	                    Base.EURUSD_UP_S2_OCO1Sets5.Add( Base.EURUSD_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP6,"TP6_EURUSD_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP6_EURUSD_UP_S2_OCO1"));
		                 };
	                    Base.EURUSD_UP_S2_OCO1Sets6.Add( Base.EURUSD_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURUSD_OCO1S1_UP_S2 = 0;
	                for (; EURUSD_OCO1S1_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets1.Count; EURUSD_OCO1S1_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO1Sets1[EURUSD_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO1Sets1[EURUSD_OCO1S1_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO1Sets1.RemoveAt(EURUSD_OCO1S1_UP_S2);
	                        EURUSD_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURUSD_OCO1S2_UP_S2 = 0;
	                for (; EURUSD_OCO1S2_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets2.Count; EURUSD_OCO1S2_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO1Sets2[EURUSD_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO1Sets2[EURUSD_OCO1S2_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO1Sets2.RemoveAt(EURUSD_OCO1S2_UP_S2);
	                        EURUSD_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO1S3_UP_S2 = 0;
	                for (; EURUSD_OCO1S3_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets3.Count; EURUSD_OCO1S3_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO1Sets3[EURUSD_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO1Sets3[EURUSD_OCO1S3_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO1Sets3.RemoveAt(EURUSD_OCO1S3_UP_S2);
	                        EURUSD_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO1S4_UP_S2 = 0;
	                for (; EURUSD_OCO1S4_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets4.Count; EURUSD_OCO1S4_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO1Sets4[EURUSD_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO1Sets4[EURUSD_OCO1S4_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO1Sets4.RemoveAt(EURUSD_OCO1S4_UP_S2);
	                        EURUSD_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURUSD_OCO1S5_UP_S2 = 0;
	                for (; EURUSD_OCO1S5_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets5.Count; EURUSD_OCO1S5_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO1Sets5[EURUSD_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO1Sets5[EURUSD_OCO1S5_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO1Sets5.RemoveAt(EURUSD_OCO1S5_UP_S2);
	                        EURUSD_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURUSD_OCO1S6_UP_S2 = 0;
	                for (; EURUSD_OCO1S6_UP_S2 < Base.EURUSD_UP_S2_OCO1Sets6.Count; EURUSD_OCO1S6_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO1Sets6[EURUSD_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO1Sets6[EURUSD_OCO1S6_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO1Sets6.RemoveAt(EURUSD_OCO1S6_UP_S2);
	                        EURUSD_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.EURUSD_OCO2_EO1_UP_S2)
	                Base.EURUSD_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURUSD_OCO2_EO2_UP_S2)
	                Base.EURUSD_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO2_EO3_UP_S2)
	                Base.EURUSD_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO2_EO4_UP_S2)
	                Base.EURUSD_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO2_EO5_UP_S2)
	                Base.EURUSD_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO2_EO6_UP_S2)
	                Base.EURUSD_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURUSD_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.EURUSD_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP1,"TP1_EURUSD_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP1_EURUSD_UP_S2_OCO2"));
		                 };
		                Base.EURUSD_UP_S2_OCO2Sets1.Add( Base.EURUSD_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURUSD_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP2,"TP2_EURUSD_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP2_EURUSD_UP_S2_OCO2"));
		                 };
	                    Base.EURUSD_UP_S2_OCO2Sets2.Add( Base.EURUSD_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP3,"TP3_EURUSD_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP3_EURUSD_UP_S2_OCO2"));
		                 };
	                    Base.EURUSD_UP_S2_OCO2Sets3.Add( Base.EURUSD_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP4,"TP4_EURUSD_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP4_EURUSD_UP_S2_OCO2"));
		                 };
	                    Base.EURUSD_UP_S2_OCO2Sets4.Add( Base.EURUSD_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP5,"TP5_EURUSD_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP5_EURUSD_UP_S2_OCO2"));
		                 };
	                    Base.EURUSD_UP_S2_OCO2Sets5.Add( Base.EURUSD_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP6,"TP6_EURUSD_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP6_EURUSD_UP_S2_OCO2"));
		                 };
	                    Base.EURUSD_UP_S2_OCO2Sets6.Add( Base.EURUSD_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURUSD_OCO2S1_UP_S2 = 0;
	                for (; EURUSD_OCO2S1_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets1.Count; EURUSD_OCO2S1_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO2Sets1[EURUSD_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO2Sets1[EURUSD_OCO2S1_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO2Sets1.RemoveAt(EURUSD_OCO2S1_UP_S2);
	                        EURUSD_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURUSD_OCO2S2_UP_S2 = 0;
	                for (; EURUSD_OCO2S2_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets2.Count; EURUSD_OCO2S2_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO2Sets2[EURUSD_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO2Sets2[EURUSD_OCO2S2_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO2Sets2.RemoveAt(EURUSD_OCO2S2_UP_S2);
	                        EURUSD_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO2S3_UP_S2 = 0;
	                for (; EURUSD_OCO2S3_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets3.Count; EURUSD_OCO2S3_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO2Sets3[EURUSD_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO2Sets3[EURUSD_OCO2S3_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO2Sets3.RemoveAt(EURUSD_OCO2S3_UP_S2);
	                        EURUSD_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO2S4_UP_S2 = 0;
	                for (; EURUSD_OCO2S4_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets4.Count; EURUSD_OCO2S4_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO2Sets4[EURUSD_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO2Sets4[EURUSD_OCO2S4_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO2Sets4.RemoveAt(EURUSD_OCO2S4_UP_S2);
	                        EURUSD_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURUSD_OCO2S5_UP_S2 = 0;
	                for (; EURUSD_OCO2S5_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets5.Count; EURUSD_OCO2S5_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO2Sets5[EURUSD_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO2Sets5[EURUSD_OCO2S5_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO2Sets5.RemoveAt(EURUSD_OCO2S5_UP_S2);
	                        EURUSD_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURUSD_OCO2S6_UP_S2 = 0;
	                for (; EURUSD_OCO2S6_UP_S2 < Base.EURUSD_UP_S2_OCO2Sets6.Count; EURUSD_OCO2S6_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO2Sets6[EURUSD_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO2Sets6[EURUSD_OCO2S6_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO2Sets6.RemoveAt(EURUSD_OCO2S6_UP_S2);
	                        EURUSD_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURUSD_OCO3_EO1_UP_S2)
	                Base.EURUSD_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURUSD_OCO3_EO2_UP_S2)
	                Base.EURUSD_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO3_EO3_UP_S2)
	                Base.EURUSD_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO3_EO4_UP_S2)
	                Base.EURUSD_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO3_EO5_UP_S2)
	                Base.EURUSD_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO3_EO6_UP_S2)
	                Base.EURUSD_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURUSD_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.EURUSD_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP1,"TP1_EURUSD_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP1_EURUSD_UP_S2_OCO3"));
		                 };
		                Base.EURUSD_UP_S2_OCO3Sets1.Add( Base.EURUSD_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURUSD_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP2,"TP2_EURUSD_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP2_EURUSD_UP_S2_OCO3"));
		                 };
	                    Base.EURUSD_UP_S2_OCO3Sets2.Add( Base.EURUSD_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP3,"TP3_EURUSD_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP3_EURUSD_UP_S2_OCO3"));
		                 };
	                    Base.EURUSD_UP_S2_OCO3Sets3.Add( Base.EURUSD_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP4,"TP4_EURUSD_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP4_EURUSD_UP_S2_OCO3"));
		                 };
	                    Base.EURUSD_UP_S2_OCO3Sets4.Add( Base.EURUSD_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP5,"TP5_EURUSD_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP5_EURUSD_UP_S2_OCO3"));
		                 };
	                    Base.EURUSD_UP_S2_OCO3Sets5.Add( Base.EURUSD_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP6,"TP6_EURUSD_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP6_EURUSD_UP_S2_OCO3"));
		                 };
	                    Base.EURUSD_UP_S2_OCO3Sets6.Add( Base.EURUSD_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURUSD_OCO3S1_UP_S2 = 0;
	                for (; EURUSD_OCO3S1_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets1.Count; EURUSD_OCO3S1_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO3Sets1[EURUSD_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO3Sets1[EURUSD_OCO3S1_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO3Sets1.RemoveAt(EURUSD_OCO3S1_UP_S2);
	                        EURUSD_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURUSD_OCO3S2_UP_S2 = 0;
	                for (; EURUSD_OCO3S2_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets2.Count; EURUSD_OCO3S2_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO3Sets2[EURUSD_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO3Sets2[EURUSD_OCO3S2_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO3Sets2.RemoveAt(EURUSD_OCO3S2_UP_S2);
	                        EURUSD_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO3S3_UP_S2 = 0;
	                for (; EURUSD_OCO3S3_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets3.Count; EURUSD_OCO3S3_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO3Sets3[EURUSD_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO3Sets3[EURUSD_OCO3S3_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO3Sets3.RemoveAt(EURUSD_OCO3S3_UP_S2);
	                        EURUSD_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO3S4_UP_S2 = 0;
	                for (; EURUSD_OCO3S4_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets4.Count; EURUSD_OCO3S4_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO3Sets4[EURUSD_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO3Sets4[EURUSD_OCO3S4_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO3Sets4.RemoveAt(EURUSD_OCO3S4_UP_S2);
	                        EURUSD_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURUSD_OCO3S5_UP_S2 = 0;
	                for (; EURUSD_OCO3S5_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets5.Count; EURUSD_OCO3S5_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO3Sets5[EURUSD_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO3Sets5[EURUSD_OCO3S5_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO3Sets5.RemoveAt(EURUSD_OCO3S5_UP_S2);
	                        EURUSD_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURUSD_OCO3S6_UP_S2 = 0;
	                for (; EURUSD_OCO3S6_UP_S2 < Base.EURUSD_UP_S2_OCO3Sets6.Count; EURUSD_OCO3S6_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO3Sets6[EURUSD_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO3Sets6[EURUSD_OCO3S6_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO3Sets6.RemoveAt(EURUSD_OCO3S6_UP_S2);
	                        EURUSD_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.EURUSD_OCO4_EO1_UP_S2)
	                Base.EURUSD_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.EURUSD_OCO4_EO2_UP_S2)
	                Base.EURUSD_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO4_EO3_UP_S2)
	                Base.EURUSD_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO4_EO4_UP_S2)
	                Base.EURUSD_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO4_EO5_UP_S2)
	                Base.EURUSD_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.EURUSD_OCO4_EO6_UP_S2)
	                Base.EURUSD_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.EURUSD_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.EURUSD_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP1,"TP1_EURUSD_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP1_EURUSD_UP_S2_OCO4"));
		                 };
		                Base.EURUSD_UP_S2_OCO4Sets1.Add( Base.EURUSD_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.EURUSD_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP2,"TP2_EURUSD_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP2_EURUSD_UP_S2_OCO4"));
		                 };
	                    Base.EURUSD_UP_S2_OCO4Sets2.Add( Base.EURUSD_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP3,"TP3_EURUSD_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP3_EURUSD_UP_S2_OCO4"));
		                 };
	                    Base.EURUSD_UP_S2_OCO4Sets3.Add( Base.EURUSD_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP4,"TP4_EURUSD_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP4_EURUSD_UP_S2_OCO4"));
		                 };
	                    Base.EURUSD_UP_S2_OCO4Sets4.Add( Base.EURUSD_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP5,"TP5_EURUSD_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP5_EURUSD_UP_S2_OCO4"));
		                 };
	                    Base.EURUSD_UP_S2_OCO4Sets5.Add( Base.EURUSD_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.EURUSD_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.EURUSD_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new EURUSD_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.EURUSD_UP_S2_TP6,"TP6_EURUSD_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.EURUSD_UP_S2_SL,"SL_TP6_EURUSD_UP_S2_OCO4"));
		                 };
	                    Base.EURUSD_UP_S2_OCO4Sets6.Add( Base.EURUSD_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.EURUSD_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int EURUSD_OCO4S1_UP_S2 = 0;
	                for (; EURUSD_OCO4S1_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets1.Count; EURUSD_OCO4S1_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO4Sets1[EURUSD_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO4Sets1[EURUSD_OCO4S1_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO4Sets1.RemoveAt(EURUSD_OCO4S1_UP_S2);
	                        EURUSD_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int EURUSD_OCO4S2_UP_S2 = 0;
	                for (; EURUSD_OCO4S2_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets2.Count; EURUSD_OCO4S2_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO4Sets2[EURUSD_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO4Sets2[EURUSD_OCO4S2_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO4Sets2.RemoveAt(EURUSD_OCO4S2_UP_S2);
	                        EURUSD_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO4S3_UP_S2 = 0;
	                for (; EURUSD_OCO4S3_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets3.Count; EURUSD_OCO4S3_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO4Sets3[EURUSD_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO4Sets3[EURUSD_OCO4S3_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO4Sets3.RemoveAt(EURUSD_OCO4S3_UP_S2);
	                        EURUSD_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int EURUSD_OCO4S4_UP_S2 = 0;
	                for (; EURUSD_OCO4S4_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets4.Count; EURUSD_OCO4S4_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO4Sets4[EURUSD_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO4Sets4[EURUSD_OCO4S4_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO4Sets4.RemoveAt(EURUSD_OCO4S4_UP_S2);
	                        EURUSD_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURUSD_OCO4S5_UP_S2 = 0;
	                for (; EURUSD_OCO4S5_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets5.Count; EURUSD_OCO4S5_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO4Sets5[EURUSD_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO4Sets5[EURUSD_OCO4S5_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO4Sets5.RemoveAt(EURUSD_OCO4S5_UP_S2);
	                        EURUSD_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int EURUSD_OCO4S6_UP_S2 = 0;
	                for (; EURUSD_OCO4S6_UP_S2 < Base.EURUSD_UP_S2_OCO4Sets6.Count; EURUSD_OCO4S6_UP_S2++)
	                    if (Base.EURUSD_UP_S2_OCO4Sets6[EURUSD_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.EURUSD_UP_S2_OCO4Sets6[EURUSD_OCO4S6_UP_S2].Filled();
	                        Base.EURUSD_UP_S2_OCO4Sets6.RemoveAt(EURUSD_OCO4S6_UP_S2);
	                        EURUSD_OCO4S6_UP_S2 = 0;
	                        break;
	                    }
		    
		        }
		}
	}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPAUD_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPAUD_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("GBPAUD_DOWN_S2_OCO1")))
			{
				Base.GBPAUD_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPAUD_DOWN_S2_OCO2")))
			{
				Base.GBPAUD_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPAUD_DOWN_S2_OCO3")))
			{
				Base.GBPAUD_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPAUD_DOWN_S2_OCO4")))
			{
				Base.GBPAUD_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPAUD_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.GBPAUD_OCO1_EO1_DOWN_S2)
	                Base.GBPAUD_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPAUD_OCO1_EO2_DOWN_S2)
	                Base.GBPAUD_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO1_EO3_DOWN_S2)
	                Base.GBPAUD_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO1_EO4_DOWN_S2)
	                Base.GBPAUD_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO1_EO5_DOWN_S2)
	                Base.GBPAUD_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO1_EO6_DOWN_S2)
	                Base.GBPAUD_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPAUD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPAUD_OCO1S1_DOWN_S2 = 0;
		                for (; GBPAUD_OCO1S1_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets1.Count; GBPAUD_OCO1S1_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO1Sets1[GBPAUD_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO1Sets1[GBPAUD_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.GBPAUD_DOWN_S2_OCO1Sets1.Clear();
		                        GBPAUD_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPAUD_OCO1S2_DOWN_S2 = 0;
		                for (; GBPAUD_OCO1S2_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets2.Count; GBPAUD_OCO1S2_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO1Sets2[GBPAUD_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO1Sets2[GBPAUD_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.GBPAUD_DOWN_S2_OCO1Sets2.Clear();
		                        GBPAUD_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO1S3_DOWN_S2 = 0;
		                for (; GBPAUD_OCO1S3_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets3.Count; GBPAUD_OCO1S3_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO1Sets3[GBPAUD_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO1Sets3[GBPAUD_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.GBPAUD_DOWN_S2_OCO1Sets3.Clear();
		                        GBPAUD_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO1S4_DOWN_S2 = 0;
		                for (; GBPAUD_OCO1S4_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets4.Count; GBPAUD_OCO1S4_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO1Sets4[GBPAUD_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO1Sets4[GBPAUD_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.GBPAUD_DOWN_S2_OCO1Sets4.Clear();
		                        GBPAUD_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO1S5_DOWN_S2 = 0;
		                for (; GBPAUD_OCO1S5_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets5.Count; GBPAUD_OCO1S5_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO1Sets5[GBPAUD_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO1Sets5[GBPAUD_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.GBPAUD_DOWN_S2_OCO1Sets5.Clear();
		                        GBPAUD_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO1S6_DOWN_S2 = 0;
		                for (; GBPAUD_OCO1S6_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO1Sets6.Count; GBPAUD_OCO1S6_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO1Sets6[GBPAUD_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO1Sets6[GBPAUD_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.GBPAUD_DOWN_S2_OCO1Sets6.Clear();
		                        GBPAUD_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPAUD_OCO2_EO1_DOWN_S2)
	                Base.GBPAUD_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPAUD_OCO2_EO2_DOWN_S2)
	                Base.GBPAUD_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO2_EO3_DOWN_S2)
	                Base.GBPAUD_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO2_EO4_DOWN_S2)
	                Base.GBPAUD_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO2_EO5_DOWN_S2)
	                Base.GBPAUD_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO2_EO6_DOWN_S2)
	                Base.GBPAUD_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPAUD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPAUD_OCO2S1_DOWN_S2 = 0;
		                for (; GBPAUD_OCO2S1_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets1.Count; GBPAUD_OCO2S1_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO2Sets1[GBPAUD_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO2Sets1[GBPAUD_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.GBPAUD_DOWN_S2_OCO2Sets1.Clear();
		                        GBPAUD_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPAUD_OCO2S2_DOWN_S2 = 0;
		                for (; GBPAUD_OCO2S2_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets2.Count; GBPAUD_OCO2S2_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO2Sets2[GBPAUD_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO2Sets2[GBPAUD_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.GBPAUD_DOWN_S2_OCO2Sets2.Clear();
		                        GBPAUD_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO2S3_DOWN_S2 = 0;
		                for (; GBPAUD_OCO2S3_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets3.Count; GBPAUD_OCO2S3_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO2Sets3[GBPAUD_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO2Sets3[GBPAUD_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.GBPAUD_DOWN_S2_OCO2Sets3.Clear();
		                        GBPAUD_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO2S4_DOWN_S2 = 0;
		                for (; GBPAUD_OCO2S4_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets4.Count; GBPAUD_OCO2S4_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO2Sets4[GBPAUD_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO2Sets4[GBPAUD_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.GBPAUD_DOWN_S2_OCO2Sets4.Clear();
		                        GBPAUD_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO2S5_DOWN_S2 = 0;
		                for (; GBPAUD_OCO2S5_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets5.Count; GBPAUD_OCO2S5_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO2Sets5[GBPAUD_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO2Sets5[GBPAUD_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.GBPAUD_DOWN_S2_OCO2Sets5.Clear();
		                        GBPAUD_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO2S6_DOWN_S2 = 0;
		                for (; GBPAUD_OCO2S6_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO2Sets6.Count; GBPAUD_OCO2S6_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO2Sets6[GBPAUD_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO2Sets6[GBPAUD_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.GBPAUD_DOWN_S2_OCO2Sets6.Clear();
		                        GBPAUD_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPAUD_OCO3_EO1_DOWN_S2)
	                Base.GBPAUD_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPAUD_OCO3_EO2_DOWN_S2)
	                Base.GBPAUD_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO3_EO3_DOWN_S2)
	                Base.GBPAUD_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO3_EO4_DOWN_S2)
	                Base.GBPAUD_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO3_EO5_DOWN_S2)
	                Base.GBPAUD_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO3_EO6_DOWN_S2)
	                Base.GBPAUD_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPAUD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPAUD_OCO3S1_DOWN_S2 = 0;
		                for (; GBPAUD_OCO3S1_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets1.Count; GBPAUD_OCO3S1_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO3Sets1[GBPAUD_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO3Sets1[GBPAUD_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.GBPAUD_DOWN_S2_OCO3Sets1.Clear();
		                        GBPAUD_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPAUD_OCO3S2_DOWN_S2 = 0;
		                for (; GBPAUD_OCO3S2_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets2.Count; GBPAUD_OCO3S2_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO3Sets2[GBPAUD_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO3Sets2[GBPAUD_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.GBPAUD_DOWN_S2_OCO3Sets2.Clear();
		                        GBPAUD_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO3S3_DOWN_S2 = 0;
		                for (; GBPAUD_OCO3S3_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets3.Count; GBPAUD_OCO3S3_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO3Sets3[GBPAUD_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO3Sets3[GBPAUD_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.GBPAUD_DOWN_S2_OCO3Sets3.Clear();
		                        GBPAUD_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO3S4_DOWN_S2 = 0;
		                for (; GBPAUD_OCO3S4_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets4.Count; GBPAUD_OCO3S4_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO3Sets4[GBPAUD_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO3Sets4[GBPAUD_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.GBPAUD_DOWN_S2_OCO3Sets4.Clear();
		                        GBPAUD_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO3S5_DOWN_S2 = 0;
		                for (; GBPAUD_OCO3S5_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets5.Count; GBPAUD_OCO3S5_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO3Sets5[GBPAUD_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO3Sets5[GBPAUD_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.GBPAUD_DOWN_S2_OCO3Sets5.Clear();
		                        GBPAUD_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO3S6_DOWN_S2 = 0;
		                for (; GBPAUD_OCO3S6_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO3Sets6.Count; GBPAUD_OCO3S6_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO3Sets6[GBPAUD_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO3Sets6[GBPAUD_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.GBPAUD_DOWN_S2_OCO3Sets6.Clear();
		                        GBPAUD_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPAUD_OCO4_EO1_DOWN_S2)
	                Base.GBPAUD_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.GBPAUD_OCO4_EO2_DOWN_S2)
	                Base.GBPAUD_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO4_EO3_DOWN_S2)
	                Base.GBPAUD_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO4_EO4_DOWN_S2)
	                Base.GBPAUD_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO4_EO5_DOWN_S2)
	                Base.GBPAUD_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO4_EO6_DOWN_S2)
	                Base.GBPAUD_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPAUD_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPAUD_OCO4S1_DOWN_S2 = 0;
		                for (; GBPAUD_OCO4S1_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets1.Count; GBPAUD_OCO4S1_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO4Sets1[GBPAUD_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO4Sets1[GBPAUD_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.GBPAUD_DOWN_S2_OCO4Sets1.Clear();
		                        GBPAUD_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int GBPAUD_OCO4S2_DOWN_S2 = 0;
		                for (; GBPAUD_OCO4S2_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets2.Count; GBPAUD_OCO4S2_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO4Sets2[GBPAUD_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO4Sets2[GBPAUD_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.GBPAUD_DOWN_S2_OCO4Sets2.Clear();
		                        GBPAUD_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO4S3_DOWN_S2 = 0;
		                for (; GBPAUD_OCO4S3_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets3.Count; GBPAUD_OCO4S3_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO4Sets3[GBPAUD_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO4Sets3[GBPAUD_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.GBPAUD_DOWN_S2_OCO4Sets3.Clear();
		                        GBPAUD_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO4S4_DOWN_S2 = 0;
		                for (; GBPAUD_OCO4S4_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets4.Count; GBPAUD_OCO4S4_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO4Sets4[GBPAUD_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO4Sets4[GBPAUD_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.GBPAUD_DOWN_S2_OCO4Sets4.Clear();
		                        GBPAUD_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO4S5_DOWN_S2 = 0;
		                for (; GBPAUD_OCO4S5_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets5.Count; GBPAUD_OCO4S5_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO4Sets5[GBPAUD_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO4Sets5[GBPAUD_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.GBPAUD_DOWN_S2_OCO4Sets5.Clear();
		                        GBPAUD_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO4S6_DOWN_S2 = 0;
		                for (; GBPAUD_OCO4S6_DOWN_S2 < Base.GBPAUD_DOWN_S2_OCO4Sets6.Count; GBPAUD_OCO4S6_DOWN_S2++)
		                    if (Base.GBPAUD_DOWN_S2_OCO4Sets6[GBPAUD_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_DOWN_S2_OCO4Sets6[GBPAUD_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.GBPAUD_DOWN_S2_OCO4Sets6.Clear();
		                        GBPAUD_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();
	            	}
	            	
					DOWM_GBPAUD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPAUD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPAUD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPAUD_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPAUD_DOWN_S2 = DOWM_GBPAUD_DOWN_S2 || DOWT_GBPAUD_DOWN_S2 || DOWW_GBPAUD_DOWN_S2 || DOWTH_GBPAUD_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPAUD"))
	            	{
	            		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.GBPAUD_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.GBPAUD_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.GBPAUD_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.GBPAUD_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.GBPAUD_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPAUD_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPAUD_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.GBPAUD_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPAUD_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPAUD_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPAUD_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.GBPAUD_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	GBPAUD_Signal_Condition_DOWN_S2 =  
	                									(
															pricesM_BID_High[0] - pricesM_BID_Open[0] > prices_BID_Close[0] * 0.008m &&
	                										pricesM_BID_High[1] - pricesM_BID_Open[1] > prices_BID_Close[0] * 0.008m &&
	                										
	                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > prices_BID_Close[0] * 0.000001m &&
	                										pricesM_ASK_Open[1] - pricesM_BID_Close[1] > prices_BID_Close[0] * 0.000001m &&

	                										prices_ASK_High[0] > pricesM_ASK_Close[0] &&
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.001m
	                									);
	                									
	                    GBPAUD_DOWN_S2_SL  =  0.0150m;
	                    GBPAUD_DOWN_S2_TP1 =  0.0025m;
	                    GBPAUD_DOWN_S2_TP2 =  GBPAUD_DOWN_S2_SL * 0;
	                    GBPAUD_DOWN_S2_TP3 =  GBPAUD_DOWN_S2_SL * 0;
	                    GBPAUD_DOWN_S2_TP4 =  GBPAUD_DOWN_S2_SL * 0;
	                    GBPAUD_DOWN_S2_TP5 =  GBPAUD_DOWN_S2_SL * 0;
	                    GBPAUD_DOWN_S2_TP6 =  GBPAUD_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPAUD_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPAUD_quantity_SL_DOWN_S2 = GBPAUD_quantity_DOWN_S2;
	                    GBPAUD_quantity_TP1_DOWN_S2 = (int)Math.Floor(GBPAUD_quantity_DOWN_S2 * 1m);
	                    GBPAUD_quantity_TP2_DOWN_S2 = (int)Math.Floor(GBPAUD_quantity_TP1_DOWN_S2 * 0m);
	                    GBPAUD_quantity_TP3_DOWN_S2 = (int)Math.Floor(GBPAUD_quantity_TP2_DOWN_S2 * 0m);
	                    GBPAUD_quantity_TP4_DOWN_S2 = (int)Math.Floor(GBPAUD_quantity_TP3_DOWN_S2 * 0m);
	                    GBPAUD_quantity_TP5_DOWN_S2 = (int)Math.Floor(GBPAUD_quantity_TP4_DOWN_S2 * 0m);
	                    GBPAUD_quantity_TP6_DOWN_S2 = (int)Math.Floor(GBPAUD_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (GBPAUD_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPAUD_DOWN_S2 && 
	                    Base.GBPAUD_OCO1_DOWN_S2_IsReady == true &&
	                    Base.GBPAUD_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPAUD_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP1_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP1_OCO1");
	                         Base.GBPAUD_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPAUD_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP2_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP2_OCO1");
	                         Base.GBPAUD_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.GBPAUD_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP3_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP3_OCO1");
	                         Base.GBPAUD_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPAUD_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP4_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP4_OCO1");
	                         Base.GBPAUD_OCO1_EO4_DOWN_S2 = false;

							Base.GBPAUD_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.GBPAUD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (GBPAUD_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPAUD_DOWN_S2 && 
	                    Base.GBPAUD_OCO2_DOWN_S2_IsReady == true &&
	                    Base.GBPAUD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPAUD_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPAUD_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP1_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP1_OCO2");
	                         Base.GBPAUD_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPAUD_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP2_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP2_OCO2");
	                         Base.GBPAUD_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.GBPAUD_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP3_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP3_OCO2");
	                         Base.GBPAUD_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPAUD_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP4_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP4_OCO2");
	                         Base.GBPAUD_OCO2_EO4_DOWN_S2 = false;

							Base.GBPAUD_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.GBPAUD_OCO2_DOWN_S2_IsReady == false && Base.GBPAUD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (GBPAUD_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPAUD_DOWN_S2 &&
	                    Base.GBPAUD_OCO3_DOWN_S2_IsReady == true &&
	                    Base.GBPAUD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPAUD_OCO2_DOWN_S2_IsReady == false && 
	                    Base.GBPAUD_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPAUD_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP1_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP1_OCO3");
	                         Base.GBPAUD_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPAUD_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP2_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP2_OCO3");
	                         Base.GBPAUD_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.GBPAUD_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP3_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP3_OCO3");
	                         Base.GBPAUD_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPAUD_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP4_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP4_OCO3");
	                         Base.GBPAUD_OCO3_EO4_DOWN_S2 = false;

							Base.GBPAUD_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.GBPAUD_OCO3_DOWN_S2_IsReady == false && Base.GBPAUD_OCO2_DOWN_S2_IsReady == false && Base.GBPAUD_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (GBPAUD_Signal_Condition_DOWN_S2 && 
	                    DOWR_GBPAUD_DOWN_S2 && 
	                    Base.GBPAUD_OCO4_DOWN_S2_IsReady == true &&
	                    Base.GBPAUD_OCO1_DOWN_S2_IsReady == false &&
	                    Base.GBPAUD_OCO2_DOWN_S2_IsReady == false &&
	                    Base.GBPAUD_OCO3_DOWN_S2_IsReady == false &&
	                    Base.GBPAUD_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPAUD_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP1_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP1_OCO4");
	                         Base.GBPAUD_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.GBPAUD_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP2_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP2_OCO4");
	                         Base.GBPAUD_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.GBPAUD_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP3_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP3_OCO4");
	                         Base.GBPAUD_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.GBPAUD_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         GBPAUD_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP4_DOWN_S2, false,"GBPAUD_DOWN_S2_Entry_TP4_OCO4");
	                         Base.GBPAUD_OCO4_EO4_DOWN_S2 = false;

							Base.GBPAUD_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.GBPAUD_OCO4_DOWN_S2_IsReady == false && Base.GBPAUD_OCO3_DOWN_S2_IsReady == false && Base.GBPAUD_OCO2_DOWN_S2_IsReady == false && Base.GBPAUD_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
    {
    	
    	public static Symbol _USDJPY;
		
    	///oco1 up
    	public static OrderTicket USDJPY_OCO1_MO1_UP_S2;
    	public static OrderTicket USDJPY_OCO1_MO2_UP_S2;
    	public static OrderTicket USDJPY_OCO1_MO3_UP_S2;
    	public static OrderTicket USDJPY_OCO1_MO4_UP_S2;
    	public static OrderTicket USDJPY_OCO1_MO5_UP_S2;
    	public static OrderTicket USDJPY_OCO1_MO6_UP_S2;
    	
    	public static int USDJPY_OCO1_EO1_UP_S2_ID ;
        public static int USDJPY_OCO1_EO2_UP_S2_ID ;
        public static int USDJPY_OCO1_EO3_UP_S2_ID ;
        public static int USDJPY_OCO1_EO4_UP_S2_ID ;
        public static int USDJPY_OCO1_EO5_UP_S2_ID ;
        public static int USDJPY_OCO1_EO6_UP_S2_ID ;
        
        public static bool USDJPY_OCO1_EO1_UP_S2 ;
        public static bool USDJPY_OCO1_EO2_UP_S2 ;
        public static bool USDJPY_OCO1_EO3_UP_S2 ;
        public static bool USDJPY_OCO1_EO4_UP_S2 ;
        public static bool USDJPY_OCO1_EO5_UP_S2 ;
        public static bool USDJPY_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_UP_S2> USDJPY_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_UP_S2> USDJPY_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_UP_S2> USDJPY_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_UP_S2> USDJPY_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_UP_S2> USDJPY_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_UP_S2> USDJPY_OOFE_OCO1_UP_S2_6 ;
        
        public static USDJPY_OCO1_UP_S2 USDJPY_PFO_OCO1_UP_S2_1 ;
        public static USDJPY_OCO1_UP_S2 USDJPY_PFO_OCO1_UP_S2_2 ;
        public static USDJPY_OCO1_UP_S2 USDJPY_PFO_OCO1_UP_S2_3 ;
        public static USDJPY_OCO1_UP_S2 USDJPY_PFO_OCO1_UP_S2_4 ;
        public static USDJPY_OCO1_UP_S2 USDJPY_PFO_OCO1_UP_S2_5 ;
        public static USDJPY_OCO1_UP_S2 USDJPY_PFO_OCO1_UP_S2_6 ;
        
        public static List<USDJPY_OCO1_UP_S2> USDJPY_UP_S2_OCO1Sets1 = new List<USDJPY_OCO1_UP_S2>();
        public static List<USDJPY_OCO1_UP_S2> USDJPY_UP_S2_OCO1Sets2 = new List<USDJPY_OCO1_UP_S2>();
        public static List<USDJPY_OCO1_UP_S2> USDJPY_UP_S2_OCO1Sets3 = new List<USDJPY_OCO1_UP_S2>();
        public static List<USDJPY_OCO1_UP_S2> USDJPY_UP_S2_OCO1Sets4 = new List<USDJPY_OCO1_UP_S2>();
        public static List<USDJPY_OCO1_UP_S2> USDJPY_UP_S2_OCO1Sets5 = new List<USDJPY_OCO1_UP_S2>();
        public static List<USDJPY_OCO1_UP_S2> USDJPY_UP_S2_OCO1Sets6 = new List<USDJPY_OCO1_UP_S2>();
        
        public static bool USDJPY_OCO1_UP_S2_IsReady = true;
        public static bool USDJPY_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket USDJPY_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO1_MO6_DOWN_S2 ;
    	
    	public static int USDJPY_OCO1_EO1_DOWN_S2_ID ;
        public static int USDJPY_OCO1_EO2_DOWN_S2_ID ;
        public static int USDJPY_OCO1_EO3_DOWN_S2_ID ;
        public static int USDJPY_OCO1_EO4_DOWN_S2_ID ;
        public static int USDJPY_OCO1_EO5_DOWN_S2_ID ;
        public static int USDJPY_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool USDJPY_OCO1_EO1_DOWN_S2 ;
        public static bool USDJPY_OCO1_EO2_DOWN_S2 ;
        public static bool USDJPY_OCO1_EO3_DOWN_S2 ;
        public static bool USDJPY_OCO1_EO4_DOWN_S2 ;
        public static bool USDJPY_OCO1_EO5_DOWN_S2 ;
        public static bool USDJPY_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_DOWN_S2> USDJPY_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_DOWN_S2> USDJPY_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_DOWN_S2> USDJPY_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_DOWN_S2> USDJPY_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_DOWN_S2> USDJPY_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO1_DOWN_S2> USDJPY_OOFE_OCO1_DOWN_S2_6 ;
        
        public static USDJPY_OCO1_DOWN_S2 USDJPY_PFO_OCO1_DOWN_S2_1 ;
        public static USDJPY_OCO1_DOWN_S2 USDJPY_PFO_OCO1_DOWN_S2_2 ;
        public static USDJPY_OCO1_DOWN_S2 USDJPY_PFO_OCO1_DOWN_S2_3 ;
        public static USDJPY_OCO1_DOWN_S2 USDJPY_PFO_OCO1_DOWN_S2_4 ;
        public static USDJPY_OCO1_DOWN_S2 USDJPY_PFO_OCO1_DOWN_S2_5 ;
        public static USDJPY_OCO1_DOWN_S2 USDJPY_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<USDJPY_OCO1_DOWN_S2> USDJPY_DOWN_S2_OCO1Sets1 = new List<USDJPY_OCO1_DOWN_S2>();
        public static List<USDJPY_OCO1_DOWN_S2> USDJPY_DOWN_S2_OCO1Sets2 = new List<USDJPY_OCO1_DOWN_S2>();
        public static List<USDJPY_OCO1_DOWN_S2> USDJPY_DOWN_S2_OCO1Sets3 = new List<USDJPY_OCO1_DOWN_S2>();
        public static List<USDJPY_OCO1_DOWN_S2> USDJPY_DOWN_S2_OCO1Sets4 = new List<USDJPY_OCO1_DOWN_S2>();
        public static List<USDJPY_OCO1_DOWN_S2> USDJPY_DOWN_S2_OCO1Sets5 = new List<USDJPY_OCO1_DOWN_S2>();
        public static List<USDJPY_OCO1_DOWN_S2> USDJPY_DOWN_S2_OCO1Sets6 = new List<USDJPY_OCO1_DOWN_S2>();
        
        public static bool USDJPY_OCO1_DOWN_S2_IsReady = true;
        public static bool USDJPY_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket USDJPY_OCO2_MO1_UP_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO2_UP_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO3_UP_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO4_UP_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO5_UP_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO6_UP_S2 ;
    	
    	public static int USDJPY_OCO2_EO1_UP_S2_ID ;
        public static int USDJPY_OCO2_EO2_UP_S2_ID ;
        public static int USDJPY_OCO2_EO3_UP_S2_ID ;
        public static int USDJPY_OCO2_EO4_UP_S2_ID ;
        public static int USDJPY_OCO2_EO5_UP_S2_ID ;
        public static int USDJPY_OCO2_EO6_UP_S2_ID ;
        
        public static bool USDJPY_OCO2_EO1_UP_S2 ;
        public static bool USDJPY_OCO2_EO2_UP_S2 ;
        public static bool USDJPY_OCO2_EO3_UP_S2 ;
        public static bool USDJPY_OCO2_EO4_UP_S2 ;
        public static bool USDJPY_OCO2_EO5_UP_S2 ;
        public static bool USDJPY_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_UP_S2> USDJPY_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_UP_S2> USDJPY_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_UP_S2> USDJPY_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_UP_S2> USDJPY_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_UP_S2> USDJPY_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_UP_S2> USDJPY_OOFE_OCO2_UP_S2_6 ;
        
        public static USDJPY_OCO2_UP_S2 USDJPY_PFO_OCO2_UP_S2_1 ;
        public static USDJPY_OCO2_UP_S2 USDJPY_PFO_OCO2_UP_S2_2 ;
        public static USDJPY_OCO2_UP_S2 USDJPY_PFO_OCO2_UP_S2_3 ;
        public static USDJPY_OCO2_UP_S2 USDJPY_PFO_OCO2_UP_S2_4 ;
        public static USDJPY_OCO2_UP_S2 USDJPY_PFO_OCO2_UP_S2_5 ;
        public static USDJPY_OCO2_UP_S2 USDJPY_PFO_OCO2_UP_S2_6 ;
        
        public static List<USDJPY_OCO2_UP_S2> USDJPY_UP_S2_OCO2Sets1 = new List<USDJPY_OCO2_UP_S2>();
        public static List<USDJPY_OCO2_UP_S2> USDJPY_UP_S2_OCO2Sets2 = new List<USDJPY_OCO2_UP_S2>();
        public static List<USDJPY_OCO2_UP_S2> USDJPY_UP_S2_OCO2Sets3 = new List<USDJPY_OCO2_UP_S2>();
        public static List<USDJPY_OCO2_UP_S2> USDJPY_UP_S2_OCO2Sets4 = new List<USDJPY_OCO2_UP_S2>();
        public static List<USDJPY_OCO2_UP_S2> USDJPY_UP_S2_OCO2Sets5 = new List<USDJPY_OCO2_UP_S2>();
        public static List<USDJPY_OCO2_UP_S2> USDJPY_UP_S2_OCO2Sets6 = new List<USDJPY_OCO2_UP_S2>();
        
        public static bool USDJPY_OCO2_UP_S2_IsReady = true;
        public static bool USDJPY_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket USDJPY_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO2_MO6_DOWN_S2 ;
    	
    	public static int USDJPY_OCO2_EO1_DOWN_S2_ID ;
        public static int USDJPY_OCO2_EO2_DOWN_S2_ID ;
        public static int USDJPY_OCO2_EO3_DOWN_S2_ID ;
        public static int USDJPY_OCO2_EO4_DOWN_S2_ID ;
        public static int USDJPY_OCO2_EO5_DOWN_S2_ID ;
        public static int USDJPY_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool USDJPY_OCO2_EO1_DOWN_S2 ;
        public static bool USDJPY_OCO2_EO2_DOWN_S2 ;
        public static bool USDJPY_OCO2_EO3_DOWN_S2 ;
        public static bool USDJPY_OCO2_EO4_DOWN_S2 ;
        public static bool USDJPY_OCO2_EO5_DOWN_S2 ;
        public static bool USDJPY_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_DOWN_S2> USDJPY_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_DOWN_S2> USDJPY_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_DOWN_S2> USDJPY_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_DOWN_S2> USDJPY_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_DOWN_S2> USDJPY_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO2_DOWN_S2> USDJPY_OOFE_OCO2_DOWN_S2_6 ;
        
        public static USDJPY_OCO2_DOWN_S2 USDJPY_PFO_OCO2_DOWN_S2_1 ;
        public static USDJPY_OCO2_DOWN_S2 USDJPY_PFO_OCO2_DOWN_S2_2 ;
        public static USDJPY_OCO2_DOWN_S2 USDJPY_PFO_OCO2_DOWN_S2_3 ;
        public static USDJPY_OCO2_DOWN_S2 USDJPY_PFO_OCO2_DOWN_S2_4 ;
        public static USDJPY_OCO2_DOWN_S2 USDJPY_PFO_OCO2_DOWN_S2_5 ;
        public static USDJPY_OCO2_DOWN_S2 USDJPY_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<USDJPY_OCO2_DOWN_S2> USDJPY_DOWN_S2_OCO2Sets1 = new List<USDJPY_OCO2_DOWN_S2>();
        public static List<USDJPY_OCO2_DOWN_S2> USDJPY_DOWN_S2_OCO2Sets2 = new List<USDJPY_OCO2_DOWN_S2>();
        public static List<USDJPY_OCO2_DOWN_S2> USDJPY_DOWN_S2_OCO2Sets3 = new List<USDJPY_OCO2_DOWN_S2>();
        public static List<USDJPY_OCO2_DOWN_S2> USDJPY_DOWN_S2_OCO2Sets4 = new List<USDJPY_OCO2_DOWN_S2>();
        public static List<USDJPY_OCO2_DOWN_S2> USDJPY_DOWN_S2_OCO2Sets5 = new List<USDJPY_OCO2_DOWN_S2>();
        public static List<USDJPY_OCO2_DOWN_S2> USDJPY_DOWN_S2_OCO2Sets6 = new List<USDJPY_OCO2_DOWN_S2>();
        
        public static bool USDJPY_OCO2_DOWN_S2_IsReady = true;
        public static bool USDJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket USDJPY_OCO3_MO1_UP_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO2_UP_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO3_UP_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO4_UP_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO5_UP_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO6_UP_S2 ;
    	
    	public static int USDJPY_OCO3_EO1_UP_S2_ID ;
        public static int USDJPY_OCO3_EO2_UP_S2_ID ;
        public static int USDJPY_OCO3_EO3_UP_S2_ID ;
        public static int USDJPY_OCO3_EO4_UP_S2_ID ;
        public static int USDJPY_OCO3_EO5_UP_S2_ID ;
        public static int USDJPY_OCO3_EO6_UP_S2_ID ;
        
        public static bool USDJPY_OCO3_EO1_UP_S2 ;
        public static bool USDJPY_OCO3_EO2_UP_S2 ;
        public static bool USDJPY_OCO3_EO3_UP_S2 ;
        public static bool USDJPY_OCO3_EO4_UP_S2 ;
        public static bool USDJPY_OCO3_EO5_UP_S2 ;
        public static bool USDJPY_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_UP_S2> USDJPY_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_UP_S2> USDJPY_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_UP_S2> USDJPY_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_UP_S2> USDJPY_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_UP_S2> USDJPY_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_UP_S2> USDJPY_OOFE_OCO3_UP_S2_6 ;
        
        public static USDJPY_OCO3_UP_S2 USDJPY_PFO_OCO3_UP_S2_1 ;
        public static USDJPY_OCO3_UP_S2 USDJPY_PFO_OCO3_UP_S2_2 ;
        public static USDJPY_OCO3_UP_S2 USDJPY_PFO_OCO3_UP_S2_3 ;
        public static USDJPY_OCO3_UP_S2 USDJPY_PFO_OCO3_UP_S2_4 ;
        public static USDJPY_OCO3_UP_S2 USDJPY_PFO_OCO3_UP_S2_5 ;
        public static USDJPY_OCO3_UP_S2 USDJPY_PFO_OCO3_UP_S2_6 ;
        
        public static List<USDJPY_OCO3_UP_S2> USDJPY_UP_S2_OCO3Sets1 = new List<USDJPY_OCO3_UP_S2>();
        public static List<USDJPY_OCO3_UP_S2> USDJPY_UP_S2_OCO3Sets2 = new List<USDJPY_OCO3_UP_S2>();
        public static List<USDJPY_OCO3_UP_S2> USDJPY_UP_S2_OCO3Sets3 = new List<USDJPY_OCO3_UP_S2>();
        public static List<USDJPY_OCO3_UP_S2> USDJPY_UP_S2_OCO3Sets4 = new List<USDJPY_OCO3_UP_S2>();
        public static List<USDJPY_OCO3_UP_S2> USDJPY_UP_S2_OCO3Sets5 = new List<USDJPY_OCO3_UP_S2>();
        public static List<USDJPY_OCO3_UP_S2> USDJPY_UP_S2_OCO3Sets6 = new List<USDJPY_OCO3_UP_S2>();
        
        public static bool USDJPY_OCO3_UP_S2_IsReady = true;
        public static bool USDJPY_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket USDJPY_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO3_MO6_DOWN_S2 ;
    	
    	public static int USDJPY_OCO3_EO1_DOWN_S2_ID ;
        public static int USDJPY_OCO3_EO2_DOWN_S2_ID ;
        public static int USDJPY_OCO3_EO3_DOWN_S2_ID ;
        public static int USDJPY_OCO3_EO4_DOWN_S2_ID ;
        public static int USDJPY_OCO3_EO5_DOWN_S2_ID ;
        public static int USDJPY_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool USDJPY_OCO3_EO1_DOWN_S2 ;
        public static bool USDJPY_OCO3_EO2_DOWN_S2 ;
        public static bool USDJPY_OCO3_EO3_DOWN_S2 ;
        public static bool USDJPY_OCO3_EO4_DOWN_S2 ;
        public static bool USDJPY_OCO3_EO5_DOWN_S2 ;
        public static bool USDJPY_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_DOWN_S2> USDJPY_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_DOWN_S2> USDJPY_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_DOWN_S2> USDJPY_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_DOWN_S2> USDJPY_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_DOWN_S2> USDJPY_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO3_DOWN_S2> USDJPY_OOFE_OCO3_DOWN_S2_6 ;
        
        public static USDJPY_OCO3_DOWN_S2 USDJPY_PFO_OCO3_DOWN_S2_1 ;
        public static USDJPY_OCO3_DOWN_S2 USDJPY_PFO_OCO3_DOWN_S2_2 ;
        public static USDJPY_OCO3_DOWN_S2 USDJPY_PFO_OCO3_DOWN_S2_3 ;
        public static USDJPY_OCO3_DOWN_S2 USDJPY_PFO_OCO3_DOWN_S2_4 ;
        public static USDJPY_OCO3_DOWN_S2 USDJPY_PFO_OCO3_DOWN_S2_5 ;
        public static USDJPY_OCO3_DOWN_S2 USDJPY_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<USDJPY_OCO3_DOWN_S2> USDJPY_DOWN_S2_OCO3Sets1 = new List<USDJPY_OCO3_DOWN_S2>();
        public static List<USDJPY_OCO3_DOWN_S2> USDJPY_DOWN_S2_OCO3Sets2 = new List<USDJPY_OCO3_DOWN_S2>();
        public static List<USDJPY_OCO3_DOWN_S2> USDJPY_DOWN_S2_OCO3Sets3 = new List<USDJPY_OCO3_DOWN_S2>();
        public static List<USDJPY_OCO3_DOWN_S2> USDJPY_DOWN_S2_OCO3Sets4 = new List<USDJPY_OCO3_DOWN_S2>();
        public static List<USDJPY_OCO3_DOWN_S2> USDJPY_DOWN_S2_OCO3Sets5 = new List<USDJPY_OCO3_DOWN_S2>();
        public static List<USDJPY_OCO3_DOWN_S2> USDJPY_DOWN_S2_OCO3Sets6 = new List<USDJPY_OCO3_DOWN_S2>();
        
        public static bool USDJPY_OCO3_DOWN_S2_IsReady = true;
        public static bool USDJPY_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket USDJPY_OCO4_MO1_UP_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO2_UP_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO3_UP_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO4_UP_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO5_UP_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO6_UP_S2 ;
    	
    	public static int USDJPY_OCO4_EO1_UP_S2_ID ;
        public static int USDJPY_OCO4_EO2_UP_S2_ID ;
        public static int USDJPY_OCO4_EO3_UP_S2_ID ;
        public static int USDJPY_OCO4_EO4_UP_S2_ID ;
        public static int USDJPY_OCO4_EO5_UP_S2_ID ;
        public static int USDJPY_OCO4_EO6_UP_S2_ID ;
        
        public static bool USDJPY_OCO4_EO1_UP_S2 ;
        public static bool USDJPY_OCO4_EO2_UP_S2 ;
        public static bool USDJPY_OCO4_EO3_UP_S2 ;
        public static bool USDJPY_OCO4_EO4_UP_S2 ;
        public static bool USDJPY_OCO4_EO5_UP_S2 ;
        public static bool USDJPY_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_UP_S2> USDJPY_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_UP_S2> USDJPY_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_UP_S2> USDJPY_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_UP_S2> USDJPY_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_UP_S2> USDJPY_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_UP_S2> USDJPY_OOFE_OCO4_UP_S2_6 ;
        
        public static USDJPY_OCO4_UP_S2 USDJPY_PFO_OCO4_UP_S2_1 ;
        public static USDJPY_OCO4_UP_S2 USDJPY_PFO_OCO4_UP_S2_2 ;
        public static USDJPY_OCO4_UP_S2 USDJPY_PFO_OCO4_UP_S2_3 ;
        public static USDJPY_OCO4_UP_S2 USDJPY_PFO_OCO4_UP_S2_4 ;
        public static USDJPY_OCO4_UP_S2 USDJPY_PFO_OCO4_UP_S2_5 ;
        public static USDJPY_OCO4_UP_S2 USDJPY_PFO_OCO4_UP_S2_6 ;
        
        public static List<USDJPY_OCO4_UP_S2> USDJPY_UP_S2_OCO4Sets1 = new List<USDJPY_OCO4_UP_S2>();
        public static List<USDJPY_OCO4_UP_S2> USDJPY_UP_S2_OCO4Sets2 = new List<USDJPY_OCO4_UP_S2>();
        public static List<USDJPY_OCO4_UP_S2> USDJPY_UP_S2_OCO4Sets3 = new List<USDJPY_OCO4_UP_S2>();
        public static List<USDJPY_OCO4_UP_S2> USDJPY_UP_S2_OCO4Sets4 = new List<USDJPY_OCO4_UP_S2>();
        public static List<USDJPY_OCO4_UP_S2> USDJPY_UP_S2_OCO4Sets5 = new List<USDJPY_OCO4_UP_S2>();
        public static List<USDJPY_OCO4_UP_S2> USDJPY_UP_S2_OCO4Sets6 = new List<USDJPY_OCO4_UP_S2>();
        
        public static bool USDJPY_OCO4_UP_S2_IsReady = true;
        public static bool USDJPY_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket USDJPY_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket USDJPY_OCO4_MO6_DOWN_S2 ;
    	
    	public static int USDJPY_OCO4_EO1_DOWN_S2_ID ;
        public static int USDJPY_OCO4_EO2_DOWN_S2_ID ;
        public static int USDJPY_OCO4_EO3_DOWN_S2_ID ;
        public static int USDJPY_OCO4_EO4_DOWN_S2_ID ;
        public static int USDJPY_OCO4_EO5_DOWN_S2_ID ;
        public static int USDJPY_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool USDJPY_OCO4_EO1_DOWN_S2 ;
        public static bool USDJPY_OCO4_EO2_DOWN_S2 ;
        public static bool USDJPY_OCO4_EO3_DOWN_S2 ;
        public static bool USDJPY_OCO4_EO4_DOWN_S2 ;
        public static bool USDJPY_OCO4_EO5_DOWN_S2 ;
        public static bool USDJPY_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_DOWN_S2> USDJPY_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_DOWN_S2> USDJPY_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_DOWN_S2> USDJPY_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_DOWN_S2> USDJPY_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_DOWN_S2> USDJPY_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, USDJPY_OCO4_DOWN_S2> USDJPY_OOFE_OCO4_DOWN_S2_6 ;
        
        public static USDJPY_OCO4_DOWN_S2 USDJPY_PFO_OCO4_DOWN_S2_1 ;
        public static USDJPY_OCO4_DOWN_S2 USDJPY_PFO_OCO4_DOWN_S2_2 ;
        public static USDJPY_OCO4_DOWN_S2 USDJPY_PFO_OCO4_DOWN_S2_3 ;
        public static USDJPY_OCO4_DOWN_S2 USDJPY_PFO_OCO4_DOWN_S2_4 ;
        public static USDJPY_OCO4_DOWN_S2 USDJPY_PFO_OCO4_DOWN_S2_5 ;
        public static USDJPY_OCO4_DOWN_S2 USDJPY_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<USDJPY_OCO4_DOWN_S2> USDJPY_DOWN_S2_OCO4Sets1 = new List<USDJPY_OCO4_DOWN_S2>();
        public static List<USDJPY_OCO4_DOWN_S2> USDJPY_DOWN_S2_OCO4Sets2 = new List<USDJPY_OCO4_DOWN_S2>();
        public static List<USDJPY_OCO4_DOWN_S2> USDJPY_DOWN_S2_OCO4Sets3 = new List<USDJPY_OCO4_DOWN_S2>();
        public static List<USDJPY_OCO4_DOWN_S2> USDJPY_DOWN_S2_OCO4Sets4 = new List<USDJPY_OCO4_DOWN_S2>();
        public static List<USDJPY_OCO4_DOWN_S2> USDJPY_DOWN_S2_OCO4Sets5 = new List<USDJPY_OCO4_DOWN_S2>();
        public static List<USDJPY_OCO4_DOWN_S2> USDJPY_DOWN_S2_OCO4Sets6 = new List<USDJPY_OCO4_DOWN_S2>();
        
        public static bool USDJPY_OCO4_DOWN_S2_IsReady = true;
        public static bool USDJPY_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal USDJPY_UP_S2_SL {get; set;}
		public static decimal USDJPY_UP_S2_TP1 {get; set;}
		public static decimal USDJPY_UP_S2_TP2 {get; set;}
		public static decimal USDJPY_UP_S2_TP3 {get; set;}
		public static decimal USDJPY_UP_S2_TP4 {get; set;}
		public static decimal USDJPY_UP_S2_TP5 {get; set;}
		public static decimal USDJPY_UP_S2_TP6 {get; set;}
		
		public static decimal USDJPY_DOWN_S2_SL {get; set;}
		public static decimal USDJPY_DOWN_S2_TP1 {get; set;}
		public static decimal USDJPY_DOWN_S2_TP2 {get; set;}
		public static decimal USDJPY_DOWN_S2_TP3 {get; set;}
		public static decimal USDJPY_DOWN_S2_TP4 {get; set;}
		public static decimal USDJPY_DOWN_S2_TP5 {get; set;}
		public static decimal USDJPY_DOWN_S2_TP6 {get; set;}

        public static bool USDJPY_Signal_Condition_UP_1 ;
        public static bool USDJPY_Signal_Condition_UP_2 ;
        public static bool USDJPY_Signal_Condition_UP_3 ;
        
        public static bool USDJPY_Signal_Condition_DOWN_S2 ;
        
        public static int USDJPY_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int USDJPY_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int USDJPY_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int USDJPY_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int USDJPY_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int USDJPY_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int USDJPY_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int USDJPY_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int USDJPY_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int USDJPY_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_USDJPY_UP_S2 ;
        public static bool DOWM_USDJPY_UP_S2 ;
        public static bool DOWT_USDJPY_UP_S2 ;
        public static bool DOWW_USDJPY_UP_S2 ;
        public static bool DOWTH_USDJPY_UP_S2 ;
        
		public static bool DOWR_USDJPY_DOWN_S2 ;
        public static bool DOWM_USDJPY_DOWN_S2 ;
        public static bool DOWT_USDJPY_DOWN_S2 ;
        public static bool DOWW_USDJPY_DOWN_S2 ;
        public static bool DOWTH_USDJPY_DOWN_S2 ;
        
        
		public static int USDJPY_quantity_UP_S2 ;
		public static int USDJPY_quantity_SL_UP_S2 ;
		public static int USDJPY_quantity_TP1_UP_S2 ;
		public static int USDJPY_quantity_TP2_UP_S2 ;
		public static int USDJPY_quantity_TP3_UP_S2 ;
		public static int USDJPY_quantity_TP4_UP_S2 ;
		public static int USDJPY_quantity_TP5_UP_S2;
		public static int USDJPY_quantity_TP6_UP_S2 ;
		
		public static int USDJPY_quantity_DOWN_S2 ;
		public static int USDJPY_quantity_SL_DOWN_S2 ;
		public static int USDJPY_quantity_TP1_DOWN_S2 ;
		public static int USDJPY_quantity_TP2_DOWN_S2 ;
		public static int USDJPY_quantity_TP3_DOWN_S2 ;
		public static int USDJPY_quantity_TP4_DOWN_S2 ;
		public static int USDJPY_quantity_TP5_DOWN_S2;
		public static int USDJPY_quantity_TP6_DOWN_S2 ;
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_GBPAUD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_GBPAUD_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(x=>x.Tag.Contains("GBPAUD_UP_S2_OCO1")))
			{
				Base.GBPAUD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPAUD_UP_S2_OCO2")))
			{
				Base.GBPAUD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPAUD_UP_S2_OCO3")))
			{
				Base.GBPAUD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("GBPAUD_UP_S2_OCO4")))
			{
				Base.GBPAUD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("GBPAUD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.GBPAUD_OCO1_EO1_UP_S2)
	                Base.GBPAUD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPAUD_OCO1_EO2_UP_S2)
	                Base.GBPAUD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO1_EO3_UP_S2)
	                Base.GBPAUD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO1_EO4_UP_S2)
	                Base.GBPAUD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO1_EO5_UP_S2)
	                Base.GBPAUD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO1_EO6_UP_S2)
	                Base.GBPAUD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPAUD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPAUD_OCO1S1_UP_S2 = 0;
		                for (; GBPAUD_OCO1S1_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets1.Count; GBPAUD_OCO1S1_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO1Sets1[GBPAUD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO1Sets1[GBPAUD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.GBPAUD_UP_S2_OCO1Sets1.Clear();
		                        GBPAUD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPAUD_OCO1S2_UP_S2 = 0;
		                for (; GBPAUD_OCO1S2_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets2.Count; GBPAUD_OCO1S2_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO1Sets2[GBPAUD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO1Sets2[GBPAUD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.GBPAUD_UP_S2_OCO1Sets2.Clear();
		                        GBPAUD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO1S3_UP_S2 = 0;
		                for (; GBPAUD_OCO1S3_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets3.Count; GBPAUD_OCO1S3_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO1Sets3[GBPAUD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO1Sets3[GBPAUD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.GBPAUD_UP_S2_OCO1Sets3.Clear();
		                        GBPAUD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO1S4_UP_S2 = 0;
		                for (; GBPAUD_OCO1S4_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets4.Count; GBPAUD_OCO1S4_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO1Sets4[GBPAUD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO1Sets4[GBPAUD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.GBPAUD_UP_S2_OCO1Sets4.Clear();
		                        GBPAUD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO1S5_UP_S2 = 0;
		                for (; GBPAUD_OCO1S5_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets5.Count; GBPAUD_OCO1S5_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO1Sets5[GBPAUD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO1Sets5[GBPAUD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.GBPAUD_UP_S2_OCO1Sets5.Clear();
		                        GBPAUD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO1S6_UP_S2 = 0;
		                for (; GBPAUD_OCO1S6_UP_S2 < Base.GBPAUD_UP_S2_OCO1Sets6.Count; GBPAUD_OCO1S6_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO1Sets6[GBPAUD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO1Sets6[GBPAUD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.GBPAUD_UP_S2_OCO1Sets6.Clear();
		                        GBPAUD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPAUD_OCO2_EO1_UP_S2)
                	Base.GBPAUD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPAUD_OCO2_EO2_UP_S2)
	                Base.GBPAUD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO2_EO3_UP_S2)
	                Base.GBPAUD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO2_EO4_UP_S2)
	                Base.GBPAUD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO2_EO5_UP_S2)
	                Base.GBPAUD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO2_EO6_UP_S2)
	                Base.GBPAUD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPAUD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPAUD_OCO2S1_UP_S2 = 0;
		                for (; GBPAUD_OCO2S1_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets1.Count; GBPAUD_OCO2S1_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO2Sets1[GBPAUD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO2Sets1[GBPAUD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.GBPAUD_UP_S2_OCO2Sets1.Clear();
		                        GBPAUD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPAUD_OCO2S2_UP_S2 = 0;
		                for (; GBPAUD_OCO2S2_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets2.Count; GBPAUD_OCO2S2_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO2Sets2[GBPAUD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO2Sets2[GBPAUD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.GBPAUD_UP_S2_OCO2Sets2.Clear();
		                        GBPAUD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO2S3_UP_S2 = 0;
		                for (; GBPAUD_OCO2S3_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets3.Count; GBPAUD_OCO2S3_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO2Sets3[GBPAUD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO2Sets3[GBPAUD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.GBPAUD_UP_S2_OCO2Sets3.Clear();
		                        GBPAUD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO2S4_UP_S2 = 0;
		                for (; GBPAUD_OCO2S4_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets4.Count; GBPAUD_OCO2S4_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO2Sets4[GBPAUD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO2Sets4[GBPAUD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.GBPAUD_UP_S2_OCO2Sets4.Clear();
		                        GBPAUD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO2S5_UP_S2 = 0;
		                for (; GBPAUD_OCO2S5_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets5.Count; GBPAUD_OCO2S5_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO2Sets5[GBPAUD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO2Sets5[GBPAUD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.GBPAUD_UP_S2_OCO2Sets5.Clear();
		                        GBPAUD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO2S6_UP_S2 = 0;
		                for (; GBPAUD_OCO2S6_UP_S2 < Base.GBPAUD_UP_S2_OCO2Sets6.Count; GBPAUD_OCO2S6_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO2Sets6[GBPAUD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO2Sets6[GBPAUD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.GBPAUD_UP_S2_OCO2Sets6.Clear();
		                        GBPAUD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.GBPAUD_OCO3_EO1_UP_S2)
            		Base.GBPAUD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPAUD_OCO3_EO2_UP_S2)
	                Base.GBPAUD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO3_EO3_UP_S2)
	                Base.GBPAUD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO3_EO4_UP_S2)
	                Base.GBPAUD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO3_EO5_UP_S2)
	                Base.GBPAUD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO3_EO6_UP_S2)
	                Base.GBPAUD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPAUD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPAUD_OCO3S1_UP_S2 = 0;
		                for (; GBPAUD_OCO3S1_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets1.Count; GBPAUD_OCO3S1_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO3Sets1[GBPAUD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO3Sets1[GBPAUD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.GBPAUD_UP_S2_OCO3Sets1.Clear();
		                        GBPAUD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPAUD_OCO3S2_UP_S2 = 0;
		                for (; GBPAUD_OCO3S2_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets2.Count; GBPAUD_OCO3S2_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO3Sets2[GBPAUD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO3Sets2[GBPAUD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.GBPAUD_UP_S2_OCO3Sets2.Clear();
		                        GBPAUD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO3S3_UP_S2 = 0;
		                for (; GBPAUD_OCO3S3_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets3.Count; GBPAUD_OCO3S3_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO3Sets3[GBPAUD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO3Sets3[GBPAUD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.GBPAUD_UP_S2_OCO3Sets3.Clear();
		                        GBPAUD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO3S4_UP_S2 = 0;
		                for (; GBPAUD_OCO3S4_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets4.Count; GBPAUD_OCO3S4_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO3Sets4[GBPAUD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO3Sets4[GBPAUD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.GBPAUD_UP_S2_OCO3Sets4.Clear();
		                        GBPAUD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO3S5_UP_S2 = 0;
		                for (; GBPAUD_OCO3S5_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets5.Count; GBPAUD_OCO3S5_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO3Sets5[GBPAUD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO3Sets5[GBPAUD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.GBPAUD_UP_S2_OCO3Sets5.Clear();
		                        GBPAUD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO3S6_UP_S2 = 0;
		                for (; GBPAUD_OCO3S6_UP_S2 < Base.GBPAUD_UP_S2_OCO3Sets6.Count; GBPAUD_OCO3S6_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO3Sets6[GBPAUD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO3Sets6[GBPAUD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.GBPAUD_UP_S2_OCO3Sets6.Clear();
		                        GBPAUD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.GBPAUD_OCO4_EO1_UP_S2)
            		Base.GBPAUD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.GBPAUD_OCO4_EO2_UP_S2)
	                Base.GBPAUD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO4_EO3_UP_S2)
	                Base.GBPAUD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO4_EO4_UP_S2)
	                Base.GBPAUD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO4_EO5_UP_S2)
	                Base.GBPAUD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.GBPAUD_OCO4_EO6_UP_S2)
	                Base.GBPAUD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.GBPAUD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int GBPAUD_OCO4S1_UP_S2 = 0;
		                for (; GBPAUD_OCO4S1_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets1.Count; GBPAUD_OCO4S1_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO4Sets1[GBPAUD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO4Sets1[GBPAUD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.GBPAUD_UP_S2_OCO4Sets1.Clear();
		                        GBPAUD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int GBPAUD_OCO4S2_UP_S2 = 0;
		                for (; GBPAUD_OCO4S2_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets2.Count; GBPAUD_OCO4S2_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO4Sets2[GBPAUD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO4Sets2[GBPAUD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.GBPAUD_UP_S2_OCO4Sets2.Clear();
		                        GBPAUD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO4S3_UP_S2 = 0;
		                for (; GBPAUD_OCO4S3_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets3.Count; GBPAUD_OCO4S3_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO4Sets3[GBPAUD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO4Sets3[GBPAUD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.GBPAUD_UP_S2_OCO4Sets3.Clear();
		                        GBPAUD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int GBPAUD_OCO4S4_UP_S2 = 0;
		                for (; GBPAUD_OCO4S4_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets4.Count; GBPAUD_OCO4S4_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO4Sets4[GBPAUD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO4Sets4[GBPAUD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.GBPAUD_UP_S2_OCO4Sets4.Clear();
		                        GBPAUD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO4S5_UP_S2 = 0;
		                for (; GBPAUD_OCO4S5_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets5.Count; GBPAUD_OCO4S5_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO4Sets5[GBPAUD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO4Sets5[GBPAUD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.GBPAUD_UP_S2_OCO4Sets5.Clear();
		                        GBPAUD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int GBPAUD_OCO4S6_UP_S2 = 0;
		                for (; GBPAUD_OCO4S6_UP_S2 < Base.GBPAUD_UP_S2_OCO4Sets6.Count; GBPAUD_OCO4S6_UP_S2++)
		                    if (Base.GBPAUD_UP_S2_OCO4Sets6[GBPAUD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.GBPAUD_UP_S2_OCO4Sets6[GBPAUD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("GBPAUD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("GBPAUD", order.Quantity, false, "GBPAUD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.GBPAUD_UP_S2_OCO4Sets6.Clear();
		                        GBPAUD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_GBPAUD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_GBPAUD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_GBPAUD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_GBPAUD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_GBPAUD_UP_S2 = DOWM_GBPAUD_UP_S2 || DOWT_GBPAUD_UP_S2 || DOWW_GBPAUD_UP_S2 || DOWTH_GBPAUD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("GBPAUD"))
	            	{
	            		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.GBPAUD_OCO1_UP_S2_IsReady == false ||
	                    	Base.GBPAUD_OCO2_UP_S2_IsReady == false ||
	                    	Base.GBPAUD_OCO3_UP_S2_IsReady == false ||
	                    	Base.GBPAUD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.GBPAUD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPAUD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPAUD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.GBPAUD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.GBPAUD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.GBPAUD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.GBPAUD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.GBPAUD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	GBPAUD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											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.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*2
		                										
		                										)
		                							
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	GBPAUD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.5m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*2
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	GBPAUD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.618m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs*2
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (GBPAUD_Signal_Condition_UP_1)
	                	{
	                    	GBPAUD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPAUD_Signal_Condition_UP_2)
	                	{
	                    	GBPAUD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (GBPAUD_Signal_Condition_UP_3)
	                	{
	                    	GBPAUD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (GBPAUD_Signal_Condition_UP_1)
	                	{
	                    	GBPAUD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (GBPAUD_Signal_Condition_UP_2)
	                	{
	                    	GBPAUD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (GBPAUD_Signal_Condition_UP_3)
	                	{
	                    	GBPAUD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    GBPAUD_UP_S2_TP2 =  GBPAUD_UP_S2_SL * 0;
	                    GBPAUD_UP_S2_TP3 =  GBPAUD_UP_S2_SL * 0;
	                    GBPAUD_UP_S2_TP4 =  GBPAUD_UP_S2_SL * 0;
	                    GBPAUD_UP_S2_TP5 =  GBPAUD_UP_S2_SL * 0;
	                    GBPAUD_UP_S2_TP6 =  GBPAUD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    GBPAUD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    GBPAUD_quantity_SL_UP_S2 = GBPAUD_quantity_UP_S2;
	                    GBPAUD_quantity_TP1_UP_S2 = (int)Math.Floor(GBPAUD_quantity_UP_S2 * 1m);
	                    GBPAUD_quantity_TP2_UP_S2 = (int)Math.Floor(GBPAUD_quantity_TP1_UP_S2 * 0m);
	                    GBPAUD_quantity_TP3_UP_S2 = (int)Math.Floor(GBPAUD_quantity_TP2_UP_S2 * 0m);
	                    GBPAUD_quantity_TP4_UP_S2 = (int)Math.Floor(GBPAUD_quantity_TP3_UP_S2 * 0m);
	                    GBPAUD_quantity_TP5_UP_S2 = (int)Math.Floor(GBPAUD_quantity_TP4_UP_S2 * 0m);
	                    GBPAUD_quantity_TP6_UP_S2 = (int)Math.Floor(GBPAUD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((GBPAUD_Signal_Condition_UP_1 || GBPAUD_Signal_Condition_UP_2 || GBPAUD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPAUD_UP_S2 && 
	                    Base.GBPAUD_OCO1_UP_S2_IsReady == true &&
	                    Base.GBPAUD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPAUD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP1_UP_S2, false,"GBPAUD_UP_S2_Entry_TP1_OCO1");
	                         Base.GBPAUD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.GBPAUD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP2_UP_S2, false,"GBPAUD_UP_S2_Entry_TP2_OCO1");
	                         Base.GBPAUD_OCO1_EO2_UP_S2 = false;
	
	                         Base.GBPAUD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP3_UP_S2, false,"GBPAUD_UP_S2_Entry_TP3_OCO1");
	                         Base.GBPAUD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.GBPAUD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP4_UP_S2, false,"GBPAUD_UP_S2_Entry_TP4_OCO1");
	                         Base.GBPAUD_OCO1_EO4_UP_S2 = false;

							Base.GBPAUD_OCO1_UP_S2_IsReady = false;
							
							if (Base.GBPAUD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((GBPAUD_Signal_Condition_UP_1 || GBPAUD_Signal_Condition_UP_2 || GBPAUD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPAUD_UP_S2 && 
	                    Base.GBPAUD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPAUD_OCO2_UP_S2_IsReady == true &&
	                    Base.GBPAUD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPAUD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP1_UP_S2, false,"GBPAUD_UP_S2_Entry_TP1_OCO2");
	                         Base.GBPAUD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.GBPAUD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP2_UP_S2, false,"GBPAUD_UP_S2_Entry_TP2_OCO2");
	                         Base.GBPAUD_OCO2_EO2_UP_S2 = false;
	
	                         Base.GBPAUD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP3_UP_S2, false,"GBPAUD_UP_S2_Entry_TP3_OCO2");
	                         Base.GBPAUD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.GBPAUD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP4_UP_S2, false,"GBPAUD_UP_S2_Entry_TP4_OCO2");
	                         Base.GBPAUD_OCO2_EO4_UP_S2 = false;

							Base.GBPAUD_OCO2_UP_S2_IsReady = false;
							
							if (Base.GBPAUD_OCO2_UP_S2_IsReady == false && Base.GBPAUD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((GBPAUD_Signal_Condition_UP_1 || GBPAUD_Signal_Condition_UP_2 || GBPAUD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPAUD_UP_S2 &&
	                    Base.GBPAUD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPAUD_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPAUD_OCO3_UP_S2_IsReady == true &&
	                    Base.GBPAUD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPAUD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP1_UP_S2, false,"GBPAUD_UP_S2_Entry_TP1_OCO3");
	                         Base.GBPAUD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.GBPAUD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP2_UP_S2, false,"GBPAUD_UP_S2_Entry_TP2_OCO3");
	                         Base.GBPAUD_OCO3_EO2_UP_S2 = false;
	
	                         Base.GBPAUD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP3_UP_S2, false,"GBPAUD_UP_S2_Entry_TP3_OCO3");
	                         Base.GBPAUD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.GBPAUD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP4_UP_S2, false,"GBPAUD_UP_S2_Entry_TP4_OCO3");
	                         Base.GBPAUD_OCO3_EO4_UP_S2 = false;

							Base.GBPAUD_OCO3_UP_S2_IsReady = false;
							
							if (Base.GBPAUD_OCO3_UP_S2_IsReady == false && Base.GBPAUD_OCO2_UP_S2_IsReady == false && Base.GBPAUD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((GBPAUD_Signal_Condition_UP_1 || GBPAUD_Signal_Condition_UP_2 || GBPAUD_Signal_Condition_UP_3)  && 
	                    DOWR_GBPAUD_UP_S2 && 
	                    Base.GBPAUD_OCO1_UP_S2_IsReady == false &&
	                    Base.GBPAUD_OCO2_UP_S2_IsReady == false &&
	                    Base.GBPAUD_OCO3_UP_S2_IsReady == false &&
	                    Base.GBPAUD_OCO4_UP_S2_IsReady == true &&
	                    Base.GBPAUD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.GBPAUD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP1_UP_S2, false,"GBPAUD_UP_S2_Entry_TP1_OCO4");
	                         Base.GBPAUD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.GBPAUD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP2_UP_S2, false,"GBPAUD_UP_S2_Entry_TP2_OCO4");
	                         Base.GBPAUD_OCO4_EO2_UP_S2 = false;
	
	                         Base.GBPAUD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP3_UP_S2, false,"GBPAUD_UP_S2_Entry_TP3_OCO4");
	                         Base.GBPAUD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.GBPAUD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         GBPAUD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, GBPAUD_quantity_TP4_UP_S2, false,"GBPAUD_UP_S2_Entry_TP4_OCO4");
	                         Base.GBPAUD_OCO4_EO4_UP_S2 = false;

							Base.GBPAUD_OCO4_UP_S2_IsReady = false;
							
							if (Base.GBPAUD_OCO4_UP_S2_IsReady == false && Base.GBPAUD_OCO3_UP_S2_IsReady == false && Base.GBPAUD_OCO2_UP_S2_IsReady == false && Base.GBPAUD_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 _AUDCAD;
		
    	///oco1 up
    	public static OrderTicket AUDCAD_OCO1_MO1_UP_S2;
    	public static OrderTicket AUDCAD_OCO1_MO2_UP_S2;
    	public static OrderTicket AUDCAD_OCO1_MO3_UP_S2;
    	public static OrderTicket AUDCAD_OCO1_MO4_UP_S2;
    	public static OrderTicket AUDCAD_OCO1_MO5_UP_S2;
    	public static OrderTicket AUDCAD_OCO1_MO6_UP_S2;
    	
    	public static int AUDCAD_OCO1_EO1_UP_S2_ID ;
        public static int AUDCAD_OCO1_EO2_UP_S2_ID ;
        public static int AUDCAD_OCO1_EO3_UP_S2_ID ;
        public static int AUDCAD_OCO1_EO4_UP_S2_ID ;
        public static int AUDCAD_OCO1_EO5_UP_S2_ID ;
        public static int AUDCAD_OCO1_EO6_UP_S2_ID ;
        
        public static bool AUDCAD_OCO1_EO1_UP_S2 ;
        public static bool AUDCAD_OCO1_EO2_UP_S2 ;
        public static bool AUDCAD_OCO1_EO3_UP_S2 ;
        public static bool AUDCAD_OCO1_EO4_UP_S2 ;
        public static bool AUDCAD_OCO1_EO5_UP_S2 ;
        public static bool AUDCAD_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_UP_S2> AUDCAD_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_UP_S2> AUDCAD_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_UP_S2> AUDCAD_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_UP_S2> AUDCAD_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_UP_S2> AUDCAD_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_UP_S2> AUDCAD_OOFE_OCO1_UP_S2_6 ;
        
        public static AUDCAD_OCO1_UP_S2 AUDCAD_PFO_OCO1_UP_S2_1 ;
        public static AUDCAD_OCO1_UP_S2 AUDCAD_PFO_OCO1_UP_S2_2 ;
        public static AUDCAD_OCO1_UP_S2 AUDCAD_PFO_OCO1_UP_S2_3 ;
        public static AUDCAD_OCO1_UP_S2 AUDCAD_PFO_OCO1_UP_S2_4 ;
        public static AUDCAD_OCO1_UP_S2 AUDCAD_PFO_OCO1_UP_S2_5 ;
        public static AUDCAD_OCO1_UP_S2 AUDCAD_PFO_OCO1_UP_S2_6 ;
        
        public static List<AUDCAD_OCO1_UP_S2> AUDCAD_UP_S2_OCO1Sets1 = new List<AUDCAD_OCO1_UP_S2>();
        public static List<AUDCAD_OCO1_UP_S2> AUDCAD_UP_S2_OCO1Sets2 = new List<AUDCAD_OCO1_UP_S2>();
        public static List<AUDCAD_OCO1_UP_S2> AUDCAD_UP_S2_OCO1Sets3 = new List<AUDCAD_OCO1_UP_S2>();
        public static List<AUDCAD_OCO1_UP_S2> AUDCAD_UP_S2_OCO1Sets4 = new List<AUDCAD_OCO1_UP_S2>();
        public static List<AUDCAD_OCO1_UP_S2> AUDCAD_UP_S2_OCO1Sets5 = new List<AUDCAD_OCO1_UP_S2>();
        public static List<AUDCAD_OCO1_UP_S2> AUDCAD_UP_S2_OCO1Sets6 = new List<AUDCAD_OCO1_UP_S2>();
        
        public static bool AUDCAD_OCO1_UP_S2_IsReady = true;
		public static bool AUDCAD_OCO1_UP_S2_Monthly_IsReady = true;
        
        //oco1 down
		public static OrderTicket AUDCAD_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO1_MO6_DOWN_S2 ;
    	
    	public static int AUDCAD_OCO1_EO1_DOWN_S2_ID ;
        public static int AUDCAD_OCO1_EO2_DOWN_S2_ID ;
        public static int AUDCAD_OCO1_EO3_DOWN_S2_ID ;
        public static int AUDCAD_OCO1_EO4_DOWN_S2_ID ;
        public static int AUDCAD_OCO1_EO5_DOWN_S2_ID ;
        public static int AUDCAD_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool AUDCAD_OCO1_EO1_DOWN_S2 ;
        public static bool AUDCAD_OCO1_EO2_DOWN_S2 ;
        public static bool AUDCAD_OCO1_EO3_DOWN_S2 ;
        public static bool AUDCAD_OCO1_EO4_DOWN_S2 ;
        public static bool AUDCAD_OCO1_EO5_DOWN_S2 ;
        public static bool AUDCAD_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_DOWN_S2> AUDCAD_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_DOWN_S2> AUDCAD_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_DOWN_S2> AUDCAD_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_DOWN_S2> AUDCAD_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_DOWN_S2> AUDCAD_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO1_DOWN_S2> AUDCAD_OOFE_OCO1_DOWN_S2_6 ;
        
        public static AUDCAD_OCO1_DOWN_S2 AUDCAD_PFO_OCO1_DOWN_S2_1 ;
        public static AUDCAD_OCO1_DOWN_S2 AUDCAD_PFO_OCO1_DOWN_S2_2 ;
        public static AUDCAD_OCO1_DOWN_S2 AUDCAD_PFO_OCO1_DOWN_S2_3 ;
        public static AUDCAD_OCO1_DOWN_S2 AUDCAD_PFO_OCO1_DOWN_S2_4 ;
        public static AUDCAD_OCO1_DOWN_S2 AUDCAD_PFO_OCO1_DOWN_S2_5 ;
        public static AUDCAD_OCO1_DOWN_S2 AUDCAD_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<AUDCAD_OCO1_DOWN_S2> AUDCAD_DOWN_S2_OCO1Sets1 = new List<AUDCAD_OCO1_DOWN_S2>();
        public static List<AUDCAD_OCO1_DOWN_S2> AUDCAD_DOWN_S2_OCO1Sets2 = new List<AUDCAD_OCO1_DOWN_S2>();
        public static List<AUDCAD_OCO1_DOWN_S2> AUDCAD_DOWN_S2_OCO1Sets3 = new List<AUDCAD_OCO1_DOWN_S2>();
        public static List<AUDCAD_OCO1_DOWN_S2> AUDCAD_DOWN_S2_OCO1Sets4 = new List<AUDCAD_OCO1_DOWN_S2>();
        public static List<AUDCAD_OCO1_DOWN_S2> AUDCAD_DOWN_S2_OCO1Sets5 = new List<AUDCAD_OCO1_DOWN_S2>();
        public static List<AUDCAD_OCO1_DOWN_S2> AUDCAD_DOWN_S2_OCO1Sets6 = new List<AUDCAD_OCO1_DOWN_S2>();
        
        public static bool AUDCAD_OCO1_DOWN_S2_IsReady = true;
		public static bool AUDCAD_OCO1_DOWN_S2_Monthly_IsReady = true;
        
        //oco2 up
        public static OrderTicket AUDCAD_OCO2_MO1_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO2_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO3_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO4_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO5_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO6_UP_S2 ;
    	
    	public static int AUDCAD_OCO2_EO1_UP_S2_ID ;
        public static int AUDCAD_OCO2_EO2_UP_S2_ID ;
        public static int AUDCAD_OCO2_EO3_UP_S2_ID ;
        public static int AUDCAD_OCO2_EO4_UP_S2_ID ;
        public static int AUDCAD_OCO2_EO5_UP_S2_ID ;
        public static int AUDCAD_OCO2_EO6_UP_S2_ID ;
        
        public static bool AUDCAD_OCO2_EO1_UP_S2 ;
        public static bool AUDCAD_OCO2_EO2_UP_S2 ;
        public static bool AUDCAD_OCO2_EO3_UP_S2 ;
        public static bool AUDCAD_OCO2_EO4_UP_S2 ;
        public static bool AUDCAD_OCO2_EO5_UP_S2 ;
        public static bool AUDCAD_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_UP_S2> AUDCAD_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_UP_S2> AUDCAD_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_UP_S2> AUDCAD_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_UP_S2> AUDCAD_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_UP_S2> AUDCAD_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_UP_S2> AUDCAD_OOFE_OCO2_UP_S2_6 ;
        
        public static AUDCAD_OCO2_UP_S2 AUDCAD_PFO_OCO2_UP_S2_1 ;
        public static AUDCAD_OCO2_UP_S2 AUDCAD_PFO_OCO2_UP_S2_2 ;
        public static AUDCAD_OCO2_UP_S2 AUDCAD_PFO_OCO2_UP_S2_3 ;
        public static AUDCAD_OCO2_UP_S2 AUDCAD_PFO_OCO2_UP_S2_4 ;
        public static AUDCAD_OCO2_UP_S2 AUDCAD_PFO_OCO2_UP_S2_5 ;
        public static AUDCAD_OCO2_UP_S2 AUDCAD_PFO_OCO2_UP_S2_6 ;
        
        public static List<AUDCAD_OCO2_UP_S2> AUDCAD_UP_S2_OCO2Sets1 = new List<AUDCAD_OCO2_UP_S2>();
        public static List<AUDCAD_OCO2_UP_S2> AUDCAD_UP_S2_OCO2Sets2 = new List<AUDCAD_OCO2_UP_S2>();
        public static List<AUDCAD_OCO2_UP_S2> AUDCAD_UP_S2_OCO2Sets3 = new List<AUDCAD_OCO2_UP_S2>();
        public static List<AUDCAD_OCO2_UP_S2> AUDCAD_UP_S2_OCO2Sets4 = new List<AUDCAD_OCO2_UP_S2>();
        public static List<AUDCAD_OCO2_UP_S2> AUDCAD_UP_S2_OCO2Sets5 = new List<AUDCAD_OCO2_UP_S2>();
        public static List<AUDCAD_OCO2_UP_S2> AUDCAD_UP_S2_OCO2Sets6 = new List<AUDCAD_OCO2_UP_S2>();
        
        public static bool AUDCAD_OCO2_UP_S2_IsReady = true;
		public static bool AUDCAD_OCO2_UP_S2_Monthly_IsReady = true;
        
        //oco2 down
        public static OrderTicket AUDCAD_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO2_MO6_DOWN_S2 ;
    	
    	public static int AUDCAD_OCO2_EO1_DOWN_S2_ID ;
        public static int AUDCAD_OCO2_EO2_DOWN_S2_ID ;
        public static int AUDCAD_OCO2_EO3_DOWN_S2_ID ;
        public static int AUDCAD_OCO2_EO4_DOWN_S2_ID ;
        public static int AUDCAD_OCO2_EO5_DOWN_S2_ID ;
        public static int AUDCAD_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool AUDCAD_OCO2_EO1_DOWN_S2 ;
        public static bool AUDCAD_OCO2_EO2_DOWN_S2 ;
        public static bool AUDCAD_OCO2_EO3_DOWN_S2 ;
        public static bool AUDCAD_OCO2_EO4_DOWN_S2 ;
        public static bool AUDCAD_OCO2_EO5_DOWN_S2 ;
        public static bool AUDCAD_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_DOWN_S2> AUDCAD_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_DOWN_S2> AUDCAD_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_DOWN_S2> AUDCAD_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_DOWN_S2> AUDCAD_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_DOWN_S2> AUDCAD_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO2_DOWN_S2> AUDCAD_OOFE_OCO2_DOWN_S2_6 ;
        
        public static AUDCAD_OCO2_DOWN_S2 AUDCAD_PFO_OCO2_DOWN_S2_1 ;
        public static AUDCAD_OCO2_DOWN_S2 AUDCAD_PFO_OCO2_DOWN_S2_2 ;
        public static AUDCAD_OCO2_DOWN_S2 AUDCAD_PFO_OCO2_DOWN_S2_3 ;
        public static AUDCAD_OCO2_DOWN_S2 AUDCAD_PFO_OCO2_DOWN_S2_4 ;
        public static AUDCAD_OCO2_DOWN_S2 AUDCAD_PFO_OCO2_DOWN_S2_5 ;
        public static AUDCAD_OCO2_DOWN_S2 AUDCAD_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<AUDCAD_OCO2_DOWN_S2> AUDCAD_DOWN_S2_OCO2Sets1 = new List<AUDCAD_OCO2_DOWN_S2>();
        public static List<AUDCAD_OCO2_DOWN_S2> AUDCAD_DOWN_S2_OCO2Sets2 = new List<AUDCAD_OCO2_DOWN_S2>();
        public static List<AUDCAD_OCO2_DOWN_S2> AUDCAD_DOWN_S2_OCO2Sets3 = new List<AUDCAD_OCO2_DOWN_S2>();
        public static List<AUDCAD_OCO2_DOWN_S2> AUDCAD_DOWN_S2_OCO2Sets4 = new List<AUDCAD_OCO2_DOWN_S2>();
        public static List<AUDCAD_OCO2_DOWN_S2> AUDCAD_DOWN_S2_OCO2Sets5 = new List<AUDCAD_OCO2_DOWN_S2>();
        public static List<AUDCAD_OCO2_DOWN_S2> AUDCAD_DOWN_S2_OCO2Sets6 = new List<AUDCAD_OCO2_DOWN_S2>();
        
        public static bool AUDCAD_OCO2_DOWN_S2_IsReady = true;
		public static bool AUDCAD_OCO2_DOWN_S2_Monthly_IsReady = true;
        
        //oco3 up
        public static OrderTicket AUDCAD_OCO3_MO1_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO2_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO3_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO4_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO5_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO6_UP_S2 ;
    	
    	public static int AUDCAD_OCO3_EO1_UP_S2_ID ;
        public static int AUDCAD_OCO3_EO2_UP_S2_ID ;
        public static int AUDCAD_OCO3_EO3_UP_S2_ID ;
        public static int AUDCAD_OCO3_EO4_UP_S2_ID ;
        public static int AUDCAD_OCO3_EO5_UP_S2_ID ;
        public static int AUDCAD_OCO3_EO6_UP_S2_ID ;
        
        public static bool AUDCAD_OCO3_EO1_UP_S2 ;
        public static bool AUDCAD_OCO3_EO2_UP_S2 ;
        public static bool AUDCAD_OCO3_EO3_UP_S2 ;
        public static bool AUDCAD_OCO3_EO4_UP_S2 ;
        public static bool AUDCAD_OCO3_EO5_UP_S2 ;
        public static bool AUDCAD_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_UP_S2> AUDCAD_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_UP_S2> AUDCAD_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_UP_S2> AUDCAD_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_UP_S2> AUDCAD_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_UP_S2> AUDCAD_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_UP_S2> AUDCAD_OOFE_OCO3_UP_S2_6 ;
        
        public static AUDCAD_OCO3_UP_S2 AUDCAD_PFO_OCO3_UP_S2_1 ;
        public static AUDCAD_OCO3_UP_S2 AUDCAD_PFO_OCO3_UP_S2_2 ;
        public static AUDCAD_OCO3_UP_S2 AUDCAD_PFO_OCO3_UP_S2_3 ;
        public static AUDCAD_OCO3_UP_S2 AUDCAD_PFO_OCO3_UP_S2_4 ;
        public static AUDCAD_OCO3_UP_S2 AUDCAD_PFO_OCO3_UP_S2_5 ;
        public static AUDCAD_OCO3_UP_S2 AUDCAD_PFO_OCO3_UP_S2_6 ;
        
        public static List<AUDCAD_OCO3_UP_S2> AUDCAD_UP_S2_OCO3Sets1 = new List<AUDCAD_OCO3_UP_S2>();
        public static List<AUDCAD_OCO3_UP_S2> AUDCAD_UP_S2_OCO3Sets2 = new List<AUDCAD_OCO3_UP_S2>();
        public static List<AUDCAD_OCO3_UP_S2> AUDCAD_UP_S2_OCO3Sets3 = new List<AUDCAD_OCO3_UP_S2>();
        public static List<AUDCAD_OCO3_UP_S2> AUDCAD_UP_S2_OCO3Sets4 = new List<AUDCAD_OCO3_UP_S2>();
        public static List<AUDCAD_OCO3_UP_S2> AUDCAD_UP_S2_OCO3Sets5 = new List<AUDCAD_OCO3_UP_S2>();
        public static List<AUDCAD_OCO3_UP_S2> AUDCAD_UP_S2_OCO3Sets6 = new List<AUDCAD_OCO3_UP_S2>();
        
        public static bool AUDCAD_OCO3_UP_S2_IsReady = true;
		public static bool AUDCAD_OCO3_UP_S2_Monthly_IsReady = true;
        
        //oco3 down
        public static OrderTicket AUDCAD_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO3_MO6_DOWN_S2 ;
    	
    	public static int AUDCAD_OCO3_EO1_DOWN_S2_ID ;
        public static int AUDCAD_OCO3_EO2_DOWN_S2_ID ;
        public static int AUDCAD_OCO3_EO3_DOWN_S2_ID ;
        public static int AUDCAD_OCO3_EO4_DOWN_S2_ID ;
        public static int AUDCAD_OCO3_EO5_DOWN_S2_ID ;
        public static int AUDCAD_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool AUDCAD_OCO3_EO1_DOWN_S2 ;
        public static bool AUDCAD_OCO3_EO2_DOWN_S2 ;
        public static bool AUDCAD_OCO3_EO3_DOWN_S2 ;
        public static bool AUDCAD_OCO3_EO4_DOWN_S2 ;
        public static bool AUDCAD_OCO3_EO5_DOWN_S2 ;
        public static bool AUDCAD_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_DOWN_S2> AUDCAD_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_DOWN_S2> AUDCAD_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_DOWN_S2> AUDCAD_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_DOWN_S2> AUDCAD_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_DOWN_S2> AUDCAD_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO3_DOWN_S2> AUDCAD_OOFE_OCO3_DOWN_S2_6 ;
        
        public static AUDCAD_OCO3_DOWN_S2 AUDCAD_PFO_OCO3_DOWN_S2_1 ;
        public static AUDCAD_OCO3_DOWN_S2 AUDCAD_PFO_OCO3_DOWN_S2_2 ;
        public static AUDCAD_OCO3_DOWN_S2 AUDCAD_PFO_OCO3_DOWN_S2_3 ;
        public static AUDCAD_OCO3_DOWN_S2 AUDCAD_PFO_OCO3_DOWN_S2_4 ;
        public static AUDCAD_OCO3_DOWN_S2 AUDCAD_PFO_OCO3_DOWN_S2_5 ;
        public static AUDCAD_OCO3_DOWN_S2 AUDCAD_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<AUDCAD_OCO3_DOWN_S2> AUDCAD_DOWN_S2_OCO3Sets1 = new List<AUDCAD_OCO3_DOWN_S2>();
        public static List<AUDCAD_OCO3_DOWN_S2> AUDCAD_DOWN_S2_OCO3Sets2 = new List<AUDCAD_OCO3_DOWN_S2>();
        public static List<AUDCAD_OCO3_DOWN_S2> AUDCAD_DOWN_S2_OCO3Sets3 = new List<AUDCAD_OCO3_DOWN_S2>();
        public static List<AUDCAD_OCO3_DOWN_S2> AUDCAD_DOWN_S2_OCO3Sets4 = new List<AUDCAD_OCO3_DOWN_S2>();
        public static List<AUDCAD_OCO3_DOWN_S2> AUDCAD_DOWN_S2_OCO3Sets5 = new List<AUDCAD_OCO3_DOWN_S2>();
        public static List<AUDCAD_OCO3_DOWN_S2> AUDCAD_DOWN_S2_OCO3Sets6 = new List<AUDCAD_OCO3_DOWN_S2>();
        
        public static bool AUDCAD_OCO3_DOWN_S2_IsReady = true;
		public static bool AUDCAD_OCO3_DOWN_S2_Monthly_IsReady = true;
        
        //oco4 up
        public static OrderTicket AUDCAD_OCO4_MO1_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO2_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO3_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO4_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO5_UP_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO6_UP_S2 ;
    	
    	public static int AUDCAD_OCO4_EO1_UP_S2_ID ;
        public static int AUDCAD_OCO4_EO2_UP_S2_ID ;
        public static int AUDCAD_OCO4_EO3_UP_S2_ID ;
        public static int AUDCAD_OCO4_EO4_UP_S2_ID ;
        public static int AUDCAD_OCO4_EO5_UP_S2_ID ;
        public static int AUDCAD_OCO4_EO6_UP_S2_ID ;
        
        public static bool AUDCAD_OCO4_EO1_UP_S2 ;
        public static bool AUDCAD_OCO4_EO2_UP_S2 ;
        public static bool AUDCAD_OCO4_EO3_UP_S2 ;
        public static bool AUDCAD_OCO4_EO4_UP_S2 ;
        public static bool AUDCAD_OCO4_EO5_UP_S2 ;
        public static bool AUDCAD_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_UP_S2> AUDCAD_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_UP_S2> AUDCAD_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_UP_S2> AUDCAD_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_UP_S2> AUDCAD_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_UP_S2> AUDCAD_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_UP_S2> AUDCAD_OOFE_OCO4_UP_S2_6 ;
        
        public static AUDCAD_OCO4_UP_S2 AUDCAD_PFO_OCO4_UP_S2_1 ;
        public static AUDCAD_OCO4_UP_S2 AUDCAD_PFO_OCO4_UP_S2_2 ;
        public static AUDCAD_OCO4_UP_S2 AUDCAD_PFO_OCO4_UP_S2_3 ;
        public static AUDCAD_OCO4_UP_S2 AUDCAD_PFO_OCO4_UP_S2_4 ;
        public static AUDCAD_OCO4_UP_S2 AUDCAD_PFO_OCO4_UP_S2_5 ;
        public static AUDCAD_OCO4_UP_S2 AUDCAD_PFO_OCO4_UP_S2_6 ;
        
        public static List<AUDCAD_OCO4_UP_S2> AUDCAD_UP_S2_OCO4Sets1 = new List<AUDCAD_OCO4_UP_S2>();
        public static List<AUDCAD_OCO4_UP_S2> AUDCAD_UP_S2_OCO4Sets2 = new List<AUDCAD_OCO4_UP_S2>();
        public static List<AUDCAD_OCO4_UP_S2> AUDCAD_UP_S2_OCO4Sets3 = new List<AUDCAD_OCO4_UP_S2>();
        public static List<AUDCAD_OCO4_UP_S2> AUDCAD_UP_S2_OCO4Sets4 = new List<AUDCAD_OCO4_UP_S2>();
        public static List<AUDCAD_OCO4_UP_S2> AUDCAD_UP_S2_OCO4Sets5 = new List<AUDCAD_OCO4_UP_S2>();
        public static List<AUDCAD_OCO4_UP_S2> AUDCAD_UP_S2_OCO4Sets6 = new List<AUDCAD_OCO4_UP_S2>();
        
        public static bool AUDCAD_OCO4_UP_S2_IsReady = true;
		public static bool AUDCAD_OCO4_UP_S2_Monthly_IsReady = true;
        
        //oco4 down
        public static OrderTicket AUDCAD_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket AUDCAD_OCO4_MO6_DOWN_S2 ;
    	
    	public static int AUDCAD_OCO4_EO1_DOWN_S2_ID ;
        public static int AUDCAD_OCO4_EO2_DOWN_S2_ID ;
        public static int AUDCAD_OCO4_EO3_DOWN_S2_ID ;
        public static int AUDCAD_OCO4_EO4_DOWN_S2_ID ;
        public static int AUDCAD_OCO4_EO5_DOWN_S2_ID ;
        public static int AUDCAD_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool AUDCAD_OCO4_EO1_DOWN_S2 ;
        public static bool AUDCAD_OCO4_EO2_DOWN_S2 ;
        public static bool AUDCAD_OCO4_EO3_DOWN_S2 ;
        public static bool AUDCAD_OCO4_EO4_DOWN_S2 ;
        public static bool AUDCAD_OCO4_EO5_DOWN_S2 ;
        public static bool AUDCAD_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_DOWN_S2> AUDCAD_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_DOWN_S2> AUDCAD_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_DOWN_S2> AUDCAD_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_DOWN_S2> AUDCAD_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_DOWN_S2> AUDCAD_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, AUDCAD_OCO4_DOWN_S2> AUDCAD_OOFE_OCO4_DOWN_S2_6 ;
        
        public static AUDCAD_OCO4_DOWN_S2 AUDCAD_PFO_OCO4_DOWN_S2_1 ;
        public static AUDCAD_OCO4_DOWN_S2 AUDCAD_PFO_OCO4_DOWN_S2_2 ;
        public static AUDCAD_OCO4_DOWN_S2 AUDCAD_PFO_OCO4_DOWN_S2_3 ;
        public static AUDCAD_OCO4_DOWN_S2 AUDCAD_PFO_OCO4_DOWN_S2_4 ;
        public static AUDCAD_OCO4_DOWN_S2 AUDCAD_PFO_OCO4_DOWN_S2_5 ;
        public static AUDCAD_OCO4_DOWN_S2 AUDCAD_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<AUDCAD_OCO4_DOWN_S2> AUDCAD_DOWN_S2_OCO4Sets1 = new List<AUDCAD_OCO4_DOWN_S2>();
        public static List<AUDCAD_OCO4_DOWN_S2> AUDCAD_DOWN_S2_OCO4Sets2 = new List<AUDCAD_OCO4_DOWN_S2>();
        public static List<AUDCAD_OCO4_DOWN_S2> AUDCAD_DOWN_S2_OCO4Sets3 = new List<AUDCAD_OCO4_DOWN_S2>();
        public static List<AUDCAD_OCO4_DOWN_S2> AUDCAD_DOWN_S2_OCO4Sets4 = new List<AUDCAD_OCO4_DOWN_S2>();
        public static List<AUDCAD_OCO4_DOWN_S2> AUDCAD_DOWN_S2_OCO4Sets5 = new List<AUDCAD_OCO4_DOWN_S2>();
        public static List<AUDCAD_OCO4_DOWN_S2> AUDCAD_DOWN_S2_OCO4Sets6 = new List<AUDCAD_OCO4_DOWN_S2>();
        
        public static bool AUDCAD_OCO4_DOWN_S2_IsReady = true;
		public static bool AUDCAD_OCO4_DOWN_S2_Monthly_IsReady = true;
        
        
////////////////////////////
		public static decimal AUDCAD_UP_S2_SL {get; set;}
		public static decimal AUDCAD_UP_S2_TP1 {get; set;}
		public static decimal AUDCAD_UP_S2_TP2 {get; set;}
		public static decimal AUDCAD_UP_S2_TP3 {get; set;}
		public static decimal AUDCAD_UP_S2_TP4 {get; set;}
		public static decimal AUDCAD_UP_S2_TP5 {get; set;}
		public static decimal AUDCAD_UP_S2_TP6 {get; set;}
		
		public static decimal AUDCAD_DOWN_S2_SL {get; set;}
		public static decimal AUDCAD_DOWN_S2_TP1 {get; set;}
		public static decimal AUDCAD_DOWN_S2_TP2 {get; set;}
		public static decimal AUDCAD_DOWN_S2_TP3 {get; set;}
		public static decimal AUDCAD_DOWN_S2_TP4 {get; set;}
		public static decimal AUDCAD_DOWN_S2_TP5 {get; set;}
		public static decimal AUDCAD_DOWN_S2_TP6 {get; set;}

        public static bool AUDCAD_Signal_Condition_UP_1 ;
        public static bool AUDCAD_Signal_Condition_UP_2 ;
        public static bool AUDCAD_Signal_Condition_UP_3 ;
        public static bool AUDCAD_Signal_Condition_DOWN_S2 ;
        
        public static int AUDCAD_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int AUDCAD_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDCAD_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDCAD_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDCAD_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int AUDCAD_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int AUDCAD_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int AUDCAD_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int AUDCAD_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int AUDCAD_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_AUDCAD_UP_S2 ;
        public static bool DOWM_AUDCAD_UP_S2 ;
        public static bool DOWT_AUDCAD_UP_S2 ;
        public static bool DOWW_AUDCAD_UP_S2 ;
        public static bool DOWTH_AUDCAD_UP_S2 ;
        
		public static bool DOWR_AUDCAD_DOWN_S2 ;
        public static bool DOWM_AUDCAD_DOWN_S2 ;
        public static bool DOWT_AUDCAD_DOWN_S2 ;
        public static bool DOWW_AUDCAD_DOWN_S2 ;
        public static bool DOWTH_AUDCAD_DOWN_S2 ;
        
        
		public static int AUDCAD_quantity_UP_S2 ;
		public static int AUDCAD_quantity_SL_UP_S2 ;
		public static int AUDCAD_quantity_TP1_UP_S2 ;
		public static int AUDCAD_quantity_TP2_UP_S2 ;
		public static int AUDCAD_quantity_TP3_UP_S2 ;
		public static int AUDCAD_quantity_TP4_UP_S2 ;
		public static int AUDCAD_quantity_TP5_UP_S2;
		public static int AUDCAD_quantity_TP6_UP_S2 ;
		
		public static int AUDCAD_quantity_DOWN_S2 ;
		public static int AUDCAD_quantity_SL_DOWN_S2 ;
		public static int AUDCAD_quantity_TP1_DOWN_S2 ;
		public static int AUDCAD_quantity_TP2_DOWN_S2 ;
		public static int AUDCAD_quantity_TP3_DOWN_S2 ;
		public static int AUDCAD_quantity_TP4_DOWN_S2 ;
		public static int AUDCAD_quantity_TP5_DOWN_S2;
		public static int AUDCAD_quantity_TP6_DOWN_S2 ;
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURJPY_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURJPY_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(x=>x.Tag.Contains("EURJPY_UP_S2_OCO1")))
			{
				Base.EURJPY_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURJPY_UP_S2_OCO2")))
			{
				Base.EURJPY_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURJPY_UP_S2_OCO3")))
			{
				Base.EURJPY_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURJPY_UP_S2_OCO4")))
			{
				Base.EURJPY_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURJPY_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.EURJPY_OCO1_EO1_UP_S2)
	                Base.EURJPY_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.EURJPY_OCO1_EO2_UP_S2)
	                Base.EURJPY_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO1_EO3_UP_S2)
	                Base.EURJPY_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO1_EO4_UP_S2)
	                Base.EURJPY_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO1_EO5_UP_S2)
	                Base.EURJPY_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO1_EO6_UP_S2)
	                Base.EURJPY_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURJPY_OCO1S1_UP_S2 = 0;
		                for (; EURJPY_OCO1S1_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets1.Count; EURJPY_OCO1S1_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO1Sets1[EURJPY_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO1Sets1[EURJPY_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_1__Time out_OCO1");
		                        Base.EURJPY_UP_S2_OCO1Sets1.Clear();
		                        EURJPY_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURJPY_OCO1S2_UP_S2 = 0;
		                for (; EURJPY_OCO1S2_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets2.Count; EURJPY_OCO1S2_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO1Sets2[EURJPY_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO1Sets2[EURJPY_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_2__Time out_OCO1");
		                        Base.EURJPY_UP_S2_OCO1Sets2.Clear();
		                        EURJPY_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO1S3_UP_S2 = 0;
		                for (; EURJPY_OCO1S3_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets3.Count; EURJPY_OCO1S3_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO1Sets3[EURJPY_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO1Sets3[EURJPY_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_3__Time out_OCO1");
		                        Base.EURJPY_UP_S2_OCO1Sets3.Clear();
		                        EURJPY_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO1S4_UP_S2 = 0;
		                for (; EURJPY_OCO1S4_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets4.Count; EURJPY_OCO1S4_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO1Sets4[EURJPY_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO1Sets4[EURJPY_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_4__Time out_OCO1");
		                        Base.EURJPY_UP_S2_OCO1Sets4.Clear();
		                        EURJPY_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO1S5_UP_S2 = 0;
		                for (; EURJPY_OCO1S5_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets5.Count; EURJPY_OCO1S5_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO1Sets5[EURJPY_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO1Sets5[EURJPY_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_5__Time out_OCO1");
		                        Base.EURJPY_UP_S2_OCO1Sets5.Clear();
		                        EURJPY_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO1S6_UP_S2 = 0;
		                for (; EURJPY_OCO1S6_UP_S2 < Base.EURJPY_UP_S2_OCO1Sets6.Count; EURJPY_OCO1S6_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO1Sets6[EURJPY_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO1Sets6[EURJPY_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_6__Time out_OCO1");
		                        Base.EURJPY_UP_S2_OCO1Sets6.Clear();
		                        EURJPY_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURJPY_OCO2_EO1_UP_S2)
                	Base.EURJPY_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.EURJPY_OCO2_EO2_UP_S2)
	                Base.EURJPY_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO2_EO3_UP_S2)
	                Base.EURJPY_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO2_EO4_UP_S2)
	                Base.EURJPY_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO2_EO5_UP_S2)
	                Base.EURJPY_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO2_EO6_UP_S2)
	                Base.EURJPY_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURJPY_OCO2S1_UP_S2 = 0;
		                for (; EURJPY_OCO2S1_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets1.Count; EURJPY_OCO2S1_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO2Sets1[EURJPY_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO2Sets1[EURJPY_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_1__Time out_OCO2");
		                        Base.EURJPY_UP_S2_OCO2Sets1.Clear();
		                        EURJPY_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURJPY_OCO2S2_UP_S2 = 0;
		                for (; EURJPY_OCO2S2_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets2.Count; EURJPY_OCO2S2_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO2Sets2[EURJPY_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO2Sets2[EURJPY_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_2__Time out_OCO2");
		                        Base.EURJPY_UP_S2_OCO2Sets2.Clear();
		                        EURJPY_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO2S3_UP_S2 = 0;
		                for (; EURJPY_OCO2S3_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets3.Count; EURJPY_OCO2S3_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO2Sets3[EURJPY_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO2Sets3[EURJPY_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_3__Time out_OCO2");
		                        Base.EURJPY_UP_S2_OCO2Sets3.Clear();
		                        EURJPY_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO2S4_UP_S2 = 0;
		                for (; EURJPY_OCO2S4_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets4.Count; EURJPY_OCO2S4_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO2Sets4[EURJPY_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO2Sets4[EURJPY_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_4__Time out_OCO2");
		                        Base.EURJPY_UP_S2_OCO2Sets4.Clear();
		                        EURJPY_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO2S5_UP_S2 = 0;
		                for (; EURJPY_OCO2S5_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets5.Count; EURJPY_OCO2S5_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO2Sets5[EURJPY_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO2Sets5[EURJPY_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_5__Time out_OCO2");
		                        Base.EURJPY_UP_S2_OCO2Sets5.Clear();
		                        EURJPY_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO2S6_UP_S2 = 0;
		                for (; EURJPY_OCO2S6_UP_S2 < Base.EURJPY_UP_S2_OCO2Sets6.Count; EURJPY_OCO2S6_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO2Sets6[EURJPY_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO2Sets6[EURJPY_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_6__Time out_OCO2");
		                        Base.EURJPY_UP_S2_OCO2Sets6.Clear();
		                        EURJPY_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURJPY_OCO3_EO1_UP_S2)
            		Base.EURJPY_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.EURJPY_OCO3_EO2_UP_S2)
	                Base.EURJPY_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO3_EO3_UP_S2)
	                Base.EURJPY_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO3_EO4_UP_S2)
	                Base.EURJPY_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO3_EO5_UP_S2)
	                Base.EURJPY_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO3_EO6_UP_S2)
	                Base.EURJPY_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURJPY_OCO3S1_UP_S2 = 0;
		                for (; EURJPY_OCO3S1_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets1.Count; EURJPY_OCO3S1_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO3Sets1[EURJPY_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO3Sets1[EURJPY_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_1__Time out_OCO3");
		                        Base.EURJPY_UP_S2_OCO3Sets1.Clear();
		                        EURJPY_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURJPY_OCO3S2_UP_S2 = 0;
		                for (; EURJPY_OCO3S2_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets2.Count; EURJPY_OCO3S2_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO3Sets2[EURJPY_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO3Sets2[EURJPY_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_2__Time out_OCO3");
		                        Base.EURJPY_UP_S2_OCO3Sets2.Clear();
		                        EURJPY_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO3S3_UP_S2 = 0;
		                for (; EURJPY_OCO3S3_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets3.Count; EURJPY_OCO3S3_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO3Sets3[EURJPY_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO3Sets3[EURJPY_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_3__Time out_OCO3");
		                        Base.EURJPY_UP_S2_OCO3Sets3.Clear();
		                        EURJPY_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO3S4_UP_S2 = 0;
		                for (; EURJPY_OCO3S4_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets4.Count; EURJPY_OCO3S4_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO3Sets4[EURJPY_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO3Sets4[EURJPY_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_4__Time out_OCO3");
		                        Base.EURJPY_UP_S2_OCO3Sets4.Clear();
		                        EURJPY_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO3S5_UP_S2 = 0;
		                for (; EURJPY_OCO3S5_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets5.Count; EURJPY_OCO3S5_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO3Sets5[EURJPY_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO3Sets5[EURJPY_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_5__Time out_OCO3");
		                        Base.EURJPY_UP_S2_OCO3Sets5.Clear();
		                        EURJPY_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO3S6_UP_S2 = 0;
		                for (; EURJPY_OCO3S6_UP_S2 < Base.EURJPY_UP_S2_OCO3Sets6.Count; EURJPY_OCO3S6_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO3Sets6[EURJPY_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO3Sets6[EURJPY_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_6__Time out_OCO3");
		                        Base.EURJPY_UP_S2_OCO3Sets6.Clear();
		                        EURJPY_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURJPY_OCO4_EO1_UP_S2)
            		Base.EURJPY_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.EURJPY_OCO4_EO2_UP_S2)
	                Base.EURJPY_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO4_EO3_UP_S2)
	                Base.EURJPY_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO4_EO4_UP_S2)
	                Base.EURJPY_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO4_EO5_UP_S2)
	                Base.EURJPY_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO4_EO6_UP_S2)
	                Base.EURJPY_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURJPY_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURJPY_OCO4S1_UP_S2 = 0;
		                for (; EURJPY_OCO4S1_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets1.Count; EURJPY_OCO4S1_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO4Sets1[EURJPY_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO4Sets1[EURJPY_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_1__Time out_OCO4");
		                        Base.EURJPY_UP_S2_OCO4Sets1.Clear();
		                        EURJPY_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURJPY_OCO4S2_UP_S2 = 0;
		                for (; EURJPY_OCO4S2_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets2.Count; EURJPY_OCO4S2_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO4Sets2[EURJPY_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO4Sets2[EURJPY_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_2__Time out_OCO4");
		                        Base.EURJPY_UP_S2_OCO4Sets2.Clear();
		                        EURJPY_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO4S3_UP_S2 = 0;
		                for (; EURJPY_OCO4S3_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets3.Count; EURJPY_OCO4S3_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO4Sets3[EURJPY_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO4Sets3[EURJPY_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_3__Time out_OCO4");
		                        Base.EURJPY_UP_S2_OCO4Sets3.Clear();
		                        EURJPY_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO4S4_UP_S2 = 0;
		                for (; EURJPY_OCO4S4_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets4.Count; EURJPY_OCO4S4_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO4Sets4[EURJPY_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO4Sets4[EURJPY_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_4__Time out_OCO4");
		                        Base.EURJPY_UP_S2_OCO4Sets4.Clear();
		                        EURJPY_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO4S5_UP_S2 = 0;
		                for (; EURJPY_OCO4S5_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets5.Count; EURJPY_OCO4S5_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO4Sets5[EURJPY_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO4Sets5[EURJPY_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_5__Time out_OCO4");
		                        Base.EURJPY_UP_S2_OCO4Sets5.Clear();
		                        EURJPY_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO4S6_UP_S2 = 0;
		                for (; EURJPY_OCO4S6_UP_S2 < Base.EURJPY_UP_S2_OCO4Sets6.Count; EURJPY_OCO4S6_UP_S2++)
		                    if (Base.EURJPY_UP_S2_OCO4Sets6[EURJPY_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_UP_S2_OCO4Sets6[EURJPY_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Down, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_UP_S2_Entry_6__Time out_OCO4");
		                        Base.EURJPY_UP_S2_OCO4Sets6.Clear();
		                        EURJPY_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_EURJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURJPY_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURJPY_UP_S2 = DOWM_EURJPY_UP_S2 || DOWT_EURJPY_UP_S2 || DOWW_EURJPY_UP_S2 || DOWTH_EURJPY_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURJPY") && SY1D.Symbol.ID.Market == Market.FXCM)
	            	{
	            		if(SY1D.BQ[0].Open != 0)
	            		{
	            			algorithm.Debug("ID : " + SY1D.Symbol.ID.Market);
	            		}
	            		
	            		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.EURJPY_OCO1_UP_S2_IsReady == false ||
	                    	Base.EURJPY_OCO2_UP_S2_IsReady == false ||
	                    	Base.EURJPY_OCO3_UP_S2_IsReady == false ||
	                    	Base.EURJPY_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.EURJPY_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.EURJPY_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.EURJPY_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.EURJPY_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURJPY_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.EURJPY_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.EURJPY_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.EURJPY_OCO4_UP_S2_Monthly_IsReady = true;
                    	}

	                	EURJPY_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										
		                										)
		                							
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                	EURJPY_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                									
	                	EURJPY_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Yen_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Yen_Min_Size_bs
		                										&&
		                										
		                										(

		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.681m) &&
				                									prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.681m) &&
				                									(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Yen_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Yen_Min_SPRD
	                									);
	                									
	                	if (EURJPY_Signal_Condition_UP_1)
	                	{
	                    	EURJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURJPY_Signal_Condition_UP_2)
	                	{
	                    	EURJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURJPY_Signal_Condition_UP_3)
	                	{
	                    	EURJPY_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (EURJPY_Signal_Condition_UP_1)
	                	{
	                    	EURJPY_UP_S2_TP1  =  Base.Yen_TP_1 ;
	                	}
	                	
	                	if (EURJPY_Signal_Condition_UP_2)
	                	{
	                    	EURJPY_UP_S2_TP1  =  Base.Yen_TP_2 ;
	                	}
	                	
	                	if (EURJPY_Signal_Condition_UP_3)
	                	{
	                    	EURJPY_UP_S2_TP1  =  Base.Yen_TP_3 ;
	                	}

	                    EURJPY_UP_S2_TP2 =  EURJPY_UP_S2_SL * 0;
	                    EURJPY_UP_S2_TP3 =  EURJPY_UP_S2_SL * 0;
	                    EURJPY_UP_S2_TP4 =  EURJPY_UP_S2_SL * 0;
	                    EURJPY_UP_S2_TP5 =  EURJPY_UP_S2_SL * 0;
	                    EURJPY_UP_S2_TP6 =  EURJPY_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURJPY_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURJPY_quantity_SL_UP_S2 = EURJPY_quantity_UP_S2;
	                    EURJPY_quantity_TP1_UP_S2 = (int)Math.Floor(EURJPY_quantity_UP_S2 * 1m);
	                    EURJPY_quantity_TP2_UP_S2 = (int)Math.Floor(EURJPY_quantity_TP1_UP_S2 * 0m);
	                    EURJPY_quantity_TP3_UP_S2 = (int)Math.Floor(EURJPY_quantity_TP2_UP_S2 * 0m);
	                    EURJPY_quantity_TP4_UP_S2 = (int)Math.Floor(EURJPY_quantity_TP3_UP_S2 * 0m);
	                    EURJPY_quantity_TP5_UP_S2 = (int)Math.Floor(EURJPY_quantity_TP4_UP_S2 * 0m);
	                    EURJPY_quantity_TP6_UP_S2 = (int)Math.Floor(EURJPY_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((EURJPY_Signal_Condition_UP_1 || EURJPY_Signal_Condition_UP_2 || EURJPY_Signal_Condition_UP_3)  && 
	                    DOWR_EURJPY_UP_S2 && 
	                    Base.EURJPY_OCO1_UP_S2_IsReady == true &&
	                    Base.EURJPY_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURJPY_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP1_UP_S2, false,"EURJPY_UP_S2_Entry_TP1_OCO1");
	                         Base.EURJPY_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.EURJPY_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP2_UP_S2, false,"EURJPY_UP_S2_Entry_TP2_OCO1");
	                         Base.EURJPY_OCO1_EO2_UP_S2 = false;
	
	                         Base.EURJPY_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP3_UP_S2, false,"EURJPY_UP_S2_Entry_TP3_OCO1");
	                         Base.EURJPY_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.EURJPY_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP4_UP_S2, false,"EURJPY_UP_S2_Entry_TP4_OCO1");
	                         Base.EURJPY_OCO1_EO4_UP_S2 = false;

							Base.EURJPY_OCO1_UP_S2_IsReady = false;
							
							if (Base.EURJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco2:
	                    if ((EURJPY_Signal_Condition_UP_1 || EURJPY_Signal_Condition_UP_2 || EURJPY_Signal_Condition_UP_3)  && 
	                    DOWR_EURJPY_UP_S2 && 
	                    Base.EURJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.EURJPY_OCO2_UP_S2_IsReady == true &&
	                    Base.EURJPY_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURJPY_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP1_UP_S2, false,"EURJPY_UP_S2_Entry_TP1_OCO2");
	                         Base.EURJPY_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.EURJPY_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP2_UP_S2, false,"EURJPY_UP_S2_Entry_TP2_OCO2");
	                         Base.EURJPY_OCO2_EO2_UP_S2 = false;
	
	                         Base.EURJPY_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP3_UP_S2, false,"EURJPY_UP_S2_Entry_TP3_OCO2");
	                         Base.EURJPY_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.EURJPY_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP4_UP_S2, false,"EURJPY_UP_S2_Entry_TP4_OCO2");
	                         Base.EURJPY_OCO2_EO4_UP_S2 = false;

							Base.EURJPY_OCO2_UP_S2_IsReady = false;
							
							if (Base.EURJPY_OCO2_UP_S2_IsReady == false && Base.EURJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco3:
	                    if ((EURJPY_Signal_Condition_UP_1 || EURJPY_Signal_Condition_UP_2 || EURJPY_Signal_Condition_UP_3)  && 
	                    DOWR_EURJPY_UP_S2 &&
	                    Base.EURJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.EURJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.EURJPY_OCO3_UP_S2_IsReady == true &&
	                    Base.EURJPY_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURJPY_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP1_UP_S2, false,"EURJPY_UP_S2_Entry_TP1_OCO3");
	                         Base.EURJPY_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.EURJPY_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP2_UP_S2, false,"EURJPY_UP_S2_Entry_TP2_OCO3");
	                         Base.EURJPY_OCO3_EO2_UP_S2 = false;
	
	                         Base.EURJPY_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP3_UP_S2, false,"EURJPY_UP_S2_Entry_TP3_OCO3");
	                         Base.EURJPY_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.EURJPY_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP4_UP_S2, false,"EURJPY_UP_S2_Entry_TP4_OCO3");
	                         Base.EURJPY_OCO3_EO4_UP_S2 = false;

							Base.EURJPY_OCO3_UP_S2_IsReady = false;
							
							if (Base.EURJPY_OCO3_UP_S2_IsReady == false && Base.EURJPY_OCO2_UP_S2_IsReady == false && Base.EURJPY_OCO1_UP_S2_IsReady == false)
							break;
	                    }
	                    
	                    oco4:
	                    if ((EURJPY_Signal_Condition_UP_1 || EURJPY_Signal_Condition_UP_2 || EURJPY_Signal_Condition_UP_3)  && 
	                    DOWR_EURJPY_UP_S2 && 
	                    Base.EURJPY_OCO1_UP_S2_IsReady == false &&
	                    Base.EURJPY_OCO2_UP_S2_IsReady == false &&
	                    Base.EURJPY_OCO3_UP_S2_IsReady == false &&
	                    Base.EURJPY_OCO4_UP_S2_IsReady == true &&
	                    Base.EURJPY_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURJPY_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP1_UP_S2, false,"EURJPY_UP_S2_Entry_TP1_OCO4");
	                         Base.EURJPY_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.EURJPY_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP2_UP_S2, false,"EURJPY_UP_S2_Entry_TP2_OCO4");
	                         Base.EURJPY_OCO4_EO2_UP_S2 = false;
	
	                         Base.EURJPY_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP3_UP_S2, false,"EURJPY_UP_S2_Entry_TP3_OCO4");
	                         Base.EURJPY_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.EURJPY_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURJPY_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP4_UP_S2, false,"EURJPY_UP_S2_Entry_TP4_OCO4");
	                         Base.EURJPY_OCO4_EO4_UP_S2 = false;

							Base.EURJPY_OCO4_UP_S2_IsReady = false;
							
							if (Base.EURJPY_OCO4_UP_S2_IsReady == false && Base.EURJPY_OCO3_UP_S2_IsReady == false && Base.EURJPY_OCO2_UP_S2_IsReady == false && Base.EURJPY_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.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 AUDCHF_UP_S2_OnOrderEvent
	{
		private QCAlgorithm _algorithm;

		public AUDCHF_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("AUDCHF OCO1 CANCEL 1 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 1 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 1 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCHF OCO1 CANCEL 2 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 2 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 2 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCHF OCO1 CANCEL 3 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 3 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 3 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCHF OCO1 CANCEL 4 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 4 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 4 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCHF OCO1 CANCEL 5 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 5 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 5 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCHF OCO1 CANCEL 6 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 6 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 6 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        	
		        	if (OrderID.Tag.StartsWith("AUDCHF OCO1 CANCEL 7 UP S2") || 
		        		OrderID.Tag.StartsWith("AUDCHF OCO2 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO3 CANCEL 7 UP S2") ||
		        		OrderID.Tag.StartsWith("AUDCHF OCO4 CANCEL 7 UP S2"))
		        	{ 
		        		_algorithm.MarketOrder(OrderID.Symbol, -OrderID.Quantity, false, "OrderID rescue AUDCHF S2");
		        	}
		        }
		        
				if (Base.AUDCHF_OCO1_EO1_UP_S2)
	                Base.AUDCHF_OCO1_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCHF_OCO1_EO2_UP_S2)
	                Base.AUDCHF_OCO1_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO1_EO3_UP_S2)
	                Base.AUDCHF_OCO1_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO1_EO4_UP_S2)
	                Base.AUDCHF_OCO1_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO1_EO5_UP_S2)
	                Base.AUDCHF_OCO1_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO1_EO6_UP_S2)
	                Base.AUDCHF_OCO1_EO6_UP_S2_ID = orderEvent.OrderId;

		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO1_UP_S2_ID)
	                {
	                	Base.AUDCHF_OOFE_OCO1_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP1,"TP1_AUDCHF_UP_S2_OCO1"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP1_AUDCHF_UP_S2_OCO1"));
		                 };
		                Base.AUDCHF_UP_S2_OCO1Sets1.Add( Base.AUDCHF_OOFE_OCO1_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO2_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO1_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP2,"TP2_AUDCHF_UP_S2_OCO1"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP2_AUDCHF_UP_S2_OCO1"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO1Sets2.Add( Base.AUDCHF_OOFE_OCO1_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO3_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO1_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP3,"TP3_AUDCHF_UP_S2_OCO1"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP3_AUDCHF_UP_S2_OCO1"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO1Sets3.Add( Base.AUDCHF_OOFE_OCO1_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO4_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO1_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP4,"TP4_AUDCHF_UP_S2_OCO1"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP4_AUDCHF_UP_S2_OCO1"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO1Sets4.Add( Base.AUDCHF_OOFE_OCO1_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO5_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO1_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP5,"TP5_AUDCHF_UP_S2_OCO1"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP5_AUDCHF_UP_S2_OCO1"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO1Sets5.Add( Base.AUDCHF_OOFE_OCO1_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO1_EO6_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO1_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO1_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP6,"TP6_AUDCHF_UP_S2_OCO1"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP6_AUDCHF_UP_S2_OCO1"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO1Sets6.Add( Base.AUDCHF_OOFE_OCO1_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO1_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDCHF_OCO1S1_UP_S2 = 0;
	                for (; AUDCHF_OCO1S1_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets1.Count; AUDCHF_OCO1S1_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO1Sets1[AUDCHF_OCO1S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO1Sets1[AUDCHF_OCO1S1_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO1Sets1.RemoveAt(AUDCHF_OCO1S1_UP_S2);
	                        AUDCHF_OCO1S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCHF_OCO1S2_UP_S2 = 0;
	                for (; AUDCHF_OCO1S2_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets2.Count; AUDCHF_OCO1S2_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO1Sets2[AUDCHF_OCO1S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO1Sets2[AUDCHF_OCO1S2_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO1Sets2.RemoveAt(AUDCHF_OCO1S2_UP_S2);
	                        AUDCHF_OCO1S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO1S3_UP_S2 = 0;
	                for (; AUDCHF_OCO1S3_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets3.Count; AUDCHF_OCO1S3_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO1Sets3[AUDCHF_OCO1S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO1Sets3[AUDCHF_OCO1S3_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO1Sets3.RemoveAt(AUDCHF_OCO1S3_UP_S2);
	                        AUDCHF_OCO1S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO1S4_UP_S2 = 0;
	                for (; AUDCHF_OCO1S4_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets4.Count; AUDCHF_OCO1S4_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO1Sets4[AUDCHF_OCO1S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO1Sets4[AUDCHF_OCO1S4_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO1Sets4.RemoveAt(AUDCHF_OCO1S4_UP_S2);
	                        AUDCHF_OCO1S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCHF_OCO1S5_UP_S2 = 0;
	                for (; AUDCHF_OCO1S5_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets5.Count; AUDCHF_OCO1S5_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO1Sets5[AUDCHF_OCO1S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO1Sets5[AUDCHF_OCO1S5_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO1Sets5.RemoveAt(AUDCHF_OCO1S5_UP_S2);
	                        AUDCHF_OCO1S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCHF_OCO1S6_UP_S2 = 0;
	                for (; AUDCHF_OCO1S6_UP_S2 < Base.AUDCHF_UP_S2_OCO1Sets6.Count; AUDCHF_OCO1S6_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO1Sets6[AUDCHF_OCO1S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO1Sets6[AUDCHF_OCO1S6_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO1Sets6.RemoveAt(AUDCHF_OCO1S6_UP_S2);
	                        AUDCHF_OCO1S6_UP_S2 = 0;
	                        break;
	                    }
		        }

		        if (Base.AUDCHF_OCO2_EO1_UP_S2)
	                Base.AUDCHF_OCO2_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCHF_OCO2_EO2_UP_S2)
	                Base.AUDCHF_OCO2_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO2_EO3_UP_S2)
	                Base.AUDCHF_OCO2_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO2_EO4_UP_S2)
	                Base.AUDCHF_OCO2_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO2_EO5_UP_S2)
	                Base.AUDCHF_OCO2_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO2_EO6_UP_S2)
	                Base.AUDCHF_OCO2_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO1_UP_S2_ID)
	                {
	                	Base.AUDCHF_OOFE_OCO2_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP1,"TP1_AUDCHF_UP_S2_OCO2"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP1_AUDCHF_UP_S2_OCO2"));
		                 };
		                Base.AUDCHF_UP_S2_OCO2Sets1.Add( Base.AUDCHF_OOFE_OCO2_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO2_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO2_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP2,"TP2_AUDCHF_UP_S2_OCO2"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP2_AUDCHF_UP_S2_OCO2"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO2Sets2.Add( Base.AUDCHF_OOFE_OCO2_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO3_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO2_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP3,"TP3_AUDCHF_UP_S2_OCO2"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP3_AUDCHF_UP_S2_OCO2"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO2Sets3.Add( Base.AUDCHF_OOFE_OCO2_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO4_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO2_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP4,"TP4_AUDCHF_UP_S2_OCO2"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP4_AUDCHF_UP_S2_OCO2"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO2Sets4.Add( Base.AUDCHF_OOFE_OCO2_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO5_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO2_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP5,"TP5_AUDCHF_UP_S2_OCO2"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP5_AUDCHF_UP_S2_OCO2"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO2Sets5.Add( Base.AUDCHF_OOFE_OCO2_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO2_EO6_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO2_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO2_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP6,"TP6_AUDCHF_UP_S2_OCO2"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP6_AUDCHF_UP_S2_OCO2"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO2Sets6.Add( Base.AUDCHF_OOFE_OCO2_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO2_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDCHF_OCO2S1_UP_S2 = 0;
	                for (; AUDCHF_OCO2S1_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets1.Count; AUDCHF_OCO2S1_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO2Sets1[AUDCHF_OCO2S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO2Sets1[AUDCHF_OCO2S1_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO2Sets1.RemoveAt(AUDCHF_OCO2S1_UP_S2);
	                        AUDCHF_OCO2S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCHF_OCO2S2_UP_S2 = 0;
	                for (; AUDCHF_OCO2S2_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets2.Count; AUDCHF_OCO2S2_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO2Sets2[AUDCHF_OCO2S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO2Sets2[AUDCHF_OCO2S2_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO2Sets2.RemoveAt(AUDCHF_OCO2S2_UP_S2);
	                        AUDCHF_OCO2S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO2S3_UP_S2 = 0;
	                for (; AUDCHF_OCO2S3_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets3.Count; AUDCHF_OCO2S3_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO2Sets3[AUDCHF_OCO2S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO2Sets3[AUDCHF_OCO2S3_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO2Sets3.RemoveAt(AUDCHF_OCO2S3_UP_S2);
	                        AUDCHF_OCO2S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO2S4_UP_S2 = 0;
	                for (; AUDCHF_OCO2S4_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets4.Count; AUDCHF_OCO2S4_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO2Sets4[AUDCHF_OCO2S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO2Sets4[AUDCHF_OCO2S4_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO2Sets4.RemoveAt(AUDCHF_OCO2S4_UP_S2);
	                        AUDCHF_OCO2S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCHF_OCO2S5_UP_S2 = 0;
	                for (; AUDCHF_OCO2S5_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets5.Count; AUDCHF_OCO2S5_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO2Sets5[AUDCHF_OCO2S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO2Sets5[AUDCHF_OCO2S5_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO2Sets5.RemoveAt(AUDCHF_OCO2S5_UP_S2);
	                        AUDCHF_OCO2S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCHF_OCO2S6_UP_S2 = 0;
	                for (; AUDCHF_OCO2S6_UP_S2 < Base.AUDCHF_UP_S2_OCO2Sets6.Count; AUDCHF_OCO2S6_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO2Sets6[AUDCHF_OCO2S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO2Sets6[AUDCHF_OCO2S6_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO2Sets6.RemoveAt(AUDCHF_OCO2S6_UP_S2);
	                        AUDCHF_OCO2S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCHF_OCO3_EO1_UP_S2)
	                Base.AUDCHF_OCO3_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCHF_OCO3_EO2_UP_S2)
	                Base.AUDCHF_OCO3_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO3_EO3_UP_S2)
	                Base.AUDCHF_OCO3_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO3_EO4_UP_S2)
	                Base.AUDCHF_OCO3_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO3_EO5_UP_S2)
	                Base.AUDCHF_OCO3_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO3_EO6_UP_S2)
	                Base.AUDCHF_OCO3_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO1_UP_S2_ID)
	                {
	                	Base.AUDCHF_OOFE_OCO3_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP1,"TP1_AUDCHF_UP_S2_OCO3"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP1_AUDCHF_UP_S2_OCO3"));
		                 };
		                Base.AUDCHF_UP_S2_OCO3Sets1.Add( Base.AUDCHF_OOFE_OCO3_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO2_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO3_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP2,"TP2_AUDCHF_UP_S2_OCO3"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP2_AUDCHF_UP_S2_OCO3"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO3Sets2.Add( Base.AUDCHF_OOFE_OCO3_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO3_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO3_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP3,"TP3_AUDCHF_UP_S2_OCO3"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP3_AUDCHF_UP_S2_OCO3"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO3Sets3.Add( Base.AUDCHF_OOFE_OCO3_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO4_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO3_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP4,"TP4_AUDCHF_UP_S2_OCO3"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP4_AUDCHF_UP_S2_OCO3"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO3Sets4.Add( Base.AUDCHF_OOFE_OCO3_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO5_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO3_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP5,"TP5_AUDCHF_UP_S2_OCO3"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP5_AUDCHF_UP_S2_OCO3"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO3Sets5.Add( Base.AUDCHF_OOFE_OCO3_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO3_EO6_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO3_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO3_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP6,"TP6_AUDCHF_UP_S2_OCO3"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP6_AUDCHF_UP_S2_OCO3"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO3Sets6.Add( Base.AUDCHF_OOFE_OCO3_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO3_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDCHF_OCO3S1_UP_S2 = 0;
	                for (; AUDCHF_OCO3S1_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets1.Count; AUDCHF_OCO3S1_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO3Sets1[AUDCHF_OCO3S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO3Sets1[AUDCHF_OCO3S1_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO3Sets1.RemoveAt(AUDCHF_OCO3S1_UP_S2);
	                        AUDCHF_OCO3S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCHF_OCO3S2_UP_S2 = 0;
	                for (; AUDCHF_OCO3S2_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets2.Count; AUDCHF_OCO3S2_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO3Sets2[AUDCHF_OCO3S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO3Sets2[AUDCHF_OCO3S2_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO3Sets2.RemoveAt(AUDCHF_OCO3S2_UP_S2);
	                        AUDCHF_OCO3S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO3S3_UP_S2 = 0;
	                for (; AUDCHF_OCO3S3_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets3.Count; AUDCHF_OCO3S3_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO3Sets3[AUDCHF_OCO3S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO3Sets3[AUDCHF_OCO3S3_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO3Sets3.RemoveAt(AUDCHF_OCO3S3_UP_S2);
	                        AUDCHF_OCO3S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO3S4_UP_S2 = 0;
	                for (; AUDCHF_OCO3S4_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets4.Count; AUDCHF_OCO3S4_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO3Sets4[AUDCHF_OCO3S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO3Sets4[AUDCHF_OCO3S4_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO3Sets4.RemoveAt(AUDCHF_OCO3S4_UP_S2);
	                        AUDCHF_OCO3S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCHF_OCO3S5_UP_S2 = 0;
	                for (; AUDCHF_OCO3S5_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets5.Count; AUDCHF_OCO3S5_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO3Sets5[AUDCHF_OCO3S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO3Sets5[AUDCHF_OCO3S5_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO3Sets5.RemoveAt(AUDCHF_OCO3S5_UP_S2);
	                        AUDCHF_OCO3S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCHF_OCO3S6_UP_S2 = 0;
	                for (; AUDCHF_OCO3S6_UP_S2 < Base.AUDCHF_UP_S2_OCO3Sets6.Count; AUDCHF_OCO3S6_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO3Sets6[AUDCHF_OCO3S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO3Sets6[AUDCHF_OCO3S6_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO3Sets6.RemoveAt(AUDCHF_OCO3S6_UP_S2);
	                        AUDCHF_OCO3S6_UP_S2 = 0;
	                        break;
	                    }
		        }
		        
		        if (Base.AUDCHF_OCO4_EO1_UP_S2)
	                Base.AUDCHF_OCO4_EO1_UP_S2_ID = orderEvent.OrderId;
	            if (Base.AUDCHF_OCO4_EO2_UP_S2)
	                Base.AUDCHF_OCO4_EO2_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO4_EO3_UP_S2)
	                Base.AUDCHF_OCO4_EO3_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO4_EO4_UP_S2)
	                Base.AUDCHF_OCO4_EO4_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO4_EO5_UP_S2)
	                Base.AUDCHF_OCO4_EO5_UP_S2_ID = orderEvent.OrderId;
	        	if (Base.AUDCHF_OCO4_EO6_UP_S2)
	                Base.AUDCHF_OCO4_EO6_UP_S2_ID = orderEvent.OrderId;
	                
		        if (orderEvent.Status == OrderStatus.Filled || orderEvent.Status == OrderStatus.PartiallyFilled)
		        {	
		            if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO1_UP_S2_ID)
	                {
	                	Base.AUDCHF_OOFE_OCO4_UP_S2_1 = (algo1, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_UP_S2(
		                        algo1.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP1,"TP1_AUDCHF_UP_S2_OCO4"),
		                        algo1.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP1_AUDCHF_UP_S2_OCO4"));
		                 };
		                Base.AUDCHF_UP_S2_OCO4Sets1.Add( Base.AUDCHF_OOFE_OCO4_UP_S2_1(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO1_UP_S2_ID = -1;
	                }

	                if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO2_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO4_UP_S2_2 = (algo2, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_UP_S2(
		                        algo2.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP2,"TP2_AUDCHF_UP_S2_OCO4"),
		                        algo2.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP2_AUDCHF_UP_S2_OCO4"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO4Sets2.Add( Base.AUDCHF_OOFE_OCO4_UP_S2_2(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO2_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO3_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO4_UP_S2_3 = (algo3, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_UP_S2(
		                        algo3.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP3,"TP3_AUDCHF_UP_S2_OCO4"),
		                        algo3.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP3_AUDCHF_UP_S2_OCO4"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO4Sets3.Add( Base.AUDCHF_OOFE_OCO4_UP_S2_3(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO3_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO4_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO4_UP_S2_4 = (algo4, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_UP_S2(
		                        algo4.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP4,"TP4_AUDCHF_UP_S2_OCO4"),
		                        algo4.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP4_AUDCHF_UP_S2_OCO4"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO4Sets4.Add( Base.AUDCHF_OOFE_OCO4_UP_S2_4(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO4_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO5_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO4_UP_S2_5 = (algo5, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_UP_S2(
		                        algo5.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP5,"TP5_AUDCHF_UP_S2_OCO4"),
		                        algo5.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP5_AUDCHF_UP_S2_OCO4"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO4Sets5.Add( Base.AUDCHF_OOFE_OCO4_UP_S2_5(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO5_UP_S2_ID = -1;
	                }
	                
	                if (orderEvent.OrderId == Base.AUDCHF_OCO4_EO6_UP_S2_ID) 
	                {
	                	Base.AUDCHF_OOFE_OCO4_UP_S2_6 = (algo6, symbol, filledPrice, fillQ) =>
		                {
		                    return new AUDCHF_OCO4_UP_S2(
		                        algo6.LimitOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice + Base.AUDCHF_UP_S2_TP6,"TP6_AUDCHF_UP_S2_OCO4"),
		                        algo6.StopMarketOrder(orderEvent.Symbol,  -orderEvent.Quantity,  orderEvent.FillPrice - Base.AUDCHF_UP_S2_SL,"SL_TP6_AUDCHF_UP_S2_OCO4"));
		                 };
	                    Base.AUDCHF_UP_S2_OCO4Sets6.Add( Base.AUDCHF_OOFE_OCO4_UP_S2_6(_algorithm, orderEvent.Symbol, orderEvent.FillPrice, orderEvent.Quantity));
	                    Base.AUDCHF_OCO4_EO6_UP_S2_ID = -1;
	                }
	                
	                int AUDCHF_OCO4S1_UP_S2 = 0;
	                for (; AUDCHF_OCO4S1_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets1.Count; AUDCHF_OCO4S1_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO4Sets1[AUDCHF_OCO4S1_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO4Sets1[AUDCHF_OCO4S1_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO4Sets1.RemoveAt(AUDCHF_OCO4S1_UP_S2);
	                        AUDCHF_OCO4S1_UP_S2 = 0;
	                        break;
	                    }
	            
	                int AUDCHF_OCO4S2_UP_S2 = 0;
	                for (; AUDCHF_OCO4S2_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets2.Count; AUDCHF_OCO4S2_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO4Sets2[AUDCHF_OCO4S2_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO4Sets2[AUDCHF_OCO4S2_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO4Sets2.RemoveAt(AUDCHF_OCO4S2_UP_S2);
	                        AUDCHF_OCO4S2_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO4S3_UP_S2 = 0;
	                for (; AUDCHF_OCO4S3_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets3.Count; AUDCHF_OCO4S3_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO4Sets3[AUDCHF_OCO4S3_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO4Sets3[AUDCHF_OCO4S3_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO4Sets3.RemoveAt(AUDCHF_OCO4S3_UP_S2);
	                        AUDCHF_OCO4S3_UP_S2 = 0;
	                        break;
	                    }
	                    
	                int AUDCHF_OCO4S4_UP_S2 = 0;
	                for (; AUDCHF_OCO4S4_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets4.Count; AUDCHF_OCO4S4_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO4Sets4[AUDCHF_OCO4S4_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO4Sets4[AUDCHF_OCO4S4_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO4Sets4.RemoveAt(AUDCHF_OCO4S4_UP_S2);
	                        AUDCHF_OCO4S4_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCHF_OCO4S5_UP_S2 = 0;
	                for (; AUDCHF_OCO4S5_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets5.Count; AUDCHF_OCO4S5_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO4Sets5[AUDCHF_OCO4S5_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO4Sets5[AUDCHF_OCO4S5_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO4Sets5.RemoveAt(AUDCHF_OCO4S5_UP_S2);
	                        AUDCHF_OCO4S5_UP_S2 = 0;
	                        break;
	                    }
	                
	                int AUDCHF_OCO4S6_UP_S2 = 0;
	                for (; AUDCHF_OCO4S6_UP_S2 < Base.AUDCHF_UP_S2_OCO4Sets6.Count; AUDCHF_OCO4S6_UP_S2++)
	                    if (Base.AUDCHF_UP_S2_OCO4Sets6[AUDCHF_OCO4S6_UP_S2].InOrders(orderEvent.OrderId)) 
	                    {
	                        Base.AUDCHF_UP_S2_OCO4Sets6[AUDCHF_OCO4S6_UP_S2].Filled();
	                        Base.AUDCHF_UP_S2_OCO4Sets6.RemoveAt(AUDCHF_OCO4S6_UP_S2);
	                        AUDCHF_OCO4S6_UP_S2 = 0;
	                        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 _EURGBP;
		
    	///oco1 up
    	public static OrderTicket EURGBP_OCO1_MO1_UP_S2;
    	public static OrderTicket EURGBP_OCO1_MO2_UP_S2;
    	public static OrderTicket EURGBP_OCO1_MO3_UP_S2;
    	public static OrderTicket EURGBP_OCO1_MO4_UP_S2;
    	public static OrderTicket EURGBP_OCO1_MO5_UP_S2;
    	public static OrderTicket EURGBP_OCO1_MO6_UP_S2;
    	
    	public static int EURGBP_OCO1_EO1_UP_S2_ID ;
        public static int EURGBP_OCO1_EO2_UP_S2_ID ;
        public static int EURGBP_OCO1_EO3_UP_S2_ID ;
        public static int EURGBP_OCO1_EO4_UP_S2_ID ;
        public static int EURGBP_OCO1_EO5_UP_S2_ID ;
        public static int EURGBP_OCO1_EO6_UP_S2_ID ;
        
        public static bool EURGBP_OCO1_EO1_UP_S2 ;
        public static bool EURGBP_OCO1_EO2_UP_S2 ;
        public static bool EURGBP_OCO1_EO3_UP_S2 ;
        public static bool EURGBP_OCO1_EO4_UP_S2 ;
        public static bool EURGBP_OCO1_EO5_UP_S2 ;
        public static bool EURGBP_OCO1_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_UP_S2> EURGBP_OOFE_OCO1_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_UP_S2> EURGBP_OOFE_OCO1_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_UP_S2> EURGBP_OOFE_OCO1_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_UP_S2> EURGBP_OOFE_OCO1_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_UP_S2> EURGBP_OOFE_OCO1_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_UP_S2> EURGBP_OOFE_OCO1_UP_S2_6 ;
        
        public static EURGBP_OCO1_UP_S2 EURGBP_PFO_OCO1_UP_S2_1 ;
        public static EURGBP_OCO1_UP_S2 EURGBP_PFO_OCO1_UP_S2_2 ;
        public static EURGBP_OCO1_UP_S2 EURGBP_PFO_OCO1_UP_S2_3 ;
        public static EURGBP_OCO1_UP_S2 EURGBP_PFO_OCO1_UP_S2_4 ;
        public static EURGBP_OCO1_UP_S2 EURGBP_PFO_OCO1_UP_S2_5 ;
        public static EURGBP_OCO1_UP_S2 EURGBP_PFO_OCO1_UP_S2_6 ;
        
        public static List<EURGBP_OCO1_UP_S2> EURGBP_UP_S2_OCO1Sets1 = new List<EURGBP_OCO1_UP_S2>();
        public static List<EURGBP_OCO1_UP_S2> EURGBP_UP_S2_OCO1Sets2 = new List<EURGBP_OCO1_UP_S2>();
        public static List<EURGBP_OCO1_UP_S2> EURGBP_UP_S2_OCO1Sets3 = new List<EURGBP_OCO1_UP_S2>();
        public static List<EURGBP_OCO1_UP_S2> EURGBP_UP_S2_OCO1Sets4 = new List<EURGBP_OCO1_UP_S2>();
        public static List<EURGBP_OCO1_UP_S2> EURGBP_UP_S2_OCO1Sets5 = new List<EURGBP_OCO1_UP_S2>();
        public static List<EURGBP_OCO1_UP_S2> EURGBP_UP_S2_OCO1Sets6 = new List<EURGBP_OCO1_UP_S2>();
        
        public static bool EURGBP_OCO1_UP_S2_IsReady = true;
        public static bool EURGBP_OCO1_UP_S2_Monthly_IsReady = true;

        
        //oco1 down
		public static OrderTicket EURGBP_OCO1_MO1_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO1_MO2_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO1_MO3_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO1_MO4_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO1_MO5_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO1_MO6_DOWN_S2 ;
    	
    	public static int EURGBP_OCO1_EO1_DOWN_S2_ID ;
        public static int EURGBP_OCO1_EO2_DOWN_S2_ID ;
        public static int EURGBP_OCO1_EO3_DOWN_S2_ID ;
        public static int EURGBP_OCO1_EO4_DOWN_S2_ID ;
        public static int EURGBP_OCO1_EO5_DOWN_S2_ID ;
        public static int EURGBP_OCO1_EO6_DOWN_S2_ID ;
        
        public static bool EURGBP_OCO1_EO1_DOWN_S2 ;
        public static bool EURGBP_OCO1_EO2_DOWN_S2 ;
        public static bool EURGBP_OCO1_EO3_DOWN_S2 ;
        public static bool EURGBP_OCO1_EO4_DOWN_S2 ;
        public static bool EURGBP_OCO1_EO5_DOWN_S2 ;
        public static bool EURGBP_OCO1_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_DOWN_S2> EURGBP_OOFE_OCO1_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_DOWN_S2> EURGBP_OOFE_OCO1_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_DOWN_S2> EURGBP_OOFE_OCO1_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_DOWN_S2> EURGBP_OOFE_OCO1_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_DOWN_S2> EURGBP_OOFE_OCO1_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO1_DOWN_S2> EURGBP_OOFE_OCO1_DOWN_S2_6 ;
        
        public static EURGBP_OCO1_DOWN_S2 EURGBP_PFO_OCO1_DOWN_S2_1 ;
        public static EURGBP_OCO1_DOWN_S2 EURGBP_PFO_OCO1_DOWN_S2_2 ;
        public static EURGBP_OCO1_DOWN_S2 EURGBP_PFO_OCO1_DOWN_S2_3 ;
        public static EURGBP_OCO1_DOWN_S2 EURGBP_PFO_OCO1_DOWN_S2_4 ;
        public static EURGBP_OCO1_DOWN_S2 EURGBP_PFO_OCO1_DOWN_S2_5 ;
        public static EURGBP_OCO1_DOWN_S2 EURGBP_PFO_OCO1_DOWN_S2_6 ;
        
        public static List<EURGBP_OCO1_DOWN_S2> EURGBP_DOWN_S2_OCO1Sets1 = new List<EURGBP_OCO1_DOWN_S2>();
        public static List<EURGBP_OCO1_DOWN_S2> EURGBP_DOWN_S2_OCO1Sets2 = new List<EURGBP_OCO1_DOWN_S2>();
        public static List<EURGBP_OCO1_DOWN_S2> EURGBP_DOWN_S2_OCO1Sets3 = new List<EURGBP_OCO1_DOWN_S2>();
        public static List<EURGBP_OCO1_DOWN_S2> EURGBP_DOWN_S2_OCO1Sets4 = new List<EURGBP_OCO1_DOWN_S2>();
        public static List<EURGBP_OCO1_DOWN_S2> EURGBP_DOWN_S2_OCO1Sets5 = new List<EURGBP_OCO1_DOWN_S2>();
        public static List<EURGBP_OCO1_DOWN_S2> EURGBP_DOWN_S2_OCO1Sets6 = new List<EURGBP_OCO1_DOWN_S2>();
        
        public static bool EURGBP_OCO1_DOWN_S2_IsReady = true;
        public static bool EURGBP_OCO1_DOWN_S2_Monthly_IsReady = true;

        
        //oco2 up
        public static OrderTicket EURGBP_OCO2_MO1_UP_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO2_UP_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO3_UP_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO4_UP_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO5_UP_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO6_UP_S2 ;
    	
    	public static int EURGBP_OCO2_EO1_UP_S2_ID ;
        public static int EURGBP_OCO2_EO2_UP_S2_ID ;
        public static int EURGBP_OCO2_EO3_UP_S2_ID ;
        public static int EURGBP_OCO2_EO4_UP_S2_ID ;
        public static int EURGBP_OCO2_EO5_UP_S2_ID ;
        public static int EURGBP_OCO2_EO6_UP_S2_ID ;
        
        public static bool EURGBP_OCO2_EO1_UP_S2 ;
        public static bool EURGBP_OCO2_EO2_UP_S2 ;
        public static bool EURGBP_OCO2_EO3_UP_S2 ;
        public static bool EURGBP_OCO2_EO4_UP_S2 ;
        public static bool EURGBP_OCO2_EO5_UP_S2 ;
        public static bool EURGBP_OCO2_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_UP_S2> EURGBP_OOFE_OCO2_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_UP_S2> EURGBP_OOFE_OCO2_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_UP_S2> EURGBP_OOFE_OCO2_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_UP_S2> EURGBP_OOFE_OCO2_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_UP_S2> EURGBP_OOFE_OCO2_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_UP_S2> EURGBP_OOFE_OCO2_UP_S2_6 ;
        
        public static EURGBP_OCO2_UP_S2 EURGBP_PFO_OCO2_UP_S2_1 ;
        public static EURGBP_OCO2_UP_S2 EURGBP_PFO_OCO2_UP_S2_2 ;
        public static EURGBP_OCO2_UP_S2 EURGBP_PFO_OCO2_UP_S2_3 ;
        public static EURGBP_OCO2_UP_S2 EURGBP_PFO_OCO2_UP_S2_4 ;
        public static EURGBP_OCO2_UP_S2 EURGBP_PFO_OCO2_UP_S2_5 ;
        public static EURGBP_OCO2_UP_S2 EURGBP_PFO_OCO2_UP_S2_6 ;
        
        public static List<EURGBP_OCO2_UP_S2> EURGBP_UP_S2_OCO2Sets1 = new List<EURGBP_OCO2_UP_S2>();
        public static List<EURGBP_OCO2_UP_S2> EURGBP_UP_S2_OCO2Sets2 = new List<EURGBP_OCO2_UP_S2>();
        public static List<EURGBP_OCO2_UP_S2> EURGBP_UP_S2_OCO2Sets3 = new List<EURGBP_OCO2_UP_S2>();
        public static List<EURGBP_OCO2_UP_S2> EURGBP_UP_S2_OCO2Sets4 = new List<EURGBP_OCO2_UP_S2>();
        public static List<EURGBP_OCO2_UP_S2> EURGBP_UP_S2_OCO2Sets5 = new List<EURGBP_OCO2_UP_S2>();
        public static List<EURGBP_OCO2_UP_S2> EURGBP_UP_S2_OCO2Sets6 = new List<EURGBP_OCO2_UP_S2>();
        
        public static bool EURGBP_OCO2_UP_S2_IsReady = true;
        public static bool EURGBP_OCO2_UP_S2_Monthly_IsReady = true;

        
        //oco2 down
        public static OrderTicket EURGBP_OCO2_MO1_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO2_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO3_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO4_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO5_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO2_MO6_DOWN_S2 ;
    	
    	public static int EURGBP_OCO2_EO1_DOWN_S2_ID ;
        public static int EURGBP_OCO2_EO2_DOWN_S2_ID ;
        public static int EURGBP_OCO2_EO3_DOWN_S2_ID ;
        public static int EURGBP_OCO2_EO4_DOWN_S2_ID ;
        public static int EURGBP_OCO2_EO5_DOWN_S2_ID ;
        public static int EURGBP_OCO2_EO6_DOWN_S2_ID ;
        
        public static bool EURGBP_OCO2_EO1_DOWN_S2 ;
        public static bool EURGBP_OCO2_EO2_DOWN_S2 ;
        public static bool EURGBP_OCO2_EO3_DOWN_S2 ;
        public static bool EURGBP_OCO2_EO4_DOWN_S2 ;
        public static bool EURGBP_OCO2_EO5_DOWN_S2 ;
        public static bool EURGBP_OCO2_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_DOWN_S2> EURGBP_OOFE_OCO2_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_DOWN_S2> EURGBP_OOFE_OCO2_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_DOWN_S2> EURGBP_OOFE_OCO2_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_DOWN_S2> EURGBP_OOFE_OCO2_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_DOWN_S2> EURGBP_OOFE_OCO2_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO2_DOWN_S2> EURGBP_OOFE_OCO2_DOWN_S2_6 ;
        
        public static EURGBP_OCO2_DOWN_S2 EURGBP_PFO_OCO2_DOWN_S2_1 ;
        public static EURGBP_OCO2_DOWN_S2 EURGBP_PFO_OCO2_DOWN_S2_2 ;
        public static EURGBP_OCO2_DOWN_S2 EURGBP_PFO_OCO2_DOWN_S2_3 ;
        public static EURGBP_OCO2_DOWN_S2 EURGBP_PFO_OCO2_DOWN_S2_4 ;
        public static EURGBP_OCO2_DOWN_S2 EURGBP_PFO_OCO2_DOWN_S2_5 ;
        public static EURGBP_OCO2_DOWN_S2 EURGBP_PFO_OCO2_DOWN_S2_6 ;
        
        public static List<EURGBP_OCO2_DOWN_S2> EURGBP_DOWN_S2_OCO2Sets1 = new List<EURGBP_OCO2_DOWN_S2>();
        public static List<EURGBP_OCO2_DOWN_S2> EURGBP_DOWN_S2_OCO2Sets2 = new List<EURGBP_OCO2_DOWN_S2>();
        public static List<EURGBP_OCO2_DOWN_S2> EURGBP_DOWN_S2_OCO2Sets3 = new List<EURGBP_OCO2_DOWN_S2>();
        public static List<EURGBP_OCO2_DOWN_S2> EURGBP_DOWN_S2_OCO2Sets4 = new List<EURGBP_OCO2_DOWN_S2>();
        public static List<EURGBP_OCO2_DOWN_S2> EURGBP_DOWN_S2_OCO2Sets5 = new List<EURGBP_OCO2_DOWN_S2>();
        public static List<EURGBP_OCO2_DOWN_S2> EURGBP_DOWN_S2_OCO2Sets6 = new List<EURGBP_OCO2_DOWN_S2>();
        
        public static bool EURGBP_OCO2_DOWN_S2_IsReady = true;
        public static bool EURGBP_OCO2_DOWN_S2_Monthly_IsReady = true;
 
        
        //oco3 up
        public static OrderTicket EURGBP_OCO3_MO1_UP_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO2_UP_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO3_UP_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO4_UP_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO5_UP_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO6_UP_S2 ;
    	
    	public static int EURGBP_OCO3_EO1_UP_S2_ID ;
        public static int EURGBP_OCO3_EO2_UP_S2_ID ;
        public static int EURGBP_OCO3_EO3_UP_S2_ID ;
        public static int EURGBP_OCO3_EO4_UP_S2_ID ;
        public static int EURGBP_OCO3_EO5_UP_S2_ID ;
        public static int EURGBP_OCO3_EO6_UP_S2_ID ;
        
        public static bool EURGBP_OCO3_EO1_UP_S2 ;
        public static bool EURGBP_OCO3_EO2_UP_S2 ;
        public static bool EURGBP_OCO3_EO3_UP_S2 ;
        public static bool EURGBP_OCO3_EO4_UP_S2 ;
        public static bool EURGBP_OCO3_EO5_UP_S2 ;
        public static bool EURGBP_OCO3_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_UP_S2> EURGBP_OOFE_OCO3_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_UP_S2> EURGBP_OOFE_OCO3_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_UP_S2> EURGBP_OOFE_OCO3_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_UP_S2> EURGBP_OOFE_OCO3_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_UP_S2> EURGBP_OOFE_OCO3_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_UP_S2> EURGBP_OOFE_OCO3_UP_S2_6 ;
        
        public static EURGBP_OCO3_UP_S2 EURGBP_PFO_OCO3_UP_S2_1 ;
        public static EURGBP_OCO3_UP_S2 EURGBP_PFO_OCO3_UP_S2_2 ;
        public static EURGBP_OCO3_UP_S2 EURGBP_PFO_OCO3_UP_S2_3 ;
        public static EURGBP_OCO3_UP_S2 EURGBP_PFO_OCO3_UP_S2_4 ;
        public static EURGBP_OCO3_UP_S2 EURGBP_PFO_OCO3_UP_S2_5 ;
        public static EURGBP_OCO3_UP_S2 EURGBP_PFO_OCO3_UP_S2_6 ;
        
        public static List<EURGBP_OCO3_UP_S2> EURGBP_UP_S2_OCO3Sets1 = new List<EURGBP_OCO3_UP_S2>();
        public static List<EURGBP_OCO3_UP_S2> EURGBP_UP_S2_OCO3Sets2 = new List<EURGBP_OCO3_UP_S2>();
        public static List<EURGBP_OCO3_UP_S2> EURGBP_UP_S2_OCO3Sets3 = new List<EURGBP_OCO3_UP_S2>();
        public static List<EURGBP_OCO3_UP_S2> EURGBP_UP_S2_OCO3Sets4 = new List<EURGBP_OCO3_UP_S2>();
        public static List<EURGBP_OCO3_UP_S2> EURGBP_UP_S2_OCO3Sets5 = new List<EURGBP_OCO3_UP_S2>();
        public static List<EURGBP_OCO3_UP_S2> EURGBP_UP_S2_OCO3Sets6 = new List<EURGBP_OCO3_UP_S2>();
        
        public static bool EURGBP_OCO3_UP_S2_IsReady = true;
        public static bool EURGBP_OCO3_UP_S2_Monthly_IsReady = true;

        
        //oco3 down
        public static OrderTicket EURGBP_OCO3_MO1_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO2_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO3_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO4_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO5_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO3_MO6_DOWN_S2 ;
    	
    	public static int EURGBP_OCO3_EO1_DOWN_S2_ID ;
        public static int EURGBP_OCO3_EO2_DOWN_S2_ID ;
        public static int EURGBP_OCO3_EO3_DOWN_S2_ID ;
        public static int EURGBP_OCO3_EO4_DOWN_S2_ID ;
        public static int EURGBP_OCO3_EO5_DOWN_S2_ID ;
        public static int EURGBP_OCO3_EO6_DOWN_S2_ID ;
        
        public static bool EURGBP_OCO3_EO1_DOWN_S2 ;
        public static bool EURGBP_OCO3_EO2_DOWN_S2 ;
        public static bool EURGBP_OCO3_EO3_DOWN_S2 ;
        public static bool EURGBP_OCO3_EO4_DOWN_S2 ;
        public static bool EURGBP_OCO3_EO5_DOWN_S2 ;
        public static bool EURGBP_OCO3_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_DOWN_S2> EURGBP_OOFE_OCO3_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_DOWN_S2> EURGBP_OOFE_OCO3_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_DOWN_S2> EURGBP_OOFE_OCO3_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_DOWN_S2> EURGBP_OOFE_OCO3_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_DOWN_S2> EURGBP_OOFE_OCO3_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO3_DOWN_S2> EURGBP_OOFE_OCO3_DOWN_S2_6 ;
        
        public static EURGBP_OCO3_DOWN_S2 EURGBP_PFO_OCO3_DOWN_S2_1 ;
        public static EURGBP_OCO3_DOWN_S2 EURGBP_PFO_OCO3_DOWN_S2_2 ;
        public static EURGBP_OCO3_DOWN_S2 EURGBP_PFO_OCO3_DOWN_S2_3 ;
        public static EURGBP_OCO3_DOWN_S2 EURGBP_PFO_OCO3_DOWN_S2_4 ;
        public static EURGBP_OCO3_DOWN_S2 EURGBP_PFO_OCO3_DOWN_S2_5 ;
        public static EURGBP_OCO3_DOWN_S2 EURGBP_PFO_OCO3_DOWN_S2_6 ;
        
        public static List<EURGBP_OCO3_DOWN_S2> EURGBP_DOWN_S2_OCO3Sets1 = new List<EURGBP_OCO3_DOWN_S2>();
        public static List<EURGBP_OCO3_DOWN_S2> EURGBP_DOWN_S2_OCO3Sets2 = new List<EURGBP_OCO3_DOWN_S2>();
        public static List<EURGBP_OCO3_DOWN_S2> EURGBP_DOWN_S2_OCO3Sets3 = new List<EURGBP_OCO3_DOWN_S2>();
        public static List<EURGBP_OCO3_DOWN_S2> EURGBP_DOWN_S2_OCO3Sets4 = new List<EURGBP_OCO3_DOWN_S2>();
        public static List<EURGBP_OCO3_DOWN_S2> EURGBP_DOWN_S2_OCO3Sets5 = new List<EURGBP_OCO3_DOWN_S2>();
        public static List<EURGBP_OCO3_DOWN_S2> EURGBP_DOWN_S2_OCO3Sets6 = new List<EURGBP_OCO3_DOWN_S2>();
        
        public static bool EURGBP_OCO3_DOWN_S2_IsReady = true;
        public static bool EURGBP_OCO3_DOWN_S2_Monthly_IsReady = true;

        
        //oco4 up
        public static OrderTicket EURGBP_OCO4_MO1_UP_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO2_UP_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO3_UP_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO4_UP_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO5_UP_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO6_UP_S2 ;
    	
    	public static int EURGBP_OCO4_EO1_UP_S2_ID ;
        public static int EURGBP_OCO4_EO2_UP_S2_ID ;
        public static int EURGBP_OCO4_EO3_UP_S2_ID ;
        public static int EURGBP_OCO4_EO4_UP_S2_ID ;
        public static int EURGBP_OCO4_EO5_UP_S2_ID ;
        public static int EURGBP_OCO4_EO6_UP_S2_ID ;
        
        public static bool EURGBP_OCO4_EO1_UP_S2 ;
        public static bool EURGBP_OCO4_EO2_UP_S2 ;
        public static bool EURGBP_OCO4_EO3_UP_S2 ;
        public static bool EURGBP_OCO4_EO4_UP_S2 ;
        public static bool EURGBP_OCO4_EO5_UP_S2 ;
        public static bool EURGBP_OCO4_EO6_UP_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_UP_S2> EURGBP_OOFE_OCO4_UP_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_UP_S2> EURGBP_OOFE_OCO4_UP_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_UP_S2> EURGBP_OOFE_OCO4_UP_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_UP_S2> EURGBP_OOFE_OCO4_UP_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_UP_S2> EURGBP_OOFE_OCO4_UP_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_UP_S2> EURGBP_OOFE_OCO4_UP_S2_6 ;
        
        public static EURGBP_OCO4_UP_S2 EURGBP_PFO_OCO4_UP_S2_1 ;
        public static EURGBP_OCO4_UP_S2 EURGBP_PFO_OCO4_UP_S2_2 ;
        public static EURGBP_OCO4_UP_S2 EURGBP_PFO_OCO4_UP_S2_3 ;
        public static EURGBP_OCO4_UP_S2 EURGBP_PFO_OCO4_UP_S2_4 ;
        public static EURGBP_OCO4_UP_S2 EURGBP_PFO_OCO4_UP_S2_5 ;
        public static EURGBP_OCO4_UP_S2 EURGBP_PFO_OCO4_UP_S2_6 ;
        
        public static List<EURGBP_OCO4_UP_S2> EURGBP_UP_S2_OCO4Sets1 = new List<EURGBP_OCO4_UP_S2>();
        public static List<EURGBP_OCO4_UP_S2> EURGBP_UP_S2_OCO4Sets2 = new List<EURGBP_OCO4_UP_S2>();
        public static List<EURGBP_OCO4_UP_S2> EURGBP_UP_S2_OCO4Sets3 = new List<EURGBP_OCO4_UP_S2>();
        public static List<EURGBP_OCO4_UP_S2> EURGBP_UP_S2_OCO4Sets4 = new List<EURGBP_OCO4_UP_S2>();
        public static List<EURGBP_OCO4_UP_S2> EURGBP_UP_S2_OCO4Sets5 = new List<EURGBP_OCO4_UP_S2>();
        public static List<EURGBP_OCO4_UP_S2> EURGBP_UP_S2_OCO4Sets6 = new List<EURGBP_OCO4_UP_S2>();
        
        public static bool EURGBP_OCO4_UP_S2_IsReady = true;
        public static bool EURGBP_OCO4_UP_S2_Monthly_IsReady = true;

        
        //oco4 down
        public static OrderTicket EURGBP_OCO4_MO1_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO2_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO3_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO4_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO5_DOWN_S2 ;
    	public static OrderTicket EURGBP_OCO4_MO6_DOWN_S2 ;
    	
    	public static int EURGBP_OCO4_EO1_DOWN_S2_ID ;
        public static int EURGBP_OCO4_EO2_DOWN_S2_ID ;
        public static int EURGBP_OCO4_EO3_DOWN_S2_ID ;
        public static int EURGBP_OCO4_EO4_DOWN_S2_ID ;
        public static int EURGBP_OCO4_EO5_DOWN_S2_ID ;
        public static int EURGBP_OCO4_EO6_DOWN_S2_ID ;
        
        public static bool EURGBP_OCO4_EO1_DOWN_S2 ;
        public static bool EURGBP_OCO4_EO2_DOWN_S2 ;
        public static bool EURGBP_OCO4_EO3_DOWN_S2 ;
        public static bool EURGBP_OCO4_EO4_DOWN_S2 ;
        public static bool EURGBP_OCO4_EO5_DOWN_S2 ;
        public static bool EURGBP_OCO4_EO6_DOWN_S2 ;
        
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_DOWN_S2> EURGBP_OOFE_OCO4_DOWN_S2_1 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_DOWN_S2> EURGBP_OOFE_OCO4_DOWN_S2_2 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_DOWN_S2> EURGBP_OOFE_OCO4_DOWN_S2_3 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_DOWN_S2> EURGBP_OOFE_OCO4_DOWN_S2_4 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_DOWN_S2> EURGBP_OOFE_OCO4_DOWN_S2_5 ;
        public static Func<QCAlgorithm, string, decimal, decimal, EURGBP_OCO4_DOWN_S2> EURGBP_OOFE_OCO4_DOWN_S2_6 ;
        
        public static EURGBP_OCO4_DOWN_S2 EURGBP_PFO_OCO4_DOWN_S2_1 ;
        public static EURGBP_OCO4_DOWN_S2 EURGBP_PFO_OCO4_DOWN_S2_2 ;
        public static EURGBP_OCO4_DOWN_S2 EURGBP_PFO_OCO4_DOWN_S2_3 ;
        public static EURGBP_OCO4_DOWN_S2 EURGBP_PFO_OCO4_DOWN_S2_4 ;
        public static EURGBP_OCO4_DOWN_S2 EURGBP_PFO_OCO4_DOWN_S2_5 ;
        public static EURGBP_OCO4_DOWN_S2 EURGBP_PFO_OCO4_DOWN_S2_6 ;
        
        public static List<EURGBP_OCO4_DOWN_S2> EURGBP_DOWN_S2_OCO4Sets1 = new List<EURGBP_OCO4_DOWN_S2>();
        public static List<EURGBP_OCO4_DOWN_S2> EURGBP_DOWN_S2_OCO4Sets2 = new List<EURGBP_OCO4_DOWN_S2>();
        public static List<EURGBP_OCO4_DOWN_S2> EURGBP_DOWN_S2_OCO4Sets3 = new List<EURGBP_OCO4_DOWN_S2>();
        public static List<EURGBP_OCO4_DOWN_S2> EURGBP_DOWN_S2_OCO4Sets4 = new List<EURGBP_OCO4_DOWN_S2>();
        public static List<EURGBP_OCO4_DOWN_S2> EURGBP_DOWN_S2_OCO4Sets5 = new List<EURGBP_OCO4_DOWN_S2>();
        public static List<EURGBP_OCO4_DOWN_S2> EURGBP_DOWN_S2_OCO4Sets6 = new List<EURGBP_OCO4_DOWN_S2>();
        
        public static bool EURGBP_OCO4_DOWN_S2_IsReady = true;
        public static bool EURGBP_OCO4_DOWN_S2_Monthly_IsReady = true;

        
        
////////////////////////////
		public static decimal EURGBP_UP_S2_SL {get; set;}
		public static decimal EURGBP_UP_S2_TP1 {get; set;}
		public static decimal EURGBP_UP_S2_TP2 {get; set;}
		public static decimal EURGBP_UP_S2_TP3 {get; set;}
		public static decimal EURGBP_UP_S2_TP4 {get; set;}
		public static decimal EURGBP_UP_S2_TP5 {get; set;}
		public static decimal EURGBP_UP_S2_TP6 {get; set;}
		
		public static decimal EURGBP_DOWN_S2_SL {get; set;}
		public static decimal EURGBP_DOWN_S2_TP1 {get; set;}
		public static decimal EURGBP_DOWN_S2_TP2 {get; set;}
		public static decimal EURGBP_DOWN_S2_TP3 {get; set;}
		public static decimal EURGBP_DOWN_S2_TP4 {get; set;}
		public static decimal EURGBP_DOWN_S2_TP5 {get; set;}
		public static decimal EURGBP_DOWN_S2_TP6 {get; set;}

        public static bool EURGBP_Signal_Condition_UP_1 ;
        public static bool EURGBP_Signal_Condition_UP_2 ;
        public static bool EURGBP_Signal_Condition_UP_3 ;
        public static bool EURGBP_Signal_Condition_DOWN_S2 ;
        
        public static int EURGBP_UP_S2_OCO_DELAY_7DAY = 10080;
        public static int EURGBP_UP_S2_OCOM_DELAY_DAY = 4320;
		public static int EURGBP_UP_S2_OCOT_DELAY_DAY = 2880;
		public static int EURGBP_UP_S2_OCOW_DELAY_DAY = 1440;
		public static int EURGBP_UP_S2_OCOTH_DELAY_DAY = 720;
		
		public static int EURGBP_DOWN_S2_OCO_DELAY_7DAY = 10080;
		public static int EURGBP_DOWN_S2_OCOM_DELAY_DAY = 4320;
		public static int EURGBP_DOWN_S2_OCOT_DELAY_DAY = 2880;
		public static int EURGBP_DOWN_S2_OCOW_DELAY_DAY = 1440;
		public static int EURGBP_DOWN_S2_OCOTH_DELAY_DAY = 720;
		
		public static bool DOWR_EURGBP_UP_S2 ;
        public static bool DOWM_EURGBP_UP_S2 ;
        public static bool DOWT_EURGBP_UP_S2 ;
        public static bool DOWW_EURGBP_UP_S2 ;
        public static bool DOWTH_EURGBP_UP_S2 ;
        
		public static bool DOWR_EURGBP_DOWN_S2 ;
        public static bool DOWM_EURGBP_DOWN_S2 ;
        public static bool DOWT_EURGBP_DOWN_S2 ;
        public static bool DOWW_EURGBP_DOWN_S2 ;
        public static bool DOWTH_EURGBP_DOWN_S2 ;
        
        
		public static int EURGBP_quantity_UP_S2 ;
		public static int EURGBP_quantity_SL_UP_S2 ;
		public static int EURGBP_quantity_TP1_UP_S2 ;
		public static int EURGBP_quantity_TP2_UP_S2 ;
		public static int EURGBP_quantity_TP3_UP_S2 ;
		public static int EURGBP_quantity_TP4_UP_S2 ;
		public static int EURGBP_quantity_TP5_UP_S2;
		public static int EURGBP_quantity_TP6_UP_S2 ;
		
		public static int EURGBP_quantity_DOWN_S2 ;
		public static int EURGBP_quantity_SL_DOWN_S2 ;
		public static int EURGBP_quantity_TP1_DOWN_S2 ;
		public static int EURGBP_quantity_TP2_DOWN_S2 ;
		public static int EURGBP_quantity_TP3_DOWN_S2 ;
		public static int EURGBP_quantity_TP4_DOWN_S2 ;
		public static int EURGBP_quantity_TP5_DOWN_S2;
		public static int EURGBP_quantity_TP6_DOWN_S2 ;
    }
}
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct EURUSD_OCO1_DOWN_S2
    {
        public EURUSD_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 =="TP1_EURUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD 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 =="TP1_EURUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURUSD_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD 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 EURUSD_OCO1_UP_S2
    {
        public EURUSD_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 =="TP1_EURUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD 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 =="TP1_EURUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURUSD_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURUSD 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 EURUSD_OCO2_DOWN_S2
    {
        public EURUSD_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 =="TP1_EURUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD 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 =="TP1_EURUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURUSD_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD 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 EURUSD_OCO2_UP_S2
    {
        public EURUSD_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 =="TP1_EURUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD 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 =="TP1_EURUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURUSD_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURUSD 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 EURUSD_OCO3_DOWN_S2
    {
        public EURUSD_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 =="TP1_EURUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD 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 =="TP1_EURUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURUSD_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD 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 EURUSD_OCO3_UP_S2
    {
        public EURUSD_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 =="TP1_EURUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD 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 =="TP1_EURUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURUSD_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURUSD 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 EURUSD_OCO4_DOWN_S2
    {
        public EURUSD_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 =="TP1_EURUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD 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 =="TP1_EURUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURUSD_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD 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 EURUSD_OCO4_UP_S2
    {
        public EURUSD_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 =="TP1_EURUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD 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 =="TP1_EURUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURUSD_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURUSD_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURUSD 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.Linq;
using System.Collections.Generic;
using QuantConnect.Orders;
using NodaTime;
using NodaTime.TimeZones;

namespace QuantConnect 
{
    public struct EURGBP_OCO1_DOWN_S2
    {
        public EURGBP_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 =="TP1_EURGBP_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURGBP_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURGBP_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURGBP_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURGBP_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP 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 =="TP1_EURGBP_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURGBP_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURGBP_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURGBP_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_DOWN_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURGBP_DOWN_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP 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 EURGBP_OCO1_UP_S2
    {
        public EURGBP_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 =="TP1_EURGBP_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURGBP_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURGBP_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURGBP_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURGBP_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP 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 =="TP1_EURGBP_UP_S2_OCO1" || orderTicket.Tag =="SL_TP1_EURGBP_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_UP_S2_OCO1" || orderTicket.Tag =="SL_TP2_EURGBP_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_UP_S2_OCO1" || orderTicket.Tag =="SL_TP3_EURGBP_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_UP_S2_OCO1" || orderTicket.Tag =="SL_TP4_EURGBP_UP_S2_OCO1")
                	{
                    	orderTicket.Cancel("EURGBP 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 EURGBP_OCO2_DOWN_S2
    {
        public EURGBP_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 =="TP1_EURGBP_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURGBP_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO2 CANCEL 1 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURGBP_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO2 CANCEL 2 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURGBP_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO2 CANCEL 3 DOWN S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURGBP_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP 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 =="TP1_EURGBP_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURGBP_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURGBP_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURGBP_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO1 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_DOWN_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURGBP_DOWN_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP 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 EURGBP_OCO2_UP_S2
    {
        public EURGBP_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 =="TP1_EURGBP_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURGBP_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO2 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURGBP_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO2 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURGBP_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO2 CANCEL 3 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURGBP_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP 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 =="TP1_EURGBP_UP_S2_OCO2" || orderTicket.Tag =="SL_TP1_EURGBP_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO2 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_UP_S2_OCO2" || orderTicket.Tag =="SL_TP2_EURGBP_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO2 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_UP_S2_OCO2" || orderTicket.Tag =="SL_TP3_EURGBP_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP OCO2 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_UP_S2_OCO2" || orderTicket.Tag =="SL_TP4_EURGBP_UP_S2_OCO2")
                	{
                    	orderTicket.Cancel("EURGBP 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 EURGBP_OCO3_DOWN_S2
    {
        public EURGBP_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 =="TP1_EURGBP_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURGBP_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURGBP_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURGBP_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURGBP_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP 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 =="TP1_EURGBP_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURGBP_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURGBP_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURGBP_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_DOWN_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURGBP_DOWN_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP 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 EURGBP_OCO3_UP_S2
    {
        public EURGBP_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 =="TP1_EURGBP_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURGBP_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 1 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURGBP_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 2 UP S2");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURGBP_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURGBP_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP 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 =="TP1_EURGBP_UP_S2_OCO3" || orderTicket.Tag =="SL_TP1_EURGBP_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_UP_S2_OCO3" || orderTicket.Tag =="SL_TP2_EURGBP_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_UP_S2_OCO3" || orderTicket.Tag =="SL_TP3_EURGBP_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP OCO3 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_UP_S2_OCO3" || orderTicket.Tag =="SL_TP4_EURGBP_UP_S2_OCO3")
                	{
                    	orderTicket.Cancel("EURGBP 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 EURGBP_OCO4_DOWN_S2
    {
        public EURGBP_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 =="TP1_EURGBP_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURGBP_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 1 DOWN S2");
                		
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURGBP_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 2 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURGBP_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 3 DOWN S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURGBP_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP 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 =="TP1_EURGBP_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURGBP_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 1 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURGBP_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 2 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURGBP_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 3 DOWN S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_DOWN_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURGBP_DOWN_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP 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 EURGBP_OCO4_UP_S2
    {
        public EURGBP_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 =="TP1_EURGBP_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURGBP_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 1 UP S2");
                    	
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURGBP_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 2 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURGBP_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 3 UP S2");

                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURGBP_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP 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 =="TP1_EURGBP_UP_S2_OCO4" || orderTicket.Tag =="SL_TP1_EURGBP_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 1 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP2_EURGBP_UP_S2_OCO4" || orderTicket.Tag =="SL_TP2_EURGBP_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 2 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP3_EURGBP_UP_S2_OCO4" || orderTicket.Tag =="SL_TP3_EURGBP_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP OCO4 CANCEL 3 UP S2 TIMEOUT");
                	}
                	
                	if(orderTicket.Tag =="TP4_EURGBP_UP_S2_OCO4" || orderTicket.Tag =="SL_TP4_EURGBP_UP_S2_OCO4")
                	{
                    	orderTicket.Cancel("EURGBP 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURGBP_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURGBP_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("EURGBP_DOWN_S2_OCO1")))
			{
				Base.EURGBP_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURGBP_DOWN_S2_OCO2")))
			{
				Base.EURGBP_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURGBP_DOWN_S2_OCO3")))
			{
				Base.EURGBP_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURGBP_DOWN_S2_OCO4")))
			{
				Base.EURGBP_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURGBP_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.EURGBP_OCO1_EO1_DOWN_S2)
	                Base.EURGBP_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURGBP_OCO1_EO2_DOWN_S2)
	                Base.EURGBP_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO1_EO3_DOWN_S2)
	                Base.EURGBP_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO1_EO4_DOWN_S2)
	                Base.EURGBP_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO1_EO5_DOWN_S2)
	                Base.EURGBP_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO1_EO6_DOWN_S2)
	                Base.EURGBP_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURGBP_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURGBP_OCO1S1_DOWN_S2 = 0;
		                for (; EURGBP_OCO1S1_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets1.Count; EURGBP_OCO1S1_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO1Sets1[EURGBP_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO1Sets1[EURGBP_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.EURGBP_DOWN_S2_OCO1Sets1.Clear();
		                        EURGBP_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURGBP_OCO1S2_DOWN_S2 = 0;
		                for (; EURGBP_OCO1S2_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets2.Count; EURGBP_OCO1S2_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO1Sets2[EURGBP_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO1Sets2[EURGBP_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.EURGBP_DOWN_S2_OCO1Sets2.Clear();
		                        EURGBP_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO1S3_DOWN_S2 = 0;
		                for (; EURGBP_OCO1S3_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets3.Count; EURGBP_OCO1S3_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO1Sets3[EURGBP_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO1Sets3[EURGBP_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.EURGBP_DOWN_S2_OCO1Sets3.Clear();
		                        EURGBP_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO1S4_DOWN_S2 = 0;
		                for (; EURGBP_OCO1S4_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets4.Count; EURGBP_OCO1S4_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO1Sets4[EURGBP_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO1Sets4[EURGBP_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.EURGBP_DOWN_S2_OCO1Sets4.Clear();
		                        EURGBP_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO1S5_DOWN_S2 = 0;
		                for (; EURGBP_OCO1S5_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets5.Count; EURGBP_OCO1S5_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO1Sets5[EURGBP_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO1Sets5[EURGBP_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.EURGBP_DOWN_S2_OCO1Sets5.Clear();
		                        EURGBP_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO1S6_DOWN_S2 = 0;
		                for (; EURGBP_OCO1S6_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO1Sets6.Count; EURGBP_OCO1S6_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO1Sets6[EURGBP_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO1Sets6[EURGBP_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.EURGBP_DOWN_S2_OCO1Sets6.Clear();
		                        EURGBP_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURGBP_OCO2_EO1_DOWN_S2)
	                Base.EURGBP_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURGBP_OCO2_EO2_DOWN_S2)
	                Base.EURGBP_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO2_EO3_DOWN_S2)
	                Base.EURGBP_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO2_EO4_DOWN_S2)
	                Base.EURGBP_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO2_EO5_DOWN_S2)
	                Base.EURGBP_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO2_EO6_DOWN_S2)
	                Base.EURGBP_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURGBP_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURGBP_OCO2S1_DOWN_S2 = 0;
		                for (; EURGBP_OCO2S1_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets1.Count; EURGBP_OCO2S1_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO2Sets1[EURGBP_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO2Sets1[EURGBP_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.EURGBP_DOWN_S2_OCO2Sets1.Clear();
		                        EURGBP_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURGBP_OCO2S2_DOWN_S2 = 0;
		                for (; EURGBP_OCO2S2_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets2.Count; EURGBP_OCO2S2_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO2Sets2[EURGBP_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO2Sets2[EURGBP_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.EURGBP_DOWN_S2_OCO2Sets2.Clear();
		                        EURGBP_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO2S3_DOWN_S2 = 0;
		                for (; EURGBP_OCO2S3_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets3.Count; EURGBP_OCO2S3_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO2Sets3[EURGBP_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO2Sets3[EURGBP_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.EURGBP_DOWN_S2_OCO2Sets3.Clear();
		                        EURGBP_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO2S4_DOWN_S2 = 0;
		                for (; EURGBP_OCO2S4_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets4.Count; EURGBP_OCO2S4_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO2Sets4[EURGBP_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO2Sets4[EURGBP_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.EURGBP_DOWN_S2_OCO2Sets4.Clear();
		                        EURGBP_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO2S5_DOWN_S2 = 0;
		                for (; EURGBP_OCO2S5_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets5.Count; EURGBP_OCO2S5_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO2Sets5[EURGBP_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO2Sets5[EURGBP_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.EURGBP_DOWN_S2_OCO2Sets5.Clear();
		                        EURGBP_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO2S6_DOWN_S2 = 0;
		                for (; EURGBP_OCO2S6_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO2Sets6.Count; EURGBP_OCO2S6_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO2Sets6[EURGBP_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO2Sets6[EURGBP_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.EURGBP_DOWN_S2_OCO2Sets6.Clear();
		                        EURGBP_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURGBP_OCO3_EO1_DOWN_S2)
	                Base.EURGBP_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURGBP_OCO3_EO2_DOWN_S2)
	                Base.EURGBP_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO3_EO3_DOWN_S2)
	                Base.EURGBP_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO3_EO4_DOWN_S2)
	                Base.EURGBP_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO3_EO5_DOWN_S2)
	                Base.EURGBP_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO3_EO6_DOWN_S2)
	                Base.EURGBP_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURGBP_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURGBP_OCO3S1_DOWN_S2 = 0;
		                for (; EURGBP_OCO3S1_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets1.Count; EURGBP_OCO3S1_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO3Sets1[EURGBP_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO3Sets1[EURGBP_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.EURGBP_DOWN_S2_OCO3Sets1.Clear();
		                        EURGBP_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURGBP_OCO3S2_DOWN_S2 = 0;
		                for (; EURGBP_OCO3S2_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets2.Count; EURGBP_OCO3S2_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO3Sets2[EURGBP_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO3Sets2[EURGBP_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.EURGBP_DOWN_S2_OCO3Sets2.Clear();
		                        EURGBP_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO3S3_DOWN_S2 = 0;
		                for (; EURGBP_OCO3S3_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets3.Count; EURGBP_OCO3S3_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO3Sets3[EURGBP_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO3Sets3[EURGBP_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.EURGBP_DOWN_S2_OCO3Sets3.Clear();
		                        EURGBP_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO3S4_DOWN_S2 = 0;
		                for (; EURGBP_OCO3S4_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets4.Count; EURGBP_OCO3S4_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO3Sets4[EURGBP_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO3Sets4[EURGBP_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.EURGBP_DOWN_S2_OCO3Sets4.Clear();
		                        EURGBP_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO3S5_DOWN_S2 = 0;
		                for (; EURGBP_OCO3S5_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets5.Count; EURGBP_OCO3S5_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO3Sets5[EURGBP_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO3Sets5[EURGBP_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.EURGBP_DOWN_S2_OCO3Sets5.Clear();
		                        EURGBP_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO3S6_DOWN_S2 = 0;
		                for (; EURGBP_OCO3S6_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO3Sets6.Count; EURGBP_OCO3S6_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO3Sets6[EURGBP_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO3Sets6[EURGBP_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.EURGBP_DOWN_S2_OCO3Sets6.Clear();
		                        EURGBP_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURGBP_OCO4_EO1_DOWN_S2)
	                Base.EURGBP_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURGBP_OCO4_EO2_DOWN_S2)
	                Base.EURGBP_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO4_EO3_DOWN_S2)
	                Base.EURGBP_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO4_EO4_DOWN_S2)
	                Base.EURGBP_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO4_EO5_DOWN_S2)
	                Base.EURGBP_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURGBP_OCO4_EO6_DOWN_S2)
	                Base.EURGBP_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURGBP_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURGBP_OCO4S1_DOWN_S2 = 0;
		                for (; EURGBP_OCO4S1_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets1.Count; EURGBP_OCO4S1_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO4Sets1[EURGBP_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO4Sets1[EURGBP_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.EURGBP_DOWN_S2_OCO4Sets1.Clear();
		                        EURGBP_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURGBP_OCO4S2_DOWN_S2 = 0;
		                for (; EURGBP_OCO4S2_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets2.Count; EURGBP_OCO4S2_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO4Sets2[EURGBP_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO4Sets2[EURGBP_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.EURGBP_DOWN_S2_OCO4Sets2.Clear();
		                        EURGBP_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO4S3_DOWN_S2 = 0;
		                for (; EURGBP_OCO4S3_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets3.Count; EURGBP_OCO4S3_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO4Sets3[EURGBP_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO4Sets3[EURGBP_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.EURGBP_DOWN_S2_OCO4Sets3.Clear();
		                        EURGBP_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURGBP_OCO4S4_DOWN_S2 = 0;
		                for (; EURGBP_OCO4S4_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets4.Count; EURGBP_OCO4S4_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO4Sets4[EURGBP_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO4Sets4[EURGBP_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.EURGBP_DOWN_S2_OCO4Sets4.Clear();
		                        EURGBP_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO4S5_DOWN_S2 = 0;
		                for (; EURGBP_OCO4S5_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets5.Count; EURGBP_OCO4S5_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO4Sets5[EURGBP_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO4Sets5[EURGBP_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.EURGBP_DOWN_S2_OCO4Sets5.Clear();
		                        EURGBP_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURGBP_OCO4S6_DOWN_S2 = 0;
		                for (; EURGBP_OCO4S6_DOWN_S2 < Base.EURGBP_DOWN_S2_OCO4Sets6.Count; EURGBP_OCO4S6_DOWN_S2++)
		                    if (Base.EURGBP_DOWN_S2_OCO4Sets6[EURGBP_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURGBP_DOWN_S2_OCO4Sets6[EURGBP_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURGBP", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURGBP", order.Quantity, false, "EURGBP_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.EURGBP_DOWN_S2_OCO4Sets6.Clear();
		                        EURGBP_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();
	            	}
	            	
					DOWM_EURGBP_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURGBP_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURGBP_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURGBP_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURGBP_DOWN_S2 = DOWM_EURGBP_DOWN_S2 || DOWT_EURGBP_DOWN_S2 || DOWW_EURGBP_DOWN_S2 || DOWTH_EURGBP_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURGBP"))
	            	{
	            		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.EURGBP_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.EURGBP_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.EURGBP_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.EURGBP_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.EURGBP_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURGBP_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURGBP_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURGBP_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURGBP_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURGBP_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURGBP_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURGBP_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	EURGBP_Signal_Condition_DOWN_S2 =  
	                									(
															pricesM_BID_High[0] - pricesM_BID_Open[0] > prices_BID_Close[0] * 0.00001m &&
		                										pricesM_BID_High[1] - pricesM_BID_Open[1] > prices_BID_Close[0] * 0.00001m &&
		                										
		                										pricesM_ASK_Open[0] - pricesM_BID_Close[0] > prices_BID_Close[0] * 0.0001m &&
		                										pricesM_ASK_Open[1] - pricesM_BID_Close[1] > prices_BID_Close[0] * 0.01m &&
	
		                										prices_ASK_High[0] > pricesM_ASK_High[0] &&
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < 0.001m
	                									);
	                									
	                    EURGBP_DOWN_S2_SL  =  0.02m;
	                    EURGBP_DOWN_S2_TP1 =  0.0025m;
	                    EURGBP_DOWN_S2_TP2 =  EURGBP_DOWN_S2_SL * 0;
	                    EURGBP_DOWN_S2_TP3 =  EURGBP_DOWN_S2_SL * 0;
	                    EURGBP_DOWN_S2_TP4 =  EURGBP_DOWN_S2_SL * 0;
	                    EURGBP_DOWN_S2_TP5 =  EURGBP_DOWN_S2_SL * 0;
	                    EURGBP_DOWN_S2_TP6 =  EURGBP_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURGBP_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURGBP_quantity_SL_DOWN_S2 = EURGBP_quantity_DOWN_S2;
	                    EURGBP_quantity_TP1_DOWN_S2 = (int)Math.Floor(EURGBP_quantity_DOWN_S2 * 1m);
	                    EURGBP_quantity_TP2_DOWN_S2 = (int)Math.Floor(EURGBP_quantity_TP1_DOWN_S2 * 0m);
	                    EURGBP_quantity_TP3_DOWN_S2 = (int)Math.Floor(EURGBP_quantity_TP2_DOWN_S2 * 0m);
	                    EURGBP_quantity_TP4_DOWN_S2 = (int)Math.Floor(EURGBP_quantity_TP3_DOWN_S2 * 0m);
	                    EURGBP_quantity_TP5_DOWN_S2 = (int)Math.Floor(EURGBP_quantity_TP4_DOWN_S2 * 0m);
	                    EURGBP_quantity_TP6_DOWN_S2 = (int)Math.Floor(EURGBP_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (EURGBP_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURGBP_DOWN_S2 && 
	                    Base.EURGBP_OCO1_DOWN_S2_IsReady == true &&
	                    Base.EURGBP_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURGBP_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP1_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP1_OCO1");
	                         Base.EURGBP_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.EURGBP_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP2_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP2_OCO1");
	                         Base.EURGBP_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.EURGBP_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP3_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP3_OCO1");
	                         Base.EURGBP_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.EURGBP_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP4_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP4_OCO1");
	                         Base.EURGBP_OCO1_EO4_DOWN_S2 = false;

							Base.EURGBP_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.EURGBP_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (EURGBP_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURGBP_DOWN_S2 && 
	                    Base.EURGBP_OCO2_DOWN_S2_IsReady == true &&
	                    Base.EURGBP_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURGBP_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURGBP_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP1_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP1_OCO2");
	                         Base.EURGBP_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.EURGBP_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP2_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP2_OCO2");
	                         Base.EURGBP_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.EURGBP_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP3_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP3_OCO2");
	                         Base.EURGBP_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.EURGBP_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP4_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP4_OCO2");
	                         Base.EURGBP_OCO2_EO4_DOWN_S2 = false;

							Base.EURGBP_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.EURGBP_OCO2_DOWN_S2_IsReady == false && Base.EURGBP_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (EURGBP_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURGBP_DOWN_S2 &&
	                    Base.EURGBP_OCO3_DOWN_S2_IsReady == true &&
	                    Base.EURGBP_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURGBP_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURGBP_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURGBP_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP1_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP1_OCO3");
	                         Base.EURGBP_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.EURGBP_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP2_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP2_OCO3");
	                         Base.EURGBP_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.EURGBP_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP3_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP3_OCO3");
	                         Base.EURGBP_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.EURGBP_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP4_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP4_OCO3");
	                         Base.EURGBP_OCO3_EO4_DOWN_S2 = false;

							Base.EURGBP_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.EURGBP_OCO3_DOWN_S2_IsReady == false && Base.EURGBP_OCO2_DOWN_S2_IsReady == false && Base.EURGBP_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (EURGBP_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURGBP_DOWN_S2 && 
	                    Base.EURGBP_OCO4_DOWN_S2_IsReady == true &&
	                    Base.EURGBP_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURGBP_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURGBP_OCO3_DOWN_S2_IsReady == false &&
	                    Base.EURGBP_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURGBP_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP1_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP1_OCO4");
	                         Base.EURGBP_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.EURGBP_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP2_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP2_OCO4");
	                         Base.EURGBP_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.EURGBP_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP3_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP3_OCO4");
	                         Base.EURGBP_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.EURGBP_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURGBP_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURGBP_quantity_TP4_DOWN_S2, false,"EURGBP_DOWN_S2_Entry_TP4_OCO4");
	                         Base.EURGBP_OCO4_EO4_DOWN_S2 = false;

							Base.EURGBP_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.EURGBP_OCO4_DOWN_S2_IsReady == false && Base.EURGBP_OCO3_DOWN_S2_IsReady == false && Base.EURGBP_OCO2_DOWN_S2_IsReady == false && Base.EURGBP_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURNZD_UP_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURNZD_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(x=>x.Tag.Contains("EURNZD_UP_S2_OCO1")))
			{
				Base.EURNZD_OCO1_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURNZD_UP_S2_OCO2")))
			{
				Base.EURNZD_OCO2_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURNZD_UP_S2_OCO3")))
			{
				Base.EURNZD_OCO3_UP_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURNZD_UP_S2_OCO4")))
			{
				Base.EURNZD_OCO4_UP_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURNZD_UP_S2")))
			{
			foreach (var order in open_orders)
		    {
				if (Base.EURNZD_OCO1_EO1_UP_S2)
	                Base.EURNZD_OCO1_EO1_UP_S2_ID = order.Id;
	            if (Base.EURNZD_OCO1_EO2_UP_S2)
	                Base.EURNZD_OCO1_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO1_EO3_UP_S2)
	                Base.EURNZD_OCO1_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO1_EO4_UP_S2)
	                Base.EURNZD_OCO1_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO1_EO5_UP_S2)
	                Base.EURNZD_OCO1_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO1_EO6_UP_S2)
	                Base.EURNZD_OCO1_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURNZD_OCO1S1_UP_S2 = 0;
		                for (; EURNZD_OCO1S1_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets1.Count; EURNZD_OCO1S1_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO1Sets1[EURNZD_OCO1S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO1Sets1[EURNZD_OCO1S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_1__Time out_OCO1");
		                        Base.EURNZD_UP_S2_OCO1Sets1.Clear();
		                        EURNZD_OCO1S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURNZD_OCO1S2_UP_S2 = 0;
		                for (; EURNZD_OCO1S2_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets2.Count; EURNZD_OCO1S2_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO1Sets2[EURNZD_OCO1S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO1Sets2[EURNZD_OCO1S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_2__Time out_OCO1");
		                        Base.EURNZD_UP_S2_OCO1Sets2.Clear();
		                        EURNZD_OCO1S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO1S3_UP_S2 = 0;
		                for (; EURNZD_OCO1S3_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets3.Count; EURNZD_OCO1S3_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO1Sets3[EURNZD_OCO1S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO1Sets3[EURNZD_OCO1S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_3__Time out_OCO1");
		                        Base.EURNZD_UP_S2_OCO1Sets3.Clear();
		                        EURNZD_OCO1S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO1S4_UP_S2 = 0;
		                for (; EURNZD_OCO1S4_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets4.Count; EURNZD_OCO1S4_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO1Sets4[EURNZD_OCO1S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO1Sets4[EURNZD_OCO1S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_4__Time out_OCO1");
		                        Base.EURNZD_UP_S2_OCO1Sets4.Clear();
		                        EURNZD_OCO1S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO1S5_UP_S2 = 0;
		                for (; EURNZD_OCO1S5_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets5.Count; EURNZD_OCO1S5_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO1Sets5[EURNZD_OCO1S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO1Sets5[EURNZD_OCO1S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_5__Time out_OCO1");
		                        Base.EURNZD_UP_S2_OCO1Sets5.Clear();
		                        EURNZD_OCO1S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO1S6_UP_S2 = 0;
		                for (; EURNZD_OCO1S6_UP_S2 < Base.EURNZD_UP_S2_OCO1Sets6.Count; EURNZD_OCO1S6_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO1Sets6[EURNZD_OCO1S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO1Sets6[EURNZD_OCO1S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_6__Time out_OCO1");
		                        Base.EURNZD_UP_S2_OCO1Sets6.Clear();
		                        EURNZD_OCO1S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURNZD_OCO2_EO1_UP_S2)
                	Base.EURNZD_OCO2_EO1_UP_S2_ID = order.Id;
	            if (Base.EURNZD_OCO2_EO2_UP_S2)
	                Base.EURNZD_OCO2_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO2_EO3_UP_S2)
	                Base.EURNZD_OCO2_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO2_EO4_UP_S2)
	                Base.EURNZD_OCO2_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO2_EO5_UP_S2)
	                Base.EURNZD_OCO2_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO2_EO6_UP_S2)
	                Base.EURNZD_OCO2_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURNZD_OCO2S1_UP_S2 = 0;
		                for (; EURNZD_OCO2S1_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets1.Count; EURNZD_OCO2S1_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO2Sets1[EURNZD_OCO2S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO2Sets1[EURNZD_OCO2S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_1__Time out_OCO2");
		                        Base.EURNZD_UP_S2_OCO2Sets1.Clear();
		                        EURNZD_OCO2S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURNZD_OCO2S2_UP_S2 = 0;
		                for (; EURNZD_OCO2S2_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets2.Count; EURNZD_OCO2S2_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO2Sets2[EURNZD_OCO2S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO2Sets2[EURNZD_OCO2S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_2__Time out_OCO2");
		                        Base.EURNZD_UP_S2_OCO2Sets2.Clear();
		                        EURNZD_OCO2S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO2S3_UP_S2 = 0;
		                for (; EURNZD_OCO2S3_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets3.Count; EURNZD_OCO2S3_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO2Sets3[EURNZD_OCO2S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO2Sets3[EURNZD_OCO2S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_3__Time out_OCO2");
		                        Base.EURNZD_UP_S2_OCO2Sets3.Clear();
		                        EURNZD_OCO2S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO2S4_UP_S2 = 0;
		                for (; EURNZD_OCO2S4_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets4.Count; EURNZD_OCO2S4_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO2Sets4[EURNZD_OCO2S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO2Sets4[EURNZD_OCO2S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_4__Time out_OCO2");
		                        Base.EURNZD_UP_S2_OCO2Sets4.Clear();
		                        EURNZD_OCO2S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO2S5_UP_S2 = 0;
		                for (; EURNZD_OCO2S5_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets5.Count; EURNZD_OCO2S5_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO2Sets5[EURNZD_OCO2S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO2Sets5[EURNZD_OCO2S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_5__Time out_OCO2");
		                        Base.EURNZD_UP_S2_OCO2Sets5.Clear();
		                        EURNZD_OCO2S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO2S6_UP_S2 = 0;
		                for (; EURNZD_OCO2S6_UP_S2 < Base.EURNZD_UP_S2_OCO2Sets6.Count; EURNZD_OCO2S6_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO2Sets6[EURNZD_OCO2S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO2Sets6[EURNZD_OCO2S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_6__Time out_OCO2");
		                        Base.EURNZD_UP_S2_OCO2Sets6.Clear();
		                        EURNZD_OCO2S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
		        if (Base.EURNZD_OCO3_EO1_UP_S2)
            		Base.EURNZD_OCO3_EO1_UP_S2_ID = order.Id;
	            if (Base.EURNZD_OCO3_EO2_UP_S2)
	                Base.EURNZD_OCO3_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO3_EO3_UP_S2)
	                Base.EURNZD_OCO3_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO3_EO4_UP_S2)
	                Base.EURNZD_OCO3_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO3_EO5_UP_S2)
	                Base.EURNZD_OCO3_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO3_EO6_UP_S2)
	                Base.EURNZD_OCO3_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURNZD_OCO3S1_UP_S2 = 0;
		                for (; EURNZD_OCO3S1_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets1.Count; EURNZD_OCO3S1_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO3Sets1[EURNZD_OCO3S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO3Sets1[EURNZD_OCO3S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_1__Time out_OCO3");
		                        Base.EURNZD_UP_S2_OCO3Sets1.Clear();
		                        EURNZD_OCO3S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURNZD_OCO3S2_UP_S2 = 0;
		                for (; EURNZD_OCO3S2_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets2.Count; EURNZD_OCO3S2_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO3Sets2[EURNZD_OCO3S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO3Sets2[EURNZD_OCO3S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_2__Time out_OCO3");
		                        Base.EURNZD_UP_S2_OCO3Sets2.Clear();
		                        EURNZD_OCO3S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO3S3_UP_S2 = 0;
		                for (; EURNZD_OCO3S3_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets3.Count; EURNZD_OCO3S3_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO3Sets3[EURNZD_OCO3S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO3Sets3[EURNZD_OCO3S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_3__Time out_OCO3");
		                        Base.EURNZD_UP_S2_OCO3Sets3.Clear();
		                        EURNZD_OCO3S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO3S4_UP_S2 = 0;
		                for (; EURNZD_OCO3S4_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets4.Count; EURNZD_OCO3S4_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO3Sets4[EURNZD_OCO3S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO3Sets4[EURNZD_OCO3S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_4__Time out_OCO3");
		                        Base.EURNZD_UP_S2_OCO3Sets4.Clear();
		                        EURNZD_OCO3S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO3S5_UP_S2 = 0;
		                for (; EURNZD_OCO3S5_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets5.Count; EURNZD_OCO3S5_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO3Sets5[EURNZD_OCO3S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO3Sets5[EURNZD_OCO3S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_5__Time out_OCO3");
		                        Base.EURNZD_UP_S2_OCO3Sets5.Clear();
		                        EURNZD_OCO3S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO3S6_UP_S2 = 0;
		                for (; EURNZD_OCO3S6_UP_S2 < Base.EURNZD_UP_S2_OCO3Sets6.Count; EURNZD_OCO3S6_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO3Sets6[EURNZD_OCO3S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO3Sets6[EURNZD_OCO3S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_6__Time out_OCO3");
		                        Base.EURNZD_UP_S2_OCO3Sets6.Clear();
		                        EURNZD_OCO3S6_UP_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURNZD_OCO4_EO1_UP_S2)
            		Base.EURNZD_OCO4_EO1_UP_S2_ID = order.Id;
	            if (Base.EURNZD_OCO4_EO2_UP_S2)
	                Base.EURNZD_OCO4_EO2_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO4_EO3_UP_S2)
	                Base.EURNZD_OCO4_EO3_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO4_EO4_UP_S2)
	                Base.EURNZD_OCO4_EO4_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO4_EO5_UP_S2)
	                Base.EURNZD_OCO4_EO5_UP_S2_ID = order.Id;
	        	if (Base.EURNZD_OCO4_EO6_UP_S2)
	                Base.EURNZD_OCO4_EO6_UP_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURNZD_UP_S2_OCO_DELAY_7DAY))
			        {
			        	int EURNZD_OCO4S1_UP_S2 = 0;
		                for (; EURNZD_OCO4S1_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets1.Count; EURNZD_OCO4S1_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO4Sets1[EURNZD_OCO4S1_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO4Sets1[EURNZD_OCO4S1_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_1__Time out_OCO4");
		                        Base.EURNZD_UP_S2_OCO4Sets1.Clear();
		                        EURNZD_OCO4S1_UP_S2 = 0;
		                        break;
		                    }
		            
		                int EURNZD_OCO4S2_UP_S2 = 0;
		                for (; EURNZD_OCO4S2_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets2.Count; EURNZD_OCO4S2_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO4Sets2[EURNZD_OCO4S2_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO4Sets2[EURNZD_OCO4S2_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_2__Time out_OCO4");
		                        Base.EURNZD_UP_S2_OCO4Sets2.Clear();
		                        EURNZD_OCO4S2_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO4S3_UP_S2 = 0;
		                for (; EURNZD_OCO4S3_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets3.Count; EURNZD_OCO4S3_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO4Sets3[EURNZD_OCO4S3_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO4Sets3[EURNZD_OCO4S3_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_3__Time out_OCO4");
		                        Base.EURNZD_UP_S2_OCO4Sets3.Clear();
		                        EURNZD_OCO4S3_UP_S2 = 0;
		                        break;
		                    }
		                    
		                int EURNZD_OCO4S4_UP_S2 = 0;
		                for (; EURNZD_OCO4S4_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets4.Count; EURNZD_OCO4S4_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO4Sets4[EURNZD_OCO4S4_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO4Sets4[EURNZD_OCO4S4_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_4__Time out_OCO4");
		                        Base.EURNZD_UP_S2_OCO4Sets4.Clear();
		                        EURNZD_OCO4S4_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO4S5_UP_S2 = 0;
		                for (; EURNZD_OCO4S5_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets5.Count; EURNZD_OCO4S5_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO4Sets5[EURNZD_OCO4S5_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO4Sets5[EURNZD_OCO4S5_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_5__Time out_OCO4");
		                        Base.EURNZD_UP_S2_OCO4Sets5.Clear();
		                        EURNZD_OCO4S5_UP_S2 = 0;
		                        break;
		                    }
		                
		                int EURNZD_OCO4S6_UP_S2 = 0;
		                for (; EURNZD_OCO4S6_UP_S2 < Base.EURNZD_UP_S2_OCO4Sets6.Count; EURNZD_OCO4S6_UP_S2++)
		                    if (Base.EURNZD_UP_S2_OCO4Sets6[EURNZD_OCO4S6_UP_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURNZD_UP_S2_OCO4Sets6[EURNZD_OCO4S6_UP_S2].TimeOut();
		                        yield return Insight.Price("EURNZD", TimeSpan.FromMilliseconds(1001), InsightDirection.Down);
		                        algorithm.MarketOrder("EURNZD", order.Quantity, false, "EURNZD_UP_S2_Entry_6__Time out_OCO4");
		                        Base.EURNZD_UP_S2_OCO4Sets6.Clear();
		                        EURNZD_OCO4S6_UP_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();
	            	}
	            	
	            	DOWM_EURNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURNZD_UP_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURNZD_UP_S2 = DOWM_EURNZD_UP_S2 || DOWT_EURNZD_UP_S2 || DOWW_EURNZD_UP_S2 || DOWTH_EURNZD_UP_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURNZD"))
	            	{
	            		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.EURNZD_OCO1_UP_S2_IsReady == false ||
	                    	Base.EURNZD_OCO2_UP_S2_IsReady == false ||
	                    	Base.EURNZD_OCO3_UP_S2_IsReady == false ||
	                    	Base.EURNZD_OCO4_UP_S2_IsReady == false)
	                    {
	                    	Base.EURNZD_OCO1_UP_S2_Monthly_IsReady = false;
	                    	Base.EURNZD_OCO2_UP_S2_Monthly_IsReady = false;
	                    	Base.EURNZD_OCO3_UP_S2_Monthly_IsReady = false;
	                    	Base.EURNZD_OCO4_UP_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURNZD_OCO1_UP_S2_Monthly_IsReady = true;
                    		Base.EURNZD_OCO2_UP_S2_Monthly_IsReady = true;
                    		Base.EURNZD_OCO3_UP_S2_Monthly_IsReady = true;
                    		Base.EURNZD_OCO4_UP_S2_Monthly_IsReady = true;
                    	}
						
						
	                	EURNZD_Signal_Condition_UP_1 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.382m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
		                										
		                										)
		                							
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	EURNZD_Signal_Condition_UP_2 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(
		                										
		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.5m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                									
	                	EURNZD_Signal_Condition_UP_3 =	
	                									(
		                										pricesM_BID_Close[0] - pricesM_ASK_Open[0] > Base.Oth_Min_Size &&
		                										
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low > 0 &&
		                										SY1D.BQ[7].Ask.High - SY1D.BQ[0].Bid.Low < Base.Oth_Min_Size_bs
		                										
		                										&&
		                										
		                										(

		                											prices_BID_Low[7] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
		                											prices_BID_Low[0] < pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*1.618m) &&
		                											(pricesM_BID_Low[0] - ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*0.382m)) - prices_BID_Low[0] > Base.Oth_Min_Size_bs
		                										
		                										)
		                										
		                										&&
		                										
																prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
																prices_ASK_Close[0] - prices_BID_Close[0] < Base.Oth_Min_SPRD
	                									);
	                									
	                	if (EURNZD_Signal_Condition_UP_1)
	                	{
	                    	EURNZD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURNZD_Signal_Condition_UP_2)
	                	{
	                    	EURNZD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	if (EURNZD_Signal_Condition_UP_3)
	                	{
	                    	EURNZD_UP_S2_SL  = ((pricesM_ASK_High[0] - pricesM_BID_Low[0])*Base.Coef_SL);
	                	}
	                	
	                	
	                	if (EURNZD_Signal_Condition_UP_1)
	                	{
	                    	EURNZD_UP_S2_TP1  =  Base.Oth_TP_1 ;
	                	}
	                	
	                	if (EURNZD_Signal_Condition_UP_2)
	                	{
	                    	EURNZD_UP_S2_TP1  =  Base.Oth_TP_2 ;
	                	}
	                	
	                	if (EURNZD_Signal_Condition_UP_3)
	                	{
	                    	EURNZD_UP_S2_TP1  =  Base.Oth_TP_3 ;
	                	}

	                    EURNZD_UP_S2_TP2 =  EURNZD_UP_S2_SL * 0;
	                    EURNZD_UP_S2_TP3 =  EURNZD_UP_S2_SL * 0;
	                    EURNZD_UP_S2_TP4 =  EURNZD_UP_S2_SL * 0;
	                    EURNZD_UP_S2_TP5 =  EURNZD_UP_S2_SL * 0;
	                    EURNZD_UP_S2_TP6 =  EURNZD_UP_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURNZD_quantity_UP_S2 = (int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURNZD_quantity_SL_UP_S2 = EURNZD_quantity_UP_S2;
	                    EURNZD_quantity_TP1_UP_S2 = (int)Math.Floor(EURNZD_quantity_UP_S2 * 1m);
	                    EURNZD_quantity_TP2_UP_S2 = (int)Math.Floor(EURNZD_quantity_TP1_UP_S2 * 0m);
	                    EURNZD_quantity_TP3_UP_S2 = (int)Math.Floor(EURNZD_quantity_TP2_UP_S2 * 0m);
	                    EURNZD_quantity_TP4_UP_S2 = (int)Math.Floor(EURNZD_quantity_TP3_UP_S2 * 0m);
	                    EURNZD_quantity_TP5_UP_S2 = (int)Math.Floor(EURNZD_quantity_TP4_UP_S2 * 0m);
	                    EURNZD_quantity_TP6_UP_S2 = (int)Math.Floor(EURNZD_quantity_TP5_UP_S2 * 0m);
	                    }

						oco1:
	                    if ((EURNZD_Signal_Condition_UP_1 || EURNZD_Signal_Condition_UP_2 || EURNZD_Signal_Condition_UP_3)  && 
	                    DOWR_EURNZD_UP_S2 && 
	                    Base.EURNZD_OCO1_UP_S2_IsReady == true &&
	                    Base.EURNZD_OCO1_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURNZD_OCO1_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO1_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP1_UP_S2, false,"EURNZD_UP_S2_Entry_TP1_OCO1");
	                         Base.EURNZD_OCO1_EO1_UP_S2 = false;
	                         
	                         Base.EURNZD_OCO1_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO1_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP2_UP_S2, false,"EURNZD_UP_S2_Entry_TP2_OCO1");
	                         Base.EURNZD_OCO1_EO2_UP_S2 = false;
	
	                         Base.EURNZD_OCO1_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO1_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP3_UP_S2, false,"EURNZD_UP_S2_Entry_TP3_OCO1");
	                         Base.EURNZD_OCO1_EO3_UP_S2 = false;
	                    
	                         Base.EURNZD_OCO1_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO1_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP4_UP_S2, false,"EURNZD_UP_S2_Entry_TP4_OCO1");
	                         Base.EURNZD_OCO1_EO4_UP_S2 = false;

							Base.EURNZD_OCO1_UP_S2_IsReady = false;
							
							if (Base.EURNZD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if ((EURNZD_Signal_Condition_UP_1 || EURNZD_Signal_Condition_UP_2 || EURNZD_Signal_Condition_UP_3)  && 
	                    DOWR_EURNZD_UP_S2 && 
	                    Base.EURNZD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURNZD_OCO2_UP_S2_IsReady == true &&
	                    Base.EURNZD_OCO2_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURNZD_OCO2_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO2_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP1_UP_S2, false,"EURNZD_UP_S2_Entry_TP1_OCO2");
	                         Base.EURNZD_OCO2_EO1_UP_S2 = false;
	                         
	                         Base.EURNZD_OCO2_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO2_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP2_UP_S2, false,"EURNZD_UP_S2_Entry_TP2_OCO2");
	                         Base.EURNZD_OCO2_EO2_UP_S2 = false;
	
	                         Base.EURNZD_OCO2_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO2_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP3_UP_S2, false,"EURNZD_UP_S2_Entry_TP3_OCO2");
	                         Base.EURNZD_OCO2_EO3_UP_S2 = false;
	                    
	                         Base.EURNZD_OCO2_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO2_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP4_UP_S2, false,"EURNZD_UP_S2_Entry_TP4_OCO2");
	                         Base.EURNZD_OCO2_EO4_UP_S2 = false;

							Base.EURNZD_OCO2_UP_S2_IsReady = false;
							
							if (Base.EURNZD_OCO2_UP_S2_IsReady == false && Base.EURNZD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if ((EURNZD_Signal_Condition_UP_1 || EURNZD_Signal_Condition_UP_2 || EURNZD_Signal_Condition_UP_3)  && 
	                    DOWR_EURNZD_UP_S2 &&
	                    Base.EURNZD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURNZD_OCO2_UP_S2_IsReady == false &&
	                    Base.EURNZD_OCO3_UP_S2_IsReady == true &&
	                    Base.EURNZD_OCO3_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURNZD_OCO3_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO3_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP1_UP_S2, false,"EURNZD_UP_S2_Entry_TP1_OCO3");
	                         Base.EURNZD_OCO3_EO1_UP_S2 = false;
	                         
	                         Base.EURNZD_OCO3_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO3_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP2_UP_S2, false,"EURNZD_UP_S2_Entry_TP2_OCO3");
	                         Base.EURNZD_OCO3_EO2_UP_S2 = false;
	
	                         Base.EURNZD_OCO3_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO3_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP3_UP_S2, false,"EURNZD_UP_S2_Entry_TP3_OCO3");
	                         Base.EURNZD_OCO3_EO3_UP_S2 = false;
	                    
	                         Base.EURNZD_OCO3_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO3_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP4_UP_S2, false,"EURNZD_UP_S2_Entry_TP4_OCO3");
	                         Base.EURNZD_OCO3_EO4_UP_S2 = false;

							Base.EURNZD_OCO3_UP_S2_IsReady = false;
							
							if (Base.EURNZD_OCO3_UP_S2_IsReady == false && Base.EURNZD_OCO2_UP_S2_IsReady == false && Base.EURNZD_OCO1_UP_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if ((EURNZD_Signal_Condition_UP_1 || EURNZD_Signal_Condition_UP_2 || EURNZD_Signal_Condition_UP_3)  && 
	                    DOWR_EURNZD_UP_S2 && 
	                    Base.EURNZD_OCO1_UP_S2_IsReady == false &&
	                    Base.EURNZD_OCO2_UP_S2_IsReady == false &&
	                    Base.EURNZD_OCO3_UP_S2_IsReady == false &&
	                    Base.EURNZD_OCO4_UP_S2_IsReady == true &&
	                    Base.EURNZD_OCO4_UP_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURNZD_OCO4_EO1_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO4_MO1_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP1_UP_S2, false,"EURNZD_UP_S2_Entry_TP1_OCO4");
	                         Base.EURNZD_OCO4_EO1_UP_S2 = false;
	                         
	                         Base.EURNZD_OCO4_EO2_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO4_MO2_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP2_UP_S2, false,"EURNZD_UP_S2_Entry_TP2_OCO4");
	                         Base.EURNZD_OCO4_EO2_UP_S2 = false;
	
	                         Base.EURNZD_OCO4_EO3_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO4_MO3_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP3_UP_S2, false,"EURNZD_UP_S2_Entry_TP3_OCO4");
	                         Base.EURNZD_OCO4_EO3_UP_S2 = false;
	                    
	                         Base.EURNZD_OCO4_EO4_UP_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Up, null, null, null, 1);
	                         EURNZD_OCO4_MO4_UP_S2 = algorithm.MarketOrder(SY1D.Symbol, EURNZD_quantity_TP4_UP_S2, false,"EURNZD_UP_S2_Entry_TP4_OCO4");
	                         Base.EURNZD_OCO4_EO4_UP_S2 = false;

							Base.EURNZD_OCO4_UP_S2_IsReady = false;
							
							if (Base.EURNZD_OCO4_UP_S2_IsReady == false && Base.EURNZD_OCO3_UP_S2_IsReady == false && Base.EURNZD_OCO2_UP_S2_IsReady == false && Base.EURNZD_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 : 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 int RLLWS_1440 = 1440;
        public static int RLLWS_720 = 720;
        public static int RLLWS_360 = 360;
        public static int RLLWS_60 = 60;
        public static int RLLWS_15 = 15;
        
        public static decimal Yen_Min_SPRD = 0.01m;
        public static decimal Oth_Min_SPRD = 0.001m;
        
        public static decimal Yen_Min_Size = 0.5m;
        public static decimal Oth_Min_Size = 0.005m;
        
        public static decimal Coef_SL = 0.382m;
        
        public static decimal Yen_Min_Size_bs = 0.05m;
        public static decimal Oth_Min_Size_bs = 0.001m;
        
        public static decimal Yen_TP_1 = 0.05m; 
        public static decimal Yen_TP_2 = 0.05m; 
        public static decimal Yen_TP_3 = 0.05m; 
        
        public static decimal Oth_TP_1 = 0.0005m; 
        public static decimal Oth_TP_2 = 0.0005m; 
        public static decimal Oth_TP_3 = 0.0005m; 

        public static decimal Static_Yen_TP_1 = 1m; 
        public static decimal Static_Yen_TP_2 = 1m; 
        public static decimal Static_Yen_TP_3 = 1m; 
        
        public static decimal Static_Oth_TP_1 = 1m; 
        public static decimal Static_Oth_TP_2 = 1m; 
        public static decimal Static_Oth_TP_3 = 1m; 
        
        public static int SymbolCount = 0;
        
        public static Dictionary<string, SY1D> D1D = new Dictionary<string, SY1D>();

    	private EURUSD_UP_S2_OnOrderEvent eurusd_UP_S2_OnOrderEvent;
        private EURUSD_DOWN_S2_OnOrderEvent eurusd_DOWN_S2_OnOrderEvent;
        
        private EURGBP_UP_S2_OnOrderEvent eurgbp_UP_S2_OnOrderEvent;
        private EURGBP_DOWN_S2_OnOrderEvent eurgbp_DOWN_S2_OnOrderEvent;
        
        private EURCHF_UP_S2_OnOrderEvent eurchf_UP_S2_OnOrderEvent;
        private EURCHF_DOWN_S2_OnOrderEvent eurchf_DOWN_S2_OnOrderEvent;
        
        private EURJPY_UP_S2_OnOrderEvent eurjpy_UP_S2_OnOrderEvent;
        private EURJPY_DOWN_S2_OnOrderEvent eurjpy_DOWN_S2_OnOrderEvent;
        
        private EURCAD_UP_S2_OnOrderEvent eurcad_UP_S2_OnOrderEvent;
        private EURCAD_DOWN_S2_OnOrderEvent eurcad_DOWN_S2_OnOrderEvent;
        
        private EURAUD_UP_S2_OnOrderEvent euraud_UP_S2_OnOrderEvent;
        private EURAUD_DOWN_S2_OnOrderEvent euraud_DOWN_S2_OnOrderEvent;
        
        private EURNZD_UP_S2_OnOrderEvent eurnzd_UP_S2_OnOrderEvent;
        private EURNZD_DOWN_S2_OnOrderEvent eurnzd_DOWN_S2_OnOrderEvent;
        
        
        private USDJPY_UP_S2_OnOrderEvent usdjpy_UP_S2_OnOrderEvent;
        private USDJPY_DOWN_S2_OnOrderEvent usdjpy_DOWN_S2_OnOrderEvent; 
        
        private USDCAD_UP_S2_OnOrderEvent usdcad_UP_S2_OnOrderEvent;
        private USDCAD_DOWN_S2_OnOrderEvent usdcad_DOWN_S2_OnOrderEvent;
        
        private USDCHF_UP_S2_OnOrderEvent usdchf_UP_S2_OnOrderEvent;
        private USDCHF_DOWN_S2_OnOrderEvent usdchf_DOWN_S2_OnOrderEvent;
        
        
    	private GBPUSD_UP_S2_OnOrderEvent gbpusd_UP_S2_OnOrderEvent;
        private GBPUSD_DOWN_S2_OnOrderEvent gbpusd_DOWN_S2_OnOrderEvent;

        private GBPCHF_UP_S2_OnOrderEvent gbpchf_UP_S2_OnOrderEvent;
        private GBPCHF_DOWN_S2_OnOrderEvent gbpchf_DOWN_S2_OnOrderEvent;
        
        private GBPJPY_UP_S2_OnOrderEvent gbpjpy_UP_S2_OnOrderEvent;
        private GBPJPY_DOWN_S2_OnOrderEvent gbpjpy_DOWN_S2_OnOrderEvent;
        
        private GBPCAD_UP_S2_OnOrderEvent gbpcad_UP_S2_OnOrderEvent;
        private GBPCAD_DOWN_S2_OnOrderEvent gbpcad_DOWN_S2_OnOrderEvent;
        
        private GBPAUD_UP_S2_OnOrderEvent gbpaud_UP_S2_OnOrderEvent;
        private GBPAUD_DOWN_S2_OnOrderEvent gbpaud_DOWN_S2_OnOrderEvent;
        
        private GBPNZD_UP_S2_OnOrderEvent gbpnzd_UP_S2_OnOrderEvent;
        private GBPNZD_DOWN_S2_OnOrderEvent gbpnzd_DOWN_S2_OnOrderEvent; 
        
        private CHFJPY_UP_S2_OnOrderEvent chfjpy_UP_S2_OnOrderEvent;
        private CHFJPY_DOWN_S2_OnOrderEvent chfjpy_DOWN_S2_OnOrderEvent; 
        
        
        private CADJPY_UP_S2_OnOrderEvent cadjpy_UP_S2_OnOrderEvent;
        private CADJPY_DOWN_S2_OnOrderEvent cadjpy_DOWN_S2_OnOrderEvent;
        
        
        private AUDCHF_UP_S2_OnOrderEvent audchf_UP_S2_OnOrderEvent;
        private AUDCHF_DOWN_S2_OnOrderEvent audchf_DOWN_S2_OnOrderEvent; 
        
        private AUDCAD_UP_S2_OnOrderEvent audcad_UP_S2_OnOrderEvent;
        private AUDCAD_DOWN_S2_OnOrderEvent audcad_DOWN_S2_OnOrderEvent; 
        
        private AUDJPY_UP_S2_OnOrderEvent audjpy_UP_S2_OnOrderEvent;
        private AUDJPY_DOWN_S2_OnOrderEvent audjpy_DOWN_S2_OnOrderEvent; 
        
        private AUDNZD_UP_S2_OnOrderEvent audnzd_UP_S2_OnOrderEvent;
        private AUDNZD_DOWN_S2_OnOrderEvent audnzd_DOWN_S2_OnOrderEvent; 
        
        private AUDUSD_UP_S2_OnOrderEvent audusd_UP_S2_OnOrderEvent;
        private AUDUSD_DOWN_S2_OnOrderEvent audusd_DOWN_S2_OnOrderEvent; 
        
        
        private NZDCAD_UP_S2_OnOrderEvent nzdcad_UP_S2_OnOrderEvent;
        private NZDCAD_DOWN_S2_OnOrderEvent nzdcad_DOWN_S2_OnOrderEvent; 
        
        private NZDCHF_UP_S2_OnOrderEvent nzdchf_UP_S2_OnOrderEvent;
        private NZDCHF_DOWN_S2_OnOrderEvent nzdchf_DOWN_S2_OnOrderEvent; 
        
        private NZDJPY_UP_S2_OnOrderEvent nzdjpy_UP_S2_OnOrderEvent;
        private NZDJPY_DOWN_S2_OnOrderEvent nzdjpy_DOWN_S2_OnOrderEvent; 
        
        private NZDUSD_UP_S2_OnOrderEvent nzdusd_UP_S2_OnOrderEvent;
        private NZDUSD_DOWN_S2_OnOrderEvent nzdusd_DOWN_S2_OnOrderEvent; 
        
        List<string> Pairs = new List<string>
        {
			"EURUSD",
			"EURGBP",
			"EURCHF",
			"EURJPY",
			"EURCAD",
			"EURAUD",
			"EURNZD",
			"USDJPY",
			"USDCAD",
			"USDCHF",
			"GBPUSD",
			"GBPCHF",
			"GBPJPY",
			"GBPCAD",
			"GBPAUD",
			"GBPNZD",
			"CHFJPY",
			"CADJPY",
			"AUDJPY",
			"AUDUSD",
			"AUDCAD",
			"AUDCHF",
			"AUDNZD",
			"NZDJPY",
			"NZDCAD",
			"NZDCHF",
			"NZDUSD"
        };

	    public override void Initialize()
	    {
	        SetStartDate(2010, 10, 1);
	        SetEndDate(DateTime.Now);
	        
	       // SetEndDate(2016, 1, 1);
	        
	        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));
			}
            

				eurusd_UP_S2_OnOrderEvent = new EURUSD_UP_S2_OnOrderEvent(this);
				eurusd_DOWN_S2_OnOrderEvent = new EURUSD_DOWN_S2_OnOrderEvent(this);
				
				eurgbp_UP_S2_OnOrderEvent = new EURGBP_UP_S2_OnOrderEvent(this);
				eurgbp_DOWN_S2_OnOrderEvent = new EURGBP_DOWN_S2_OnOrderEvent(this);
				
				eurchf_UP_S2_OnOrderEvent = new EURCHF_UP_S2_OnOrderEvent(this);
				eurchf_DOWN_S2_OnOrderEvent = new EURCHF_DOWN_S2_OnOrderEvent(this);
				
				eurjpy_UP_S2_OnOrderEvent = new EURJPY_UP_S2_OnOrderEvent(this);
				eurjpy_DOWN_S2_OnOrderEvent = new EURJPY_DOWN_S2_OnOrderEvent(this);
				
				eurcad_UP_S2_OnOrderEvent = new EURCAD_UP_S2_OnOrderEvent(this);
				eurcad_DOWN_S2_OnOrderEvent = new EURCAD_DOWN_S2_OnOrderEvent(this);
				
				euraud_UP_S2_OnOrderEvent = new EURAUD_UP_S2_OnOrderEvent(this);
				euraud_DOWN_S2_OnOrderEvent = new EURAUD_DOWN_S2_OnOrderEvent(this);
				
				eurnzd_UP_S2_OnOrderEvent = new EURNZD_UP_S2_OnOrderEvent(this);
				eurnzd_DOWN_S2_OnOrderEvent = new EURNZD_DOWN_S2_OnOrderEvent(this);
				
				
				usdjpy_UP_S2_OnOrderEvent = new USDJPY_UP_S2_OnOrderEvent(this);
				usdjpy_DOWN_S2_OnOrderEvent = new USDJPY_DOWN_S2_OnOrderEvent(this); 
				
				usdcad_UP_S2_OnOrderEvent = new USDCAD_UP_S2_OnOrderEvent(this);
				usdcad_DOWN_S2_OnOrderEvent = new USDCAD_DOWN_S2_OnOrderEvent(this);
				
			    usdchf_UP_S2_OnOrderEvent = new USDCHF_UP_S2_OnOrderEvent(this);
				usdchf_DOWN_S2_OnOrderEvent = new USDCHF_DOWN_S2_OnOrderEvent(this);
				
				
				gbpusd_UP_S2_OnOrderEvent = new GBPUSD_UP_S2_OnOrderEvent(this);
				gbpusd_DOWN_S2_OnOrderEvent = new GBPUSD_DOWN_S2_OnOrderEvent(this);

				gbpchf_UP_S2_OnOrderEvent = new GBPCHF_UP_S2_OnOrderEvent(this);
				gbpchf_DOWN_S2_OnOrderEvent = new GBPCHF_DOWN_S2_OnOrderEvent(this);
				
				gbpjpy_UP_S2_OnOrderEvent = new GBPJPY_UP_S2_OnOrderEvent(this);
				gbpjpy_DOWN_S2_OnOrderEvent = new GBPJPY_DOWN_S2_OnOrderEvent(this);
				
				gbpcad_UP_S2_OnOrderEvent = new GBPCAD_UP_S2_OnOrderEvent(this);
				gbpcad_DOWN_S2_OnOrderEvent = new GBPCAD_DOWN_S2_OnOrderEvent(this);
				
				gbpaud_UP_S2_OnOrderEvent = new GBPAUD_UP_S2_OnOrderEvent(this);
				gbpaud_DOWN_S2_OnOrderEvent = new GBPAUD_DOWN_S2_OnOrderEvent(this);
				
				gbpnzd_UP_S2_OnOrderEvent = new GBPNZD_UP_S2_OnOrderEvent(this);
				gbpnzd_DOWN_S2_OnOrderEvent = new GBPNZD_DOWN_S2_OnOrderEvent(this); 
				
				
				chfjpy_UP_S2_OnOrderEvent = new CHFJPY_UP_S2_OnOrderEvent(this);
				chfjpy_DOWN_S2_OnOrderEvent = new CHFJPY_DOWN_S2_OnOrderEvent(this); 
				
				
				cadjpy_UP_S2_OnOrderEvent = new CADJPY_UP_S2_OnOrderEvent(this);
				cadjpy_DOWN_S2_OnOrderEvent = new CADJPY_DOWN_S2_OnOrderEvent(this); 
				
				
				audjpy_UP_S2_OnOrderEvent = new AUDJPY_UP_S2_OnOrderEvent(this);
				audjpy_DOWN_S2_OnOrderEvent = new AUDJPY_DOWN_S2_OnOrderEvent(this); 
				
				audcad_UP_S2_OnOrderEvent = new AUDCAD_UP_S2_OnOrderEvent(this);
				audcad_DOWN_S2_OnOrderEvent = new AUDCAD_DOWN_S2_OnOrderEvent(this); 
				
				audchf_UP_S2_OnOrderEvent = new AUDCHF_UP_S2_OnOrderEvent(this);
				audchf_DOWN_S2_OnOrderEvent = new AUDCHF_DOWN_S2_OnOrderEvent(this); 
				
				audusd_UP_S2_OnOrderEvent = new AUDUSD_UP_S2_OnOrderEvent(this);
				audusd_DOWN_S2_OnOrderEvent = new AUDUSD_DOWN_S2_OnOrderEvent(this); 
				
				audnzd_UP_S2_OnOrderEvent = new AUDNZD_UP_S2_OnOrderEvent(this);
				audnzd_DOWN_S2_OnOrderEvent = new AUDNZD_DOWN_S2_OnOrderEvent(this); 
				
				
				nzdjpy_UP_S2_OnOrderEvent = new NZDJPY_UP_S2_OnOrderEvent(this);
				nzdjpy_DOWN_S2_OnOrderEvent = new NZDJPY_DOWN_S2_OnOrderEvent(this); 
				
				nzdcad_UP_S2_OnOrderEvent = new NZDCAD_UP_S2_OnOrderEvent(this);
				nzdcad_DOWN_S2_OnOrderEvent = new NZDCAD_DOWN_S2_OnOrderEvent(this); 
				
				nzdchf_UP_S2_OnOrderEvent = new NZDCHF_UP_S2_OnOrderEvent(this);
				nzdchf_DOWN_S2_OnOrderEvent = new NZDCHF_DOWN_S2_OnOrderEvent(this); 
				
				nzdusd_UP_S2_OnOrderEvent = new NZDUSD_UP_S2_OnOrderEvent(this);
				nzdusd_DOWN_S2_OnOrderEvent = new NZDUSD_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);

	        }
	        
	        AddAlpha(new Alpha_EURUSD_UP_S2(_EURUSD));    //ok
	        //AddAlpha(new Alpha_EURUSD_DOWN_S2(_EURUSD));  //ok
	        
	        AddAlpha(new Alpha_EURGBP_UP_S2(_EURGBP));   //ok
	        //AddAlpha(new Alpha_EURGBP_DOWN_S2(_EURGBP)); //ok
	        
	    	AddAlpha(new Alpha_EURCHF_UP_S2(_EURCHF));  //ok 
	        //AddAlpha(new Alpha_EURCHF_DOWN_S2(_EURCHF)); //ok
	        
	        AddAlpha(new Alpha_EURJPY_UP_S2(_EURJPY));    //ok
	        //AddAlpha(new Alpha_EURJPY_DOWN_S2(_EURJPY)); //OK
	        
	        AddAlpha(new Alpha_EURCAD_UP_S2(_EURCAD));   //ok
	        //AddAlpha(new Alpha_EURCAD_DOWN_S2(_EURCAD)); //ok
	        
	        AddAlpha(new Alpha_EURAUD_UP_S2(_EURAUD));   //ok
	        //AddAlpha(new Alpha_EURAUD_DOWN_S2(_EURAUD)); //ok
	        
	        AddAlpha(new Alpha_EURNZD_UP_S2(_EURNZD));   //Ok
	        //AddAlpha(new Alpha_EURNZD_DOWN_S2(_EURNZD)); //Ok
	        
	        
	        AddAlpha(new Alpha_USDJPY_UP_S2(_USDJPY));   //ok
	        //AddAlpha(new Alpha_USDJPY_DOWN_S2(_USDJPY)); //ok
	        
	        AddAlpha(new Alpha_USDCAD_UP_S2(_USDCAD));   //OK
	        //AddAlpha(new Alpha_USDCAD_DOWN_S2(_USDCAD)); //ok
	       
	    	AddAlpha(new Alpha_USDCHF_UP_S2(_USDCHF));   //ok
	        //AddAlpha(new Alpha_USDCHF_DOWN_S2(_USDCHF)); //ok
	        
	        
	        AddAlpha(new Alpha_GBPUSD_UP_S2(_GBPUSD));    //ok
	    	//AddAlpha(new Alpha_GBPUSD_DOWN_S2(_GBPUSD));  //ok

	    	AddAlpha(new Alpha_GBPCHF_UP_S2(_GBPCHF));    //ok
	        //AddAlpha(new Alpha_GBPCHF_DOWN_S2(_GBPCHF));  //ok
	        
	    	AddAlpha(new Alpha_GBPJPY_UP_S2(_GBPJPY));    //ok
	        //AddAlpha(new Alpha_GBPJPY_DOWN_S2(_GBPJPY));  //ok
	        
	        AddAlpha(new Alpha_GBPCAD_UP_S2(_GBPCAD));    //ok A baisser pour opti psr
	        //AddAlpha(new Alpha_GBPCAD_DOWN_S2(_GBPCAD));  //ok 
	        
	        AddAlpha(new Alpha_GBPAUD_UP_S2(_GBPAUD));    //ok
	        //AddAlpha(new Alpha_GBPAUD_DOWN_S2(_GBPAUD));  //ok 
	        
	        AddAlpha(new Alpha_GBPNZD_UP_S2(_GBPNZD));   //ok  
	        //AddAlpha(new Alpha_GBPNZD_DOWN_S2(_GBPNZD)); //ok  
	        
	        AddAlpha(new Alpha_CHFJPY_UP_S2(_CHFJPY));  //ok
	        //AddAlpha(new Alpha_CHFJPY_DOWN_S2(_CHFJPY)); //ok
	        
	        
  	        AddAlpha(new Alpha_CADJPY_UP_S2(_CADJPY));    //ok
	        //AddAlpha(new Alpha_CADJPY_DOWN_S2(_CADJPY));  //ok
	        
	        
	        AddAlpha(new Alpha_AUDJPY_UP_S2(_AUDJPY));   //ok
	        //AddAlpha(new Alpha_AUDJPY_DOWN_S2(_AUDJPY)); //ok
	        
	    	AddAlpha(new Alpha_AUDCAD_UP_S2(_AUDCAD));   //OK
	        //AddAlpha(new Alpha_AUDCAD_DOWN_S2(_AUDCAD)); //OK
	        
	    	AddAlpha(new Alpha_AUDCHF_UP_S2(_AUDCHF));    //ok
	        //AddAlpha(new Alpha_AUDCHF_DOWN_S2(_AUDCHF));  //ok
	        
	    	AddAlpha(new Alpha_AUDNZD_UP_S2(_AUDNZD));   //ok
	        //AddAlpha(new Alpha_AUDNZD_DOWN_S2(_AUDNZD)); //ok
	        
	        AddAlpha(new Alpha_AUDUSD_UP_S2(_AUDUSD));   //ok
	        //AddAlpha(new Alpha_AUDUSD_DOWN_S2(_AUDUSD)); //ok
	        
	        
	        AddAlpha(new Alpha_NZDJPY_UP_S2(_NZDJPY));   //ok
	        //AddAlpha(new Alpha_NZDJPY_DOWN_S2(_NZDJPY)); //ok
	        
	        AddAlpha(new Alpha_NZDCAD_UP_S2(_NZDCAD));   //ok  
	        //AddAlpha(new Alpha_NZDCAD_DOWN_S2(_NZDCAD)); //ok
	        
	        AddAlpha(new Alpha_NZDUSD_UP_S2(_NZDUSD));    //ok
	        //AddAlpha(new Alpha_NZDUSD_DOWN_S2(_NZDUSD));  //ok
	        
	    	AddAlpha(new Alpha_NZDCHF_UP_S2(_NZDCHF));   //ok
	        //AddAlpha(new Alpha_NZDCHF_DOWN_S2(_NZDCHF)); //ok
	  
	    }

	    public override void OnOrderEvent(OrderEvent orderEvent)
	    {
		 	eurusd_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	eurusd_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	eurgbp_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	eurgbp_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	eurchf_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	eurchf_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	eurjpy_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	eurjpy_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	eurcad_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	eurcad_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	euraud_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	euraud_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	eurnzd_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	eurnzd_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	
	    	usdjpy_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	usdjpy_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);   
	    	
	    	usdcad_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	usdcad_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	        usdchf_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	usdchf_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	
	    	gbpusd_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	gbpusd_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	gbpchf_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	gbpchf_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	gbpjpy_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	gbpjpy_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	gbpcad_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	gbpcad_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	gbpaud_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	gbpaud_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	
	    	gbpnzd_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	gbpnzd_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);   
	    	
	    	
	    	chfjpy_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	chfjpy_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);   
	    	
	    	
	    	cadjpy_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	cadjpy_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    	
	    	
	    	audjpy_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	audjpy_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    	
	    	audchf_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	audchf_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    	
	    	audcad_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	audcad_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    	
	    	audnzd_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	audnzd_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    	
	    	audusd_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	audusd_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    	
	    	
	    	nzdjpy_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	nzdjpy_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    	
	    	nzdcad_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	nzdcad_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    	
	    	nzdusd_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	nzdusd_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    	
	    	nzdchf_UP_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);
	    	nzdchf_DOWN_S2_OnOrderEvent.OnOrderEvent(this, orderEvent);  
	    }

        public void OnInsightsGeneratedVerifier(IAlgorithm algorithm, GeneratedInsightsCollection insightsCollection)
    	{
	        if (
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("EURUSD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("EURGBP")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("EURCHF")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("EURJPY")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("EURCAD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("EURAUD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("EURNZD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("USDJPY")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("USDCAD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("USDCHF")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("GBPUSD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("GBPNZD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("GBPJPY")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("GBPCHF")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("GBPCAD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("GBPAUD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("CHFJPY")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("CADJPY")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("AUDJPY")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("AUDCHF")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("AUDCAD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("AUDNZD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("AUDUSD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("NZDJPY")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("NZDCHF")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("NZDUSD")) != 1 ||
	        	insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("NZDCAD")) != 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 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;
        }
    }
}
namespace QuantConnect 
{
public partial class Base	///ONDATA
{
	public class Alpha_EURJPY_DOWN_S2 : AlphaModel
    {   
    	private readonly Symbol _symbol;
        public Alpha_EURJPY_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("EURJPY_DOWN_S2_OCO1")))
			{
				Base.EURJPY_OCO1_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURJPY_DOWN_S2_OCO2")))
			{
				Base.EURJPY_OCO2_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURJPY_DOWN_S2_OCO3")))
			{
				Base.EURJPY_OCO3_DOWN_S2_IsReady = true;
			}
			
			if (!open_orders.Any(x=>x.Tag.Contains("EURJPY_DOWN_S2_OCO4")))
			{
				Base.EURJPY_OCO4_DOWN_S2_IsReady = true;
			}
			
			if (open_orders.Any(x=>x.Tag.Contains("EURJPY_DOWN_S2")))
			{
        	foreach (var order in open_orders)
		    {
				if (Base.EURJPY_OCO1_EO1_DOWN_S2)
	                Base.EURJPY_OCO1_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURJPY_OCO1_EO2_DOWN_S2)
	                Base.EURJPY_OCO1_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO1_EO3_DOWN_S2)
	                Base.EURJPY_OCO1_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO1_EO4_DOWN_S2)
	                Base.EURJPY_OCO1_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO1_EO5_DOWN_S2)
	                Base.EURJPY_OCO1_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO1_EO6_DOWN_S2)
	                Base.EURJPY_OCO1_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURJPY_OCO1S1_DOWN_S2 = 0;
		                for (; EURJPY_OCO1S1_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets1.Count; EURJPY_OCO1S1_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO1Sets1[EURJPY_OCO1S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO1Sets1[EURJPY_OCO1S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_1__Time out_OCO1");
		                        Base.EURJPY_DOWN_S2_OCO1Sets1.Clear();
		                        EURJPY_OCO1S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURJPY_OCO1S2_DOWN_S2 = 0;
		                for (; EURJPY_OCO1S2_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets2.Count; EURJPY_OCO1S2_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO1Sets2[EURJPY_OCO1S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO1Sets2[EURJPY_OCO1S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_2__Time out_OCO1");
		                        Base.EURJPY_DOWN_S2_OCO1Sets2.Clear();
		                        EURJPY_OCO1S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO1S3_DOWN_S2 = 0;
		                for (; EURJPY_OCO1S3_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets3.Count; EURJPY_OCO1S3_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO1Sets3[EURJPY_OCO1S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO1Sets3[EURJPY_OCO1S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_3__Time out_OCO1");
		                        Base.EURJPY_DOWN_S2_OCO1Sets3.Clear();
		                        EURJPY_OCO1S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO1S4_DOWN_S2 = 0;
		                for (; EURJPY_OCO1S4_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets4.Count; EURJPY_OCO1S4_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO1Sets4[EURJPY_OCO1S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO1Sets4[EURJPY_OCO1S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_4__Time out_OCO1");
		                        Base.EURJPY_DOWN_S2_OCO1Sets4.Clear();
		                        EURJPY_OCO1S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO1S5_DOWN_S2 = 0;
		                for (; EURJPY_OCO1S5_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets5.Count; EURJPY_OCO1S5_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO1Sets5[EURJPY_OCO1S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO1Sets5[EURJPY_OCO1S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_5__Time out_OCO1");
		                        Base.EURJPY_DOWN_S2_OCO1Sets5.Clear();
		                        EURJPY_OCO1S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO1S6_DOWN_S2 = 0;
		                for (; EURJPY_OCO1S6_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO1Sets6.Count; EURJPY_OCO1S6_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO1Sets6[EURJPY_OCO1S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO1Sets6[EURJPY_OCO1S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_6__Time out_OCO1");
		                        Base.EURJPY_DOWN_S2_OCO1Sets6.Clear();
		                        EURJPY_OCO1S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURJPY_OCO2_EO1_DOWN_S2)
	                Base.EURJPY_OCO2_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURJPY_OCO2_EO2_DOWN_S2)
	                Base.EURJPY_OCO2_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO2_EO3_DOWN_S2)
	                Base.EURJPY_OCO2_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO2_EO4_DOWN_S2)
	                Base.EURJPY_OCO2_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO2_EO5_DOWN_S2)
	                Base.EURJPY_OCO2_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO2_EO6_DOWN_S2)
	                Base.EURJPY_OCO2_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURJPY_OCO2S1_DOWN_S2 = 0;
		                for (; EURJPY_OCO2S1_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets1.Count; EURJPY_OCO2S1_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO2Sets1[EURJPY_OCO2S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO2Sets1[EURJPY_OCO2S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_1__Time out_OCO2");
		                        Base.EURJPY_DOWN_S2_OCO2Sets1.Clear();
		                        EURJPY_OCO2S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURJPY_OCO2S2_DOWN_S2 = 0;
		                for (; EURJPY_OCO2S2_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets2.Count; EURJPY_OCO2S2_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO2Sets2[EURJPY_OCO2S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO2Sets2[EURJPY_OCO2S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_2__Time out_OCO2");
		                        Base.EURJPY_DOWN_S2_OCO2Sets2.Clear();
		                        EURJPY_OCO2S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO2S3_DOWN_S2 = 0;
		                for (; EURJPY_OCO2S3_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets3.Count; EURJPY_OCO2S3_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO2Sets3[EURJPY_OCO2S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO2Sets3[EURJPY_OCO2S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_3__Time out_OCO2");
		                        Base.EURJPY_DOWN_S2_OCO2Sets3.Clear();
		                        EURJPY_OCO2S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO2S4_DOWN_S2 = 0;
		                for (; EURJPY_OCO2S4_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets4.Count; EURJPY_OCO2S4_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO2Sets4[EURJPY_OCO2S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO2Sets4[EURJPY_OCO2S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_4__Time out_OCO2");
		                        Base.EURJPY_DOWN_S2_OCO2Sets4.Clear();
		                        EURJPY_OCO2S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO2S5_DOWN_S2 = 0;
		                for (; EURJPY_OCO2S5_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets5.Count; EURJPY_OCO2S5_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO2Sets5[EURJPY_OCO2S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO2Sets5[EURJPY_OCO2S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_5__Time out_OCO2");
		                        Base.EURJPY_DOWN_S2_OCO2Sets5.Clear();
		                        EURJPY_OCO2S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO2S6_DOWN_S2 = 0;
		                for (; EURJPY_OCO2S6_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO2Sets6.Count; EURJPY_OCO2S6_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO2Sets6[EURJPY_OCO2S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO2Sets6[EURJPY_OCO2S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_6__Time out_OCO2");
		                        Base.EURJPY_DOWN_S2_OCO2Sets6.Clear();
		                        EURJPY_OCO2S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURJPY_OCO3_EO1_DOWN_S2)
	                Base.EURJPY_OCO3_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURJPY_OCO3_EO2_DOWN_S2)
	                Base.EURJPY_OCO3_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO3_EO3_DOWN_S2)
	                Base.EURJPY_OCO3_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO3_EO4_DOWN_S2)
	                Base.EURJPY_OCO3_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO3_EO5_DOWN_S2)
	                Base.EURJPY_OCO3_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO3_EO6_DOWN_S2)
	                Base.EURJPY_OCO3_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURJPY_OCO3S1_DOWN_S2 = 0;
		                for (; EURJPY_OCO3S1_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets1.Count; EURJPY_OCO3S1_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO3Sets1[EURJPY_OCO3S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO3Sets1[EURJPY_OCO3S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_1__Time out_OCO3");
		                        Base.EURJPY_DOWN_S2_OCO3Sets1.Clear();
		                        EURJPY_OCO3S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURJPY_OCO3S2_DOWN_S2 = 0;
		                for (; EURJPY_OCO3S2_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets2.Count; EURJPY_OCO3S2_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO3Sets2[EURJPY_OCO3S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO3Sets2[EURJPY_OCO3S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_2__Time out_OCO3");
		                        Base.EURJPY_DOWN_S2_OCO3Sets2.Clear();
		                        EURJPY_OCO3S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO3S3_DOWN_S2 = 0;
		                for (; EURJPY_OCO3S3_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets3.Count; EURJPY_OCO3S3_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO3Sets3[EURJPY_OCO3S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO3Sets3[EURJPY_OCO3S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_3__Time out_OCO3");
		                        Base.EURJPY_DOWN_S2_OCO3Sets3.Clear();
		                        EURJPY_OCO3S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO3S4_DOWN_S2 = 0;
		                for (; EURJPY_OCO3S4_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets4.Count; EURJPY_OCO3S4_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO3Sets4[EURJPY_OCO3S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO3Sets4[EURJPY_OCO3S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_4__Time out_OCO3");
		                        Base.EURJPY_DOWN_S2_OCO3Sets4.Clear();
		                        EURJPY_OCO3S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO3S5_DOWN_S2 = 0;
		                for (; EURJPY_OCO3S5_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets5.Count; EURJPY_OCO3S5_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO3Sets5[EURJPY_OCO3S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO3Sets5[EURJPY_OCO3S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_5__Time out_OCO3");
		                        Base.EURJPY_DOWN_S2_OCO3Sets5.Clear();
		                        EURJPY_OCO3S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO3S6_DOWN_S2 = 0;
		                for (; EURJPY_OCO3S6_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO3Sets6.Count; EURJPY_OCO3S6_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO3Sets6[EURJPY_OCO3S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO3Sets6[EURJPY_OCO3S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_6__Time out_OCO3");
		                        Base.EURJPY_DOWN_S2_OCO3Sets6.Clear();
		                        EURJPY_OCO3S6_DOWN_S2 = 0;
		                        break;
		                    }
			        }
			        
			    if (Base.EURJPY_OCO4_EO1_DOWN_S2)
	                Base.EURJPY_OCO4_EO1_DOWN_S2_ID = order.Id;
	            if (Base.EURJPY_OCO4_EO2_DOWN_S2)
	                Base.EURJPY_OCO4_EO2_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO4_EO3_DOWN_S2)
	                Base.EURJPY_OCO4_EO3_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO4_EO4_DOWN_S2)
	                Base.EURJPY_OCO4_EO4_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO4_EO5_DOWN_S2)
	                Base.EURJPY_OCO4_EO5_DOWN_S2_ID = order.Id;
	        	if (Base.EURJPY_OCO4_EO6_DOWN_S2)
	                Base.EURJPY_OCO4_EO6_DOWN_S2_ID = order.Id;
	
			        if (algorithm.Time - order.CreatedTime >= TimeSpan.FromMinutes(Base.EURJPY_DOWN_S2_OCO_DELAY_7DAY))
			        {
			        	int EURJPY_OCO4S1_DOWN_S2 = 0;
		                for (; EURJPY_OCO4S1_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets1.Count; EURJPY_OCO4S1_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO4Sets1[EURJPY_OCO4S1_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO4Sets1[EURJPY_OCO4S1_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_1__Time out_OCO4");
		                        Base.EURJPY_DOWN_S2_OCO4Sets1.Clear();
		                        EURJPY_OCO4S1_DOWN_S2 = 0;
		                        break;
		                    }
		            
		                int EURJPY_OCO4S2_DOWN_S2 = 0;
		                for (; EURJPY_OCO4S2_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets2.Count; EURJPY_OCO4S2_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO4Sets2[EURJPY_OCO4S2_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO4Sets2[EURJPY_OCO4S2_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_2__Time out_OCO4");
		                        Base.EURJPY_DOWN_S2_OCO4Sets2.Clear();
		                        EURJPY_OCO4S2_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO4S3_DOWN_S2 = 0;
		                for (; EURJPY_OCO4S3_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets3.Count; EURJPY_OCO4S3_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO4Sets3[EURJPY_OCO4S3_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO4Sets3[EURJPY_OCO4S3_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_3__Time out_OCO4");
		                        Base.EURJPY_DOWN_S2_OCO4Sets3.Clear();
		                        EURJPY_OCO4S3_DOWN_S2 = 0;
		                        break;
		                    }
		                    
		                int EURJPY_OCO4S4_DOWN_S2 = 0;
		                for (; EURJPY_OCO4S4_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets4.Count; EURJPY_OCO4S4_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO4Sets4[EURJPY_OCO4S4_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO4Sets4[EURJPY_OCO4S4_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_4__Time out_OCO4");
		                        Base.EURJPY_DOWN_S2_OCO4Sets4.Clear();
		                        EURJPY_OCO4S4_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO4S5_DOWN_S2 = 0;
		                for (; EURJPY_OCO4S5_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets5.Count; EURJPY_OCO4S5_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO4Sets5[EURJPY_OCO4S5_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO4Sets5[EURJPY_OCO4S5_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_5__Time out_OCO4");
		                        Base.EURJPY_DOWN_S2_OCO4Sets5.Clear();
		                        EURJPY_OCO4S5_DOWN_S2 = 0;
		                        break;
		                    }
		                
		                int EURJPY_OCO4S6_DOWN_S2 = 0;
		                for (; EURJPY_OCO4S6_DOWN_S2 < Base.EURJPY_DOWN_S2_OCO4Sets6.Count; EURJPY_OCO4S6_DOWN_S2++)
		                    if (Base.EURJPY_DOWN_S2_OCO4Sets6[EURJPY_OCO4S6_DOWN_S2].InOrders(order.Id)) 
		                    {
		                        Base.EURJPY_DOWN_S2_OCO4Sets6[EURJPY_OCO4S6_DOWN_S2].TimeOut();
		                        yield return Insight.Price("EURJPY", TimeSpan.FromMilliseconds(1001), InsightDirection.Up, null, null, null, 1);
		                        algorithm.MarketOrder("EURJPY", order.Quantity, false, "EURJPY_DOWN_S2_Entry_6__Time out_OCO4");
		                        Base.EURJPY_DOWN_S2_OCO4Sets6.Clear();
		                        EURJPY_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();
	            	}
	            	
					DOWM_EURJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Monday);
					DOWT_EURJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Tuesday);
					DOWW_EURJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Wednesday);
					DOWTH_EURJPY_DOWN_S2 = (algorithm.Time.DayOfWeek == DayOfWeek.Thursday);
					DOWR_EURJPY_DOWN_S2 = DOWM_EURJPY_DOWN_S2 || DOWT_EURJPY_DOWN_S2 || DOWW_EURJPY_DOWN_S2 || DOWTH_EURJPY_DOWN_S2 || algorithm.Time.DayOfWeek == DayOfWeek.Friday;

	            	if (SY1D.Symbol.Equals("EURJPY"))
	            	{
	            		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.EURJPY_OCO1_DOWN_S2_IsReady == false ||
	                    	Base.EURJPY_OCO2_DOWN_S2_IsReady == false ||
	                    	Base.EURJPY_OCO3_DOWN_S2_IsReady == false ||
	                    	Base.EURJPY_OCO4_DOWN_S2_IsReady == false)
	                    {
	                    	Base.EURJPY_OCO1_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURJPY_OCO2_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURJPY_OCO3_DOWN_S2_Monthly_IsReady = false;
	                    	Base.EURJPY_OCO4_DOWN_S2_Monthly_IsReady = false;
	                    }

	            		if (algorithm.Time == SY1D.BQM[0].EndTime)
                    	{
                    		Base.EURJPY_OCO1_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURJPY_OCO2_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURJPY_OCO3_DOWN_S2_Monthly_IsReady = true;
                    		Base.EURJPY_OCO4_DOWN_S2_Monthly_IsReady = true;
                    	}

	                	EURJPY_Signal_Condition_DOWN_S2 =  
	                									(
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] > prices_ASK_Close[0] * 0.0000001m &&
	                										//pricesM_ASK_High[0] - pricesM_ASK_Close[0] < prices_ASK_Close[0] * 0.04m &&
	                										
	                										//prices_ASK_Low[0] > pricesM_ASK_Close[0] &&
	                										//prices_ASK_High[0] < pricesM_ASK_High[0] &&

	                										//prices_ASK_High[0] - pricesM_BID_High[1] > prices_ASK_Close[0] * 0.02m &&

	                										//pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 && //yuhukj
	                										
	                										//prices_BID_Open[0] - prices_ASK_Close[0] > 0 &&
 	                										
	                										//prices_BID_Close[0] > pricesM_ASK_High[0] && 
	                										//prices_ASK_High[0] > pricesM_ASK_High[0] && 
	                										
	                										pricesM_BID_Open[0] - pricesM_ASK_Close[0] > 0 &&
	                										pricesM_BID_Open[1] - pricesM_ASK_Close[1] > 0 &&
	                										
	                										//pricesM_BID_High[0] - pricesM_ASK_Open[0] > pricesM_BID_High[1] - pricesM_ASK_Open[1] &&
	                										
	                										//pricesM_BID_High[0] > pricesM_BID_High[1] &&
	                										
	                										//prices_BID_Close[0] > prices_ASK_Close[0]
	                										
	                										//prices_BID_Close[0] - prices_ASK_Open[0] > prices_ASK_Open[0] * 0.00001m &&
	                										
	                										prices_ASK_High[0] > pricesM_ASK_High[0] &&
	                										//prices_BID_Close[0] < pricesM_BID_High[0] &&
	                										
															prices_ASK_Close[0] - prices_BID_Close[0] > 0 &&
															prices_ASK_Close[0] - prices_BID_Close[0] < 0.1m
	                									);

	                    EURJPY_DOWN_S2_SL  =  0.5m;
	                    EURJPY_DOWN_S2_TP1 =  1.5m;
	                    EURJPY_DOWN_S2_TP2 =  EURJPY_DOWN_S2_TP1 * 1m;
	                    EURJPY_DOWN_S2_TP3 =  EURJPY_DOWN_S2_TP1 * 0;
	                    EURJPY_DOWN_S2_TP4 =  EURJPY_DOWN_S2_TP1 * 0;
	                    EURJPY_DOWN_S2_TP5 =  EURJPY_DOWN_S2_SL * 0;
	                    EURJPY_DOWN_S2_TP6 =  EURJPY_DOWN_S2_SL * 0;

	                    if (coefIntS2 != 0)
	                    {
	                    EURJPY_quantity_DOWN_S2 = -(int)Math.Floor(algorithm.Portfolio.GetBuyingPower(SY1D.Symbol, 0)/Base.SymbolCount*0.2m);
	                    EURJPY_quantity_SL_DOWN_S2 = EURJPY_quantity_DOWN_S2;
	                    EURJPY_quantity_TP1_DOWN_S2 = (int)Math.Floor(EURJPY_quantity_DOWN_S2 * 1m);
	                    EURJPY_quantity_TP2_DOWN_S2 = (int)Math.Floor(EURJPY_quantity_TP1_DOWN_S2 * 0m);
	                    EURJPY_quantity_TP3_DOWN_S2 = (int)Math.Floor(EURJPY_quantity_TP2_DOWN_S2 * 0m);
	                    EURJPY_quantity_TP4_DOWN_S2 = (int)Math.Floor(EURJPY_quantity_TP3_DOWN_S2 * 0m);
	                    EURJPY_quantity_TP5_DOWN_S2 = (int)Math.Floor(EURJPY_quantity_TP4_DOWN_S2 * 0m);
	                    EURJPY_quantity_TP6_DOWN_S2 = (int)Math.Floor(EURJPY_quantity_TP5_DOWN_S2 * 0m);
	                    }
	                    
	                    oco1:
	                    if (EURJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURJPY_DOWN_S2 && 
	                    Base.EURJPY_OCO1_DOWN_S2_IsReady == true &&
	                    Base.EURJPY_OCO1_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURJPY_OCO1_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO1_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP1_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP1_OCO1");
	                         Base.EURJPY_OCO1_EO1_DOWN_S2 = false;
	                         
	                         Base.EURJPY_OCO1_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO1_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP2_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP2_OCO1");
	                         Base.EURJPY_OCO1_EO2_DOWN_S2 = false;
	
	                         Base.EURJPY_OCO1_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO1_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP3_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP3_OCO1");
	                         Base.EURJPY_OCO1_EO3_DOWN_S2 = false;
	                    
	                         Base.EURJPY_OCO1_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO1_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP4_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP4_OCO1");
	                         Base.EURJPY_OCO1_EO4_DOWN_S2 = false;

							Base.EURJPY_OCO1_DOWN_S2_IsReady = false;
							
							if (Base.EURJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco2:
	                    if (EURJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURJPY_DOWN_S2 && 
	                    Base.EURJPY_OCO2_DOWN_S2_IsReady == true &&
	                    Base.EURJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURJPY_OCO2_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURJPY_OCO2_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO2_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP1_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP1_OCO2");
	                         Base.EURJPY_OCO2_EO1_DOWN_S2 = false;
	                         
	                         Base.EURJPY_OCO2_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO2_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP2_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP2_OCO2");
	                         Base.EURJPY_OCO2_EO2_DOWN_S2 = false;
	
	                         Base.EURJPY_OCO2_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO2_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP3_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP3_OCO2");
	                         Base.EURJPY_OCO2_EO3_DOWN_S2 = false;
	                    
	                         Base.EURJPY_OCO2_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO2_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP4_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP4_OCO2");
	                         Base.EURJPY_OCO2_EO4_DOWN_S2 = false;

							Base.EURJPY_OCO2_DOWN_S2_IsReady = false;
							
							if (Base.EURJPY_OCO2_DOWN_S2_IsReady == false && Base.EURJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco3:
	                    if (EURJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURJPY_DOWN_S2 &&
	                    Base.EURJPY_OCO3_DOWN_S2_IsReady == true &&
	                    Base.EURJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURJPY_OCO3_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURJPY_OCO3_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO3_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP1_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP1_OCO3");
	                         Base.EURJPY_OCO3_EO1_DOWN_S2 = false;
	                         
	                         Base.EURJPY_OCO3_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO3_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP2_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP2_OCO3");
	                         Base.EURJPY_OCO3_EO2_DOWN_S2 = false;
	
	                         Base.EURJPY_OCO3_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO3_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP3_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP3_OCO3");
	                         Base.EURJPY_OCO3_EO3_DOWN_S2 = false;
	                    
	                         Base.EURJPY_OCO3_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO3_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP4_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP4_OCO3");
	                         Base.EURJPY_OCO3_EO4_DOWN_S2 = false;

							Base.EURJPY_OCO3_DOWN_S2_IsReady = false;
							
							if (Base.EURJPY_OCO3_DOWN_S2_IsReady == false && Base.EURJPY_OCO2_DOWN_S2_IsReady == false && Base.EURJPY_OCO1_DOWN_S2_IsReady == false)
							break;

	                    }
	                    
	                    oco4:
	                    if (EURJPY_Signal_Condition_DOWN_S2 && 
	                    DOWR_EURJPY_DOWN_S2 && 
	                    Base.EURJPY_OCO4_DOWN_S2_IsReady == true &&
	                    Base.EURJPY_OCO1_DOWN_S2_IsReady == false &&
	                    Base.EURJPY_OCO2_DOWN_S2_IsReady == false &&
	                    Base.EURJPY_OCO3_DOWN_S2_IsReady == false &&
	                    Base.EURJPY_OCO4_DOWN_S2_Monthly_IsReady == true)
	                    {
	                         Base.EURJPY_OCO4_EO1_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO4_MO1_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP1_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP1_OCO4");
	                         Base.EURJPY_OCO4_EO1_DOWN_S2 = false;
	                         
	                         Base.EURJPY_OCO4_EO2_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO4_MO2_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP2_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP2_OCO4");
	                         Base.EURJPY_OCO4_EO2_DOWN_S2 = false;
	
	                         Base.EURJPY_OCO4_EO3_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO4_MO3_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP3_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP3_OCO4");
	                         Base.EURJPY_OCO4_EO3_DOWN_S2 = false;
	                    
	                         Base.EURJPY_OCO4_EO4_DOWN_S2 = true;
	                         yield return Insight.Price(SY1D.Symbol, TimeSpan.FromMinutes(5), InsightDirection.Down, null, null, null, 1);
	                         EURJPY_OCO4_MO4_DOWN_S2 = algorithm.MarketOrder(SY1D.Symbol, EURJPY_quantity_TP4_DOWN_S2, false,"EURJPY_DOWN_S2_Entry_TP4_OCO4");
	                         Base.EURJPY_OCO4_EO4_DOWN_S2 = false;

							Base.EURJPY_OCO4_DOWN_S2_IsReady = false;
							
							if (Base.EURJPY_OCO4_DOWN_S2_IsReady == false && Base.EURJPY_OCO3_DOWN_S2_IsReady == false && Base.EURJPY_OCO2_DOWN_S2_IsReady == false && Base.EURJPY_OCO1_DOWN_S2_IsReady == false)
							break;
	                    }
	                yield break;
	            }
	        }
	    }
	}
	}
}
}