public override bool Initialize(List <IProcessorInput> inputs, string parameters, ILogger logger) { ClosePositionStopTrade += Stop; if (Models.InputItemInteractivBrokerModel.IB == null) { return(false); } this.logger = logger; ParametersParser parser = CreateParser(parameters); zigzagid = parser.GetInt("ZigZag_ID"); zigzagidsmall = parser.GetInt("ZigZagSmall_ID"); if (zigzagid < 0 || zigzagid > Model.Project.Outputs.Count) { return(false); } if (zigzagidsmall < 0 || zigzagidsmall > Model.Project.Outputs.Count) { return(false); } gappos = parser.GetInt("Gap"); if (gappos < 0 || gappos > Model.Project.Outputs.Count) { return(false); } //Gap = Model.Project.Proccesors[gappos]; //Gap.ProcessorAction += PositionHandler; //ZigZag = Model.Project.Proccesors[zigzagid]; //ZigZag.ProcessorAction += EventHandler; MinValueSmall = new List <ProbaStruct>(); MaxValueSmall = new List <ProbaStruct>(); MinValueBig = new List <ProbaStruct>(); MaxValueBig = new List <ProbaStruct>(); PositionShort = new Position(); PositionLong = new Position(); name = parser.GetString("Name"); ratio = parser.GetDouble("Ratio"); tradeTerminal = new ModelsAT.BrokerMT(parser.GetInt("tradeTerminalID")); tradeTerminal.setBrokerParam("Name", parser.GetString("ServerName")); tradeTerminal.SetServer(); Size = parser.GetInt("Size"); if (parser.GetInt("IsReal") == 1) { tradeTerminal.isReal = true; } if (parser.GetInt("Logg") == 1) { LoggNeeded = true; } else { LoggNeeded = false; } //if (divergence > size || divergence == 0) return false; openlongcloseshort = false; openshortcloselong = false; longlock = false; shortlock = false; profit_to_close = parser.GetInt("TakeProfit") * Math.Pow(10, -Model.Project.Outputs[gappos].Digits); lose_to_close = parser.GetInt("StopLoss") * Math.Pow(10, -Model.Project.Outputs[gappos].Digits); convergenceshort = false; convergencelong = false; divergenceshort = false; divergencelong = false; lastvalue = LastZigZagValue.NONE; all_profit = 0; openpos = OpenPosition.NONE; ConvergenMin = new ProbaStruct(); ConvergenMax = new ProbaStruct(); Model.OutputsInitializeEnd += InitializeHandler; Model.LoadSimulation += LoadSec; return(true); }
public override bool Initialize(List <IProcessorInput> inputs, string parameters, ILogger logger) { ClosePositionStopTrade += Stop; if (Models.InputItemInteractivBrokerModel.IB == null) { return(false); } this.logger = logger; ParametersParser parser = CreateParser(parameters); zigzagid_1 = parser.GetInt("ZigZag_ID1"); if (zigzagid_1 < 0 || zigzagid_1 > Model.Project.Outputs.Count) { return(false); } zigzagid_2 = parser.GetInt("ZigZag_ID2"); if (zigzagid_2 < 0 || zigzagid_2 > Model.Project.Outputs.Count) { return(false); } zigzagid_2_2 = parser.GetInt("ZigZag_ID2_2"); gappos = parser.GetInt("Gap"); if (gappos < 0 || gappos > Model.Project.Outputs.Count) { return(false); } int t_t = parser.GetInt("type"); switch (t_t) { case (0): trader_type = TradeType.STANDART; break; case (1): trader_type = TradeType.IN_OUT; break; default: trader_type = TradeType.ONE_IN_TWO_OUT; break; } //Gap = Model.Project.Proccesors[gappos]; //Gap.ProcessorAction += PositionHandler; //ZigZag = Model.Project.Proccesors[zigzagid]; //ZigZag.ProcessorAction += EventHandler; divergenceOpen = parser.GetInt("DivergenceOpen"); divergenceClose = parser.GetInt("DivergenceClose"); convergen_counter = parser.GetInt("Convergence"); if (divergenceOpen < 0 || divergenceClose < 0 || convergen_counter < 0) { return(false); } MinValueOpen_1 = new List <ProbaStruct>(); MaxValueOpen_1 = new List <ProbaStruct>(); MinValueClose_1 = new List <ProbaStruct>(); MaxValueClose_1 = new List <ProbaStruct>(); MinValueOpen_2 = new List <ProbaStruct>(); MaxValueOpen_2 = new List <ProbaStruct>(); MinValueClose_2 = new List <ProbaStruct>(); MaxValueClose_2 = new List <ProbaStruct>(); MinValueOpen_2_2 = new List <ProbaStruct>(); MaxValueOpen_2_2 = new List <ProbaStruct>(); MinValueClose_2_2 = new List <ProbaStruct>(); MaxValueClose_2_2 = new List <ProbaStruct>(); PositionShort = new List <Position>(); PositionLong = new List <Position>(); name = parser.GetString("Name"); ratio = parser.GetDouble("Ratio"); profit_to_close = parser.GetInt("TakeProfit") * Math.Pow(10, -Model.Project.Outputs[gappos].Digits); lose_to_close = parser.GetInt("StopLoss") * Math.Pow(10, -Model.Project.Outputs[gappos].Digits); ratio_exp = parser.GetDouble("Ratio_O"); tradeTerminal = new ModelsAT.BrokerMT(parser.GetInt("tradeTerminalID")); tradeTerminal.setBrokerParam("Name", parser.GetString("ServerName")); tradeTerminal.SetServer(); if (parser.GetInt("IsReal") == 1) { tradeTerminal.isReal = true; } else { tradeTerminal.isReal = false; } if (parser.GetInt("Logg") == 1) { LoggNeeded = true; } else { LoggNeeded = false; } if (parser.GetInt("Expand") == 1) { can_expand = true; } else { can_expand = false; } divergence_max_open = 0; divergence_min_open = 0; divergence_max_close = 0; divergence_min_close = 0; openlong = false; openshort = false; closelong = false; expand_position_short = false; expand_position_long = false; closeshort = false; lastvalue = LastZigZagValue.NONE; all_profit = 0; openpos = OpenPosition.NONE; convergen_min = 0; convergen_max = 0; ConvergenMin = new ProbaStruct(); ConvergenMax = new ProbaStruct(); last_pos = new LastPosition(); Model.OutputsInitializeEnd += InitializeHandler; Model.LoadSimulation += LoadSec; return(true); }