//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2020, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ #ifndef CTRL_PANEL_INPUT_STRUCT_V2_MQH #define CTRL_PANEL_INPUT_STRUCT_V2_MQH //+------------------------------------------------------------------+ //| Структуры и функции механизма записи просадки в бинарный файл | //+------------------------------------------------------------------+ #define LBF_WORD "EASETKA" #define LBF_VERSION 2 #define LBF_SET_STRUCT_VERSION 1 #define LBF_MOD_BASE "BASE" #define LBF_MOD_ADXIMP "ADX-IMP" #define LBF_MOD_RSICCIAS "RCI-CCI-AS" struct LBFBalanceItem { datetime dt; double balance; double equity; double free_margin; int count_buy; int count_sell; double drawdown; double margin; double drawdown_buy; double drawdown_sell; double length_buy; double length_sell; double volume_buy; double volume_sell; double tick_value; }; struct LBFHeader { uchar word[7]; // Ключевое слово EA-SETKA uchar format_ver; // Версия формата uchar bot_ver[10]; // Версия бота uchar bot_mod[10]; // Мод бота long leverage; // Плечо тестирования long count_item; // Количество элементов для записи uchar set_struct_version; // Версия структуры содержащей сет int size_of_set_struct; // Размер структуры содержащей сет }; struct LBFSetStruct { bool TradeSell; bool TradeBuy; bool S_OpenFirstOrder; bool B_OpenFirstOrder; bool S_CloseAllOrders; bool B_CloseAllOrders; int S_PauseOnClose; int B_PauseOnClose; int MagicNumber; bool ReflectSellSettingsToBuy; float MaxSpread; int MaxSpreadStopTradingTimining; int MinLeverage; int MinTimeStep; int MaxTradePairs; int CurrencyBlock; int No1Order_ByDrawdownPercent; int No1Order_ByDrawdownPercent_Off; int StopTrade_ByDrawdownPercent; int StopTrade_ByDrawdownPercent_Off; int StopTrade_ByDrawdownMoney; int StopTrade_ByDrawdownMoney_Off; double CloseAllOrders_ByProfitPercent; double CloseAllOrders_ByProfitMoney; double CloseAllOrders_ByDrawdownPercent; double CloseAllOrders_ByDrawdownMoney; double S_CloseOrders_ByDrawdown_For001Lot; double B_CloseOrders_ByDrawdown_For001Lot; bool CloseAllOrders_ByDrawdown_StopTrade; int S_MaxOpenOrders; int S_GridStep; int S_GridLevel; int S_GridStep_AddPips; int S_GridStep_Level2; int S_GridStep_Level2_AddPips; int S_Grid3; int S_Grid3Add; int S_GridStop; enum_calc_lot_type S_CalcLotType; int S_CurrencyFor001Lot; double S_MinLot; double S_Mult; int S_MultStart; int S_MultLevel2; double S_MultCorr; int S_MultLevel3; double S_MultСorrLevel3; int S_Mult3; double S_Mult3Add; int S_MultStop; double S_MaxLotCoef; double S_TestMinLot; enum_take_profit_calc_type S_TakeProffitType; int S_TakeProffit; int S_TakeProffit_Level1; int S_TakeProffit_Level1Corr; int S_TakeProffit_Level1_5; int S_TakeProffit_Level1_5Corr; int S_TakeProffit_Level2; int S_TakeProffit_Level2FixPips; int B_MaxOpenOrders; int B_GridStep; int B_GridLevel; int B_GridStep_AddPips; int B_GridStep_Level2; int B_GridStep_Level2_AddPips; int B_Grid3; int B_Grid3Add; int B_GridStop; enum_calc_lot_type B_CalcLotType; int B_CurrencyFor001Lot; double B_MinLot; double B_Mult; int B_MultStart; int B_MultLevel2; double B_MultCorr; int B_MultLevel3; double B_MultСorrLevel3; int B_Mult3; double B_Mult3Add; int B_MultStop; double B_MaxLotCoef; double B_TestMinLot; enum_take_profit_calc_type B_TakeProffitType; int B_TakeProffit; int B_TakeProffit_Level1; int B_TakeProffit_Level1Corr; int B_TakeProffit_Level1_5; int B_TakeProffit_Level1_5Corr; int B_TakeProffit_Level2; int B_TakeProffit_Level2FixPips; enum_use_indicator use_ADX_for1Order; enum_time_frames AdxTimeFrame1; int AdxPeriod1; double AdxLevel1; double use_ADX_ds1; bool use_ADX_p3_1; int use_ADX_for_next_Order; enum_time_frames AdxTimeFrame; int AdxPeriod; double AdxLevel; double use_ADX_ds; bool use_ADX_p3; enum_use_indicator use_imp_for1Order; enum_impulse_select imp_indi_1order; enum_time_frames ImpTimeFrame1; int ImpPeriod1; double LGCoeff1; double ImpLevel1; int use_imp_for_next_Order; enum_impulse_select imp_indi_next_order; enum_time_frames ImpTimeFrame; int ImpPeriod; double LGCoeff; double ImpLevel; enum_time_frames CandleTimeframe; enum_time_frames CandleTimeframeNext; enum_time_frames RsiTimeframe; int RsiPeriod; int RsiLevel; enum_time_frames RsiTimeframeNext; int RsiPeriodNext; int RsiLevelNext; enum_time_frames CciTimeframe; int CciPeriod; int CciLevel; enum_time_frames CciTimeframeNext; int CciPeriodNext; int CciLevelNext; bool use_for1Order; int use_for_next_Order; enum_time_frames OpenFirstOrderTF; int CandlesToOpen1Order; bool CandlesToOpen1Order_OpenClose; int CandlesToOpen1Order_MinPips; int CandlesToOpen1Order_MaxPips; bool ReversSignalToOpen1Order; bool CandlesToOpen1Order_OneWay; enum_gap_control_type GapControl; int GapMaxStopOrders; int GapMinDistanceFromMarket; int S_GapMinPips; int S_GapMinPercent; double S_GapLotKoef; double S_GapLastOrderKoef; int B_GapMinPips; int B_GapMinPercent; double B_GapLotKoef; double B_GapLastOrderKoef; int VolFromLevel; int VolEndLevel; enum_time_frames VolCandleTF; int VolCandles; bool VolNullBar; bool VolCandles_OneWay; int VolCandleMaxSize; bool VolCandle_OpenClose; int VolStopTradeTimining; bool VolBlockBothDirection; int Vol2FromLevel; int Vol2EndLevel; enum_time_frames Vol2CandleTF; int Vol2Candles; bool Vol2NullBar; bool Vol2Candles_OneWay; int Vol2CandleMaxSize; bool Vol2Candle_OpenClose; int Vol2StopTradeTimining; bool Vol2BlockBothDirection; int Vol3FromLevel; int Vol3EndLevel; enum_time_frames Vol3CandleTF; int Vol3Candles; bool Vol3NullBar; bool Vol3Candles_OneWay; int Vol3CandleMaxSize; bool Vol3Candle_OpenClose; int Vol3StopTradeTimining; bool Vol3BlockBothDirection; day_of_week_t TradeStartDay; int TradeStartHour; int TradeStartMinute; day_of_week_t TradeEndDay; int TradeEndHour; int TradeEndMinute; #define input_new_position_pause_s(number) \ datetime NewPositionPause##number##Start; \ datetime NewPositionPause##number##End; input_new_position_pause_s(1); input_new_position_pause_s(2); input_new_position_pause_s(3); input_new_position_pause_s(4); input_new_position_pause_s(5); input_new_position_pause_s(6); input_new_position_pause_s(7); input_new_position_pause_s(8); input_new_position_pause_s(9); input_new_position_pause_s(10); char NewPositionPauseNewYearDayStart; char NewPositionPauseNewYearDayEnd; #define input_intraday_s(number) \ ushort IntraDay##number##StartHour; \ ushort IntraDay##number##StartMinute; \ ushort IntraDay##number##EndHour; \ ushort IntraDay##number##EndMinute; input_intraday_s(1); input_intraday_s(2); input_intraday_s(3); input_intraday_s(4); input_intraday_s(5); input_intraday_s(6); input_intraday_s(7); input_intraday_s(8); input_intraday_s(9); input_intraday_s(10); #define input_tradepause_s(number) \ datetime TradePause##number##Start; \ datetime TradePause##number##End; input_tradepause_s(1); input_tradepause_s(2); input_tradepause_s(3); input_tradepause_s(4); input_tradepause_s(5); input_tradepause_s(6); input_tradepause_s(7); input_tradepause_s(8); input_tradepause_s(9); input_tradepause_s(10); #define input_stoptrade_s(number) \ ushort IntraDayStopTrade##number##StartHour; \ ushort IntraDayStopTrade##number##StartMinute; \ ushort IntraDayStopTrade##number##EndHour; \ ushort IntraDayStopTrade##number##EndMinute; input_stoptrade_s(1); input_stoptrade_s(2); input_stoptrade_s(3); input_stoptrade_s(4); input_stoptrade_s(5); input_stoptrade_s(6); input_stoptrade_s(7); input_stoptrade_s(8); input_stoptrade_s(9); input_stoptrade_s(10); int CloseAllOrders_EveryDay_Hour; int CloseAllOrders_EveryDay_Minute; int TakeProffitControlTiming; int TakeProffitControlNoLossFixPips; datetime FinalGridDate; int GlobalParamsUpdateTiming; int LogVerbose ; }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #ifndef _LBF_UTIL bool LBFWriteHeaderToFile(int file_handle, long count_item) { LBFHeader header= {{0,0,0,0,0,0,0}, LBF_VERSION, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0},0,0, LBF_SET_STRUCT_VERSION, sizeof(LBFSetStruct)}; StringToCharArray(LBF_WORD,header.word,0, 7); StringToCharArray(VER,header.bot_ver,0, 10); StringToCharArray(LBF_MOD_BASE,header.bot_mod,0, 10); header.leverage=kernel_account::leverage(); header.count_item=count_item; #ifdef USE_FILTERS StringToCharArray(LBF_MOD_ADXIMP,header.bot_mod,0, 10); #endif #ifdef RSI_CCI StringToCharArray(LBF_MOD_RSICCIAS,header.bot_mod,0, 10); #endif uint byteswritten=FileWriteStruct(file_handle,header); if(byteswritten!=sizeof(LBFHeader)) { return false; } return true; } #endif //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ string LBFDoubleToString(double val,bool is_dec_sep_comma, int size_dec=2) { string s=DoubleToString(val,size_dec); if(is_dec_sep_comma) StringReplace(s,".",","); else StringReplace(s,",","."); return s; } #define LBFDtoS(val) LBFDoubleToString(val,is_dec_sep_comma) #define LBFDtoSE(val,s) LBFDoubleToString(val,is_dec_sep_comma,s) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool LBFWriteItemToCVSFile(int file_handle, LBFBalanceItem& item,bool is_dec_sep_comma) { FileWrite(file_handle,item.dt,LBFDtoS(item.balance),LBFDtoS(item.equity),LBFDtoS(item.free_margin),IntegerToString(item.count_buy) ,IntegerToString(item.count_sell),LBFDtoS(item.drawdown),LBFDtoS(item.margin),LBFDtoS(item.drawdown_buy),LBFDtoS(item.drawdown_sell),LBFDtoS(item.length_buy),LBFDtoS(item.length_sell),LBFDtoS(item.volume_buy),LBFDtoS(item.volume_sell),LBFDtoSE(item.tick_value,5)); return true; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool LBFWriteHeaderCVSFile(int file_handle) { FileWrite(file_handle,"DATETIME","BALANCE", "EQUITY", "FREE MARGIN","COUNT BUY","COUNT SELL" ,"DRAWDOWN","MARGIN","DRAWDOWN BUY","DRAWDOWN SELL", "LENGTH BUY","LENGTH SELL","VOLUME BUY","VOLUME SELL","TICK_VALUE"); return true; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #ifndef _LBF_UTIL bool LBFWriteSetToFile(int file_handle) { LBFSetStruct sst; ZeroMemory(sst); sst.TradeSell=TradeSell; sst.TradeBuy=TradeBuy; sst.S_OpenFirstOrder=S_OpenFirstOrder; sst.B_OpenFirstOrder=B_OpenFirstOrder ; sst.S_CloseAllOrders=S_CloseAllOrders ; sst.B_CloseAllOrders=B_CloseAllOrders ; sst.S_PauseOnClose=S_PauseOnClose ; sst.B_PauseOnClose=B_PauseOnClose ; sst.MagicNumber=MagicNumber ; sst.ReflectSellSettingsToBuy=ReflectSellSettingsToBuy ; sst.MaxSpread=MaxSpread ; sst.MaxSpreadStopTradingTimining=MaxSpreadStopTradingTimining ; sst.MinLeverage=MinLeverage ; sst.MinTimeStep=MinTimeStep ; sst.MaxTradePairs=MaxTradePairs ; sst.CurrencyBlock=CurrencyBlock ; sst.No1Order_ByDrawdownPercent=No1Order_ByDrawdownPercent ; sst.No1Order_ByDrawdownPercent_Off=No1Order_ByDrawdownPercent_Off ; sst.StopTrade_ByDrawdownPercent=StopTrade_ByDrawdownPercent ; sst.StopTrade_ByDrawdownPercent_Off=StopTrade_ByDrawdownPercent_Off ; sst.StopTrade_ByDrawdownMoney=StopTrade_ByDrawdownMoney ; sst.StopTrade_ByDrawdownMoney_Off=StopTrade_ByDrawdownMoney_Off ; sst.CloseAllOrders_ByProfitPercent=CloseAllOrders_ByProfitPercent ; sst.CloseAllOrders_ByProfitMoney=CloseAllOrders_ByProfitMoney ; sst.CloseAllOrders_ByDrawdownPercent=CloseAllOrders_ByDrawdownPercent ; sst.CloseAllOrders_ByDrawdownMoney=CloseAllOrders_ByDrawdownMoney ; sst.S_CloseOrders_ByDrawdown_For001Lot=S_CloseOrders_ByDrawdown_For001Lot ; sst.B_CloseOrders_ByDrawdown_For001Lot=B_CloseOrders_ByDrawdown_For001Lot ; sst.CloseAllOrders_ByDrawdown_StopTrade=CloseAllOrders_ByDrawdown_StopTrade ; sst.S_MaxOpenOrders=S_MaxOpenOrders ; sst.S_GridStep=S_GridStep ; sst.S_GridLevel=S_GridLevel ; sst.S_GridStep_AddPips=S_GridStep_AddPips ; sst.S_GridStep_Level2=S_GridStep_Level2 ; sst.S_GridStep_Level2_AddPips=S_GridStep_Level2_AddPips ; sst.S_Grid3=S_Grid3 ; sst.S_Grid3Add=S_Grid3Add ; sst.S_GridStop=S_GridStop ; sst.S_CalcLotType=S_CalcLotType ; sst.S_CurrencyFor001Lot=S_CurrencyFor001Lot ; sst.S_MinLot=S_MinLot ; sst.S_Mult=S_Mult ; sst.S_MultStart=S_MultStart ; sst.S_MultLevel2=S_MultLevel2 ; sst.S_MultCorr=S_MultCorr ; sst.S_MultLevel3=S_MultLevel3 ; sst.S_MultСorrLevel3=S_MultСorrLevel3 ; sst.S_Mult3=S_Mult3 ; sst.S_Mult3Add=S_Mult3Add ; sst.S_MultStop=S_MultStop ; sst.S_MaxLotCoef=S_MaxLotCoef ; sst.S_TestMinLot=S_TestMinLot ; sst.S_TakeProffitType=S_TakeProffitType ; sst.S_TakeProffit=S_TakeProffit ; sst.S_TakeProffit_Level1=S_TakeProffit_Level1 ; sst.S_TakeProffit_Level1Corr=S_TakeProffit_Level1Corr ; sst.S_TakeProffit_Level1_5=S_TakeProffit_Level1_5 ; sst.S_TakeProffit_Level1_5Corr=S_TakeProffit_Level1_5Corr ; sst.S_TakeProffit_Level2=S_TakeProffit_Level2 ; sst.S_TakeProffit_Level2FixPips=S_TakeProffit_Level2FixPips ; sst.B_MaxOpenOrders=B_MaxOpenOrders ; sst.B_GridStep=B_GridStep ; sst.B_GridLevel=B_GridLevel ; sst.B_GridStep_AddPips=B_GridStep_AddPips ; sst.B_GridStep_Level2=B_GridStep_Level2 ; sst.B_GridStep_Level2_AddPips=B_GridStep_Level2_AddPips ; sst.B_Grid3=B_Grid3 ; sst.B_Grid3Add=B_Grid3Add ; sst.B_GridStop=B_GridStop ; sst.B_CalcLotType=B_CalcLotType ; sst.B_CurrencyFor001Lot=B_CurrencyFor001Lot ; sst.B_MinLot=B_MinLot ; sst.B_Mult=B_Mult ; sst.B_MultStart=B_MultStart ; sst.B_MultLevel2=B_MultLevel2 ; sst.B_MultCorr=B_MultCorr ; sst.B_MultLevel3=B_MultLevel3 ; sst.B_MultСorrLevel3=B_MultСorrLevel3 ; sst.B_Mult3=B_Mult3 ; sst.B_Mult3Add=B_Mult3Add ; sst.B_MultStop=B_MultStop ; sst.B_MaxLotCoef=B_MaxLotCoef ; sst.B_TestMinLot=B_TestMinLot ; sst.B_TakeProffitType=B_TakeProffitType ; sst.B_TakeProffit=B_TakeProffit ; sst.B_TakeProffit_Level1=B_TakeProffit_Level1 ; sst.B_TakeProffit_Level1Corr=B_TakeProffit_Level1Corr ; sst.B_TakeProffit_Level1_5=B_TakeProffit_Level1_5 ; sst.B_TakeProffit_Level1_5Corr=B_TakeProffit_Level1_5Corr ; sst.B_TakeProffit_Level2=B_TakeProffit_Level2 ; sst.B_TakeProffit_Level2FixPips=B_TakeProffit_Level2FixPips ; #ifdef USE_FILTERS sst.use_ADX_for1Order=use_ADX_for1Order ; sst.AdxTimeFrame1=AdxTimeFrame1 ; sst.AdxPeriod1=AdxPeriod1 ; sst.AdxLevel1=AdxLevel1 ; sst.use_ADX_ds1=use_ADX_ds1 ; sst.use_ADX_p3_1=use_ADX_p3_1 ; sst.use_ADX_for_next_Order=use_ADX_for_next_Order ; sst.AdxTimeFrame=AdxTimeFrame ; sst.AdxPeriod=AdxPeriod ; sst.AdxLevel=AdxLevel ; sst.use_ADX_ds=use_ADX_ds ; sst.use_ADX_p3=use_ADX_p3 ; sst.use_imp_for1Order=use_imp_for1Order ; sst.imp_indi_1order=imp_indi_1order ; sst.ImpTimeFrame1=ImpTimeFrame1 ; sst.ImpPeriod1=ImpPeriod1 ; sst.LGCoeff1=LGCoeff1 ; sst.ImpLevel1=ImpLevel1 ; sst.use_imp_for_next_Order=use_imp_for_next_Order ; sst.imp_indi_next_order=imp_indi_next_order ; sst.ImpTimeFrame=ImpTimeFrame ; sst.ImpPeriod=ImpPeriod ; sst.LGCoeff=LGCoeff ; sst.ImpLevel=ImpLevel ; #endif #ifdef RSI_CCI sst.CandleTimeframe=CandleTimeframe ; sst.CandleTimeframeNext=CandleTimeframeNext ; sst.RsiTimeframe=RsiTimeframe ; sst.RsiPeriod=RsiPeriod ; sst.RsiLevel=RsiLevel ; sst.RsiTimeframeNext=RsiTimeframeNext ; sst.RsiPeriodNext=RsiPeriodNext ; sst.RsiLevelNext=RsiLevelNext ; sst.CciTimeframe=CciTimeframe ; sst.CciPeriod=CciPeriod ; sst.CciLevel=CciLevel ; sst.CciTimeframeNext=CciTimeframeNext ; sst.CciPeriodNext=CciPeriodNext ; sst.CciLevelNext=CciLevelNext ; sst.use_for1Order=use_for1Order ; sst.use_for_next_Order=use_for_next_Order ; #endif //USE_RSI_CCI sst.OpenFirstOrderTF=OpenFirstOrderTF ; sst.CandlesToOpen1Order=CandlesToOpen1Order ; sst.CandlesToOpen1Order_OpenClose=CandlesToOpen1Order_OpenClose ; sst.CandlesToOpen1Order_MinPips=CandlesToOpen1Order_MinPips ; sst.CandlesToOpen1Order_MaxPips=CandlesToOpen1Order_MaxPips ; sst.ReversSignalToOpen1Order=ReversSignalToOpen1Order ; sst.CandlesToOpen1Order_OneWay=CandlesToOpen1Order_OneWay ; sst.GapControl=GapControl ; sst.GapMaxStopOrders=GapMaxStopOrders ; sst.GapMinDistanceFromMarket=GapMinDistanceFromMarket ; sst.S_GapMinPips=S_GapMinPips ; sst.S_GapMinPercent=S_GapMinPercent ; sst.S_GapLotKoef=S_GapLotKoef ; sst.S_GapLastOrderKoef=S_GapLastOrderKoef ; sst.B_GapMinPips=B_GapMinPips ; sst.B_GapMinPercent=B_GapMinPercent ; sst.B_GapLotKoef=B_GapLotKoef ; sst.B_GapLastOrderKoef=B_GapLastOrderKoef ; sst.VolFromLevel=VolFromLevel ; sst.VolCandleTF=VolCandleTF ; sst.VolCandleMaxSize=VolCandleMaxSize ; sst.VolStopTradeTimining=VolStopTradeTimining ; sst.VolBlockBothDirection=VolBlockBothDirection ; sst.VolEndLevel=VolEndLevel ; sst.VolCandles=VolCandles ; sst.VolNullBar=VolNullBar ; sst.VolCandles_OneWay=VolCandles_OneWay ; sst.VolCandle_OpenClose=VolCandle_OpenClose ; sst.Vol2FromLevel=Vol2FromLevel ; sst.Vol2EndLevel=Vol2EndLevel ; sst.Vol2CandleTF=Vol2CandleTF ; sst.Vol2Candles=Vol2Candles ; sst.Vol2NullBar=Vol2NullBar ; sst.Vol2Candles_OneWay=Vol2Candles_OneWay ; sst.Vol2CandleMaxSize=Vol2CandleMaxSize ; sst.Vol2Candle_OpenClose=Vol2Candle_OpenClose ; sst.Vol2StopTradeTimining=Vol2StopTradeTimining ; sst.Vol2BlockBothDirection=Vol2BlockBothDirection ; sst.Vol3FromLevel=Vol3FromLevel ; sst.Vol3EndLevel=Vol3EndLevel ; sst.Vol3CandleTF=Vol3CandleTF ; sst.Vol3Candles=Vol3Candles ; sst.Vol3NullBar=Vol3NullBar ; sst.Vol3Candles_OneWay=Vol3Candles_OneWay ; sst.Vol3CandleMaxSize=Vol3CandleMaxSize ; sst.Vol3Candle_OpenClose=Vol3Candle_OpenClose ; sst.Vol3StopTradeTimining=Vol3StopTradeTimining ; sst.Vol3BlockBothDirection=Vol3BlockBothDirection ; sst.TradeStartDay=TradeStartDay ; sst.TradeStartHour=TradeStartHour ; sst.TradeStartMinute=TradeStartMinute ; sst.TradeEndDay=TradeEndDay ; sst.TradeEndHour=TradeEndHour ; sst.TradeEndMinute=TradeEndMinute ; #define input_new_position_pause_sd(number) \ sst.NewPositionPause##number##Start=NewPositionPause##number##Start; \ sst.NewPositionPause##number##End=NewPositionPause##number##End ; input_new_position_pause_sd(1); input_new_position_pause_sd(2); input_new_position_pause_sd(3); input_new_position_pause_sd(4); input_new_position_pause_sd(5); input_new_position_pause_sd(6); input_new_position_pause_sd(7); input_new_position_pause_sd(8); input_new_position_pause_sd(9); input_new_position_pause_sd(10); sst.NewPositionPauseNewYearDayStart=NewPositionPauseNewYearDayStart ; sst.NewPositionPauseNewYearDayEnd=NewPositionPauseNewYearDayEnd ; #define input_intraday_sd(number) \ sst.IntraDay##number##StartHour=IntraDay##number##StartHour ; \ sst.IntraDay##number##StartMinute=IntraDay##number##StartMinute ; \ sst.IntraDay##number##EndHour=IntraDay##number##EndHour ; \ sst.IntraDay##number##EndMinute=IntraDay##number##EndMinute ; input_intraday_sd(1); input_intraday_sd(2); input_intraday_sd(3); input_intraday_sd(4); input_intraday_sd(5); input_intraday_sd(6); input_intraday_sd(7); input_intraday_sd(8); input_intraday_sd(9); input_intraday_sd(10); #define input_tradepause_sd(number) \ sst.TradePause##number##Start=TradePause##number##Start ; \ sst.TradePause##number##End=TradePause##number##End ; input_tradepause_sd(1); input_tradepause_sd(2); input_tradepause_sd(3); input_tradepause_sd(4); input_tradepause_sd(5); input_tradepause_sd(6); input_tradepause_sd(7); input_tradepause_sd(8); input_tradepause_sd(9); input_tradepause_sd(10); #define input_stoptrade_sd(number) \ sst.IntraDayStopTrade##number##StartHour=IntraDayStopTrade##number##StartHour ; \ sst.IntraDayStopTrade##number##StartMinute=IntraDayStopTrade##number##StartMinute ; \ sst.IntraDayStopTrade##number##EndHour=IntraDayStopTrade##number##EndHour ; \ sst.IntraDayStopTrade##number##EndMinute=IntraDayStopTrade##number##EndMinute ; input_stoptrade_sd(1); input_stoptrade_sd(2); input_stoptrade_sd(3); input_stoptrade_sd(4); input_stoptrade_sd(5); input_stoptrade_sd(6); input_stoptrade_sd(7); input_stoptrade_sd(8); input_stoptrade_sd(9); input_stoptrade_sd(10); sst.CloseAllOrders_EveryDay_Hour=CloseAllOrders_EveryDay_Hour ; sst.CloseAllOrders_EveryDay_Minute=CloseAllOrders_EveryDay_Minute ; sst.TakeProffitControlTiming=TakeProffitControlTiming ; sst.TakeProffitControlNoLossFixPips=TakeProffitControlNoLossFixPips ; sst.FinalGridDate=FinalGridDate ; sst.GlobalParamsUpdateTiming=GlobalParamsUpdateTiming ; sst.LogVerbose=LogVerbose; uint byteswritten=0; byteswritten=FileWriteStruct(file_handle,sst); if(byteswritten!=sizeof(LBFSetStruct)) { return false; } return true; } #endif #define LBFWRITESETPARAMTOFILE(param) FileWrite(file_handle,#param,"=",sst.param); //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool LBFWriteSetToCSVFile(int file_handle,LBFHeader& header,LBFSetStruct& sst) { LBFWRITESETPARAMTOFILE(TradeSell) LBFWRITESETPARAMTOFILE(TradeBuy) LBFWRITESETPARAMTOFILE(S_OpenFirstOrder); LBFWRITESETPARAMTOFILE(B_OpenFirstOrder); LBFWRITESETPARAMTOFILE(S_CloseAllOrders); LBFWRITESETPARAMTOFILE(B_CloseAllOrders); LBFWRITESETPARAMTOFILE(S_PauseOnClose); LBFWRITESETPARAMTOFILE(B_PauseOnClose); LBFWRITESETPARAMTOFILE(MagicNumber); LBFWRITESETPARAMTOFILE(ReflectSellSettingsToBuy); LBFWRITESETPARAMTOFILE(MaxSpread); LBFWRITESETPARAMTOFILE(MaxSpreadStopTradingTimining); LBFWRITESETPARAMTOFILE(MinLeverage); LBFWRITESETPARAMTOFILE(MinTimeStep); LBFWRITESETPARAMTOFILE(MaxTradePairs); LBFWRITESETPARAMTOFILE(CurrencyBlock); LBFWRITESETPARAMTOFILE(No1Order_ByDrawdownPercent); LBFWRITESETPARAMTOFILE(No1Order_ByDrawdownPercent_Off); LBFWRITESETPARAMTOFILE(StopTrade_ByDrawdownPercent); LBFWRITESETPARAMTOFILE(StopTrade_ByDrawdownPercent_Off); LBFWRITESETPARAMTOFILE(StopTrade_ByDrawdownMoney); LBFWRITESETPARAMTOFILE(StopTrade_ByDrawdownMoney_Off); LBFWRITESETPARAMTOFILE(CloseAllOrders_ByProfitPercent); LBFWRITESETPARAMTOFILE(CloseAllOrders_ByProfitMoney); LBFWRITESETPARAMTOFILE(CloseAllOrders_ByDrawdownPercent); LBFWRITESETPARAMTOFILE(CloseAllOrders_ByDrawdownMoney); LBFWRITESETPARAMTOFILE(S_CloseOrders_ByDrawdown_For001Lot); LBFWRITESETPARAMTOFILE(B_CloseOrders_ByDrawdown_For001Lot); LBFWRITESETPARAMTOFILE(CloseAllOrders_ByDrawdown_StopTrade); LBFWRITESETPARAMTOFILE(S_MaxOpenOrders); LBFWRITESETPARAMTOFILE(S_GridStep); LBFWRITESETPARAMTOFILE(S_GridLevel); LBFWRITESETPARAMTOFILE(S_GridStep_AddPips); LBFWRITESETPARAMTOFILE(S_GridStep_Level2); LBFWRITESETPARAMTOFILE(S_GridStep_Level2_AddPips); LBFWRITESETPARAMTOFILE(S_Grid3); LBFWRITESETPARAMTOFILE(S_Grid3Add); LBFWRITESETPARAMTOFILE(S_GridStop); LBFWRITESETPARAMTOFILE(S_CalcLotType) ; LBFWRITESETPARAMTOFILE(S_CurrencyFor001Lot); LBFWRITESETPARAMTOFILE(S_MinLot); LBFWRITESETPARAMTOFILE(S_Mult); LBFWRITESETPARAMTOFILE(S_MultStart); LBFWRITESETPARAMTOFILE(S_MultLevel2); LBFWRITESETPARAMTOFILE(S_MultCorr); LBFWRITESETPARAMTOFILE(S_MultLevel3); LBFWRITESETPARAMTOFILE(S_MultСorrLevel3); LBFWRITESETPARAMTOFILE(S_Mult3); LBFWRITESETPARAMTOFILE(S_Mult3Add); LBFWRITESETPARAMTOFILE(S_MultStop); LBFWRITESETPARAMTOFILE(S_MaxLotCoef); LBFWRITESETPARAMTOFILE(S_TestMinLot); LBFWRITESETPARAMTOFILE(S_TakeProffitType); LBFWRITESETPARAMTOFILE(S_TakeProffit); LBFWRITESETPARAMTOFILE(S_TakeProffit_Level1); LBFWRITESETPARAMTOFILE(S_TakeProffit_Level1Corr); LBFWRITESETPARAMTOFILE(S_TakeProffit_Level1_5); LBFWRITESETPARAMTOFILE(S_TakeProffit_Level1_5Corr); LBFWRITESETPARAMTOFILE(S_TakeProffit_Level2); LBFWRITESETPARAMTOFILE(S_TakeProffit_Level2FixPips); LBFWRITESETPARAMTOFILE(B_MaxOpenOrders); LBFWRITESETPARAMTOFILE(B_GridStep); LBFWRITESETPARAMTOFILE(B_GridLevel); LBFWRITESETPARAMTOFILE(B_GridStep_AddPips); LBFWRITESETPARAMTOFILE(B_GridStep_Level2); LBFWRITESETPARAMTOFILE(B_GridStep_Level2_AddPips); LBFWRITESETPARAMTOFILE(B_Grid3); LBFWRITESETPARAMTOFILE(B_Grid3Add); LBFWRITESETPARAMTOFILE(B_GridStop); LBFWRITESETPARAMTOFILE(B_CalcLotType); LBFWRITESETPARAMTOFILE(B_CurrencyFor001Lot); LBFWRITESETPARAMTOFILE(B_MinLot); LBFWRITESETPARAMTOFILE(B_Mult); LBFWRITESETPARAMTOFILE(B_MultStart); LBFWRITESETPARAMTOFILE(B_MultLevel2); LBFWRITESETPARAMTOFILE(B_MultCorr); LBFWRITESETPARAMTOFILE(B_MultLevel3); LBFWRITESETPARAMTOFILE(B_MultСorrLevel3); LBFWRITESETPARAMTOFILE(B_Mult3); LBFWRITESETPARAMTOFILE(B_Mult3Add); LBFWRITESETPARAMTOFILE(B_MultStop); LBFWRITESETPARAMTOFILE(B_MaxLotCoef); LBFWRITESETPARAMTOFILE(B_TestMinLot); LBFWRITESETPARAMTOFILE(B_TakeProffitType); LBFWRITESETPARAMTOFILE(B_TakeProffit); LBFWRITESETPARAMTOFILE(B_TakeProffit_Level1); LBFWRITESETPARAMTOFILE(B_TakeProffit_Level1Corr); LBFWRITESETPARAMTOFILE(B_TakeProffit_Level1_5); LBFWRITESETPARAMTOFILE(B_TakeProffit_Level1_5Corr); LBFWRITESETPARAMTOFILE(B_TakeProffit_Level2); LBFWRITESETPARAMTOFILE(B_TakeProffit_Level2FixPips); if(!StringCompare(CharArrayToString(header.bot_mod),LBF_MOD_ADXIMP)) { LBFWRITESETPARAMTOFILE(use_ADX_for1Order) ; LBFWRITESETPARAMTOFILE(AdxTimeFrame1) ; LBFWRITESETPARAMTOFILE(AdxPeriod1); LBFWRITESETPARAMTOFILE(AdxLevel1); LBFWRITESETPARAMTOFILE(use_ADX_ds1); LBFWRITESETPARAMTOFILE(use_ADX_p3_1); LBFWRITESETPARAMTOFILE(use_ADX_for_next_Order); LBFWRITESETPARAMTOFILE(AdxTimeFrame); LBFWRITESETPARAMTOFILE(AdxPeriod) ; LBFWRITESETPARAMTOFILE(AdxLevel); LBFWRITESETPARAMTOFILE(use_ADX_ds) ; LBFWRITESETPARAMTOFILE(use_ADX_p3) ; LBFWRITESETPARAMTOFILE(use_imp_for1Order); LBFWRITESETPARAMTOFILE(imp_indi_1order) ; LBFWRITESETPARAMTOFILE(ImpTimeFrame1); LBFWRITESETPARAMTOFILE(ImpPeriod1) ; LBFWRITESETPARAMTOFILE(LGCoeff1) ; LBFWRITESETPARAMTOFILE(ImpLevel1) ; LBFWRITESETPARAMTOFILE(use_imp_for_next_Order) ; LBFWRITESETPARAMTOFILE(imp_indi_next_order) ; LBFWRITESETPARAMTOFILE(ImpTimeFrame); LBFWRITESETPARAMTOFILE(ImpPeriod); LBFWRITESETPARAMTOFILE(LGCoeff) ; LBFWRITESETPARAMTOFILE(ImpLevel) ; } if(!StringCompare(CharArrayToString(header.bot_mod),LBF_MOD_RSICCIAS)) { LBFWRITESETPARAMTOFILE(CandleTimeframe); LBFWRITESETPARAMTOFILE(CandleTimeframeNext); LBFWRITESETPARAMTOFILE(RsiTimeframe); LBFWRITESETPARAMTOFILE(RsiPeriod); LBFWRITESETPARAMTOFILE(RsiLevel); LBFWRITESETPARAMTOFILE(RsiTimeframeNext); LBFWRITESETPARAMTOFILE(RsiPeriodNext); LBFWRITESETPARAMTOFILE(RsiLevelNext); LBFWRITESETPARAMTOFILE(CciTimeframe); LBFWRITESETPARAMTOFILE(CciPeriod); LBFWRITESETPARAMTOFILE(CciLevel); LBFWRITESETPARAMTOFILE(CciTimeframeNext); LBFWRITESETPARAMTOFILE(CciPeriodNext); LBFWRITESETPARAMTOFILE(CciLevelNext); LBFWRITESETPARAMTOFILE(use_for1Order); LBFWRITESETPARAMTOFILE(use_for_next_Order); } LBFWRITESETPARAMTOFILE(OpenFirstOrderTF); LBFWRITESETPARAMTOFILE(CandlesToOpen1Order); LBFWRITESETPARAMTOFILE(CandlesToOpen1Order_OpenClose); LBFWRITESETPARAMTOFILE(CandlesToOpen1Order_MinPips); LBFWRITESETPARAMTOFILE(CandlesToOpen1Order_MaxPips); LBFWRITESETPARAMTOFILE(ReversSignalToOpen1Order); LBFWRITESETPARAMTOFILE(CandlesToOpen1Order_OneWay) ; LBFWRITESETPARAMTOFILE(GapControl) ; LBFWRITESETPARAMTOFILE(GapMaxStopOrders); LBFWRITESETPARAMTOFILE(GapMinDistanceFromMarket); LBFWRITESETPARAMTOFILE(S_GapMinPips); LBFWRITESETPARAMTOFILE(S_GapMinPercent); LBFWRITESETPARAMTOFILE(S_GapLotKoef); LBFWRITESETPARAMTOFILE(S_GapLastOrderKoef); LBFWRITESETPARAMTOFILE(B_GapMinPips) ; LBFWRITESETPARAMTOFILE(B_GapMinPercent); LBFWRITESETPARAMTOFILE(B_GapLotKoef) ; LBFWRITESETPARAMTOFILE(B_GapLastOrderKoef); LBFWRITESETPARAMTOFILE(VolFromLevel); LBFWRITESETPARAMTOFILE(VolCandleTF) ; LBFWRITESETPARAMTOFILE(VolCandleMaxSize) ; LBFWRITESETPARAMTOFILE(VolStopTradeTimining) ; LBFWRITESETPARAMTOFILE(VolBlockBothDirection) ; if(StringToInteger(CharArrayToString(header.bot_ver,0,1))!=1) { LBFWRITESETPARAMTOFILE(VolEndLevel); LBFWRITESETPARAMTOFILE(VolCandles); LBFWRITESETPARAMTOFILE(VolNullBar) ; LBFWRITESETPARAMTOFILE(VolCandles_OneWay) ; LBFWRITESETPARAMTOFILE(VolCandle_OpenClose); LBFWRITESETPARAMTOFILE(Vol2FromLevel) ; LBFWRITESETPARAMTOFILE(Vol2EndLevel) ; LBFWRITESETPARAMTOFILE(Vol2CandleTF) ; LBFWRITESETPARAMTOFILE(Vol2Candles) ; LBFWRITESETPARAMTOFILE(Vol2NullBar) ; LBFWRITESETPARAMTOFILE(Vol2Candles_OneWay) ; LBFWRITESETPARAMTOFILE(Vol2CandleMaxSize) ; LBFWRITESETPARAMTOFILE(Vol2Candle_OpenClose); LBFWRITESETPARAMTOFILE(Vol2StopTradeTimining) ; LBFWRITESETPARAMTOFILE(Vol2BlockBothDirection) ; LBFWRITESETPARAMTOFILE(Vol3FromLevel) ; LBFWRITESETPARAMTOFILE(Vol3EndLevel) ; LBFWRITESETPARAMTOFILE(Vol3CandleTF); LBFWRITESETPARAMTOFILE(Vol3Candles); LBFWRITESETPARAMTOFILE(Vol3NullBar) ; LBFWRITESETPARAMTOFILE(Vol3Candles_OneWay) ; LBFWRITESETPARAMTOFILE(Vol3CandleMaxSize) ; LBFWRITESETPARAMTOFILE(Vol3Candle_OpenClose) ; LBFWRITESETPARAMTOFILE(Vol3StopTradeTimining) ; LBFWRITESETPARAMTOFILE(Vol3BlockBothDirection); } LBFWRITESETPARAMTOFILE(TradeStartDay) ; LBFWRITESETPARAMTOFILE(TradeStartHour); LBFWRITESETPARAMTOFILE(TradeStartMinute) ; LBFWRITESETPARAMTOFILE(TradeEndDay) ; LBFWRITESETPARAMTOFILE(TradeEndHour) ; LBFWRITESETPARAMTOFILE(TradeEndMinute) ; #define input_new_position_pause_sdd(number) \ LBFWRITESETPARAMTOFILE(NewPositionPause##number##Start); \ LBFWRITESETPARAMTOFILE(NewPositionPause##number##End) ; input_new_position_pause_sdd(1); input_new_position_pause_sdd(2); input_new_position_pause_sdd(3); input_new_position_pause_sdd(4); input_new_position_pause_sdd(5); input_new_position_pause_sdd(6); input_new_position_pause_sdd(7); input_new_position_pause_sdd(8); input_new_position_pause_sdd(9); input_new_position_pause_sdd(10); LBFWRITESETPARAMTOFILE(NewPositionPauseNewYearDayStart) ; LBFWRITESETPARAMTOFILE(NewPositionPauseNewYearDayEnd) ; #define input_intraday_sdd(number) \ LBFWRITESETPARAMTOFILE(IntraDay##number##StartHour) ; \ LBFWRITESETPARAMTOFILE(IntraDay##number##StartMinute) ; \ LBFWRITESETPARAMTOFILE(IntraDay##number##EndHour) ; \ LBFWRITESETPARAMTOFILE(IntraDay##number##EndMinute) ; input_intraday_sdd(1); input_intraday_sdd(2); input_intraday_sdd(3); input_intraday_sdd(4); input_intraday_sdd(5); input_intraday_sdd(6); input_intraday_sdd(7); input_intraday_sdd(8); input_intraday_sdd(9); input_intraday_sdd(10); #define input_tradepause_sdd(number) \ LBFWRITESETPARAMTOFILE(TradePause##number##Start) ; \ LBFWRITESETPARAMTOFILE(TradePause##number##End) ; input_tradepause_sdd(1); input_tradepause_sdd(2); input_tradepause_sdd(3); input_tradepause_sdd(4); input_tradepause_sdd(5); input_tradepause_sdd(6); input_tradepause_sdd(7); input_tradepause_sdd(8); input_tradepause_sdd(9); input_tradepause_sdd(10); #define input_stoptrade_sdd(number) \ LBFWRITESETPARAMTOFILE(IntraDayStopTrade##number##StartHour) ; \ LBFWRITESETPARAMTOFILE(IntraDayStopTrade##number##StartMinute) ; \ LBFWRITESETPARAMTOFILE(IntraDayStopTrade##number##EndHour) ; \ LBFWRITESETPARAMTOFILE(IntraDayStopTrade##number##EndMinute) ; input_stoptrade_sdd(1); input_stoptrade_sdd(2); input_stoptrade_sdd(3); input_stoptrade_sdd(4); input_stoptrade_sdd(5); input_stoptrade_sdd(6); input_stoptrade_sdd(7); input_stoptrade_sdd(8); input_stoptrade_sdd(9); input_stoptrade_sdd(10); LBFWRITESETPARAMTOFILE(CloseAllOrders_EveryDay_Hour); LBFWRITESETPARAMTOFILE(CloseAllOrders_EveryDay_Minute); LBFWRITESETPARAMTOFILE(TakeProffitControlTiming); LBFWRITESETPARAMTOFILE(TakeProffitControlNoLossFixPips); LBFWRITESETPARAMTOFILE(FinalGridDate); LBFWRITESETPARAMTOFILE(GlobalParamsUpdateTiming); LBFWRITESETPARAMTOFILE(LogVerbose); return true; } #endif //+------------------------------------------------------------------+ //+------------------------------------------------------------------+