myeatrade

社区

郁闷,我设置的自动交易系统怎么测试老是出错误啊。

zdzzkb zdzzkb 2012-12-18 11:56
高手帮我看看问题出在哪里啊,我设置的4小时交易系统如下:
做多:4小时macd大于0,4小时kd已经金叉,10均线>15日均线>20日均线>25日均线,5日均线<10日均线,执行条件5日均线与10日均线金叉买多,5日均线与10日均线死叉平仓,止损300个点,止盈600个点,仓位0.1手。
做空:4小时macd小于0,4小时kd已经死叉,10均线<15日均线<20日均线<25日均线,5日均线>10日均线,执行条件5日均线与10日均线死叉买空,5日均线与10日均线金叉平仓,止损300个点,止盈600个点,仓位0.1手。
源代码如下:
/+------------------------------------------------------------------+
// Copyright , myEAtrade
// http://www.myEAtrade.com
// System Name: 4小时趋势交易系统
// Automatically generated by the myEAtrade.com
// at Tuesday 18th of December 2012 02:55:21 AM
//+------------------------------------------------------------------+
#property copyright \"myEAtrade , www.myeatrade.com\"
#property link \"http://www.myeatrade.com/\"




///////////////////////////Model1////////////////////////////
extern string Model1_tip=\"做多\";
bool Model1_AutoTrade=1;
extern int Model1_CalculateModel=0;
extern int Model1_CalculateModelTimeframe=5;
extern double Model1_DefaultLots=0.1;
extern bool Model1_MoneyManagement=0;
extern double Model1_Risk=2;
extern int Model1_LotDigits=1;
extern double Model1_MinLots=0.1;
extern double Model1_MaxLots=100;
extern int Model1_StopLoss=0;
extern int Model1_TakeProfit=0;
extern int Model1_BreakEven=0;
extern int Model1_TrailMode=0;
extern int Model1_TrailStart=50;
extern int Model1_TrailStop=20;
extern int Model1_MaxSpread=0;
extern int Model1_Slippage=0;
extern bool Model1_ECN=1;
extern bool Model1_MultiOrder=0;
extern int Model1_MaxOrder=5;
extern int Model1_MultiOrderTimeInterval=5;
extern bool Model1_InstantOrder=1;
extern bool Model1_StopOrder=0;
extern bool Model1_LimitOrder=0;
extern int Model1_PendingGap=20;
extern int Model1_PendingExpiration=720;
extern int Model1_HardCloseTime=0;
extern bool Model1_ReverseOrder=0;
string M6637_Symbol;double M6637_Point;int M6637_Mt;datetime Model1_lastOpenOrderTime;
extern string M1G1_tip=\"Condition Group1\";
extern string M1G1_FilterOpt12_tip=\"Filter Conditions\";
extern string M1G1_FilterOpt12Con1_tip=\"Filter Opt12 Condition 1\";
string m1g1c1_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m1g1c1_Filter_Opt12_APara2=240; // Timeframe
extern double m1g1c1_Filter_Opt12_APara3=0; // Mode
extern double m1g1c1_Filter_Opt12_APara4=12; // Fast EMA
extern double m1g1c1_Filter_Opt12_APara5=26; // Slow EMA
extern double m1g1c1_Filter_Opt12_APara6=9; // MACD SMA
extern double m1g1c1_Filter_Opt12_APara7=0; // Apply to
extern double m1g1c1_Filter_Opt12_BPara1=0; // Value
extern string M1G1_FilterOpt12Con2_tip=\"Filter Opt12 Condition 2\";
string m1g1c2_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m1g1c2_Filter_Opt12_APara2=240; // Timeframe
extern double m1g1c2_Filter_Opt12_APara3=0; // Mode
extern double m1g1c2_Filter_Opt12_APara4=5; // %K period
extern double m1g1c2_Filter_Opt12_APara5=3; // %D period
extern double m1g1c2_Filter_Opt12_APara6=3; // Slowing
extern double m1g1c2_Filter_Opt12_APara7=0; // MA method
extern double m1g1c2_Filter_Opt12_APara8=0; // Price field
string m1g1c2_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m1g1c2_Filter_Opt12_BPara2=0; // Timeframe
extern double m1g1c2_Filter_Opt12_BPara3=1; // Mode
extern double m1g1c2_Filter_Opt12_BPara4=5; // %K period
extern double m1g1c2_Filter_Opt12_BPara5=3; // %D period
extern double m1g1c2_Filter_Opt12_BPara6=3; // Slowing
extern double m1g1c2_Filter_Opt12_BPara7=0; // MA method
extern double m1g1c2_Filter_Opt12_BPara8=0; // Price field
extern string M1G1_FilterOpt12Con3_tip=\"Filter Opt12 Condition 3\";
string m1g1c3_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m1g1c3_Filter_Opt12_APara2=240; // Timeframe
extern double m1g1c3_Filter_Opt12_APara3=0; // MA method
extern double m1g1c3_Filter_Opt12_APara4=10; // Period
extern double m1g1c3_Filter_Opt12_APara5=0; // Apply to
extern double m1g1c3_Filter_Opt12_APara6=0; // Shift
string m1g1c3_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m1g1c3_Filter_Opt12_BPara2=240; // Timeframe
extern double m1g1c3_Filter_Opt12_BPara3=0; // MA method
extern double m1g1c3_Filter_Opt12_BPara4=15; // Period
extern double m1g1c3_Filter_Opt12_BPara5=0; // Apply to
extern double m1g1c3_Filter_Opt12_BPara6=0; // Shift
extern string M1G1_FilterOpt12Con4_tip=\"Filter Opt12 Condition 4\";
string m1g1c4_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m1g1c4_Filter_Opt12_APara2=240; // Timeframe
extern double m1g1c4_Filter_Opt12_APara3=0; // MA method
extern double m1g1c4_Filter_Opt12_APara4=15; // Period
extern double m1g1c4_Filter_Opt12_APara5=0; // Apply to
extern double m1g1c4_Filter_Opt12_APara6=0; // Shift
string m1g1c4_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m1g1c4_Filter_Opt12_BPara2=240; // Timeframe
extern double m1g1c4_Filter_Opt12_BPara3=0; // MA method
extern double m1g1c4_Filter_Opt12_BPara4=20; // Period
extern double m1g1c4_Filter_Opt12_BPara5=0; // Apply to
extern double m1g1c4_Filter_Opt12_BPara6=0; // Shift
extern string M1G1_FilterOpt12Con5_tip=\"Filter Opt12 Condition 5\";
string m1g1c5_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m1g1c5_Filter_Opt12_APara2=240; // Timeframe
extern double m1g1c5_Filter_Opt12_APara3=0; // MA method
extern double m1g1c5_Filter_Opt12_APara4=20; // Period
extern double m1g1c5_Filter_Opt12_APara5=0; // Apply to
extern double m1g1c5_Filter_Opt12_APara6=0; // Shift
string m1g1c5_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m1g1c5_Filter_Opt12_BPara2=240; // Timeframe
extern double m1g1c5_Filter_Opt12_BPara3=0; // MA method
extern double m1g1c5_Filter_Opt12_BPara4=25; // Period
extern double m1g1c5_Filter_Opt12_BPara5=0; // Apply to
extern double m1g1c5_Filter_Opt12_BPara6=0; // Shift
extern string M1G1_FilterOpt12Con6_tip=\"Filter Opt12 Condition 6\";
string m1g1c6_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m1g1c6_Filter_Opt12_APara2=240; // Timeframe
extern double m1g1c6_Filter_Opt12_APara3=0; // MA method
extern double m1g1c6_Filter_Opt12_APara4=5; // Period
extern double m1g1c6_Filter_Opt12_APara5=0; // Apply to
extern double m1g1c6_Filter_Opt12_APara6=0; // Shift
string m1g1c6_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m1g1c6_Filter_Opt12_BPara2=240; // Timeframe
extern double m1g1c6_Filter_Opt12_BPara3=0; // MA method
extern double m1g1c6_Filter_Opt12_BPara4=10; // Period
extern double m1g1c6_Filter_Opt12_BPara5=0; // Apply to
extern double m1g1c6_Filter_Opt12_BPara6=0; // Shift
extern string M1G1_FilterOpt34_tip=\"Filter Conditions\";
extern string M1G1_Exe_tip=\"Execution Conditions\";
extern string M1G1_ExeCon1_tip=\"Execution Condition 1\";
string m1g1c1_Exec_Opt12_APara1=\"NULL\"; // Symbol
extern double m1g1c1_Exec_Opt12_APara2=240; // Timeframe
extern double m1g1c1_Exec_Opt12_APara3=0; // MA method
extern double m1g1c1_Exec_Opt12_APara4=5; // Period
extern double m1g1c1_Exec_Opt12_APara5=0; // Apply to
extern double m1g1c1_Exec_Opt12_APara6=0; // Shift
string m1g1c1_Exec_Opt12_BPara1=\"NULL\"; // Symbol
extern double m1g1c1_Exec_Opt12_BPara2=240; // Timeframe
extern double m1g1c1_Exec_Opt12_BPara3=0; // MA method
extern double m1g1c1_Exec_Opt12_BPara4=10; // Period
extern double m1g1c1_Exec_Opt12_BPara5=0; // Apply to
extern double m1g1c1_Exec_Opt12_BPara6=0; // Shift
extern string M1G1_Shift_tip=\"Shift Conditions\";

///////////////////////////Model2////////////////////////////
extern string Model2_tip=\"做空\";
bool Model2_AutoTrade=1;
extern int Model2_CalculateModel=0;
extern int Model2_CalculateModelTimeframe=5;
extern double Model2_DefaultLots=0.1;
extern bool Model2_MoneyManagement=0;
extern double Model2_Risk=2;
extern int Model2_LotDigits=1;
extern double Model2_MinLots=0.1;
extern double Model2_MaxLots=100;
extern int Model2_StopLoss=0;
extern int Model2_TakeProfit=0;
extern int Model2_BreakEven=0;
extern int Model2_TrailMode=0;
extern int Model2_TrailStart=50;
extern int Model2_TrailStop=20;
extern int Model2_MaxSpread=0;
extern int Model2_Slippage=0;
extern bool Model2_ECN=1;
extern bool Model2_MultiOrder=0;
extern int Model2_MaxOrder=5;
extern int Model2_MultiOrderTimeInterval=5;
extern bool Model2_InstantOrder=1;
extern bool Model2_StopOrder=0;
extern bool Model2_LimitOrder=0;
extern int Model2_PendingGap=20;
extern int Model2_PendingExpiration=720;
extern int Model2_HardCloseTime=0;
extern bool Model2_ReverseOrder=0;
string M6638_Symbol;double M6638_Point;int M6638_Mt;datetime Model2_lastOpenOrderTime;
extern string M2G1_tip=\"Condition Group1\";
extern string M2G1_FilterOpt12_tip=\"Filter Conditions\";
extern string M2G1_FilterOpt12Con1_tip=\"Filter Opt12 Condition 1\";
string m2g1c1_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m2g1c1_Filter_Opt12_APara2=240; // Timeframe
extern double m2g1c1_Filter_Opt12_APara3=0; // Mode
extern double m2g1c1_Filter_Opt12_APara4=12; // Fast EMA
extern double m2g1c1_Filter_Opt12_APara5=26; // Slow EMA
extern double m2g1c1_Filter_Opt12_APara6=9; // MACD SMA
extern double m2g1c1_Filter_Opt12_APara7=0; // Apply to
extern double m2g1c1_Filter_Opt12_BPara1=0; // Value
extern string M2G1_FilterOpt12Con2_tip=\"Filter Opt12 Condition 2\";
string m2g1c2_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m2g1c2_Filter_Opt12_APara2=240; // Timeframe
extern double m2g1c2_Filter_Opt12_APara3=0; // Mode
extern double m2g1c2_Filter_Opt12_APara4=5; // %K period
extern double m2g1c2_Filter_Opt12_APara5=3; // %D period
extern double m2g1c2_Filter_Opt12_APara6=3; // Slowing
extern double m2g1c2_Filter_Opt12_APara7=0; // MA method
extern double m2g1c2_Filter_Opt12_APara8=0; // Price field
string m2g1c2_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m2g1c2_Filter_Opt12_BPara2=240; // Timeframe
extern double m2g1c2_Filter_Opt12_BPara3=1; // Mode
extern double m2g1c2_Filter_Opt12_BPara4=5; // %K period
extern double m2g1c2_Filter_Opt12_BPara5=3; // %D period
extern double m2g1c2_Filter_Opt12_BPara6=3; // Slowing
extern double m2g1c2_Filter_Opt12_BPara7=0; // MA method
extern double m2g1c2_Filter_Opt12_BPara8=0; // Price field
extern string M2G1_FilterOpt12Con3_tip=\"Filter Opt12 Condition 3\";
string m2g1c3_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m2g1c3_Filter_Opt12_APara2=240; // Timeframe
extern double m2g1c3_Filter_Opt12_APara3=0; // MA method
extern double m2g1c3_Filter_Opt12_APara4=10; // Period
extern double m2g1c3_Filter_Opt12_APara5=0; // Apply to
extern double m2g1c3_Filter_Opt12_APara6=0; // Shift
string m2g1c3_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m2g1c3_Filter_Opt12_BPara2=240; // Timeframe
extern double m2g1c3_Filter_Opt12_BPara3=0; // MA method
extern double m2g1c3_Filter_Opt12_BPara4=15; // Period
extern double m2g1c3_Filter_Opt12_BPara5=0; // Apply to
extern double m2g1c3_Filter_Opt12_BPara6=0; // Shift
extern string M2G1_FilterOpt12Con4_tip=\"Filter Opt12 Condition 4\";
string m2g1c4_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m2g1c4_Filter_Opt12_APara2=240; // Timeframe
extern double m2g1c4_Filter_Opt12_APara3=0; // MA method
extern double m2g1c4_Filter_Opt12_APara4=15; // Period
extern double m2g1c4_Filter_Opt12_APara5=0; // Apply to
extern double m2g1c4_Filter_Opt12_APara6=0; // Shift
string m2g1c4_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m2g1c4_Filter_Opt12_BPara2=240; // Timeframe
extern double m2g1c4_Filter_Opt12_BPara3=0; // MA method
extern double m2g1c4_Filter_Opt12_BPara4=20; // Period
extern double m2g1c4_Filter_Opt12_BPara5=0; // Apply to
extern double m2g1c4_Filter_Opt12_BPara6=0; // Shift
extern string M2G1_FilterOpt12Con5_tip=\"Filter Opt12 Condition 5\";
string m2g1c5_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m2g1c5_Filter_Opt12_APara2=240; // Timeframe
extern double m2g1c5_Filter_Opt12_APara3=0; // MA method
extern double m2g1c5_Filter_Opt12_APara4=20; // Period
extern double m2g1c5_Filter_Opt12_APara5=0; // Apply to
extern double m2g1c5_Filter_Opt12_APara6=0; // Shift
string m2g1c5_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m2g1c5_Filter_Opt12_BPara2=240; // Timeframe
extern double m2g1c5_Filter_Opt12_BPara3=0; // MA method
extern double m2g1c5_Filter_Opt12_BPara4=25; // Period
extern double m2g1c5_Filter_Opt12_BPara5=0; // Apply to
extern double m2g1c5_Filter_Opt12_BPara6=0; // Shift
extern string M2G1_FilterOpt12Con6_tip=\"Filter Opt12 Condition 6\";
string m2g1c6_Filter_Opt12_APara1=\"NULL\"; // Symbol
extern double m2g1c6_Filter_Opt12_APara2=240; // Timeframe
extern double m2g1c6_Filter_Opt12_APara3=0; // MA method
extern double m2g1c6_Filter_Opt12_APara4=5; // Period
extern double m2g1c6_Filter_Opt12_APara5=0; // Apply to
extern double m2g1c6_Filter_Opt12_APara6=0; // Shift
string m2g1c6_Filter_Opt12_BPara1=\"NULL\"; // Symbol
extern double m2g1c6_Filter_Opt12_BPara2=240; // Timeframe
extern double m2g1c6_Filter_Opt12_BPara3=0; // MA method
extern double m2g1c6_Filter_Opt12_BPara4=10; // Period
extern double m2g1c6_Filter_Opt12_BPara5=0; // Apply to
extern double m2g1c6_Filter_Opt12_BPara6=0; // Shift
extern string M2G1_FilterOpt34_tip=\"Filter Conditions\";
extern string M2G1_Exe_tip=\"Execution Conditions\";
extern string M2G1_ExeCon1_tip=\"Execution Condition 1\";
string m2g1c1_Exec_Opt12_APara1=\"NULL\"; // Symbol
extern double m2g1c1_Exec_Opt12_APara2=240; // Timeframe
extern double m2g1c1_Exec_Opt12_APara3=0; // MA method
extern double m2g1c1_Exec_Opt12_APara4=5; // Period
extern double m2g1c1_Exec_Opt12_APara5=0; // Apply to
extern double m2g1c1_Exec_Opt12_APara6=0; // Shift
string m2g1c1_Exec_Opt12_BPara1=\"NULL\"; // Symbol
extern double m2g1c1_Exec_Opt12_BPara2=240; // Timeframe
extern double m2g1c1_Exec_Opt12_BPara3=0; // MA method
extern double m2g1c1_Exec_Opt12_BPara4=10; // Period
extern double m2g1c1_Exec_Opt12_BPara5=0; // Apply to
extern double m2g1c1_Exec_Opt12_BPara6=0; // Shift
extern string M2G1_Shift_tip=\"Shift Conditions\";

///////////////////////////Model3////////////////////////////
extern string Model3_tip=\"做多平仓\";
bool Model3_AutoTrade=1;
extern int Model3_CalculateModel=2;
extern int Model3_CalculateModelTimeframe=5;
extern double Model3_DefaultLots=0.1;
extern bool Model3_MoneyManagement=0;
extern double Model3_Risk=2;
extern int Model3_LotDigits=1;
extern double Model3_MinLots=0.1;
extern double Model3_MaxLots=100;
extern int Model3_StopLoss=0;
extern int Model3_TakeProfit=0;
extern int Model3_BreakEven=0;
extern int Model3_TrailMode=0;
extern int Model3_TrailStart=50;
extern int Model3_TrailStop=20;
extern int Model3_MaxSpread=0;
extern int Model3_Slippage=0;
extern bool Model3_ECN=1;
extern bool Model3_MultiOrder=0;
extern int Model3_MaxOrder=5;
extern int Model3_MultiOrderTimeInterval=5;
extern bool Model3_InstantOrder=1;
extern bool Model3_StopOrder=0;
extern bool Model3_LimitOrder=0;
extern int Model3_PendingGap=20;
extern int Model3_PendingExpiration=720;
extern int Model3_HardCloseTime=0;
extern bool Model3_ReverseOrder=0;
string M6639_Symbol;double M6639_Point;int M6639_Mt;datetime Model3_lastOpenOrderTime;
extern string M3G1_tip=\"Condition Group1\";
extern string M3G1_FilterOpt12_tip=\"Filter Conditions\";
extern string M3G1_FilterOpt34_tip=\"Filter Conditions\";
extern string M3G1_Exe_tip=\"Execution Conditions\";
extern string M3G1_ExeCon1_tip=\"Execution Condition 1\";
string m3g1c1_Exec_Opt12_APara1=\"NULL\"; // Symbol
extern double m3g1c1_Exec_Opt12_APara2=240; // Timeframe
extern double m3g1c1_Exec_Opt12_APara3=0; // MA method
extern double m3g1c1_Exec_Opt12_APara4=5; // Period
extern double m3g1c1_Exec_Opt12_APara5=0; // Apply to
extern double m3g1c1_Exec_Opt12_APara6=0; // Shift
string m3g1c1_Exec_Opt12_BPara1=\"NULL\"; // Symbol
extern double m3g1c1_Exec_Opt12_BPara2=240; // Timeframe
extern double m3g1c1_Exec_Opt12_BPara3=0; // MA method
extern double m3g1c1_Exec_Opt12_BPara4=10; // Period
extern double m3g1c1_Exec_Opt12_BPara5=0; // Apply to
extern double m3g1c1_Exec_Opt12_BPara6=0; // Shift
extern string M3G1_Shift_tip=\"Shift Conditions\";

///////////////////////////Model4////////////////////////////
extern string Model4_tip=\"做空平仓\";
bool Model4_AutoTrade=1;
extern int Model4_CalculateModel=2;
extern int Model4_CalculateModelTimeframe=5;
extern double Model4_DefaultLots=0.1;
extern bool Model4_MoneyManagement=0;
extern double Model4_Risk=2;
extern int Model4_LotDigits=1;
extern double Model4_MinLots=0.1;
extern double Model4_MaxLots=100;
extern int Model4_StopLoss=0;
extern int Model4_TakeProfit=0;
extern int Model4_BreakEven=0;
extern int Model4_TrailMode=0;
extern int Model4_TrailStart=50;
extern int Model4_TrailStop=20;
extern int Model4_MaxSpread=0;
extern int Model4_Slippage=0;
extern bool Model4_ECN=1;
extern bool Model4_MultiOrder=0;
extern int Model4_MaxOrder=5;
extern int Model4_MultiOrderTimeInterval=5;
extern bool Model4_InstantOrder=1;
extern bool Model4_StopOrder=0;
extern bool Model4_LimitOrder=0;
extern int Model4_PendingGap=20;
extern int Model4_PendingExpiration=720;
extern int Model4_HardCloseTime=0;
extern bool Model4_ReverseOrder=0;
string M6640_Symbol;double M6640_Point;int M6640_Mt;datetime Model4_lastOpenOrderTime;
extern string M4G1_tip=\"Condition Group1\";
extern string M4G1_FilterOpt12_tip=\"Filter Conditions\";
extern string M4G1_FilterOpt34_tip=\"Filter Conditions\";
extern string M4G1_Exe_tip=\"Execution Conditions\";
extern string M4G1_ExeCon1_tip=\"Execution Condition 1\";
string m4g1c1_Exec_Opt12_APara1=\"NULL\"; // Symbol
extern double m4g1c1_Exec_Opt12_APara2=240; // Timeframe
extern double m4g1c1_Exec_Opt12_APara3=0; // MA method
extern double m4g1c1_Exec_Opt12_APara4=5; // Period
extern double m4g1c1_Exec_Opt12_APara5=0; // Apply to
extern double m4g1c1_Exec_Opt12_APara6=0; // Shift
string m4g1c1_Exec_Opt12_BPara1=\"NULL\"; // Symbol
extern double m4g1c1_Exec_Opt12_BPara2=240; // Timeframe
extern double m4g1c1_Exec_Opt12_BPara3=0; // MA method
extern double m4g1c1_Exec_Opt12_BPara4=10; // Period
extern double m4g1c1_Exec_Opt12_BPara5=0; // Apply to
extern double m4g1c1_Exec_Opt12_BPara6=0; // Shift
extern string M4G1_Shift_tip=\"Shift Conditions\";
double m1g1c1_Filter_Opt12_A_val[2];double m1g1c1_Filter_Opt12_B_val[2];double m1g1c2_Filter_Opt12_A_val[2];double m1g1c2_Filter_Opt12_B_val[2];double m1g1c3_Filter_Opt12_A_val[2];double m1g1c3_Filter_Opt12_B_val[2];double m1g1c4_Filter_Opt12_A_val[2];double m1g1c4_Filter_Opt12_B_val[2];double m1g1c5_Filter_Opt12_A_val[2];double m1g1c5_Filter_Opt12_B_val[2];double m1g1c6_Filter_Opt12_A_val[2];double m1g1c6_Filter_Opt12_B_val[2];double m1g1c1_Exec_Opt12_A_val[3];double m1g1c1_Exec_Opt12_B_val[3];double m2g1c1_Filter_Opt12_A_val[2];double m2g1c1_Filter_Opt12_B_val[2];double m2g1c2_Filter_Opt12_A_val[2];double m2g1c2_Filter_Opt12_B_val[2];double m2g1c3_Filter_Opt12_A_val[2];double m2g1c3_Filter_Opt12_B_val[2];double m2g1c4_Filter_Opt12_A_val[2];double m2g1c4_Filter_Opt12_B_val[2];double m2g1c5_Filter_Opt12_A_val[2];double m2g1c5_Filter_Opt12_B_val[2];double m2g1c6_Filter_Opt12_A_val[2];double m2g1c6_Filter_Opt12_B_val[2];double m2g1c1_Exec_Opt12_A_val[3];double m2g1c1_Exec_Opt12_B_val[3];double m3g1c1_Exec_Opt12_A_val[3];double m3g1c1_Exec_Opt12_B_val[3];double m4g1c1_Exec_Opt12_A_val[3];double m4g1c1_Exec_Opt12_B_val[3];
datetime lastBarTime[5];
int modelMagic[5];
bool canClose31=true;
bool closeOneTime31=1;
bool canClose41=true;
bool closeOneTime41=1;


int maxtry=10;
bool printLog=true;

int init(){
M6637_Symbol=Symbol(); double m1_point = MarketInfo(M6637_Symbol,MODE_POINT); int m1_digits = MarketInfo(M6637_Symbol,MODE_DIGITS); if(m1_digits==3 || m1_digits==5){
M6637_Point=m1_point*10;
M6637_Mt=10;
}else{
M6637_Point=m1_point;
M6637_Mt=1;
}
modelMagic[1]=6637;
M6638_Symbol=Symbol(); double m2_point = MarketInfo(M6638_Symbol,MODE_POINT); int m2_digits = MarketInfo(M6638_Symbol,MODE_DIGITS); if(m2_digits==3 || m2_digits==5){
M6638_Point=m2_point*10;
M6638_Mt=10;
}else{
M6638_Point=m2_point;
M6638_Mt=1;
}
modelMagic[2]=6638;
M6639_Symbol=Symbol(); double m3_point = MarketInfo(M6639_Symbol,MODE_POINT); int m3_digits = MarketInfo(M6639_Symbol,MODE_DIGITS); if(m3_digits==3 || m3_digits==5){
M6639_Point=m3_point*10;
M6639_Mt=10;
}else{
M6639_Point=m3_point;
M6639_Mt=1;
}
modelMagic[3]=6639;
M6640_Symbol=Symbol(); double m4_point = MarketInfo(M6640_Symbol,MODE_POINT); int m4_digits = MarketInfo(M6640_Symbol,MODE_DIGITS); if(m4_digits==3 || m4_digits==5){
M6640_Point=m4_point*10;
M6640_Mt=10;
}else{
M6640_Point=m4_point;
M6640_Mt=1;
}
modelMagic[4]=6640;
m1g1c1_Filter_Opt12_APara1=Symbol();m1g1c2_Filter_Opt12_APara1=Symbol();m1g1c2_Filter_Opt12_BPara1=Symbol();m1g1c3_Filter_Opt12_APara1=Symbol();m1g1c3_Filter_Opt12_BPara1=Symbol();m1g1c4_Filter_Opt12_APara1=Symbol();m1g1c4_Filter_Opt12_BPara1=Symbol();m1g1c5_Filter_Opt12_APara1=Symbol();m1g1c5_Filter_Opt12_BPara1=Symbol();m1g1c6_Filter_Opt12_APara1=Symbol();m1g1c6_Filter_Opt12_BPara1=Symbol();m1g1c1_Exec_Opt12_APara1=Symbol();m1g1c1_Exec_Opt12_BPara1=Symbol();m2g1c1_Filter_Opt12_APara1=Symbol();m2g1c2_Filter_Opt12_APara1=Symbol();m2g1c2_Filter_Opt12_BPara1=Symbol();m2g1c3_Filter_Opt12_APara1=Symbol();m2g1c3_Filter_Opt12_BPara1=Symbol();m2g1c4_Filter_Opt12_APara1=Symbol();m2g1c4_Filter_Opt12_BPara1=Symbol();m2g1c5_Filter_Opt12_APara1=Symbol();m2g1c5_Filter_Opt12_BPara1=Symbol();m2g1c6_Filter_Opt12_APara1=Symbol();m2g1c6_Filter_Opt12_BPara1=Symbol();m2g1c1_Exec_Opt12_APara1=Symbol();m2g1c1_Exec_Opt12_BPara1=Symbol();m3g1c1_Exec_Opt12_APara1=Symbol();m3g1c1_Exec_Opt12_BPara1=Symbol();m4g1c1_Exec_Opt12_APara1=Symbol();m4g1c1_Exec_Opt12_BPara1=Symbol();
}

int start(){
runModel1();runModel2();runModel3();runModel4();
return (0);
}


void runModel1(){
int totalPosition = countPositionByMagicSymbol(6637,M6637_Symbol,Model1_HardCloseTime);
if( Model1_MaxSpread>0 && (MarketInfo(M6637_Symbol,MODE_ASK)-MarketInfo(M6637_Symbol,MODE_BID))>Model1_MaxSpread*M6637_Point )return;
if((Model1_CalculateModel!=0)&&(!isNewBar(M6637_Symbol,Model1_CalculateModelTimeframe,1))) return;
bool canRunCheck=false;
if(!Model1_MultiOrder)Model1_MaxOrder=1;
if(totalPosition<Model1_MaxOrder)canRunCheck=true;
if(Model1_MaxOrder>1&&totalPosition>=1){
if(TimeCurrent()<(Model1_lastOpenOrderTime+Model1_MultiOrderTimeInterval*60))canRunCheck=false;
}
if(Model1_BreakEven>0&&totalPosition>0)breakEven(6637,M6637_Symbol,Model1_BreakEven,M6637_Point);
if(Model1_TrailMode>0&&Model1_TrailMode<=2&&totalPosition>0)trailStop(6637,M6637_Symbol,Model1_TrailMode,Model1_TrailStart,Model1_TrailStop,M6637_Point);
if(canRunCheck){
if(checkM1G1()){
int orderType=OP_BUY;if(Model1_ReverseOrder)orderType=OP_SELL;
if(Model1_AutoTrade){
double lots = getlots(Model1_DefaultLots,Model1_MoneyManagement,Model1_Risk,Model1_StopLoss,M6637_Symbol,M6637_Mt,Model1_LotDigits,Model1_MinLots,Model1_MaxLots);
int sl= Model1_StopLoss;
int tp = Model1_TakeProfit;
int ticket = openposition(
M6637_Symbol,
orderType,
lots,
sl,
tp,
6637,
Model1_ECN,
Model1_InstantOrder,
Model1_StopOrder,
Model1_LimitOrder,
Model1_PendingGap,
Model1_PendingExpiration,
M6637_Point,
M6637_Mt,
Model1_Slippage);
Model1_lastOpenOrderTime = getOrderOpenTime(ticket);}
}
}
}
void runModel2(){
int totalPosition = countPositionByMagicSymbol(6638,M6638_Symbol,Model2_HardCloseTime);
if( Model2_MaxSpread>0 && (MarketInfo(M6638_Symbol,MODE_ASK)-MarketInfo(M6638_Symbol,MODE_BID))>Model2_MaxSpread*M6638_Point )return;
if((Model2_CalculateModel!=0)&&(!isNewBar(M6638_Symbol,Model2_CalculateModelTimeframe,2))) return;
bool canRunCheck=false;
if(!Model2_MultiOrder)Model2_MaxOrder=1;
if(totalPosition<Model2_MaxOrder)canRunCheck=true;
if(Model2_MaxOrder>1&&totalPosition>=1){
if(TimeCurrent()<(Model2_lastOpenOrderTime+Model2_MultiOrderTimeInterval*60))canRunCheck=false;
}
if(Model2_BreakEven>0&&totalPosition>0)breakEven(6638,M6638_Symbol,Model2_BreakEven,M6638_Point);
if(Model2_TrailMode>0&&Model2_TrailMode<=2&&totalPosition>0)trailStop(6638,M6638_Symbol,Model2_TrailMode,Model2_TrailStart,Model2_TrailStop,M6638_Point);
if(canRunCheck){
if(checkM2G1()){
int orderType=OP_SELL;if(Model2_ReverseOrder)orderType=OP_BUY;
if(Model2_AutoTrade){
double lots = getlots(Model2_DefaultLots,Model2_MoneyManagement,Model2_Risk,Model2_StopLoss,M6638_Symbol,M6638_Mt,Model2_LotDigits,Model2_MinLots,Model2_MaxLots);
int sl= Model2_StopLoss;
int tp = Model2_TakeProfit;
int ticket = openposition(
M6638_Symbol,
orderType,
lots,
sl,
tp,
6638,
Model2_ECN,
Model2_InstantOrder,
Model2_StopOrder,
Model2_LimitOrder,
Model2_PendingGap,
Model2_PendingExpiration,
M6638_Point,
M6638_Mt,
Model2_Slippage);
Model2_lastOpenOrderTime = getOrderOpenTime(ticket);}
}
}
}
void runModel3(){
if((Model3_CalculateModel!=0)&&(!isNewBar(M6639_Symbol,Model3_CalculateModelTimeframe,3))) return;
bool canRunCheck=false;
if(checkHasPosition(6637,M6637_Symbol)){canRunCheck=true;}else{if(closeOneTime31)canClose31=true;}
bool spread31=true; if( Model3_MaxSpread>0 && (MarketInfo(M6637_Symbol,MODE_ASK)-MarketInfo(M6637_Symbol,MODE_BID))>Model3_MaxSpread*M6637_Point )spread31=false;
if(canRunCheck){
if(checkM3G1()){
bool allClose;
if(canClose31&&spread31){
allClose=closeModelPosition(6637,M6637_Symbol,1,0,M6639_Mt,Model3_Slippage);
if(closeOneTime31&&allClose)canClose31=false;
if(!checkHasPosition(6637,M6637_Symbol)){if(closeOneTime31)canClose31=true;}
}
}
}
}
void runModel4(){
if((Model4_CalculateModel!=0)&&(!isNewBar(M6640_Symbol,Model4_CalculateModelTimeframe,4))) return;
bool canRunCheck=false;
if(checkHasPosition(6638,M6638_Symbol)){canRunCheck=true;}else{if(closeOneTime41)canClose41=true;}
bool spread41=true; if( Model4_MaxSpread>0 && (MarketInfo(M6638_Symbol,MODE_ASK)-MarketInfo(M6638_Symbol,MODE_BID))>Model4_MaxSpread*M6638_Point )spread41=false;
if(canRunCheck){
if(checkM4G1()){
bool allClose;
if(canClose41&&spread41){
allClose=closeModelPosition(6638,M6638_Symbol,1,0,M6640_Mt,Model4_Slippage);
if(closeOneTime41&&allClose)canClose41=false;
if(!checkHasPosition(6638,M6638_Symbol)){if(closeOneTime41)canClose41=true;}
}
}
}
}
bool checkM1G1(){
int i;
bool reValue=false;
int preBar=0;
if(Model1_CalculateModel==2)preBar=1;

bool filter12=true;
if(filter12){
int f12cBar111=1; if(preBar==1&&f12cBar111==0)f12cBar111=1;
for(i=preBar;i<=f12cBar111;i++){
m1g1c1_Filter_Opt12_A_val=iMACD(m1g1c1_Filter_Opt12_APara1,
m1g1c1_Filter_Opt12_APara2,
m1g1c1_Filter_Opt12_APara4,
m1g1c1_Filter_Opt12_APara5,
m1g1c1_Filter_Opt12_APara6,
m1g1c1_Filter_Opt12_APara7,
m1g1c1_Filter_Opt12_APara3,
i);
m1g1c1_Filter_Opt12_B_val=m1g1c1_Filter_Opt12_BPara1;
}
for(i=preBar;i<=f12cBar111;i++){
if(!(m1g1c1_Filter_Opt12_A_val>(m1g1c1_Filter_Opt12_B_val+0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar112=1; if(preBar==1&&f12cBar112==0)f12cBar112=1;
for(i=preBar;i<=f12cBar112;i++){
m1g1c2_Filter_Opt12_A_val=iStochastic(m1g1c2_Filter_Opt12_APara1,
m1g1c2_Filter_Opt12_APara2,
m1g1c2_Filter_Opt12_APara4,
m1g1c2_Filter_Opt12_APara5,
m1g1c2_Filter_Opt12_APara6,
m1g1c2_Filter_Opt12_APara7,
m1g1c2_Filter_Opt12_APara8,
m1g1c2_Filter_Opt12_APara3,
i);
m1g1c2_Filter_Opt12_B_val=iStochastic(m1g1c2_Filter_Opt12_BPara1,
m1g1c2_Filter_Opt12_BPara2,
m1g1c2_Filter_Opt12_BPara4,
m1g1c2_Filter_Opt12_BPara5,
m1g1c2_Filter_Opt12_BPara6,
m1g1c2_Filter_Opt12_BPara7,
m1g1c2_Filter_Opt12_BPara8,
m1g1c2_Filter_Opt12_BPara3,
i);
}
for(i=preBar;i<=f12cBar112;i++){
if(!(m1g1c2_Filter_Opt12_A_val>(m1g1c2_Filter_Opt12_B_val+0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar113=1; if(preBar==1&&f12cBar113==0)f12cBar113=1;
for(i=preBar;i<=f12cBar113;i++){
m1g1c3_Filter_Opt12_A_val=iMA(m1g1c3_Filter_Opt12_APara1,
m1g1c3_Filter_Opt12_APara2,
m1g1c3_Filter_Opt12_APara4,
m1g1c3_Filter_Opt12_APara6,
m1g1c3_Filter_Opt12_APara3,
m1g1c3_Filter_Opt12_APara5,
i);
m1g1c3_Filter_Opt12_B_val=iMA(m1g1c3_Filter_Opt12_BPara1,
m1g1c3_Filter_Opt12_BPara2,
m1g1c3_Filter_Opt12_BPara4,
m1g1c3_Filter_Opt12_BPara6,
m1g1c3_Filter_Opt12_BPara3,
m1g1c3_Filter_Opt12_BPara5,
i);
}
for(i=preBar;i<=f12cBar113;i++){
if(!(m1g1c3_Filter_Opt12_A_val>(m1g1c3_Filter_Opt12_B_val+0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar114=1; if(preBar==1&&f12cBar114==0)f12cBar114=1;
for(i=preBar;i<=f12cBar114;i++){
m1g1c4_Filter_Opt12_A_val=iMA(m1g1c4_Filter_Opt12_APara1,
m1g1c4_Filter_Opt12_APara2,
m1g1c4_Filter_Opt12_APara4,
m1g1c4_Filter_Opt12_APara6,
m1g1c4_Filter_Opt12_APara3,
m1g1c4_Filter_Opt12_APara5,
i);
m1g1c4_Filter_Opt12_B_val=iMA(m1g1c4_Filter_Opt12_BPara1,
m1g1c4_Filter_Opt12_BPara2,
m1g1c4_Filter_Opt12_BPara4,
m1g1c4_Filter_Opt12_BPara6,
m1g1c4_Filter_Opt12_BPara3,
m1g1c4_Filter_Opt12_BPara5,
i);
}
for(i=preBar;i<=f12cBar114;i++){
if(!(m1g1c4_Filter_Opt12_A_val>(m1g1c4_Filter_Opt12_B_val+0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar115=1; if(preBar==1&&f12cBar115==0)f12cBar115=1;
for(i=preBar;i<=f12cBar115;i++){
m1g1c5_Filter_Opt12_A_val=iMA(m1g1c5_Filter_Opt12_APara1,
m1g1c5_Filter_Opt12_APara2,
m1g1c5_Filter_Opt12_APara4,
m1g1c5_Filter_Opt12_APara6,
m1g1c5_Filter_Opt12_APara3,
m1g1c5_Filter_Opt12_APara5,
i);
m1g1c5_Filter_Opt12_B_val=iMA(m1g1c5_Filter_Opt12_BPara1,
m1g1c5_Filter_Opt12_BPara2,
m1g1c5_Filter_Opt12_BPara4,
m1g1c5_Filter_Opt12_BPara6,
m1g1c5_Filter_Opt12_BPara3,
m1g1c5_Filter_Opt12_BPara5,
i);
}
for(i=preBar;i<=f12cBar115;i++){
if(!(m1g1c5_Filter_Opt12_A_val>(m1g1c5_Filter_Opt12_B_val+0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar116=1; if(preBar==1&&f12cBar116==0)f12cBar116=1;
for(i=preBar;i<=f12cBar116;i++){
m1g1c6_Filter_Opt12_A_val=iMA(m1g1c6_Filter_Opt12_APara1,
m1g1c6_Filter_Opt12_APara2,
m1g1c6_Filter_Opt12_APara4,
m1g1c6_Filter_Opt12_APara6,
m1g1c6_Filter_Opt12_APara3,
m1g1c6_Filter_Opt12_APara5,
i);
m1g1c6_Filter_Opt12_B_val=iMA(m1g1c6_Filter_Opt12_BPara1,
m1g1c6_Filter_Opt12_BPara2,
m1g1c6_Filter_Opt12_BPara4,
m1g1c6_Filter_Opt12_BPara6,
m1g1c6_Filter_Opt12_BPara3,
m1g1c6_Filter_Opt12_BPara5,
i);
}
for(i=preBar;i<=f12cBar116;i++){
if(!(m1g1c6_Filter_Opt12_A_val<(m1g1c6_Filter_Opt12_B_val-0))){filter12=false;break;}
}
}
bool filter34=true;
bool exec12_temp=true, exec12_a=false, exec12_b=true,exec12=false;
if(exec12_b){
exec12_temp=true;
int e12cBar111=2; if(preBar==1&&e12cBar111==1)e12cBar111=2;
for(i=preBar;i<=e12cBar111;i++){
m1g1c1_Exec_Opt12_A_val=iMA(m1g1c1_Exec_Opt12_APara1,
m1g1c1_Exec_Opt12_APara2,
m1g1c1_Exec_Opt12_APara4,
m1g1c1_Exec_Opt12_APara6,
m1g1c1_Exec_Opt12_APara3,
m1g1c1_Exec_Opt12_APara5,
i);
m1g1c1_Exec_Opt12_B_val=iMA(m1g1c1_Exec_Opt12_BPara1,
m1g1c1_Exec_Opt12_BPara2,
m1g1c1_Exec_Opt12_BPara4,
m1g1c1_Exec_Opt12_BPara6,
m1g1c1_Exec_Opt12_BPara3,
m1g1c1_Exec_Opt12_BPara5,
i);
}
if(!(m1g1c1_Exec_Opt12_A_val[preBar]>(m1g1c1_Exec_Opt12_B_val[preBar]+0))){exec12_temp=false;}
if(exec12_temp){
for(i=preBar+1;i<e12cBar111;i++){
if(!(m1g1c1_Exec_Opt12_A_val>m1g1c1_Exec_Opt12_B_val)){exec12_temp=false;}
}
}
if(!exec12_temp)exec12_b=false;
if(exec12_temp){
if(m1g1c1_Exec_Opt12_A_val[e12cBar111]>m1g1c1_Exec_Opt12_B_val[e12cBar111]){exec12_temp=false;}
}
if(exec12_temp)exec12_a=true;
}
if(exec12_a&&exec12_b)exec12=true;
bool bshift=true;
if(filter12&&filter34&&exec12&&bshift)reValue=true;
return (reValue);
}
bool checkM2G1(){
int i;
bool reValue=false;
int preBar=0;
if(Model2_CalculateModel==2)preBar=1;

bool filter12=true;
if(filter12){
int f12cBar211=1; if(preBar==1&&f12cBar211==0)f12cBar211=1;
for(i=preBar;i<=f12cBar211;i++){
m2g1c1_Filter_Opt12_A_val=iMACD(m2g1c1_Filter_Opt12_APara1,
m2g1c1_Filter_Opt12_APara2,
m2g1c1_Filter_Opt12_APara4,
m2g1c1_Filter_Opt12_APara5,
m2g1c1_Filter_Opt12_APara6,
m2g1c1_Filter_Opt12_APara7,
m2g1c1_Filter_Opt12_APara3,
i);
m2g1c1_Filter_Opt12_B_val=m2g1c1_Filter_Opt12_BPara1;
}
for(i=preBar;i<=f12cBar211;i++){
if(!(m2g1c1_Filter_Opt12_A_val<(m2g1c1_Filter_Opt12_B_val-0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar212=1; if(preBar==1&&f12cBar212==0)f12cBar212=1;
for(i=preBar;i<=f12cBar212;i++){
m2g1c2_Filter_Opt12_A_val=iStochastic(m2g1c2_Filter_Opt12_APara1,
m2g1c2_Filter_Opt12_APara2,
m2g1c2_Filter_Opt12_APara4,
m2g1c2_Filter_Opt12_APara5,
m2g1c2_Filter_Opt12_APara6,
m2g1c2_Filter_Opt12_APara7,
m2g1c2_Filter_Opt12_APara8,
m2g1c2_Filter_Opt12_APara3,
i);
m2g1c2_Filter_Opt12_B_val=iStochastic(m2g1c2_Filter_Opt12_BPara1,
m2g1c2_Filter_Opt12_BPara2,
m2g1c2_Filter_Opt12_BPara4,
m2g1c2_Filter_Opt12_BPara5,
m2g1c2_Filter_Opt12_BPara6,
m2g1c2_Filter_Opt12_BPara7,
m2g1c2_Filter_Opt12_BPara8,
m2g1c2_Filter_Opt12_BPara3,
i);
}
for(i=preBar;i<=f12cBar212;i++){
if(!(m2g1c2_Filter_Opt12_A_val<(m2g1c2_Filter_Opt12_B_val-0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar213=1; if(preBar==1&&f12cBar213==0)f12cBar213=1;
for(i=preBar;i<=f12cBar213;i++){
m2g1c3_Filter_Opt12_A_val=iMA(m2g1c3_Filter_Opt12_APara1,
m2g1c3_Filter_Opt12_APara2,
m2g1c3_Filter_Opt12_APara4,
m2g1c3_Filter_Opt12_APara6,
m2g1c3_Filter_Opt12_APara3,
m2g1c3_Filter_Opt12_APara5,
i);
m2g1c3_Filter_Opt12_B_val=iMA(m2g1c3_Filter_Opt12_BPara1,
m2g1c3_Filter_Opt12_BPara2,
m2g1c3_Filter_Opt12_BPara4,
m2g1c3_Filter_Opt12_BPara6,
m2g1c3_Filter_Opt12_BPara3,
m2g1c3_Filter_Opt12_BPara5,
i);
}
for(i=preBar;i<=f12cBar213;i++){
if(!(m2g1c3_Filter_Opt12_A_val<(m2g1c3_Filter_Opt12_B_val-0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar214=1; if(preBar==1&&f12cBar214==0)f12cBar214=1;
for(i=preBar;i<=f12cBar214;i++){
m2g1c4_Filter_Opt12_A_val=iMA(m2g1c4_Filter_Opt12_APara1,
m2g1c4_Filter_Opt12_APara2,
m2g1c4_Filter_Opt12_APara4,
m2g1c4_Filter_Opt12_APara6,
m2g1c4_Filter_Opt12_APara3,
m2g1c4_Filter_Opt12_APara5,
i);
m2g1c4_Filter_Opt12_B_val=iMA(m2g1c4_Filter_Opt12_BPara1,
m2g1c4_Filter_Opt12_BPara2,
m2g1c4_Filter_Opt12_BPara4,
m2g1c4_Filter_Opt12_BPara6,
m2g1c4_Filter_Opt12_BPara3,
m2g1c4_Filter_Opt12_BPara5,
i);
}
for(i=preBar;i<=f12cBar214;i++){
if(!(m2g1c4_Filter_Opt12_A_val<(m2g1c4_Filter_Opt12_B_val-0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar215=1; if(preBar==1&&f12cBar215==0)f12cBar215=1;
for(i=preBar;i<=f12cBar215;i++){
m2g1c5_Filter_Opt12_A_val=iMA(m2g1c5_Filter_Opt12_APara1,
m2g1c5_Filter_Opt12_APara2,
m2g1c5_Filter_Opt12_APara4,
m2g1c5_Filter_Opt12_APara6,
m2g1c5_Filter_Opt12_APara3,
m2g1c5_Filter_Opt12_APara5,
i);
m2g1c5_Filter_Opt12_B_val=iMA(m2g1c5_Filter_Opt12_BPara1,
m2g1c5_Filter_Opt12_BPara2,
m2g1c5_Filter_Opt12_BPara4,
m2g1c5_Filter_Opt12_BPara6,
m2g1c5_Filter_Opt12_BPara3,
m2g1c5_Filter_Opt12_BPara5,
i);
}
for(i=preBar;i<=f12cBar215;i++){
if(!(m2g1c5_Filter_Opt12_A_val<(m2g1c5_Filter_Opt12_B_val-0))){filter12=false;break;}
}
}
if(filter12){
int f12cBar216=1; if(preBar==1&&f12cBar216==0)f12cBar216=1;
for(i=preBar;i<=f12cBar216;i++){
m2g1c6_Filter_Opt12_A_val=iMA(m2g1c6_Filter_Opt12_APara1,
m2g1c6_Filter_Opt12_APara2,
m2g1c6_Filter_Opt12_APara4,
m2g1c6_Filter_Opt12_APara6,
m2g1c6_Filter_Opt12_APara3,
m2g1c6_Filter_Opt12_APara5,
i);
m2g1c6_Filter_Opt12_B_val=iMA(m2g1c6_Filter_Opt12_BPara1,
m2g1c6_Filter_Opt12_BPara2,
m2g1c6_Filter_Opt12_BPara4,
m2g1c6_Filter_Opt12_BPara6,
m2g1c6_Filter_Opt12_BPara3,
m2g1c6_Filter_Opt12_BPara5,
i);
}
for(i=preBar;i<=f12cBar216;i++){
if(!(m2g1c6_Filter_Opt12_A_val>(m2g1c6_Filter_Opt12_B_val+0))){filter12=false;break;}
}
}
bool filter34=true;
bool exec12_temp=true, exec12_a=false, exec12_b=true,exec12=false;
if(exec12_b){
exec12_temp=true;
int e12cBar211=2; if(preBar==1&&e12cBar211==1)e12cBar211=2;
for(i=preBar;i<=e12cBar211;i++){
m2g1c1_Exec_Opt12_A_val=iMA(m2g1c1_Exec_Opt12_APara1,
m2g1c1_Exec_Opt12_APara2,
m2g1c1_Exec_Opt12_APara4,
m2g1c1_Exec_Opt12_APara6,
m2g1c1_Exec_Opt12_APara3,
m2g1c1_Exec_Opt12_APara5,
i);
m2g1c1_Exec_Opt12_B_val=iMA(m2g1c1_Exec_Opt12_BPara1,
m2g1c1_Exec_Opt12_BPara2,
m2g1c1_Exec_Opt12_BPara4,
m2g1c1_Exec_Opt12_BPara6,
m2g1c1_Exec_Opt12_BPara3,
m2g1c1_Exec_Opt12_BPara5,
i);
}
if(!(m2g1c1_Exec_Opt12_A_val[preBar]<(m2g1c1_Exec_Opt12_B_val[preBar]-0))){exec12_temp=false;}
if(exec12_temp){
for(i=preBar+1;i<e12cBar211;i++){
if(!(m2g1c1_Exec_Opt12_A_val<m2g1c1_Exec_Opt12_B_val)){exec12_temp=false;}
}
}
if(!exec12_temp)exec12_b=false;
if(exec12_temp){
if(m2g1c1_Exec_Opt12_A_val[e12cBar211]<m2g1c1_Exec_Opt12_B_val[e12cBar211]){exec12_temp=false;}
}
if(exec12_temp)exec12_a=true;
}
if(exec12_a&&exec12_b)exec12=true;
bool bshift=true;
if(filter12&&filter34&&exec12&&bshift)reValue=true;
return (reValue);
}
bool checkM3G1(){
int i;
bool reValue=false;
int preBar=0;
if(Model3_CalculateModel==2)preBar=1;

bool filter12=true;
bool filter34=true;
bool exec12_temp=true, exec12_a=false, exec12_b=true,exec12=false;
if(exec12_b){
exec12_temp=true;
int e12cBar311=2; if(preBar==1&&e12cBar311==1)e12cBar311=2;
for(i=preBar;i<=e12cBar311;i++){
m3g1c1_Exec_Opt12_A_val=iMA(m3g1c1_Exec_Opt12_APara1,
m3g1c1_Exec_Opt12_APara2,
m3g1c1_Exec_Opt12_APara4,
m3g1c1_Exec_Opt12_APara6,
m3g1c1_Exec_Opt12_APara3,
m3g1c1_Exec_Opt12_APara5,
i);
m3g1c1_Exec_Opt12_B_val=iMA(m3g1c1_Exec_Opt12_BPara1,
m3g1c1_Exec_Opt12_BPara2,
m3g1c1_Exec_Opt12_BPara4,
m3g1c1_Exec_Opt12_BPara6,
m3g1c1_Exec_Opt12_BPara3,
m3g1c1_Exec_Opt12_BPara5,
i);
}
if(!(m3g1c1_Exec_Opt12_A_val[preBar]<(m3g1c1_Exec_Opt12_B_val[preBar]-0))){exec12_temp=false;}
if(exec12_temp){
for(i=preBar+1;i<e12cBar311;i++){
if(!(m3g1c1_Exec_Opt12_A_val<m3g1c1_Exec_Opt12_B_val)){exec12_temp=false;}
}
}
if(!exec12_temp)exec12_b=false;
if(exec12_temp){
if(m3g1c1_Exec_Opt12_A_val[e12cBar311]<m3g1c1_Exec_Opt12_B_val[e12cBar311]){exec12_temp=false;}
}
if(exec12_temp)exec12_a=true;
}
if(exec12_a&&exec12_b)exec12=true;
bool bshift=true;
if(filter12&&filter34&&exec12&&bshift)reValue=true;
return (reValue);
}
bool checkM4G1(){
int i;
bool reValue=false;
int preBar=0;
if(Model4_CalculateModel==2)preBar=1;

bool filter12=true;
bool filter34=true;
bool exec12_temp=true, exec12_a=false, exec12_b=true,exec12=false;
if(exec12_b){
exec12_temp=true;
int e12cBar411=2; if(preBar==1&&e12cBar411==1)e12cBar411=2;
for(i=preBar;i<=e12cBar411;i++){
m4g1c1_Exec_Opt12_A_val=iMA(m4g1c1_Exec_Opt12_APara1,
m4g1c1_Exec_Opt12_APara2,
m4g1c1_Exec_Opt12_APara4,
m4g1c1_Exec_Opt12_APara6,
m4g1c1_Exec_Opt12_APara3,
m4g1c1_Exec_Opt12_APara5,
i);
m4g1c1_Exec_Opt12_B_val=iMA(m4g1c1_Exec_Opt12_BPara1,
m4g1c1_Exec_Opt12_BPara2,
m4g1c1_Exec_Opt12_BPara4,
m4g1c1_Exec_Opt12_BPara6,
m4g1c1_Exec_Opt12_BPara3,
m4g1c1_Exec_Opt12_BPara5,
i);
}
if(!(m4g1c1_Exec_Opt12_A_val[preBar]>(m4g1c1_Exec_Opt12_B_val[preBar]+0))){exec12_temp=false;}
if(exec12_temp){
for(i=preBar+1;i<e12cBar411;i++){
if(!(m4g1c1_Exec_Opt12_A_val>m4g1c1_Exec_Opt12_B_val)){exec12_temp=false;}
}
}
if(!exec12_temp)exec12_b=false;
if(exec12_temp){
if(m4g1c1_Exec_Opt12_A_val[e12cBar411]>m4g1c1_Exec_Opt12_B_val[e12cBar411]){exec12_temp=false;}
}
if(exec12_temp)exec12_a=true;
}
if(exec12_a&&exec12_b)exec12=true;
bool bshift=true;
if(filter12&&filter34&&exec12&&bshift)reValue=true;
return (reValue);
}


bool isNewBar(string s,int timeframe,int model){
datetime currentBarTime = iTime(s,timeframe,0);
if(lastBarTime[model]!=currentBarTime){
lastBarTime[model] = currentBarTime;
return (true);
}else{
return (false);
}
}


double getlots(double DefaultLots,bool MoneyManage,double Risk,double StopLoss,string symbol,int mt,int LotDigits,double MinLots,double MaxLots){
double lot;
if(MoneyManage){
if(StopLoss>0)lot=NormalizeDouble((AccountEquity()*(Risk/100))/(MarketInfo(symbol,MODE_TICKVALUE)*mt*StopLoss ),LotDigits);
else lot= NormalizeDouble(AccountEquity()/10000,LotDigits);
if(lot<MinLots)lot=MinLots;
if(lot>MaxLots)lot=MaxLots;
}else lot=DefaultLots;
return(lot);
}


int openposition(string symbol,int type,double lots,double StopLoss,double TakeProfit,int magic,bool ECN,bool InstantOrder,bool StopOrder,bool LimitOrder,int Gap,int Expiration,double point,int mt,int Slippage){
int ticket=0;int expire=0;int try=0;
if(StopOrder || LimitOrder)if(Expiration>0)expire=TimeCurrent()+(Expiration*60);
double ask=MarketInfo(symbol,MODE_ASK);double bid=MarketInfo(symbol,MODE_BID);
if(type==OP_BUY){//buy
if(ECN){
if(InstantOrder){
while(ticket<=0 && try<maxtry){
RefreshRates();
ticket=open(symbol,OP_BUY,lots,ask,0,0,magic,expire,point,mt,Slippage,Blue);
if(ticket<0){try++;if(printLog)Print(\"Error opening Instant BUY order!\",errordescription(GetLastError()),\" retry \"+try+\" times\");}
if(ticket>0){ecnsltpLong(ticket,StopLoss,TakeProfit,point);}
}
}
if(StopOrder){
RefreshRates();
ticket=open(symbol,OP_BUYSTOP,lots,ask+Gap*point,0,0,magic,expire,point,mt,Slippage,Blue);
if(ticket>0){ecnsltpLong(ticket,StopLoss,TakeProfit,point);}
}
if(LimitOrder){
RefreshRates();
ticket=open(symbol,OP_BUYLIMIT,lots,bid-Gap*point,0,0,magic,expire,point,mt,Slippage,Blue);
if(ticket>0){ecnsltpLong(ticket,StopLoss,TakeProfit,point);}
}
}else{
if(InstantOrder){
while(ticket<=0 && try<maxtry){
RefreshRates();
ticket=open(symbol,OP_BUY,lots,ask,StopLoss,TakeProfit,magic,expire,point,mt,Slippage,Blue);
if(ticket<0){try++;if(printLog)Print(\"Error opening Instant BUY order!\",errordescription(GetLastError()),\" retry \"+try+\" times\");}
}
}
if(StopOrder){RefreshRates();ticket=open(symbol,OP_BUYSTOP,lots,ask+Gap*point,StopLoss,TakeProfit,magic,expire,point,mt,Slippage,Blue);}
if(LimitOrder){RefreshRates();ticket=open(symbol,OP_BUYLIMIT,lots,bid-Gap*point,StopLoss,TakeProfit,magic,expire,point,mt,Slippage,Blue);}
}
}else if(type==OP_SELL){ // Sell
if(ECN){
if(InstantOrder){
while(ticket<=0 && try<maxtry){
RefreshRates();
ticket=open(symbol,OP_SELL,lots,bid,0,0,magic,expire,point,mt,Slippage,Red);
if(ticket<0){try++;if(printLog)Print(\"Error opening Instant SELL order!\",errordescription(GetLastError()),\" retry \"+try+\" times\");}
if(ticket>0){ecnsltpShort(ticket,StopLoss,TakeProfit,point);}
}
}
if(StopOrder){
RefreshRates();
ticket=open(symbol,OP_SELLSTOP,lots,bid-Gap*point,0,0,magic,expire,point,mt,Slippage,Red);
if(ticket>0){ecnsltpShort(ticket,StopLoss,TakeProfit,point);}
}
if(LimitOrder){
RefreshRates();
ticket=open(symbol,OP_SELLLIMIT,lots,ask+Gap*point,0,0,magic,expire,point,mt,Slippage,Red);
if(ticket>0){ecnsltpShort(ticket,StopLoss,TakeProfit,point);}
}
}else{
if(InstantOrder){
while(ticket<=0 && try<maxtry){
RefreshRates();
ticket=open(symbol,OP_SELL,lots,bid,StopLoss,TakeProfit,magic,expire,point,mt,Slippage,Red);
if(ticket<0){try++;if(printLog)Print(\"Error opening Instant SELL order!\",errordescription(GetLastError()),\" retry \"+try+\" times\");}
}
}
if(StopOrder){RefreshRates();ticket=open(symbol,OP_SELLSTOP,lots,bid-Gap*point,StopLoss,TakeProfit,magic,expire,point,mt,Slippage,Red);}
if(LimitOrder){RefreshRates();ticket=open(symbol,OP_SELLLIMIT,lots,ask+Gap*point,StopLoss,TakeProfit,magic,expire,point,mt,Slippage,Red);}
}
}

return (ticket);
}


int open(string symbol,int type,double lots,double price,double stoploss,double takeprofit,int magic, int expire,double point,int mt,int Slippage,color clr){
int ticket=0;
double sl,tp;
if(type==OP_BUY || type==OP_BUYSTOP || type==OP_BUYLIMIT){
if(stoploss>0){sl=price-stoploss*point;}else{sl=0;}
if(takeprofit>0){tp=price+takeprofit*point;}else{tp=0;}
}
if(type==OP_SELL || type==OP_SELLSTOP || type==OP_SELLLIMIT){
if(stoploss>0){sl=price+stoploss*point;}else{sl=0;}
if(takeprofit>0){tp=price-takeprofit*point;}else{tp=0;}
}
ticket=OrderSend(symbol,type,lots,NormalizeDouble(price,MarketInfo(symbol,MODE_DIGITS)),Slippage*mt,sl,tp,\"Prower by myeatrade.com\",magic,expire,clr);
return(ticket);
}

datetime getOrderOpenTime(int ticket){
OrderSelect(ticket,SELECT_BY_TICKET);
return (OrderOpenTime());
}



void ecnsltpLong(int ticket,double StopLoss,double TakeProfit,double point){
OrderSelect(ticket,SELECT_BY_TICKET);
bool succeed;int try;
succeed=false;try=0;
if(OrderStopLoss()==0&&StopLoss>0){
while(!succeed && try<maxtry){
RefreshRates();
succeed = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-StopLoss*point,MarketInfo(OrderSymbol(),MODE_DIGITS)),OrderTakeProfit(),0,Blue);
if(!succeed){try++;if(printLog)Print(\"Error modify long order stoploss!\",errordescription(GetLastError()),\" retry \"+try+\" times\");}
}
}
RefreshRates();
succeed=false;try=0;
OrderSelect(ticket,SELECT_BY_TICKET);
if(OrderTakeProfit()==0&&TakeProfit>0){
while(!succeed && try<maxtry){
RefreshRates();
succeed = OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()+TakeProfit*point,MarketInfo(OrderSymbol(),MODE_DIGITS)),0,Blue);
if(!succeed){try++;if(printLog)Print(\"Error modify long order takeprofit!\",errordescription(GetLastError()),\" retry \"+try+\" times\");}
}
}
}

void ecnsltpShort(int ticket,double StopLoss,double TakeProfit,double point){
OrderSelect(ticket,SELECT_BY_TICKET);
bool succeed;int try;
succeed=false;try=0;
if(OrderStopLoss()==0&&StopLoss>0){
while(!succeed && try<maxtry){
RefreshRates();
succeed = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()+StopLoss*point,MarketInfo(OrderSymbol(),MODE_DIGITS)),OrderTakeProfit(),0,Blue);
if(!succeed){try++;if(printLog)Print(\"Error modify short order stoploss!\",errordescription(GetLastError()),\" retry \"+try+\" times\");}
}
}
RefreshRates();
succeed=false;try=0;
OrderSelect(ticket,SELECT_BY_TICKET);
if(OrderTakeProfit()==0&&TakeProfit>0){
while(!succeed && try<maxtry){
RefreshRates();
succeed = OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()-TakeProfit*point,MarketInfo(OrderSymbol(),MODE_DIGITS)),0,Blue);
if(!succeed){try++;if(printLog)Print(\"Error modify short order takeprofit!\",errordescription(GetLastError()),\" retry \"+try+\" times\");}
}
}
}


int countPositionByMagicSymbol(int magic,string symbol,int hardCloseTime){
int count=0;
if(OrdersTotal()>0){
for(int i=OrdersTotal();i>=0;i--){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==magic&&OrderSymbol()==symbol){
count++;
if(hardCloseTime>0&&(TimeCurrent()>OrderOpenTime()+hardCloseTime*60)){
if(OrderType()==OP_BUY)OrderClose(OrderTicket(),OrderLots(),MarketInfo(symbol,MODE_BID),0);
else if(OrderType()==OP_SELL)OrderClose(OrderTicket(),OrderLots(),MarketInfo(symbol,MODE_ASK),0);
}
}
}
return(count);
}
}



void breakEven(int magic,string symbol,int BreakEven,double point){
RefreshRates();
if(OrdersTotal()>0){
for(int i=0;i<OrdersTotal();i++){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderMagicNumber()==magic && OrderSymbol()==symbol){
if(OrderType()==OP_BUY){
if( NormalizeDouble((MarketInfo(symbol,MODE_BID)-OrderOpenPrice()),MarketInfo(symbol,MODE_DIGITS))>=NormalizeDouble(BreakEven*point,MarketInfo(symbol,MODE_DIGITS))){
if( (OrderStopLoss()-OrderOpenPrice())<0)
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Blue);
}
}else{
if( NormalizeDouble((OrderOpenPrice()-MarketInfo(symbol,MODE_ASK)),MarketInfo(symbol,MODE_DIGITS))>=NormalizeDouble(BreakEven*point,MarketInfo(symbol,MODE_DIGITS))){
if(((OrderOpenPrice()-OrderStopLoss())<0)||(OrderStopLoss()==0))
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
}
}
}
}
}
}


void trailStop(int magic,string symbol,int TrailMode,int TrailStart,int TrailStop,double point){
RefreshRates();
if(OrdersTotal()>0){
for(int i=0;i<OrdersTotal();i++){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderMagicNumber()==magic && OrderSymbol()==symbol){
int digits=MarketInfo(symbol,MODE_DIGITS);
double ask = MarketInfo(symbol,MODE_ASK);double bid = MarketInfo(symbol,MODE_BID);
if(OrderType()==OP_BUY){
if( NormalizeDouble((bid-OrderOpenPrice()),digits)>=NormalizeDouble(TrailStart*point,digits)){
if(TrailMode==1){
if(NormalizeDouble(OrderStopLoss(),digits)<NormalizeDouble(bid-TrailStop*point,digits)){
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(bid-TrailStop*point,digits),OrderTakeProfit(),0,Blue);
}
}
if(TrailMode==2){
if(bid-TrailStop*point >=OrderStopLoss()+TrailStop*point){
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(bid-TrailStop*point,digits),OrderTakeProfit(),0,Blue);
}
}
}
}else{
if( NormalizeDouble((OrderOpenPrice()-ask),digits)>=NormalizeDouble(TrailStart*point,digits)){
if(TrailMode==1){
if( (NormalizeDouble(OrderStopLoss(),digits) > NormalizeDouble(ask+TrailStop*point,digits)) || OrderStopLoss()==0 ){
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(ask+TrailStop*point,digits),OrderTakeProfit(),0,Red);
}
}
if(TrailMode==2){
if((ask+TrailStop*point <=OrderStopLoss()-TrailStop*point) || OrderStopLoss()==0 ){
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(ask+TrailStop*point,digits),OrderTakeProfit(),0,Blue);
}
}
}
}
}
}
}
}












string errordescription(int code){
string error;
switch(code){
case 0:
case 1:error=\"no error\";break;
case 2:error=\"common error\";break;
case 3:error=\"invalid trade parameters\";break;
case 4:error=\"trade server is busy\";break;
case 5:error=\"old version of the client terminal\";break;
case 6:error=\"no connection with trade server\";break;
case 7:error=\"not enough rights\";break;
case 8:error=\"too frequent requests\";break;
case 9:error=\"malfunctional trade operation\";break;
case 64:error=\"account disabled\";break;
case 65:error=\"invalid account\";break;
case 128:error=\"trade timeout\";break;
case 129:error=\"invalid price\";break;
case 130:error=\"invalid stops\";break;
case 131:error=\"invalid trade volume\";break;
case 132:error=\"market is closed\";break;
case 133:error=\"trade is disabled\";break;
case 134:error=\"not enough money\";break;
case 135:error=\"price changed\";break;
case 136:error=\"off quotes\";break;
case 137:error=\"broker is busy\";break;
case 138:error=\"requote\";break;
case 139:error=\"order is locked\";break;
case 140:error=\"long positions only allowed\";break;
case 141:error=\"too many requests\";break;
case 145:error=\"modification denied because order too close to market\";break;
case 146:error=\"trade context is busy\";break;
case 4000:error=\"no error\";break;
case 4001:error=\"wrong function pointer\";break;
case 4002:error=\"array index is out of range\";break;
case 4003:error=\"no memory for function call stack\";break;
case 4004:error=\"recursive stack overflow\";break;
case 4005:error=\"not enough stack for parameter\";break;
case 4006:error=\"no memory for parameter string\";break;
case 4007:error=\"no memory for temp string\";break;
case 4008:error=\"not initialized string\";break;
case 4009:error=\"not initialized string in array\";break;
case 4010:error=\"no memory for array\\\' string\";break;
case 4011:error=\"too long string\";break;
case 4012:error=\"remainder from zero divide\";break;
case 4013:error=\"zero divide\";break;
case 4014:error=\"unknown command\";break;
case 4015:error=\"wrong jump (never generated error)\";break;
case 4016:error=\"not initialized array\";break;
case 4017:error=\"dll calls are not allowed\";break;
case 4018:error=\"cannot load library\";break;
case 4019:error=\"cannot call function\";break;
case 4020:error=\"expert function calls are not allowed\";break;
case 4021:error=\"not enough memory for temp string returned from function\";break;
case 4022:error=\"system is busy (never generated error)\";break;
case 4050:error=\"invalid function parameters count\";break;
case 4051:error=\"invalid function parameter value\";break;
case 4052:error=\"string function internal error\";break;
case 4053:error=\"some array error\";break;
case 4054:error=\"incorrect series array using\";break;
case 4055:error=\"custom indicator error\";break;
case 4056:error=\"arrays are incompatible\";break;
case 4057:error=\"global variables processing error\";break;
case 4058:error=\"global variable not found\";break;
case 4059:error=\"function is not allowed in testing mode\";break;
case 4060:error=\"function is not confirmed\";break;
case 4061:error=\"send mail error\";break;
case 4062:error=\"string parameter expected\";break;
case 4063:error=\"integer parameter expected\";break;
case 4064:error=\"double parameter expected\";break;
case 4065:error=\"array as parameter expected\";break;
case 4066:error=\"requested history data in update state\";break;
case 4099:error=\"end of file\";break;
case 4100:error=\"some file error\";break;
case 4101:error=\"wrong file name\";break;
case 4102:error=\"too many opened files\";break;
case 4103:error=\"cannot open file\";break;
case 4104:error=\"incompatible access to a file\";break;
case 4105:error=\"no order selected\";break;
case 4106:error=\"unknown symbol\";break;
case 4107:error=\"invalid price parameter for trade function\";break;
case 4108:error=\"invalid ticket\";break;
case 4109:error=\"trade is not allowed\";break;
case 4110:error=\"longs are not allowed\";break;
case 4111:error=\"shorts are not allowed\";break;
case 4200:error=\"object is already exist\";break;
case 4201:error=\"unknown object property\";break;
case 4202:error=\"object is not exist\";break;
case 4203:error=\"unknown object type\";break;
case 4204:error=\"no object name\";break;
case 4205:error=\"object coordinates error\";break;
case 4206:error=\"no specified subwindow\";break;
default:error=\"unknown error\";
}
return(error);
}


bool checkHasPosition(int magic,string symbol){
if(OrdersTotal()>0){
for(int i=OrdersTotal();i>=0;i--){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==magic&&OrderSymbol()==symbol) return(true);
}
}
return (false);
}

bool closeModelPosition(int magic,string symbol,double percent,int m,int mt,int Slippage){
double closeLots=0;
bool AllClose=true;
if(OrdersTotal()>0){
for(int i=OrdersTotal();i>=0;i--){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==magic&&OrderSymbol()==symbol){
if(TimeCurrent()-OrderOpenTime()<m*60){AllClose=false;continue;}
closeLots=OrderLots()*percent;
if(closeLots<MarketInfo(OrderSymbol(),MODE_MINLOT))closeLots=MarketInfo(OrderSymbol(),MODE_MINLOT);
if(OrderType()==OP_BUY){
RefreshRates();
if(!OrderClose(OrderTicket(),closeLots,MarketInfo(symbol,MODE_BID),Slippage*mt)){AllClose=false;}
}
if(OrderType()==OP_SELL){
RefreshRates();
if(!OrderClose(OrderTicket(),closeLots,MarketInfo(symbol,MODE_ASK),Slippage*mt)){AllClose=false;}
}
if(OrderType()==OP_BUYLIMIT||OrderType()==OP_BUYSTOP||OrderType()==OP_SELLLIMIT||OrderType()==OP_SELLSTOP){
RefreshRates();
if(!OrderDelete(OrderTicket())){AllClose=false;}
}
}
}
}
return (AllClose);
}


bonoboss bonoboss 2012-12-18 12:37
你应该说 出什么错误
zdzzkb zdzzkb 2012-12-18 13:36
错误显示是这样的:
2012.12.18 13:24:09 4小时趋势看盘 inputs: Model1_CalculateModel=0; Model1_CalculateModelTimeframe=5; Model1_DefaultLots=0.1; Model1_Risk=2; Model1_LotDigits=1; Model1_MinLots=0.1; Model1_MaxLots=100; Model1_StopLoss=0; Model1_TakeProfit=0; Model1_BreakEven=0; Model1_TrailMode=0; Model1_TrailStart=50; Model1_TrailStop=20; Model1_MaxSpread=0; Model1_Slippage=0; Model1_MaxOrder=5; Model1_MultiOrderTimeInterval=5; Model1_PendingGap=20; Model1_PendingExpiration=720; Model1_HardCloseTime=0; m1g1c1_Filter_Opt12_APara2=240; m1g1c1_Fi
2012.12.18 13:24:09 TestGenerator: unmatched data error (volume limit 6613 at 2012.12.14 20:00 exceeded)
2012.12.18 13:24:09 TestGenerator: unmatched data error (volume limit 6613 at 2012.12.14 20:00 exceeded)
2012.12.18 13:24:09 TestGenerator: unmatched data error (volume limit 12335 at 2012.12.11 08:00 exceeded)
2012.12.18 13:24:09 TestGenerator: unmatched data error (volume limit 12335 at 2012.12.11 08:00 exceeded)
净值图没有显示曲线。
不懂是什么意思?不晓得哪点错了。
bonoboss bonoboss 2012-12-18 22:43
晕,是你的历史数据有问题
zdzzkb zdzzkb 2012-12-19 00:20
谢谢,不知道该如何设置历史数据呢

myeatrade myeatrade 2012-12-19 21:49
TestGenerator: unmatched data error 这个错误很常见,只是说历史数据有部分不太匹配而已,不影响EA的测试和运行的

净值图没有显示曲线 表示没有发生交易条件,或者 你的MT4没有该时间段的数据

zdzzkb zdzzkb 2012-12-26 09:08
哦,谢谢版主!
Page 1 of 1 1

请登录后发表回复,如果你还没有账户你可以 免费注册

回到 通常讨论
menu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loader