Skip to content

Instantly share code, notes, and snippets.

@APPEA
Created March 22, 2016 13:37
Show Gist options
  • Save APPEA/c625fdfbc9561e445f2b to your computer and use it in GitHub Desktop.
Save APPEA/c625fdfbc9561e445f2b to your computer and use it in GitHub Desktop.
達摩戰艦
#import "wininet.dll"
int InternetAttemptConnect(
int dwReserved=0
);
int InternetOpenA(uchar &lpszAgent[],int dwAccessType,uchar &lpszProxyName[],uchar &lpszProxyBypass[],int dwFlags);
int InternetConnectA(int hInternetSession,uchar &lpszServerName[],int nServerPort,uchar &lpszUserName[],uchar &lpszPassword[],int nService,int nFlags,int dwContext);
bool InternetCloseHandle(
int hInet
);
bool FtpPutFileA (
int hFtpSession,
string lpszLocalFile,
string lpszRemoteFile,
int dwFlags,
int dwContext
);
bool FtpGetFileA (int hFtpSession,uchar &lpszRemoteFile[],uchar &lpszNewFile[],bool fFailIfExists,int dwFlagsAndAttributes,uint dwFlags,int dwContext);
bool FtpCreateDirectoryA(
int hConnect,
string lpszDirectory
);
bool FtpSetCurrentDirectoryA(
int hConnect,
string lpszDirectory
);
#import
#define INTERNET_FLAG_PASSIVE 0x08000000
#define INTERNET_FLAG_RELOAD 0x80000000
#define INTERNET_FLAG_EXISTING_CONNECT 0x20000000
#define INTERNET_SERVICE_FTP 1
#define FTP_TRANSFER_TYPE_ASCII 1
#define FTP_TRANSFER_TYPE_BINARY 2
#define FTP_TRANSFER_TYPE_UNKNOWN 3
#define INTERNET_FLAG_HYPERLINK 0x00000400
static int ExtBase64Encode[64]={ 'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/' };
static int ExtBase64Decode[256]={
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
string t1 = "";
int GMT=8;
extern string T0="-------------ESP戰艦穩定煞車系統------------";
extern bool BrakeSystem=true;
int pSeconds=14;
extern string T1="能量偵測靈敏度";
extern int Energy = 40;
extern string T2="能量煞車引擎啟動時間";
extern int SleepTime=15;
int SleepStop=0;
int Position=0;
extern string T5="-------------保證金比例控制模組--------------";
extern bool MarginSleep=true;
extern double MarginLimit=1000;
extern string T6="-------------浮虧控制模組(以金額計算)-------------";
extern bool FloatEq=true;
extern double FloatAm=-6000;
extern string T7="開始時間,格式為hh";
extern int start_t=00;
extern string T8="結束時間,格式為hh";
extern int stop_t=00;
extern string T9="週一執行,鍵入1即可";
extern string T10="週一週二鍵入12,以下類推";
extern string weekday="12345";
extern bool Week15SW=true;
extern string W1="禮拜一幾點開始";
extern int W1Start=8;
extern string W2="最後一天幾點結束";
extern int W5Over=17;
extern string T11="止盈止損計算本金基準";
extern double I_balance=0;
extern string T12="止損後當日不再出兵";
extern bool SleepLoss=true;
extern string T13="最大總浮虧(以餘額計算)";
extern double SLpercent=100.0;
extern string T14="次止盈,每次最多獲利%,立即平倉歸零重啟新局";
extern double takepercent=1;
string T111="每次止盈開關";
bool next_in=true;
extern string T15="日止盈,每日最多獲利%,立即停止交易,隔日重新啟動";
extern double takepercent_day=100;
extern string T16="每局結束幾分鐘後重新啟動";
extern double NextTime=2;
extern string T9_="-------------------小虧為贏模組-------------";
extern string T17="每局最長時間(分鐘)";
extern int MaxTime=150;
extern string T18="每局最多兵力";
extern int MaxIn=40;
extern string T19="達成以上條件小虧為贏";
extern double MaxP=0.5;
extern string T20="-------------------------------------------";
extern string T21="手數";
extern double Lots = 0.01;
extern string T22="馬丁倍率";
extern double LotExponent = 1.618;
extern string T23="----------------三方向導航-----------------";
extern bool BSB=true;
int gi108 = 2;
double MaxLots = 5.0;
bool MM = FALSE;
extern string T24="獲利點數";
extern double TakeProfit = 100.0;
bool UseEquityStop = FALSE;
double TotalEquityRisk = 20.0;
string t2 = "Time Setting";
bool CloseFriday = false;
int CloseFridayHour = 17;
bool OpenMondey = false;
int OpenMondeyHour = 0;
string t3 = "";
extern string T25="A模組最多單數";
extern int MaxTrades_A=10;
bool gi220 = FALSE;
double gd224 = 48.0;
bool UseTrailingStop_Hilo = FALSE;
double g_pips236 = 500.0;
double TrailStart_Hilo = 10.0;
double TrailStop_Hilo = 5.0;
double PipStep_Hilo = 10.0;
double slip_Hilo = 3.0;
int MagicNumber_Hilo = 11111;
double g_price280;
double gd288;
double gd_unused296;
double gd_unused304;
double g_price312;
double g_bid320;
double g_ask328;
double gd336;
double gd344;
double gd352;
bool gi360;
string gs364 = "";
int gi372 = 0;
int gi376;
int gi380 = 0;
double gd384;
int g_pos392 = 0;
int gi396;
double gd400 = 0.0;
bool gi408 = FALSE;
bool gi412 = FALSE;
bool gi416 = FALSE;
int gi420;
bool gi424 = FALSE;
double gd428;
double gd436;
string t4 = "";
extern string T26="B模組最多單數";
extern int MaxTrades_B=10;
int g_timeframe496 = PERIOD_H1;
bool UseTrailingStop15 = FALSE;
double g_pips508 = 500.0;
double TrailStart15 = 10.0;
double TrailStop15 = 5.0;
bool gi532 = FALSE;
double gd536 = 48.0;
double PipStep15 = 10.0;
double slip15 = 3.0;
int g_magic17615 = 12324;
double g_price564;
double gd572;
double gd_unused580;
double gd_unused588;
double g_price596;
double g_bid604;
double g_ask612;
double gd620;
double gd628;
double gd636;
bool gi644;
string gs648 = "";
int gi656 = 0;
int gi660;
int gi664 = 0;
double gd668;
int g_pos676 = 0;
int gi680;
double gd684 = 0.0;
bool gi692 = FALSE;
bool gi696 = FALSE;
bool gi700 = FALSE;
int gi704;
bool gi708 = FALSE;
double gd712;
double gd720;
int g_datetime728 = 1;
string t5 = "";
extern string T27="C模組最多單數";
extern int MaxTrades_C=10;
int g_timeframe784 = PERIOD_M1;
bool UseTrailingStop16 = FALSE;
double g_pips792 = 500.0;
double TrailStart16 = 10.0;
double TrailStop16 = 5.0;
bool gi816 = FALSE;
double gd820 = 48.0;
double PipStep16 = 10.0;
double slip16 = 3.0;
int g_magic17616 = 16794;
double g_price848;
double gd856;
double gd_unused864;
double gd_unused872;
double g_price880;
double g_bid888;
double g_ask896;
double gd904;
double gd912;
double gd920;
bool gi928;
string gs932 = "";
int gi940 = 0;
int gi944;
int gi948 = 0;
double gd952;
int g_pos960 = 0;
int gi964;
double gd968 = 0.0;
bool gi976 = FALSE;
bool gi980 = FALSE;
bool gi984 = FALSE;
int gi988;
bool gi992 = FALSE;
double gd996;
double gd1004;
int g_datetime1012 = 1;
int g_timeframe1024 = PERIOD_M1;
int g_timeframe1028 = PERIOD_M5;
int g_timeframe1032 = PERIOD_M15;
int g_timeframe1036 = PERIOD_M30;
int g_timeframe1040 = PERIOD_H1;
int g_timeframe1044 = PERIOD_H4;
int g_timeframe1048 = PERIOD_D1;
bool g_corner1052 = TRUE;
int gi1056 = 0;
int gi1060 = 10;
int g_window1064 = 0;
bool gi1068 = TRUE;
bool gi_unused1072 = TRUE;
bool gi1076 = FALSE;
int g_color1080 = Gray;
int g_color1084 = Gray;
int g_color1088 = Gray;
int g_color1092 = DarkOrange;
int gi_unused1096 = 36095;
int g_color1100 = Lime;
int g_color1104 = OrangeRed;
int gi1108 = 65280;
int gi1112 = 17919;
int g_color1116 = Lime;
int g_color1120 = Red;
int g_color1124 = Orange;
int g_period1128 = 8;
int g_period1132 = 17;
int g_period1136 = 9;
int g_applied_price1140 = PRICE_CLOSE;
int g_color1144 = Lime;
int g_color1148 = Tomato;
int g_color1152 = Green;
int g_color1156 = Red;
string gs_unused1160 = "<<<< STR Indicator Settings >>>>>>>>>>>>>";
string gs_unused1168 = "<<<< RSI Settings >>>>>>>>>>>>>";
int g_period1176 = 9;
int g_applied_price1180 = PRICE_CLOSE;
string gs_unused1184 = "<<<< CCI Settings >>>>>>>>>>>>>>";
int g_period1192 = 13;
int g_applied_price1196 = PRICE_CLOSE;
string gs_unused1200 = "<<<< STOCH Settings >>>>>>>>>>>";
int g_period1208 = 5;
int g_period1212 = 3;
int g_slowing1216 = 3;
int g_ma_method1220 = MODE_EMA;
string gs_unused1224 = "<<<< STR Colors >>>>>>>>>>>>>>>>";
int g_color1232 = Lime;
int g_color1236 = Red;
int g_color1240 = Orange;
string gs_unused1244 = "<<<< MA Settings >>>>>>>>>>>>>>";
int g_period1252 = 5;
int g_period1256 = 9;
int g_ma_method1260 = MODE_EMA;
int g_applied_price1264 = PRICE_CLOSE;
string gs_unused1268 = "<<<< MA Colors >>>>>>>>>>>>>>";
int g_color1276 = Lime;
int g_color1280 = Red;
string gs_dummy1292;
string g_text1464;
string g_text1472;
bool gi1480 = TRUE;
string KEY = "";
int gi1492;
int g_str2int1496;
int g_str2int1500;
int g_str2int1504;
int MinPriceShot;
string maindata[300][7];
double start_balance,point;
int start_p,id1,id2,bar2;
int Pos=50;
int hourr=0;
int minutee;
int count;
bool NewsgetSW=false;
double Last_Price=-1.0;
int Last_Time=0;
int init() {
if (IsTesting()==true) {return(0);}
GlobalVariableSet("Dhamar"+Symbol(),WindowHandle(Symbol(),Period()));
ObjectCreate("Expert",OBJ_LABEL,0,0,0);
ObjectSet("Expert", OBJPROP_CORNER, 1);
ObjectSet("Expert", OBJPROP_COLOR, White);
ObjectSet("Expert", OBJPROP_XDISTANCE, 150);
ObjectSet("Expert", OBJPROP_YDISTANCE, 0);
ObjectSetText("Expert", WindowExpertName(),15,"微軟正黑體", White);
//+------------------------------------------------------------------+
MinPriceShot=Energy;
//+------------------------------------------------------------------+
bar2=Bars;
if(Digits == 5 ||Digits == 3)
{
point=Point*10;
}
else
{
point=Point;
}
//+------------------------------------------------------------------+
double Position_L=Bid+Position*point;
ObjectCreate("Light",OBJ_ARROW,0,0,0);
ObjectSet("Light",OBJPROP_ARROWCODE,108);
ObjectSet("Light", OBJPROP_CORNER, 1);
ObjectSet("Light", OBJPROP_COLOR, Lime);
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light",OBJPROP_WIDTH,5);
ObjectCreate("Light2",OBJ_ARROW,0,0,0);
ObjectSet("Light2",OBJPROP_ARROWCODE,161);
ObjectSet("Light2", OBJPROP_CORNER, 1);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_WIDTH,5);
ObjectCreate("lightstatus",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"lightstatus", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"lightstatus", OBJPROP_COLOR, clrGold);
ObjectSetInteger(0,"lightstatus", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"lightstatus", OBJPROP_YDISTANCE, Pos+135);
ObjectSetInteger(0,"lightstatus", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
//+------------------------------------------------------------------+
GlobalVariableSet("next_sw",0);
if (!GlobalVariableCheck("start_balance"))
{
GlobalVariableSet("start_balance",AccountBalance());
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
if (!GlobalVariableCheck("start_p"))
{
GlobalVariableSet("start_p",TimeCurrent());
}
start_p=GlobalVariableGet("start_p");
MathSrand(TimeLocal());
for (int i=1;i<10;i++)
{minutee=1+((59*MathRand())/32768); }
GlobalVariableSet("RUN",0);
GlobalVariableSet("UPSW",0);
GlobalVariableSet("WSW",0);
GlobalVariableSet("RUNEA",0);
GlobalVariableSet("DNSW",0);
if (GlobalVariableCheck("MaxEquity")==false)
{GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);}
ObjectCreate(0,"Newsinfo",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo", OBJPROP_YDISTANCE, Pos+95);
ObjectSetInteger(0,"Newsinfo", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
ObjectCreate(0,"Newsinfo2",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_YDISTANCE, Pos+115);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
string ls4;
string ls12;
string ls20;
string ls28;
string ls36;
string ls44;
gd352 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd636 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd920 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
ObjectCreate("Lable1", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable1", OBJPROP_CORNER, 2);
ObjectSet("Lable1", OBJPROP_XDISTANCE, 23);
ObjectSet("Lable1", OBJPROP_YDISTANCE, 21);
g_text1472 = "";
ObjectSetText("Lable1", g_text1472, 12, "Arial", DeepSkyBlue);
ObjectCreate("Lable", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable", OBJPROP_CORNER, 2);
ObjectSet("Lable", OBJPROP_XDISTANCE, 3);
ObjectSet("Lable", OBJPROP_YDISTANCE, 1);
g_text1464 = "";
ObjectSetText("Lable", g_text1464, 10, "Arial", DeepSkyBlue);
if (false/*gi1480*/) {
if (KEY != "") {
gi1492 = 0;
for (int li_0 = 0; li_0 < StringLen(KEY); li_0++) {
if (StringSubstr(KEY, li_0, 1) != "X") ls4 = ls4 + StringSubstr(KEY, li_0, 1);
else {
ls12 = ls12 + f015(ls4);
ls4 = "";
}
}
for (li_0 = 0; li_0 < StringLen(ls12); li_0 += 2) {
if (StringSubstr(ls12, li_0, 2) == "55") ls20 = ls20 + "0";
else {
if (StringSubstr(ls12, li_0, 2) == "21") ls20 = ls20 + "1";
else {
if (StringSubstr(ls12, li_0, 2) == "98") ls20 = ls20 + "2";
else {
if (StringSubstr(ls12, li_0, 2) == "42") ls20 = ls20 + "3";
else {
if (StringSubstr(ls12, li_0, 2) == "10") ls20 = ls20 + "4";
else {
if (StringSubstr(ls12, li_0, 2) == "14") ls20 = ls20 + "5";
else {
if (StringSubstr(ls12, li_0, 2) == "88") ls20 = ls20 + "6";
else {
if (StringSubstr(ls12, li_0, 2) == "66") ls20 = ls20 + "7";
else {
if (StringSubstr(ls12, li_0, 2) == "33") ls20 = ls20 + "8";
else {
if (StringSubstr(ls12, li_0, 2) == "32") ls20 = ls20 + "9";
else {
if (StringSubstr(ls12, li_0, 2) == "96") ls20 = ls20 + "a";
else {
if (StringSubstr(ls12, li_0, 2) == "30") ls20 = ls20 + "b";
else {
if (StringSubstr(ls12, li_0, 2) == "77") ls20 = ls20 + "c";
else {
if (StringSubstr(ls12, li_0, 2) == "90") ls20 = ls20 + "d";
else {
if (StringSubstr(ls12, li_0, 2) == "24") ls20 = ls20 + "e";
else {
if (StringSubstr(ls12, li_0, 2) == "29") ls20 = ls20 + "f";
else {
if (StringSubstr(ls12, li_0, 2) == "39") ls20 = ls20 + "g";
else {
if (StringSubstr(ls12, li_0, 2) == "48") ls20 = ls20 + "h";
else {
if (StringSubstr(ls12, li_0, 2) == "56") ls20 = ls20 + "i";
else {
if (StringSubstr(ls12, li_0, 2) == "16") ls20 = ls20 + "j";
else {
if (StringSubstr(ls12, li_0, 2) == "62") ls20 = ls20 + "k";
else {
if (StringSubstr(ls12, li_0, 2) == "15") ls20 = ls20 + "l";
else {
if (StringSubstr(ls12, li_0, 2) == "71") ls20 = ls20 + "m";
else {
if (StringSubstr(ls12, li_0, 2) == "81") ls20 = ls20 + "n";
else {
if (StringSubstr(ls12, li_0, 2) == "93") ls20 = ls20 + "o";
else {
if (StringSubstr(ls12, li_0, 2) == "74") ls20 = ls20 + "p";
else {
if (StringSubstr(ls12, li_0, 2) == "83") ls20 = ls20 + "q";
else {
if (StringSubstr(ls12, li_0, 2) == "44") ls20 = ls20 + "r";
else {
if (StringSubstr(ls12, li_0, 2) == "51") ls20 = ls20 + "s";
else {
if (StringSubstr(ls12, li_0, 2) == "69") ls20 = ls20 + "t";
else {
if (StringSubstr(ls12, li_0, 2) == "40") ls20 = ls20 + "u";
else {
if (StringSubstr(ls12, li_0, 2) == "73") ls20 = ls20 + "v";
else {
if (StringSubstr(ls12, li_0, 2) == "59") ls20 = ls20 + "w";
else {
if (StringSubstr(ls12, li_0, 2) == "36") ls20 = ls20 + "x";
else {
if (StringSubstr(ls12, li_0, 2) == "26") ls20 = ls20 + "y";
else {
if (StringSubstr(ls12, li_0, 2) == "25") ls20 = ls20 + "z";
else {
if (StringSubstr(ls12, li_0, 2) == "28") ls20 = ls20 + "!";
else {
if (StringSubstr(ls12, li_0, 2) == "65") ls20 = ls20 + "&";
else {
if (StringSubstr(ls12, li_0, 2) == "52") ls20 = ls20 + "#";
else {
if (StringSubstr(ls12, li_0, 2) == "57") ls20 = ls20 + "$";
else {
if (StringSubstr(ls12, li_0, 2) == "31") ls20 = ls20 + "%";
else {
if (StringSubstr(ls12, li_0, 2) == "91") ls20 = ls20 + "*";
else {
if (StringSubstr(ls12, li_0, 2) == "60") ls20 = ls20 + "+";
else {
if (StringSubstr(ls12, li_0, 2) == "92") ls20 = ls20 + "-";
else {
if (StringSubstr(ls12, li_0, 2) == "34") ls20 = ls20 + "?";
else {
if (StringSubstr(ls12, li_0, 2) == "46") ls20 = ls20 + "^";
else {
if (StringSubstr(ls12, li_0, 2) == "38") ls20 = ls20 + "|";
else {
if (StringSubstr(ls12, li_0, 2) == "37") ls20 = ls20 + "@";
else {
if (StringSubstr(ls12, li_0, 2) == "49") ls20 = ls20 + "_";
else {
if (StringSubstr(ls12, li_0, 2) == "50") ls20 = ls20 + "S";
else
if (StringSubstr(ls12, li_0, 2) == "19") ls20 = ls20 + ".";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
ls28 = StringSubstr(ls20, 1, 2);
ls36 = StringSubstr(ls20, 3, 2);
ls44 = StringSubstr(ls20, 5, 4);
g_str2int1496 = StrToInteger(ls28);
g_str2int1500 = StrToInteger(ls36);
g_str2int1504 = StrToInteger(ls44);
if (Year() > g_str2int1504) gi1492 = 3;
if (Year() == g_str2int1504) {
if (Month() > g_str2int1500) gi1492 = 3;
if (Month() == g_str2int1500)
if (Day() > g_str2int1496) gi1492 = 3;
}
} else gi1492 = 1;
gi1480 = FALSE;
}
//Comment("\n", "License will expire on ", g_str2int1496, "/", g_str2int1500, "/", g_str2int1504);
return (0);
}
int deinit() {
ObjectDelete("cja");
ObjectDelete("Signalprice");
ObjectDelete("SIG_BARS_TF1");
ObjectDelete("SIG_BARS_TF2");
ObjectDelete("SIG_BARS_TF3");
ObjectDelete("SIG_BARS_TF4");
ObjectDelete("SIG_BARS_TF5");
ObjectDelete("SIG_BARS_TF6");
ObjectDelete("SIG_BARS_TF7");
ObjectDelete("SSignalMACD_TEXT");
ObjectDelete("SSignalMACDM1");
ObjectDelete("SSignalMACDM5");
ObjectDelete("SSignalMACDM15");
ObjectDelete("SSignalMACDM30");
ObjectDelete("SSignalMACDH1");
ObjectDelete("SSignalMACDH4");
ObjectDelete("SSignalMACDD1");
ObjectDelete("SSignalSTR_TEXT");
ObjectDelete("SignalSTRM1");
ObjectDelete("SignalSTRM5");
ObjectDelete("SignalSTRM15");
ObjectDelete("SignalSTRM30");
ObjectDelete("SignalSTRH1");
ObjectDelete("SignalSTRH4");
ObjectDelete("SignalSTRD1");
ObjectDelete("SignalEMA_TEXT");
ObjectDelete("SignalEMAM1");
ObjectDelete("SignalEMAM5");
ObjectDelete("SignalEMAM15");
ObjectDelete("SignalEMAM30");
ObjectDelete("SignalEMAH1");
ObjectDelete("SignalEMAH4");
ObjectDelete("SignalEMAD1");
ObjectDelete("SIG_DETAIL1");
ObjectDelete("SIG_DETAIL2");
ObjectDelete("SIG_DETAIL3");
ObjectDelete("SIG_DETAIL4");
ObjectDelete("SIG_DETAIL5");
ObjectDelete("SIG_DETAIL6");
ObjectDelete("SIG_DETAIL7");
ObjectDelete("SIG_DETAIL8");
ObjectDelete("Lable");
ObjectDelete("Lable1");
ObjectDelete("percent");
ObjectDelete("start_p");
ObjectDelete("takepercent_day");
ObjectDelete("run");
ObjectDelete("Newsinfo");
ObjectDelete("Newsinfo2");
ObjectDelete("ERR");
ObjectDelete("ERR2");
ObjectDelete("Expert");
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
ObjectDelete("Margin");
ObjectDelete("Float");
return (0);
}
int start() {
//+------------------------------------------------Author Start--------------------------------------------------------------------------+
GlobalVariableSet("Dhamar"+Symbol()+"TF",Period());
double Position_L=Bid+Position*point;
string outDN,outUP,outtext,outtext2;
if (GlobalVariableGet("RUNEA")==1) //EA控制器
{
Alert("EA is not working");
return;
}
//+------------------------------------------------Author End----------------------------------------------------------------------------+
int Handle_Log,h1;
if ((AccountProfit()/start_balance)*100<GlobalVariableGet("MaxEquity")) GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);
displayprofit(start_p,next_in,start_balance);
//--------------------------------------------------------------------------------------Hydra
if (OrdersTotal()==0)
{
GlobalVariableSet("start_balance",AccountBalance());
GlobalVariableSet("start_p",TimeCurrent());
//GlobalVariableSet("MaxEquity",start_balance);
GlobalVariableSet("next_sw",0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),GlobalVariableGet("start_balance"),"After");
FileClose(h1);*/
Sleep(60000);
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
start_p=GlobalVariableGet("start_p");
if (GlobalVariableGet("next_sw")==1)
{
if (IsTradeContextBusy())
{
Sleep(10000);
return;
}
iCloseOrders("100%",Symbol(),id1,0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(start_p,TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),start_balance,"Before");
FileClose(h1);*/
Sleep(5000);
if (MyOrderTotal_err(id1)!=0)
{
Alert(Symbol()+" 戰場未成功離開");
Sleep(30000);
return;
}else
{
Sleep(NextTime*60*1000);
}
return(0);
}
//--------------------------------------------------------------------------------------Hydra
if (SLClose(SLpercent,start_balance))
{
if (SleepLoss)
{
GlobalVariableSet("RUN",1);
GlobalVariableSet("runtime",StrToTime(TimeToStr(TimeLocal(),TIME_DATE)));
}
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Stop Loss Close");
FileClose(Handle_Log);*/
}
if (takepercent>0){
int ii_0=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE));
if (next_in==false) {
if (profit_control(ii_0,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in flase");
FileClose(Handle_Log);*/
return(0);
}
}
if (next_in==true){
if (profit_control(start_p,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in true");
FileClose(Handle_Log);*/
}
if (profit_control(ii_0,takepercent_day,start_balance)==false)
{
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by day next_in true");
FileClose(Handle_Log);*/
return(0);
}
}
}
CheckTimeIn(MaxTime,MaxIn,MaxP,start_p);
//--------------------------------------------------------------------------------------Hydra
if (Hour()==hourr && Minute()==minutee && bar2!=Bars && GlobalVariableGet("UPSW")==0) {
GlobalVariableSet("UPSW",1);
//makefile_N();
bar2=Bars;
}
if (Hour()==hourr+1 && Minute()==0 && GlobalVariableGet("UPSW")==1)
{
GlobalVariableSet("UPSW",0);
}
//+------------------------------------------------------------------+
if (GlobalVariableGet("RUN")==1 && TimeLocal()<=GlobalVariableGet("runtime")+86400)
{
return;
}
if (GlobalVariableGet("RUN")==1 && TimeLocal()>GlobalVariableGet("runtime")+86400)
{
GlobalVariableSet("RUN",0);
}
ObjectCreate("run",OBJ_LABEL,0,0,0);
ObjectSet("run", OBJPROP_CORNER, 1);
ObjectSet("run", OBJPROP_COLOR, White);
ObjectSet("run", OBJPROP_XDISTANCE, 20);
ObjectSet("run", OBJPROP_YDISTANCE, Pos);
if (!Week15(W1Start,W5Over,start_t,stop_t,weekday) && OrdersTotal() == 0) {
ObjectSetText("run","未在設定時區內,現有戰役達成後將離開戰場",10,"微軟正黑體");
return;
}else {
ObjectSetText("run","已進入作戰時區內,全面啟動執行...",10,"微軟正黑體");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (BrakeSystem)
{
string Active="煞車系統啟動中";
string Deactive="煞車系統待命中";
color Light_status=Gold;
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSetString(0,"lightstatus",OBJPROP_FONT,"微軟正黑體");
ObjectSetInteger(0,"lightstatus",OBJPROP_FONTSIZE,10);
ObjectSetInteger(0,"lightstatus",OBJPROP_COLOR,Light_status);
int Price_Range;
int Time_Range;
int Now_Time = TimeCurrent();
double Now_Price = Close[0];
if (Last_Price != -1.0) {
Price_Range = Now_Price / Point - Last_Price / Point;
Time_Range = Now_Time - Last_Time;
//int Total_Orders = OrdersTotalCountByTypeANDMagic(OP_BUY, BuyMagic) + OrdersTotalCountByTypeANDMagic(OP_SELL, SellMagic);
if (MathAbs(Price_Range) >= MinPriceShot && Time_Range <= pSeconds) {
//if (Total_Orders < MaxOrdersCount) {
if (Now_Price > Last_Price) {
if ( MyOrderTotal_type(id1,1) > MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
if (Now_Price < Last_Price) {
if ( MyOrderTotal_type(id1,1) < MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
//} else {}//Comment("");
Last_Price = Now_Price;
Last_Time = Now_Time;
}else {
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (Time_Range >= pSeconds) {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
} else {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (TimeCurrent()<=SleepStop)
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active+", "+DoubleToStr((SleepStop-TimeCurrent())/60,0)+" 分鐘後啟動");
return;
}
}else {
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (MarginSleep) {
bool Pass=false;
if (AccountMargin() == 0) {Pass=true;}
else{
double Margin_R=(AccountEquity()/AccountMargin())*100;
if (MarginLimit >= Margin_R && !Pass) {
ObjectCreate("Margin",OBJ_LABEL,0,0,0);
ObjectSet("Margin", OBJPROP_CORNER, 1);
ObjectSet("Margin", OBJPROP_COLOR, Gold);
ObjectSet("Margin", OBJPROP_XDISTANCE, 20);
ObjectSet("Margin", OBJPROP_YDISTANCE, Pos+155);
ObjectSetText("Margin", "保證金比例低於 "+DoubleToStr(MarginLimit,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Margin");
}
}
}else {
ObjectDelete("Margin");
}
if (FloatEq) {
double Profit=AccountProfit();
if (Profit <= FloatAm) {
ObjectCreate("Float",OBJ_LABEL,0,0,0);
ObjectSet("Float", OBJPROP_CORNER, 1);
ObjectSet("Float", OBJPROP_COLOR, Gold);
ObjectSet("Float", OBJPROP_XDISTANCE, 20);
ObjectSet("Float", OBJPROP_YDISTANCE, Pos+175);
ObjectSetText("Float", "浮虧大於 "+DoubleToStr(FloatAm,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Float");
}
}else {
ObjectDelete("Float");
}
int li4;
int li8;
int li12;
int li16;
int li20;
int li24;
int li28;
color color32;
color color36;
color color40;
color color44;
color color48;
color color52;
color color56;
string ls_unused60;
color color68;
color color72;
color color76;
color color80;
color color84;
color color88;
color color92;
color color96;
string ls_unused100;
color color108;
int li_unused112;
double ihigh1128;
double ilow1136;
double iclose1144;
double iclose1152;
double ld1192;
double ld1248;
double ld1256;
int li1264;
int count1268;
double ld1316;
double ld1324;
int li1332;
int count1336;
int li992 = 0;
int li996 = 0;
int li1000 = 0;
int li1004 = 0;
int li1008 = 0;
int li1012 = 0;
li992 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
for (li1012 = 1; li1012 <= 5; li1012++) li996 = li996 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 10; li1012++) li1000 = li1000 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 20; li1012++) li1004 = li1004 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
li996 /= 5;
li1000 /= 10;
li1004 /= 20;
li1008 = (li992 + li996 + li1000 + li1004) / 4;
string ls_unused1016 = "";
string ls_unused1024 = "";
string dbl2str1032 = "";
string dbl2str1040 = "";
string dbl2str1048 = "";
string dbl2str1056 = "";
string ls_unused1064 = "";
string ls_unused1072 = "";
string ls1080 = "";
double iopen1088 = iOpen(NULL, PERIOD_D1, 0);
double iclose1096 = iClose(NULL, PERIOD_D1, 0);
double ld1104 = (Ask - Bid) / Point;
double ihigh1112 = iHigh(NULL, PERIOD_D1, 0);
double ilow1120 = iLow(NULL, PERIOD_D1, 0);
dbl2str1040 = DoubleToStr((iclose1096 - iopen1088) / Point, 0);
dbl2str1032 = DoubleToStr(ld1104, Digits - 4);
dbl2str1048 = DoubleToStr(li1008, Digits - 4);
ls1080 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
dbl2str1056 = DoubleToStr((ihigh1112 - ilow1120) / Point, 0);
if (iclose1096 >= iopen1088) {
ls_unused1064 = "-";
color108 = g_color1100;
}
if (iclose1096 < iopen1088) {
ls_unused1064 = "-";
color108 = g_color1104;
}
if (dbl2str1048 >= ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1108;
}
if (dbl2str1048 < ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1112;
}
double ld1160 = LotExponent;
int li1168 = gi108;
double ld1172 = TakeProfit;
bool bool1180 = UseEquityStop;
double ld1184 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1192 = Lots;
else ld1192 = 0.00001 * MathCeil(AccountBalance());
} else ld1192 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop_Hilo) f035(TrailStart_Hilo, TrailStop_Hilo, g_price312);
if (gi220) {
if (TimeCurrent() >= gi376) {
f024();
Print("Closed All due_Hilo to TimeOut");
}
}
if (gi372 == Time[0]) return (0);
gi372 = Time[0];
double ld1200 = f031();
if (bool1180) {
if (ld1200 < 0.0 && MathAbs(ld1200) > ld1184 / 100.0 * f07()) {
f024();
Print("Closed All due_Hilo to Stop Out");
gi424 = FALSE;
}
}
gi396 = f04();
if (gi396 == 0) gi360 = FALSE;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
gi412 = TRUE;
gi416 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
gi412 = FALSE;
gi416 = TRUE;
break;
}
}
}
if (gi396 > 0 && gi396 <= MaxTrades_A) {
RefreshRates();
gd336 = f032();
gd344 = f020();
if (gi412 && gd336 - Ask >= PipStep_Hilo * Point) gi408 = TRUE;
if (gi416 && Bid - gd344 >= PipStep_Hilo * Point) gi408 = TRUE;
}
if (gi396 < 1) {
gi416 = FALSE;
gi412 = FALSE;
gi408 = TRUE;
gd288 = AccountEquity();
}
if (gi408) {
gd336 = f032();
gd344 = f020();
if (gi416) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
RefreshRates();
gi420 = f03(1, gd384, Bid, slip_Hilo, Ask, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi408 = FALSE;
gi424 = TRUE;
} else {
if (gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
gi420 = f03(0, gd384, Ask, slip_Hilo, Bid, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi408 = FALSE;
gi424 = TRUE;
}
}
}
if (gi408 && gi396 < 1) {
ihigh1128 = iHigh(Symbol(), 0, 1);
ilow1136 = iLow(Symbol(), 0, 2);
g_bid320 = Bid;
g_ask328 = Ask;
if ((!gi416) && !gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
if (ihigh1128 > ilow1136) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi420 = f03(1, gd384, g_bid320, slip_Hilo, g_bid320, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi424 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi420 = f03(0, gd384, g_ask328, slip_Hilo, g_ask328, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi424 = TRUE;
}
}
if (gi420 > 0) gi376 = TimeCurrent() + 60.0 * (60.0 * gd224);
gi408 = FALSE;
}
}
gi396 = f04();
g_price312 = 0;
double ld1208 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price312 += OrderOpenPrice() * OrderLots();
ld1208 += OrderLots();
}
}
}
if (gi396 > 0) g_price312 = NormalizeDouble(g_price312 / ld1208, Digits);
if (gi424) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
g_price280 = g_price312 + ld1172 * Point;
gd_unused296 = g_price280;
gd400 = g_price312 - g_pips236 * Point;
gi360 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
g_price280 = g_price312 - ld1172 * Point;
gd_unused304 = g_price280;
gd400 = g_price312 + g_pips236 * Point;
gi360 = TRUE;
}
}
}
}
if (gi424) {
if (gi360 == TRUE) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) OrderModify(OrderTicket(), g_price312, OrderStopLoss(), g_price280, 0, Yellow);
gi424 = FALSE;
}
}
}
double ld1216 = LotExponent;
int li1224 = gi108;
double ld1228 = TakeProfit;
bool bool1236 = UseEquityStop;
double ld1240 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1248 = Lots;
else ld1248 = 0.00001 * MathCeil(AccountBalance());
} else ld1248 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop15) f021(TrailStart15, TrailStop15, g_price596);
if (gi532) {
if (TimeCurrent() >= gi660) {
f018();
Print("Closed All due to TimeOut");
}
}
if (gi656 != Time[0]) {
gi656 = Time[0];
ld1256 = f029();
if (bool1236) {
if (ld1256 < 0.0 && MathAbs(ld1256) > ld1240 / 100.0 * f016()) {
f018();
Print("Closed All due to Stop Out");
gi708 = FALSE;
}
}
gi680 = f05();
if (gi680 == 0) gi644 = FALSE;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
gi696 = TRUE;
gi700 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
gi696 = FALSE;
gi700 = TRUE;
break;
}
}
}
if (gi680 > 0 && gi680 <= MaxTrades_B) {
RefreshRates();
gd620 = f036();
gd628 = f028();
if (gi696 && gd620 - Ask >= PipStep15 * Point) gi692 = TRUE;
if (gi700 && Bid - gd628 >= PipStep15 * Point) gi692 = TRUE;
}
if (gi680 < 1) {
gi700 = FALSE;
gi696 = FALSE;
gi692 = TRUE;
gd572 = AccountEquity();
}
if (gi692) {
gd620 = f036();
gd628 = f028();
if (gi700) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
RefreshRates();
gi704 = f02(1, gd668, Bid, slip15, Ask, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi692 = FALSE;
gi708 = TRUE;
} else {
if (gi696) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
gi704 = f02(0, gd668, Ask, slip15, Bid, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi692 = FALSE;
gi708 = TRUE;
}
}
}
}
if (g_datetime728 != iTime(NULL, g_timeframe496, 0)) {
li1264 = OrdersTotal();
count1268 = 0;
for (int li1272 = li1264; li1272 >= 1; li1272--) {
OrderSelect(li1272 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) count1268++;
}
if (li1264 == 0 || count1268 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid604 = Bid;
g_ask612 = Ask;
gi664 = gi680;
gd668 = ld1248;
if (iclose1144 > iclose1152) {
gi704 = f02(1, gd668, g_bid604, slip15, g_bid604, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi708 = TRUE;
} else {
gi704 = f02(0, gd668, g_ask612, slip15, g_ask612, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi708 = TRUE;
}
if (gi704 > 0) gi660 = TimeCurrent() + 60.0 * (60.0 * gd536);
gi692 = FALSE;
}
g_datetime728 = iTime(NULL, g_timeframe496, 0);
}
gi680 = f05();
g_price596 = 0;
double ld1276 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price596 += OrderOpenPrice() * OrderLots();
ld1276 += OrderLots();
}
}
}
if (gi680 > 0) g_price596 = NormalizeDouble(g_price596 / ld1276, Digits);
if (gi708) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
g_price564 = g_price596 + ld1228 * Point;
gd_unused580 = g_price564;
gd684 = g_price596 - g_pips508 * Point;
gi644 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
g_price564 = g_price596 - ld1228 * Point;
gd_unused588 = g_price564;
gd684 = g_price596 + g_pips508 * Point;
gi644 = TRUE;
}
}
}
}
if (gi708) {
if (gi644 == TRUE) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) OrderModify(OrderTicket(), g_price596, OrderStopLoss(), g_price564, 0, Yellow);
gi708 = FALSE;
}
}
}
double ld1284 = LotExponent;
int li1292 = gi108;
double ld1296 = TakeProfit;
bool bool1304 = UseEquityStop;
double ld1308 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1316 = Lots;
else ld1316 = 0.00001 * MathCeil(AccountBalance());
} else ld1316 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop16) f034(TrailStart16, TrailStop16, g_price880);
if (gi816) {
if (TimeCurrent() >= gi944) {
f0_0();
Print("Closed All due to TimeOut");
}
}
if (gi940 != Time[0]) {
gi940 = Time[0];
ld1324 = f08();
if (bool1304) {
if (ld1324 < 0.0 && MathAbs(ld1324) > ld1308 / 100.0 * f030()) {
f0_0();
Print("Closed All due to Stop Out");
gi992 = FALSE;
}
}
gi964 = f012();
if (gi964 == 0) gi928 = FALSE;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
gi980 = TRUE;
gi984 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
gi980 = FALSE;
gi984 = TRUE;
break;
}
}
}
if (gi964 > 0 && gi964 <= MaxTrades_C) {
RefreshRates();
gd904 = f017();
gd912 = f027();
if (gi980 && gd904 - Ask >= PipStep16 * Point) gi976 = TRUE;
if (gi984 && Bid - gd912 >= PipStep16 * Point) gi976 = TRUE;
}
if (gi964 < 1) {
gi984 = FALSE;
gi980 = FALSE;
gd856 = AccountEquity();
}
if (gi976) {
gd904 = f017();
gd912 = f027();
if (gi984) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
RefreshRates();
gi988 = f06(1, gd952, Bid, slip16, Ask, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi976 = FALSE;
gi992 = TRUE;
} else {
if (gi980) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
gi988 = f06(0, gd952, Ask, slip16, Bid, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi976 = FALSE;
gi992 = TRUE;
}
}
}
}
if (g_datetime1012 != iTime(NULL, g_timeframe784, 0)) {
li1332 = OrdersTotal();
count1336 = 0;
for (int li1340 = li1332; li1340 >= 1; li1340--) {
OrderSelect(li1340 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) count1336++;
}
if (li1332 == 0 || count1336 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid888 = Bid;
g_ask896 = Ask;
gi948 = gi964;
gd952 = ld1316;
if (iclose1144 > iclose1152) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi988 = f06(1, gd952, g_bid888, slip16, g_bid888, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi992 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi988 = f06(0, gd952, g_ask896, slip16, g_ask896, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi992 = TRUE;
}
}
if (gi988 > 0) gi944 = TimeCurrent() + 60.0 * (60.0 * gd820);
gi976 = FALSE;
}
g_datetime1012 = iTime(NULL, g_timeframe784, 0);
}
gi964 = f012();
g_price880 = 0;
double ld1344 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price880 += OrderOpenPrice() * OrderLots();
ld1344 += OrderLots();
}
}
}
if (gi964 > 0) g_price880 = NormalizeDouble(g_price880 / ld1344, Digits);
if (gi992) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
g_price848 = g_price880 + ld1296 * Point;
gd_unused864 = g_price848;
gd968 = g_price880 - g_pips792 * Point;
gi928 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
g_price848 = g_price880 - ld1296 * Point;
gd_unused872 = g_price848;
gd968 = g_price880 + g_pips792 * Point;
gi928 = TRUE;
}
}
}
}
if (gi992) {
if (gi928 == TRUE) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) OrderModify(OrderTicket(), g_price880, OrderStopLoss(), g_price848, 0, Yellow);
gi992 = FALSE;
}
}
}
//Handle_Log=0;
return (0);
}
int f04() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f024() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip_Hilo, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip_Hilo, Red);
}
Sleep(1000);
}
}
}
int f03(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM1(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f022(Bid, ai32), f019(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f011(Ask, ai32), f01(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f022(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f011(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f019(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f01(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f031() {
double ld_ret_0 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f035(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f07() {
if (f04() == 0) gd428 = AccountEquity();
if (gd428 < gd436) gd428 = gd436;
else gd428 = AccountEquity();
gd436 = AccountEquity();
return (gd428);
}
double f032() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f020() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f05() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f018() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip15, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip15, Red);
}
Sleep(1000);
}
}
}
int f02(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM2(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f013(Bid, ai32), f025(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f033(Ask, ai32), f026(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f013(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f033(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f025(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f026(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f029() {
double ld_ret_0 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f021(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f016() {
if (f05() == 0) gd712 = AccountEquity();
if (gd712 < gd720) gd712 = gd720;
else gd712 = AccountEquity();
gd720 = AccountEquity();
return (gd712);
}
double f036() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f028() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f012() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f0_0() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip16, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip16, Red);
}
Sleep(1000);
}
}
}
int f06(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM3(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f014(Bid, ai32), f09(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f023(Ask, ai32), f010(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f014(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f023(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f09(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f010(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f08() {
double ld_ret_0 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f034(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f030() {
if (f012() == 0) gd996 = AccountEquity();
if (gd996 < gd1004) gd996 = gd1004;
else gd996 = AccountEquity();
gd1004 = AccountEquity();
return (gd996);
}
double f017() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f027() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
string f015(string as_0) {
int str_len8 = StringLen(as_0);
bool li_ret12 = FALSE;
for (int li16 = 0; li16 < str_len8; li16++) {
if (StringSubstr(as_0, li16, 1) == "1") li_ret12 = li_ret12 + MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "2") li_ret12 = li_ret12 + 2.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "3") li_ret12 = li_ret12 + 3.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "4") li_ret12 = li_ret12 + 4.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "5") li_ret12 = li_ret12 + 5.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "6") li_ret12 = li_ret12 + 6.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "7") li_ret12 = li_ret12 + 7.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "8") li_ret12 = li_ret12 + 8.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "9") li_ret12 = li_ret12 + 9.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "A") li_ret12 = li_ret12 + 10.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "B") li_ret12 = li_ret12 + 11.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "C") li_ret12 = li_ret12 + 12.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "D") li_ret12 = li_ret12 + 13.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "E") li_ret12 = li_ret12 + 14.0 * MathPow(16, str_len8 - li16 - 1);
else
if (StringSubstr(as_0, li16, 1) == "F") li_ret12 = li_ret12 + 15.0 * MathPow(16, str_len8 - li16 - 1);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return (li_ret12);
}
string MakeDateTime(string strDate, string strTime)
{
// Print("Converting Forex Factory Time into Metatrader time..."); //added by MN
// Converts forexfactory time & date into yyyy.mm.dd hh:mm
int n1stDash = StringFind(strDate, "-");
int n2ndDash = StringFind(strDate, "-", n1stDash+1);
string strMonth = StringSubstr(strDate, 0, 2);
string strDay = StringSubstr(strDate, 3, 2);
string strYear = StringSubstr(strDate, 6, 4);
// strYear = "20" + strYear;
int nTimeColonPos = StringFind(strTime, ":");
string strHour = StringSubstr(strTime, 0, nTimeColonPos);
string strMinute = StringSubstr(strTime, nTimeColonPos+1, 2);
string strAM_PM = StringSubstr(strTime, StringLen(strTime)-2);
int nHour24 = StrToInteger(strHour);
if ((strAM_PM == "pm" || strAM_PM == "PM") && nHour24 != 12)
{
nHour24 += 12;
}
if ((strAM_PM == "am" || strAM_PM == "AM") && nHour24 == 12)
{
nHour24 = 0;
}
string strHourPad = "";
if (nHour24 < 10)
strHourPad = "0";
return(StringConcatenate(strYear, ".", strMonth, ".", strDay, " ", strHourPad, nHour24, ":", strMinute));
}
bool profit_control(int i_0,double takepercent_,double start_balance)
{
double today_profit;
int i1=StrToTime(TimeToStr(TimeCurrent()+86400, TIME_DATE));
today_profit=((GetProfitFromDateInCurrency(i_0)+AccountProfit())/start_balance)*100;
if (today_profit>=takepercent_)
{
return(false);
}
return(true);
}
void displayprofit(int start_p,bool next_in,double start_balance)
{
double today_profit;
string display;
ObjectCreate("percent",OBJ_LABEL,0,0,0);
ObjectSet("percent", OBJPROP_CORNER, 1);
ObjectSet("percent", OBJPROP_COLOR, White);
ObjectSet("percent", OBJPROP_XDISTANCE, 20);
ObjectSet("percent", OBJPROP_YDISTANCE, Pos+30);
ObjectCreate("start_p",OBJ_LABEL,0,0,0);
ObjectSet("start_p", OBJPROP_CORNER, 1);
ObjectSet("start_p", OBJPROP_COLOR, White);
ObjectSet("start_p", OBJPROP_XDISTANCE, 20);
ObjectSet("start_p", OBJPROP_YDISTANCE, Pos+50);
ObjectSetText("start_p","進場經過時間 "+ DoubleToStr((TimeCurrent()-start_p)/60,1)+ " 分鐘"+" ; "+OrdersTotal()+" 兵力在戰場上",10,"微軟正黑體");
if (next_in==true)
{
today_profit=((GetProfitFromDateInCurrency(start_p)+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
GlobalVariableSet("display",today_profit);
ObjectSetText("percent","單次擄獲狂派戰俘"+display+"%"+" ; 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectCreate("takepercent_day",OBJ_LABEL,0,0,0);
ObjectSet("takepercent_day", OBJPROP_CORNER, 1);
ObjectSet("takepercent_day", OBJPROP_COLOR, White);
ObjectSet("takepercent_day", OBJPROP_XDISTANCE, 20);
ObjectSet("takepercent_day", OBJPROP_YDISTANCE, Pos+70);
ObjectSetText("takepercent_day","今日擄獲狂派戰俘累積至"+display+" ; 最大暫時被擄穫兵力 "+DoubleToStr(GlobalVariableGet("MaxEquity"),2)+" %",10,"微軟正黑體");
}
if (next_in==false)
{
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectSetText("percent","今日擄獲狂派戰俘累積至"+display+"%"+" 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
}
}
double GetProfitFromDateInCurrency(int today) {
double profit = 0;
int total = OrdersHistoryTotal();
for (int i = 0; i < total; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL ) {
if (today < OrderCloseTime()) profit += OrderProfit() + OrderCommission() + OrderSwap();
}
}
}
return (profit);
}
bool SLClose (double percent,double start_balance) {
if (AccountProfit()<=0)
{
if ((MathAbs(AccountProfit())/start_balance)*100>=percent)
{
return(true);
}
else
{
return(false);
}
}else
{
return(false);
}
}
void iCloseOrders(string myType,string currency,int id1,int type)
{
if (MyOrderTotal_err(id1)==0) return(0);
int C0_cnt,close_t[],t_cnt;
double percentlots,nd_profit;
if (myType=="Del"&&type==0)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_BUYSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="Del"&&type==1)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_SELLSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="100%")
{
for(C0_cnt=0;C0_cnt<OrdersTotal();C0_cnt++) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false)
{
//Alert(Symbol()+" OrderSelect Error");
continue;
}
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
ArrayResize(close_t,t_cnt+1);
close_t[t_cnt]=OrderTicket();
t_cnt++;
}
}
for(int i=ArraySize(close_t)-1;i>=0;i--)
{
if (OrderSelect(close_t[i],SELECT_BY_TICKET)==false)
{
Alert(Symbol()+" OrderSelect Error By Tickets");continue;
}
else
{
percentlots=OrderLots();
OrderClose(close_t[i],percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="80%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.8;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="50%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.5;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="All") //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderMagicNumber()!=0){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="BUY"&&type==0) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_BUY && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="SELL"&&type==1) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_SELL && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
}
int MyOrderTotal_err(int id1)//訂單總數函式
{
int x=0;//符合條件的BUY單數量(記次變數)
for(int z=0;z<OrdersTotal();z++)//執行N次篩選(N=訂單總數)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);//用"流水號"找訂單
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ))//挑選出同貨幣對 && BUY單 && MagicNumber=本程式 的訂單
{
x++;//符合節選結果的訂單總數
}
}
return(x);//回傳
}
int MyOrderTotal_type(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ) && OrderType()==type)
{
x++;//
}
}
return(x);
}
bool iTimeControl(int myStartHour,int myStopHour)
{
bool EA_Valid=false;
if(myStopHour == myStartHour) EA_Valid = true;
if(myStopHour < myStartHour)
{
if (TimeHour(TimeLocal()) >= myStartHour || TimeHour(TimeLocal()) < myStopHour) EA_Valid = true;
}
if (myStopHour > myStartHour) {
if ((TimeHour(TimeLocal()) >= myStartHour && TimeHour(TimeLocal()) < myStopHour))
EA_Valid = true;
}
return(EA_Valid);
}
bool Week15 (int start,int over,int myStartHour,int myStopHour,string weekday)
{
bool EA_Valid=false;
int Dayweek=TimeDayOfWeek(TimeLocal());
if (
(
(
Dayweek == 1 && TimeHour(TimeLocal()) < start
)
||
(
Dayweek == StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1)) && TimeHour(TimeLocal()) >= over
)
||
(
Dayweek > StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1))
)
)
&& Week15SW) {
EA_Valid=false;
}else {
if (iTimeControl(myStartHour,myStopHour)) {
if (StringFind(weekday,DoubleToStr(Dayweek,0),0) >= 0) {
EA_Valid=true;
}else {
EA_Valid=false;
}
}else {
EA_Valid=false;
}
}
return(EA_Valid);
}
void CheckTimeIn(int MaxTime,int MaxIn,double MaxP,int start_p)
{
int Handle_Log;
int Valid;
int RunTime=(TimeCurrent()-start_p)/60;
if (RunTime>=MaxTime && OrdersTotal() >= MaxIn && GlobalVariableGet("display")>= MaxP)
{
GlobalVariableSet("next_sw",1);
Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by CheckTimeIn");
FileClose(Handle_Log);
}
}
string Base64Decode(string in/*,string &out*/)
{
string out;
int i=0,len=StringLen(in);
int shift=0,accum=0;
while(i<len)
{
int value=ExtBase64Decode[StringGetChar(in,i)];
if(value<0 || value>63) break;
accum<<=6;
shift+=6;
accum|=value;
if(shift>=8)
{
shift-=8;
value=accum >> shift;
out=out+CharToStr(value & 0xFF);
}
i++;
}
//----
return(out);
}
bool ThreeM1(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(g_magic17616,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(g_magic17616,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM2(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17616,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17616,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM3(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
int MyOrderTotal_id(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id1 && OrderType()==type)
{
x++;//
}
}
return(x);
}
#import "wininet.dll"
int InternetAttemptConnect(
int dwReserved=0
);
int InternetOpenA(uchar &lpszAgent[],int dwAccessType,uchar &lpszProxyName[],uchar &lpszProxyBypass[],int dwFlags);
int InternetConnectA(int hInternetSession,uchar &lpszServerName[],int nServerPort,uchar &lpszUserName[],uchar &lpszPassword[],int nService,int nFlags,int dwContext);
bool InternetCloseHandle(
int hInet
);
bool FtpPutFileA (
int hFtpSession,
string lpszLocalFile,
string lpszRemoteFile,
int dwFlags,
int dwContext
);
bool FtpGetFileA (int hFtpSession,uchar &lpszRemoteFile[],uchar &lpszNewFile[],bool fFailIfExists,int dwFlagsAndAttributes,uint dwFlags,int dwContext);
bool FtpCreateDirectoryA(
int hConnect,
string lpszDirectory
);
bool FtpSetCurrentDirectoryA(
int hConnect,
string lpszDirectory
);
#import
#define INTERNET_FLAG_PASSIVE 0x08000000
#define INTERNET_FLAG_RELOAD 0x80000000
#define INTERNET_FLAG_EXISTING_CONNECT 0x20000000
#define INTERNET_SERVICE_FTP 1
#define FTP_TRANSFER_TYPE_ASCII 1
#define FTP_TRANSFER_TYPE_BINARY 2
#define FTP_TRANSFER_TYPE_UNKNOWN 3
#define INTERNET_FLAG_HYPERLINK 0x00000400
static int ExtBase64Encode[64]={ 'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/' };
static int ExtBase64Decode[256]={
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
string t1 = "";
//extern double Account = 1872377.0;
int GMT=8;
extern string T0="-------------ESP戰艦穩定煞車系統------------";
extern bool BrakeSystem=true;
int pSeconds=14;
extern string T1="能量偵測靈敏度";
extern int Energy = 40;
extern string T2="能量煞車引擎啟動時間";
extern int SleepTime=15;
int SleepStop=0;
int Position=0;
extern string T5="-------------保證金比例控制模組--------------";
extern bool MarginSleep=true;
extern double MarginLimit=1000;
extern string T6="-------------浮虧控制模組(以金額計算)-------------";
extern bool FloatEq=true;
extern double FloatAm=-6000;
extern string T7="開始時間,格式為hh";
extern int start_t=00;
extern string T8="結束時間,格式為hh";
extern int stop_t=00;
extern string T9="週一執行,鍵入1即可";
extern string T10="週一週二鍵入12,以下類推";
extern string weekday="12345";
extern bool Week15SW=true;
extern string W1="禮拜一幾點開始";
extern int W1Start=8;
extern string W2="最後一天幾點結束";
extern int W5Over=17;
extern string T11="止盈止損計算本金基準";
extern double I_balance=0;
extern string T12="止損後當日不再出兵";
extern bool SleepLoss=true;
extern string T13="最大總浮虧(以餘額計算)";
extern double SLpercent=100.0;
extern string T14="次止盈,每次最多獲利%,立即平倉歸零重啟新局";
extern double takepercent=1;
string T111="每次止盈開關";
bool next_in=true;
extern string T15="日止盈,每日最多獲利%,立即停止交易,隔日重新啟動";
extern double takepercent_day=100;
extern string T16="每局結束幾分鐘後重新啟動";
extern double NextTime=2;
extern string T9_="-------------------小虧為贏模組-------------";
extern string T17="每局最長時間(分鐘)";
extern int MaxTime=150;
extern string T18="每局最多兵力";
extern int MaxIn=40;
extern string T19="達成以上條件小虧為贏";
extern double MaxP=0.5;
extern string T20="-------------------------------------------";
extern string T21="手數";
extern double Lots = 0.01;
extern string T22="馬丁倍率";
extern double LotExponent = 1.618;
extern string T23="----------------三方向導航-----------------";
extern bool BSB=true;
int gi108 = 2;
double MaxLots = 5.0;
bool MM = FALSE;
extern string T24="獲利點數";
extern double TakeProfit = 100.0;
bool UseEquityStop = FALSE;
double TotalEquityRisk = 20.0;
string t2 = "Time Setting";
bool CloseFriday = false;
int CloseFridayHour = 17;
bool OpenMondey = false;
int OpenMondeyHour = 0;
string t3 = "";
extern string T25="A模組最多單數";
extern int MaxTrades_A=10;
bool gi220 = FALSE;
double gd224 = 48.0;
bool UseTrailingStop_Hilo = FALSE;
double g_pips236 = 500.0;
double TrailStart_Hilo = 10.0;
double TrailStop_Hilo = 5.0;
double PipStep_Hilo = 30.0;
double slip_Hilo = 3.0;
int MagicNumber_Hilo = 11111;
double g_price280;
double gd288;
double gd_unused296;
double gd_unused304;
double g_price312;
double g_bid320;
double g_ask328;
double gd336;
double gd344;
double gd352;
bool gi360;
string gs364 = "";
int gi372 = 0;
int gi376;
int gi380 = 0;
double gd384;
int g_pos392 = 0;
int gi396;
double gd400 = 0.0;
bool gi408 = FALSE;
bool gi412 = FALSE;
bool gi416 = FALSE;
int gi420;
bool gi424 = FALSE;
double gd428;
double gd436;
string t4 = "";
extern string T26="B模組最多單數";
extern int MaxTrades_B=10;
int g_timeframe496 = PERIOD_H1;
bool UseTrailingStop15 = FALSE;
double g_pips508 = 500.0;
double TrailStart15 = 10.0;
double TrailStop15 = 5.0;
bool gi532 = FALSE;
double gd536 = 48.0;
double PipStep15 = 30.0;
double slip15 = 3.0;
int g_magic17615 = 12324;
double g_price564;
double gd572;
double gd_unused580;
double gd_unused588;
double g_price596;
double g_bid604;
double g_ask612;
double gd620;
double gd628;
double gd636;
bool gi644;
string gs648 = "";
int gi656 = 0;
int gi660;
int gi664 = 0;
double gd668;
int g_pos676 = 0;
int gi680;
double gd684 = 0.0;
bool gi692 = FALSE;
bool gi696 = FALSE;
bool gi700 = FALSE;
int gi704;
bool gi708 = FALSE;
double gd712;
double gd720;
int g_datetime728 = 1;
string t5 = "";
extern string T27="C模組最多單數";
extern int MaxTrades_C=10;
int g_timeframe784 = PERIOD_M1;
bool UseTrailingStop16 = FALSE;
double g_pips792 = 500.0;
double TrailStart16 = 10.0;
double TrailStop16 = 5.0;
bool gi816 = FALSE;
double gd820 = 48.0;
double PipStep16 = 30.0;
double slip16 = 3.0;
int g_magic17616 = 16794;
double g_price848;
double gd856;
double gd_unused864;
double gd_unused872;
double g_price880;
double g_bid888;
double g_ask896;
double gd904;
double gd912;
double gd920;
bool gi928;
string gs932 = "";
int gi940 = 0;
int gi944;
int gi948 = 0;
double gd952;
int g_pos960 = 0;
int gi964;
double gd968 = 0.0;
bool gi976 = FALSE;
bool gi980 = FALSE;
bool gi984 = FALSE;
int gi988;
bool gi992 = FALSE;
double gd996;
double gd1004;
int g_datetime1012 = 1;
int g_timeframe1024 = PERIOD_M1;
int g_timeframe1028 = PERIOD_M5;
int g_timeframe1032 = PERIOD_M15;
int g_timeframe1036 = PERIOD_M30;
int g_timeframe1040 = PERIOD_H1;
int g_timeframe1044 = PERIOD_H4;
int g_timeframe1048 = PERIOD_D1;
bool g_corner1052 = TRUE;
int gi1056 = 0;
int gi1060 = 10;
int g_window1064 = 0;
bool gi1068 = TRUE;
bool gi_unused1072 = TRUE;
bool gi1076 = FALSE;
int g_color1080 = Gray;
int g_color1084 = Gray;
int g_color1088 = Gray;
int g_color1092 = DarkOrange;
int gi_unused1096 = 36095;
int g_color1100 = Lime;
int g_color1104 = OrangeRed;
int gi1108 = 65280;
int gi1112 = 17919;
int g_color1116 = Lime;
int g_color1120 = Red;
int g_color1124 = Orange;
int g_period1128 = 8;
int g_period1132 = 17;
int g_period1136 = 9;
int g_applied_price1140 = PRICE_CLOSE;
int g_color1144 = Lime;
int g_color1148 = Tomato;
int g_color1152 = Green;
int g_color1156 = Red;
string gs_unused1160 = "<<<< STR Indicator Settings >>>>>>>>>>>>>";
string gs_unused1168 = "<<<< RSI Settings >>>>>>>>>>>>>";
int g_period1176 = 9;
int g_applied_price1180 = PRICE_CLOSE;
string gs_unused1184 = "<<<< CCI Settings >>>>>>>>>>>>>>";
int g_period1192 = 13;
int g_applied_price1196 = PRICE_CLOSE;
string gs_unused1200 = "<<<< STOCH Settings >>>>>>>>>>>";
int g_period1208 = 5;
int g_period1212 = 3;
int g_slowing1216 = 3;
int g_ma_method1220 = MODE_EMA;
string gs_unused1224 = "<<<< STR Colors >>>>>>>>>>>>>>>>";
int g_color1232 = Lime;
int g_color1236 = Red;
int g_color1240 = Orange;
string gs_unused1244 = "<<<< MA Settings >>>>>>>>>>>>>>";
int g_period1252 = 5;
int g_period1256 = 9;
int g_ma_method1260 = MODE_EMA;
int g_applied_price1264 = PRICE_CLOSE;
string gs_unused1268 = "<<<< MA Colors >>>>>>>>>>>>>>";
int g_color1276 = Lime;
int g_color1280 = Red;
string gs_dummy1292;
string g_text1464;
string g_text1472;
bool gi1480 = TRUE;
string KEY = "";
int gi1492;
int g_str2int1496;
int g_str2int1500;
int g_str2int1504;
int MinPriceShot;
string maindata[300][7];
double start_balance,point;
int start_p,id1,id2,bar2;
int Pos=50;
int hourr=0;
int minutee;
int count;
bool NewsgetSW=false;
double Last_Price=-1.0;
int Last_Time=0;
int init() {
if (IsTesting()==true) {return(0);}
GlobalVariableSet("Dhamar"+Symbol(),WindowHandle(Symbol(),Period()));
ObjectCreate("Expert",OBJ_LABEL,0,0,0);
ObjectSet("Expert", OBJPROP_CORNER, 1);
ObjectSet("Expert", OBJPROP_COLOR, White);
ObjectSet("Expert", OBJPROP_XDISTANCE, 150);
ObjectSet("Expert", OBJPROP_YDISTANCE, 0);
ObjectSetText("Expert", WindowExpertName(),15,"微軟正黑體", White);
//+------------------------------------------------------------------+
MinPriceShot=Energy;
//+------------------------------------------------------------------+
bar2=Bars;
if(Digits == 5 ||Digits == 3)
{
point=Point*10;
}
else
{
point=Point;
}
//+------------------------------------------------------------------+
double Position_L=Bid+Position*point;
ObjectCreate("Light",OBJ_ARROW,0,0,0);
ObjectSet("Light",OBJPROP_ARROWCODE,108);
ObjectSet("Light", OBJPROP_CORNER, 1);
ObjectSet("Light", OBJPROP_COLOR, Lime);
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light",OBJPROP_WIDTH,5);
ObjectCreate("Light2",OBJ_ARROW,0,0,0);
ObjectSet("Light2",OBJPROP_ARROWCODE,161);
ObjectSet("Light2", OBJPROP_CORNER, 1);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_WIDTH,5);
ObjectCreate("lightstatus",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"lightstatus", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"lightstatus", OBJPROP_COLOR, clrGold);
ObjectSetInteger(0,"lightstatus", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"lightstatus", OBJPROP_YDISTANCE, Pos+135);
ObjectSetInteger(0,"lightstatus", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
//+------------------------------------------------------------------+
GlobalVariableSet("next_sw",0);
if (!GlobalVariableCheck("start_balance"))
{
GlobalVariableSet("start_balance",AccountBalance());
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
if (!GlobalVariableCheck("start_p"))
{
GlobalVariableSet("start_p",TimeCurrent());
}
start_p=GlobalVariableGet("start_p");
MathSrand(TimeLocal());
for (int i=1;i<10;i++)
{minutee=1+((59*MathRand())/32768); }
GlobalVariableSet("RUN",0);
GlobalVariableSet("UPSW",0);
GlobalVariableSet("WSW",0);
GlobalVariableSet("RUNEA",0);
GlobalVariableSet("DNSW",0);
if (GlobalVariableCheck("MaxEquity")==false)
{GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);}
ObjectCreate(0,"Newsinfo",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo", OBJPROP_YDISTANCE, Pos+95);
ObjectSetInteger(0,"Newsinfo", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
ObjectCreate(0,"Newsinfo2",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_YDISTANCE, Pos+115);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
string ls4;
string ls12;
string ls20;
string ls28;
string ls36;
string ls44;
gd352 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd636 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd920 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
ObjectCreate("Lable1", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable1", OBJPROP_CORNER, 2);
ObjectSet("Lable1", OBJPROP_XDISTANCE, 23);
ObjectSet("Lable1", OBJPROP_YDISTANCE, 21);
g_text1472 = "";
ObjectSetText("Lable1", g_text1472, 12, "Arial", DeepSkyBlue);
ObjectCreate("Lable", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable", OBJPROP_CORNER, 2);
ObjectSet("Lable", OBJPROP_XDISTANCE, 3);
ObjectSet("Lable", OBJPROP_YDISTANCE, 1);
g_text1464 = "";
ObjectSetText("Lable", g_text1464, 10, "Arial", DeepSkyBlue);
if (false/*gi1480*/) {
if (KEY != "") {
gi1492 = 0;
for (int li_0 = 0; li_0 < StringLen(KEY); li_0++) {
if (StringSubstr(KEY, li_0, 1) != "X") ls4 = ls4 + StringSubstr(KEY, li_0, 1);
else {
ls12 = ls12 + f015(ls4);
ls4 = "";
}
}
for (li_0 = 0; li_0 < StringLen(ls12); li_0 += 2) {
if (StringSubstr(ls12, li_0, 2) == "55") ls20 = ls20 + "0";
else {
if (StringSubstr(ls12, li_0, 2) == "21") ls20 = ls20 + "1";
else {
if (StringSubstr(ls12, li_0, 2) == "98") ls20 = ls20 + "2";
else {
if (StringSubstr(ls12, li_0, 2) == "42") ls20 = ls20 + "3";
else {
if (StringSubstr(ls12, li_0, 2) == "10") ls20 = ls20 + "4";
else {
if (StringSubstr(ls12, li_0, 2) == "14") ls20 = ls20 + "5";
else {
if (StringSubstr(ls12, li_0, 2) == "88") ls20 = ls20 + "6";
else {
if (StringSubstr(ls12, li_0, 2) == "66") ls20 = ls20 + "7";
else {
if (StringSubstr(ls12, li_0, 2) == "33") ls20 = ls20 + "8";
else {
if (StringSubstr(ls12, li_0, 2) == "32") ls20 = ls20 + "9";
else {
if (StringSubstr(ls12, li_0, 2) == "96") ls20 = ls20 + "a";
else {
if (StringSubstr(ls12, li_0, 2) == "30") ls20 = ls20 + "b";
else {
if (StringSubstr(ls12, li_0, 2) == "77") ls20 = ls20 + "c";
else {
if (StringSubstr(ls12, li_0, 2) == "90") ls20 = ls20 + "d";
else {
if (StringSubstr(ls12, li_0, 2) == "24") ls20 = ls20 + "e";
else {
if (StringSubstr(ls12, li_0, 2) == "29") ls20 = ls20 + "f";
else {
if (StringSubstr(ls12, li_0, 2) == "39") ls20 = ls20 + "g";
else {
if (StringSubstr(ls12, li_0, 2) == "48") ls20 = ls20 + "h";
else {
if (StringSubstr(ls12, li_0, 2) == "56") ls20 = ls20 + "i";
else {
if (StringSubstr(ls12, li_0, 2) == "16") ls20 = ls20 + "j";
else {
if (StringSubstr(ls12, li_0, 2) == "62") ls20 = ls20 + "k";
else {
if (StringSubstr(ls12, li_0, 2) == "15") ls20 = ls20 + "l";
else {
if (StringSubstr(ls12, li_0, 2) == "71") ls20 = ls20 + "m";
else {
if (StringSubstr(ls12, li_0, 2) == "81") ls20 = ls20 + "n";
else {
if (StringSubstr(ls12, li_0, 2) == "93") ls20 = ls20 + "o";
else {
if (StringSubstr(ls12, li_0, 2) == "74") ls20 = ls20 + "p";
else {
if (StringSubstr(ls12, li_0, 2) == "83") ls20 = ls20 + "q";
else {
if (StringSubstr(ls12, li_0, 2) == "44") ls20 = ls20 + "r";
else {
if (StringSubstr(ls12, li_0, 2) == "51") ls20 = ls20 + "s";
else {
if (StringSubstr(ls12, li_0, 2) == "69") ls20 = ls20 + "t";
else {
if (StringSubstr(ls12, li_0, 2) == "40") ls20 = ls20 + "u";
else {
if (StringSubstr(ls12, li_0, 2) == "73") ls20 = ls20 + "v";
else {
if (StringSubstr(ls12, li_0, 2) == "59") ls20 = ls20 + "w";
else {
if (StringSubstr(ls12, li_0, 2) == "36") ls20 = ls20 + "x";
else {
if (StringSubstr(ls12, li_0, 2) == "26") ls20 = ls20 + "y";
else {
if (StringSubstr(ls12, li_0, 2) == "25") ls20 = ls20 + "z";
else {
if (StringSubstr(ls12, li_0, 2) == "28") ls20 = ls20 + "!";
else {
if (StringSubstr(ls12, li_0, 2) == "65") ls20 = ls20 + "&";
else {
if (StringSubstr(ls12, li_0, 2) == "52") ls20 = ls20 + "#";
else {
if (StringSubstr(ls12, li_0, 2) == "57") ls20 = ls20 + "$";
else {
if (StringSubstr(ls12, li_0, 2) == "31") ls20 = ls20 + "%";
else {
if (StringSubstr(ls12, li_0, 2) == "91") ls20 = ls20 + "*";
else {
if (StringSubstr(ls12, li_0, 2) == "60") ls20 = ls20 + "+";
else {
if (StringSubstr(ls12, li_0, 2) == "92") ls20 = ls20 + "-";
else {
if (StringSubstr(ls12, li_0, 2) == "34") ls20 = ls20 + "?";
else {
if (StringSubstr(ls12, li_0, 2) == "46") ls20 = ls20 + "^";
else {
if (StringSubstr(ls12, li_0, 2) == "38") ls20 = ls20 + "|";
else {
if (StringSubstr(ls12, li_0, 2) == "37") ls20 = ls20 + "@";
else {
if (StringSubstr(ls12, li_0, 2) == "49") ls20 = ls20 + "_";
else {
if (StringSubstr(ls12, li_0, 2) == "50") ls20 = ls20 + "S";
else
if (StringSubstr(ls12, li_0, 2) == "19") ls20 = ls20 + ".";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
ls28 = StringSubstr(ls20, 1, 2);
ls36 = StringSubstr(ls20, 3, 2);
ls44 = StringSubstr(ls20, 5, 4);
g_str2int1496 = StrToInteger(ls28);
g_str2int1500 = StrToInteger(ls36);
g_str2int1504 = StrToInteger(ls44);
if (Year() > g_str2int1504) gi1492 = 3;
if (Year() == g_str2int1504) {
if (Month() > g_str2int1500) gi1492 = 3;
if (Month() == g_str2int1500)
if (Day() > g_str2int1496) gi1492 = 3;
}
} else gi1492 = 1;
gi1480 = FALSE;
}
//Comment("\n", "License will expire on ", g_str2int1496, "/", g_str2int1500, "/", g_str2int1504);
return (0);
}
int deinit() {
ObjectDelete("cja");
ObjectDelete("Signalprice");
ObjectDelete("SIG_BARS_TF1");
ObjectDelete("SIG_BARS_TF2");
ObjectDelete("SIG_BARS_TF3");
ObjectDelete("SIG_BARS_TF4");
ObjectDelete("SIG_BARS_TF5");
ObjectDelete("SIG_BARS_TF6");
ObjectDelete("SIG_BARS_TF7");
ObjectDelete("SSignalMACD_TEXT");
ObjectDelete("SSignalMACDM1");
ObjectDelete("SSignalMACDM5");
ObjectDelete("SSignalMACDM15");
ObjectDelete("SSignalMACDM30");
ObjectDelete("SSignalMACDH1");
ObjectDelete("SSignalMACDH4");
ObjectDelete("SSignalMACDD1");
ObjectDelete("SSignalSTR_TEXT");
ObjectDelete("SignalSTRM1");
ObjectDelete("SignalSTRM5");
ObjectDelete("SignalSTRM15");
ObjectDelete("SignalSTRM30");
ObjectDelete("SignalSTRH1");
ObjectDelete("SignalSTRH4");
ObjectDelete("SignalSTRD1");
ObjectDelete("SignalEMA_TEXT");
ObjectDelete("SignalEMAM1");
ObjectDelete("SignalEMAM5");
ObjectDelete("SignalEMAM15");
ObjectDelete("SignalEMAM30");
ObjectDelete("SignalEMAH1");
ObjectDelete("SignalEMAH4");
ObjectDelete("SignalEMAD1");
ObjectDelete("SIG_DETAIL1");
ObjectDelete("SIG_DETAIL2");
ObjectDelete("SIG_DETAIL3");
ObjectDelete("SIG_DETAIL4");
ObjectDelete("SIG_DETAIL5");
ObjectDelete("SIG_DETAIL6");
ObjectDelete("SIG_DETAIL7");
ObjectDelete("SIG_DETAIL8");
ObjectDelete("Lable");
ObjectDelete("Lable1");
ObjectDelete("percent");
ObjectDelete("start_p");
ObjectDelete("takepercent_day");
ObjectDelete("run");
ObjectDelete("Newsinfo");
ObjectDelete("Newsinfo2");
ObjectDelete("ERR");
ObjectDelete("ERR2");
ObjectDelete("Expert");
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
ObjectDelete("Margin");
ObjectDelete("Float");
return (0);
}
int start() {
//+------------------------------------------------Author Start--------------------------------------------------------------------------+
GlobalVariableSet("Dhamar"+Symbol()+"TF",Period());
double Position_L=Bid+Position*point;
string outDN,outUP,outtext,outtext2;
if (GlobalVariableGet("RUNEA")==1) //EA控制器
{
Alert("EA is not working");
return;
}
//+------------------------------------------------Author End----------------------------------------------------------------------------+
int Handle_Log,h1;
if ((AccountProfit()/start_balance)*100<GlobalVariableGet("MaxEquity")) GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);
displayprofit(start_p,next_in,start_balance);
//--------------------------------------------------------------------------------------Hydra
if (OrdersTotal()==0)
{
GlobalVariableSet("start_balance",AccountBalance());
GlobalVariableSet("start_p",TimeCurrent());
//GlobalVariableSet("MaxEquity",start_balance);
GlobalVariableSet("next_sw",0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),GlobalVariableGet("start_balance"),"After");
FileClose(h1);*/
Sleep(60000);
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
start_p=GlobalVariableGet("start_p");
if (GlobalVariableGet("next_sw")==1)
{
if (IsTradeContextBusy())
{
Sleep(10000);
return;
}
iCloseOrders("100%",Symbol(),id1,0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(start_p,TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),start_balance,"Before");
FileClose(h1);*/
Sleep(5000);
if (MyOrderTotal_err(id1)!=0)
{
Alert(Symbol()+" 戰場未成功離開");
Sleep(30000);
return;
}else
{
Sleep(NextTime*60*1000);
}
return(0);
}
//--------------------------------------------------------------------------------------Hydra
if (SLClose(SLpercent,start_balance))
{
if (SleepLoss)
{
GlobalVariableSet("RUN",1);
GlobalVariableSet("runtime",StrToTime(TimeToStr(TimeLocal(),TIME_DATE)));
}
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Stop Loss Close");
FileClose(Handle_Log);*/
}
if (takepercent>0){
int ii_0=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE));
if (next_in==false) {
if (profit_control(ii_0,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in flase");
FileClose(Handle_Log);*/
return(0);
}
}
if (next_in==true){
if (profit_control(start_p,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in true");
FileClose(Handle_Log);*/
}
if (profit_control(ii_0,takepercent_day,start_balance)==false)
{
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by day next_in true");
FileClose(Handle_Log);*/
return(0);
}
}
}
CheckTimeIn(MaxTime,MaxIn,MaxP,start_p);
//--------------------------------------------------------------------------------------Hydra
if (Hour()==hourr && Minute()==minutee && bar2!=Bars && GlobalVariableGet("UPSW")==0) {
GlobalVariableSet("UPSW",1);
//makefile_N();
bar2=Bars;
}
if (Hour()==hourr+1 && Minute()==0 && GlobalVariableGet("UPSW")==1)
{
GlobalVariableSet("UPSW",0);
}
//+------------------------------------------------------------------+
if (GlobalVariableGet("RUN")==1 && TimeLocal()<=GlobalVariableGet("runtime")+86400)
{
return;
}
if (GlobalVariableGet("RUN")==1 && TimeLocal()>GlobalVariableGet("runtime")+86400)
{
GlobalVariableSet("RUN",0);
}
ObjectCreate("run",OBJ_LABEL,0,0,0);
ObjectSet("run", OBJPROP_CORNER, 1);
ObjectSet("run", OBJPROP_COLOR, White);
ObjectSet("run", OBJPROP_XDISTANCE, 20);
ObjectSet("run", OBJPROP_YDISTANCE, Pos);
if (!Week15(W1Start,W5Over,start_t,stop_t,weekday) && OrdersTotal() == 0) {
ObjectSetText("run","未在設定時區內,現有戰役達成後將離開戰場",10,"微軟正黑體");
return;
}else {
ObjectSetText("run","已進入作戰時區內,全面啟動執行...",10,"微軟正黑體");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (BrakeSystem)
{
string Active="煞車系統啟動中";
string Deactive="煞車系統待命中";
color Light_status=Gold;
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSetString(0,"lightstatus",OBJPROP_FONT,"微軟正黑體");
ObjectSetInteger(0,"lightstatus",OBJPROP_FONTSIZE,10);
ObjectSetInteger(0,"lightstatus",OBJPROP_COLOR,Light_status);
int Price_Range;
int Time_Range;
int Now_Time = TimeCurrent();
double Now_Price = Close[0];
if (Last_Price != -1.0) {
Price_Range = Now_Price / Point - Last_Price / Point;
Time_Range = Now_Time - Last_Time;
//int Total_Orders = OrdersTotalCountByTypeANDMagic(OP_BUY, BuyMagic) + OrdersTotalCountByTypeANDMagic(OP_SELL, SellMagic);
if (MathAbs(Price_Range) >= MinPriceShot && Time_Range <= pSeconds) {
//if (Total_Orders < MaxOrdersCount) {
if (Now_Price > Last_Price) {
if ( MyOrderTotal_type(id1,1) > MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
if (Now_Price < Last_Price) {
if ( MyOrderTotal_type(id1,1) < MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
//} else {}//Comment("");
Last_Price = Now_Price;
Last_Time = Now_Time;
}else {
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (Time_Range >= pSeconds) {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
} else {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (TimeCurrent()<=SleepStop)
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active+", "+DoubleToStr((SleepStop-TimeCurrent())/60,0)+" 分鐘後啟動");
return;
}
}else {
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (MarginSleep) {
bool Pass=false;
if (AccountMargin() == 0) {Pass=true;}
else{
double Margin_R=(AccountEquity()/AccountMargin())*100;
if (MarginLimit >= Margin_R && !Pass) {
ObjectCreate("Margin",OBJ_LABEL,0,0,0);
ObjectSet("Margin", OBJPROP_CORNER, 1);
ObjectSet("Margin", OBJPROP_COLOR, Gold);
ObjectSet("Margin", OBJPROP_XDISTANCE, 20);
ObjectSet("Margin", OBJPROP_YDISTANCE, Pos+155);
ObjectSetText("Margin", "保證金比例低於 "+DoubleToStr(MarginLimit,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Margin");
}
}
}else {
ObjectDelete("Margin");
}
if (FloatEq) {
double Profit=AccountProfit();
if (Profit <= FloatAm) {
ObjectCreate("Float",OBJ_LABEL,0,0,0);
ObjectSet("Float", OBJPROP_CORNER, 1);
ObjectSet("Float", OBJPROP_COLOR, Gold);
ObjectSet("Float", OBJPROP_XDISTANCE, 20);
ObjectSet("Float", OBJPROP_YDISTANCE, Pos+175);
ObjectSetText("Float", "浮虧大於 "+DoubleToStr(FloatAm,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Float");
}
}else {
ObjectDelete("Float");
}
int li4;
int li8;
int li12;
int li16;
int li20;
int li24;
int li28;
color color32;
color color36;
color color40;
color color44;
color color48;
color color52;
color color56;
string ls_unused60;
color color68;
color color72;
color color76;
color color80;
color color84;
color color88;
color color92;
color color96;
string ls_unused100;
color color108;
int li_unused112;
double ihigh1128;
double ilow1136;
double iclose1144;
double iclose1152;
double ld1192;
double ld1248;
double ld1256;
int li1264;
int count1268;
double ld1316;
double ld1324;
int li1332;
int count1336;
int li992 = 0;
int li996 = 0;
int li1000 = 0;
int li1004 = 0;
int li1008 = 0;
int li1012 = 0;
li992 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
for (li1012 = 1; li1012 <= 5; li1012++) li996 = li996 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 10; li1012++) li1000 = li1000 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 20; li1012++) li1004 = li1004 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
li996 /= 5;
li1000 /= 10;
li1004 /= 20;
li1008 = (li992 + li996 + li1000 + li1004) / 4;
string ls_unused1016 = "";
string ls_unused1024 = "";
string dbl2str1032 = "";
string dbl2str1040 = "";
string dbl2str1048 = "";
string dbl2str1056 = "";
string ls_unused1064 = "";
string ls_unused1072 = "";
string ls1080 = "";
double iopen1088 = iOpen(NULL, PERIOD_D1, 0);
double iclose1096 = iClose(NULL, PERIOD_D1, 0);
double ld1104 = (Ask - Bid) / Point;
double ihigh1112 = iHigh(NULL, PERIOD_D1, 0);
double ilow1120 = iLow(NULL, PERIOD_D1, 0);
dbl2str1040 = DoubleToStr((iclose1096 - iopen1088) / Point, 0);
dbl2str1032 = DoubleToStr(ld1104, Digits - 4);
dbl2str1048 = DoubleToStr(li1008, Digits - 4);
ls1080 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
dbl2str1056 = DoubleToStr((ihigh1112 - ilow1120) / Point, 0);
if (iclose1096 >= iopen1088) {
ls_unused1064 = "-";
color108 = g_color1100;
}
if (iclose1096 < iopen1088) {
ls_unused1064 = "-";
color108 = g_color1104;
}
if (dbl2str1048 >= ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1108;
}
if (dbl2str1048 < ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1112;
}
double ld1160 = LotExponent;
int li1168 = gi108;
double ld1172 = TakeProfit;
bool bool1180 = UseEquityStop;
double ld1184 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1192 = Lots;
else ld1192 = 0.00001 * MathCeil(AccountBalance());
} else ld1192 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop_Hilo) f035(TrailStart_Hilo, TrailStop_Hilo, g_price312);
if (gi220) {
if (TimeCurrent() >= gi376) {
f024();
Print("Closed All due_Hilo to TimeOut");
}
}
if (gi372 == Time[0]) return (0);
gi372 = Time[0];
double ld1200 = f031();
if (bool1180) {
if (ld1200 < 0.0 && MathAbs(ld1200) > ld1184 / 100.0 * f07()) {
f024();
Print("Closed All due_Hilo to Stop Out");
gi424 = FALSE;
}
}
gi396 = f04();
if (gi396 == 0) gi360 = FALSE;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
gi412 = TRUE;
gi416 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
gi412 = FALSE;
gi416 = TRUE;
break;
}
}
}
if (gi396 > 0 && gi396 <= MaxTrades_A) {
RefreshRates();
gd336 = f032();
gd344 = f020();
if (gi412 && gd336 - Ask >= PipStep_Hilo * Point) gi408 = TRUE;
if (gi416 && Bid - gd344 >= PipStep_Hilo * Point) gi408 = TRUE;
}
if (gi396 < 1) {
gi416 = FALSE;
gi412 = FALSE;
gi408 = TRUE;
gd288 = AccountEquity();
}
if (gi408) {
gd336 = f032();
gd344 = f020();
if (gi416) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
RefreshRates();
gi420 = f03(1, gd384, Bid, slip_Hilo, Ask, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi408 = FALSE;
gi424 = TRUE;
} else {
if (gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
gi420 = f03(0, gd384, Ask, slip_Hilo, Bid, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi408 = FALSE;
gi424 = TRUE;
}
}
}
if (gi408 && gi396 < 1) {
ihigh1128 = iHigh(Symbol(), 0, 1);
ilow1136 = iLow(Symbol(), 0, 2);
g_bid320 = Bid;
g_ask328 = Ask;
if ((!gi416) && !gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
if (ihigh1128 > ilow1136) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi420 = f03(1, gd384, g_bid320, slip_Hilo, g_bid320, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi424 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi420 = f03(0, gd384, g_ask328, slip_Hilo, g_ask328, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi424 = TRUE;
}
}
if (gi420 > 0) gi376 = TimeCurrent() + 60.0 * (60.0 * gd224);
gi408 = FALSE;
}
}
gi396 = f04();
g_price312 = 0;
double ld1208 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price312 += OrderOpenPrice() * OrderLots();
ld1208 += OrderLots();
}
}
}
if (gi396 > 0) g_price312 = NormalizeDouble(g_price312 / ld1208, Digits);
if (gi424) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
g_price280 = g_price312 + ld1172 * Point;
gd_unused296 = g_price280;
gd400 = g_price312 - g_pips236 * Point;
gi360 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
g_price280 = g_price312 - ld1172 * Point;
gd_unused304 = g_price280;
gd400 = g_price312 + g_pips236 * Point;
gi360 = TRUE;
}
}
}
}
if (gi424) {
if (gi360 == TRUE) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) OrderModify(OrderTicket(), g_price312, OrderStopLoss(), g_price280, 0, Yellow);
gi424 = FALSE;
}
}
}
double ld1216 = LotExponent;
int li1224 = gi108;
double ld1228 = TakeProfit;
bool bool1236 = UseEquityStop;
double ld1240 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1248 = Lots;
else ld1248 = 0.00001 * MathCeil(AccountBalance());
} else ld1248 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop15) f021(TrailStart15, TrailStop15, g_price596);
if (gi532) {
if (TimeCurrent() >= gi660) {
f018();
Print("Closed All due to TimeOut");
}
}
if (gi656 != Time[0]) {
gi656 = Time[0];
ld1256 = f029();
if (bool1236) {
if (ld1256 < 0.0 && MathAbs(ld1256) > ld1240 / 100.0 * f016()) {
f018();
Print("Closed All due to Stop Out");
gi708 = FALSE;
}
}
gi680 = f05();
if (gi680 == 0) gi644 = FALSE;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
gi696 = TRUE;
gi700 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
gi696 = FALSE;
gi700 = TRUE;
break;
}
}
}
if (gi680 > 0 && gi680 <= MaxTrades_B) {
RefreshRates();
gd620 = f036();
gd628 = f028();
if (gi696 && gd620 - Ask >= PipStep15 * Point) gi692 = TRUE;
if (gi700 && Bid - gd628 >= PipStep15 * Point) gi692 = TRUE;
}
if (gi680 < 1) {
gi700 = FALSE;
gi696 = FALSE;
gi692 = TRUE;
gd572 = AccountEquity();
}
if (gi692) {
gd620 = f036();
gd628 = f028();
if (gi700) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
RefreshRates();
gi704 = f02(1, gd668, Bid, slip15, Ask, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi692 = FALSE;
gi708 = TRUE;
} else {
if (gi696) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
gi704 = f02(0, gd668, Ask, slip15, Bid, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi692 = FALSE;
gi708 = TRUE;
}
}
}
}
if (g_datetime728 != iTime(NULL, g_timeframe496, 0)) {
li1264 = OrdersTotal();
count1268 = 0;
for (int li1272 = li1264; li1272 >= 1; li1272--) {
OrderSelect(li1272 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) count1268++;
}
if (li1264 == 0 || count1268 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid604 = Bid;
g_ask612 = Ask;
gi664 = gi680;
gd668 = ld1248;
if (iclose1144 > iclose1152) {
gi704 = f02(1, gd668, g_bid604, slip15, g_bid604, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi708 = TRUE;
} else {
gi704 = f02(0, gd668, g_ask612, slip15, g_ask612, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi708 = TRUE;
}
if (gi704 > 0) gi660 = TimeCurrent() + 60.0 * (60.0 * gd536);
gi692 = FALSE;
}
g_datetime728 = iTime(NULL, g_timeframe496, 0);
}
gi680 = f05();
g_price596 = 0;
double ld1276 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price596 += OrderOpenPrice() * OrderLots();
ld1276 += OrderLots();
}
}
}
if (gi680 > 0) g_price596 = NormalizeDouble(g_price596 / ld1276, Digits);
if (gi708) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
g_price564 = g_price596 + ld1228 * Point;
gd_unused580 = g_price564;
gd684 = g_price596 - g_pips508 * Point;
gi644 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
g_price564 = g_price596 - ld1228 * Point;
gd_unused588 = g_price564;
gd684 = g_price596 + g_pips508 * Point;
gi644 = TRUE;
}
}
}
}
if (gi708) {
if (gi644 == TRUE) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) OrderModify(OrderTicket(), g_price596, OrderStopLoss(), g_price564, 0, Yellow);
gi708 = FALSE;
}
}
}
double ld1284 = LotExponent;
int li1292 = gi108;
double ld1296 = TakeProfit;
bool bool1304 = UseEquityStop;
double ld1308 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1316 = Lots;
else ld1316 = 0.00001 * MathCeil(AccountBalance());
} else ld1316 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop16) f034(TrailStart16, TrailStop16, g_price880);
if (gi816) {
if (TimeCurrent() >= gi944) {
f0_0();
Print("Closed All due to TimeOut");
}
}
if (gi940 != Time[0]) {
gi940 = Time[0];
ld1324 = f08();
if (bool1304) {
if (ld1324 < 0.0 && MathAbs(ld1324) > ld1308 / 100.0 * f030()) {
f0_0();
Print("Closed All due to Stop Out");
gi992 = FALSE;
}
}
gi964 = f012();
if (gi964 == 0) gi928 = FALSE;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
gi980 = TRUE;
gi984 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
gi980 = FALSE;
gi984 = TRUE;
break;
}
}
}
if (gi964 > 0 && gi964 <= MaxTrades_C) {
RefreshRates();
gd904 = f017();
gd912 = f027();
if (gi980 && gd904 - Ask >= PipStep16 * Point) gi976 = TRUE;
if (gi984 && Bid - gd912 >= PipStep16 * Point) gi976 = TRUE;
}
if (gi964 < 1) {
gi984 = FALSE;
gi980 = FALSE;
gd856 = AccountEquity();
}
if (gi976) {
gd904 = f017();
gd912 = f027();
if (gi984) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
RefreshRates();
gi988 = f06(1, gd952, Bid, slip16, Ask, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi976 = FALSE;
gi992 = TRUE;
} else {
if (gi980) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
gi988 = f06(0, gd952, Ask, slip16, Bid, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi976 = FALSE;
gi992 = TRUE;
}
}
}
}
if (g_datetime1012 != iTime(NULL, g_timeframe784, 0)) {
li1332 = OrdersTotal();
count1336 = 0;
for (int li1340 = li1332; li1340 >= 1; li1340--) {
OrderSelect(li1340 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) count1336++;
}
if (li1332 == 0 || count1336 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid888 = Bid;
g_ask896 = Ask;
gi948 = gi964;
gd952 = ld1316;
if (iclose1144 > iclose1152) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi988 = f06(1, gd952, g_bid888, slip16, g_bid888, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi992 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi988 = f06(0, gd952, g_ask896, slip16, g_ask896, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi992 = TRUE;
}
}
if (gi988 > 0) gi944 = TimeCurrent() + 60.0 * (60.0 * gd820);
gi976 = FALSE;
}
g_datetime1012 = iTime(NULL, g_timeframe784, 0);
}
gi964 = f012();
g_price880 = 0;
double ld1344 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price880 += OrderOpenPrice() * OrderLots();
ld1344 += OrderLots();
}
}
}
if (gi964 > 0) g_price880 = NormalizeDouble(g_price880 / ld1344, Digits);
if (gi992) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
g_price848 = g_price880 + ld1296 * Point;
gd_unused864 = g_price848;
gd968 = g_price880 - g_pips792 * Point;
gi928 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
g_price848 = g_price880 - ld1296 * Point;
gd_unused872 = g_price848;
gd968 = g_price880 + g_pips792 * Point;
gi928 = TRUE;
}
}
}
}
if (gi992) {
if (gi928 == TRUE) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) OrderModify(OrderTicket(), g_price880, OrderStopLoss(), g_price848, 0, Yellow);
gi992 = FALSE;
}
}
}
//Handle_Log=0;
return (0);
}
int f04() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f024() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip_Hilo, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip_Hilo, Red);
}
Sleep(1000);
}
}
}
int f03(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM1(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f022(Bid, ai32), f019(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f011(Ask, ai32), f01(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f022(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f011(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f019(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f01(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f031() {
double ld_ret_0 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f035(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f07() {
if (f04() == 0) gd428 = AccountEquity();
if (gd428 < gd436) gd428 = gd436;
else gd428 = AccountEquity();
gd436 = AccountEquity();
return (gd428);
}
double f032() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f020() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f05() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f018() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip15, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip15, Red);
}
Sleep(1000);
}
}
}
int f02(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM2(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f013(Bid, ai32), f025(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f033(Ask, ai32), f026(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f013(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f033(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f025(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f026(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f029() {
double ld_ret_0 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f021(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f016() {
if (f05() == 0) gd712 = AccountEquity();
if (gd712 < gd720) gd712 = gd720;
else gd712 = AccountEquity();
gd720 = AccountEquity();
return (gd712);
}
double f036() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f028() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f012() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f0_0() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip16, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip16, Red);
}
Sleep(1000);
}
}
}
int f06(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM3(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f014(Bid, ai32), f09(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f023(Ask, ai32), f010(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f014(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f023(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f09(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f010(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f08() {
double ld_ret_0 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f034(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f030() {
if (f012() == 0) gd996 = AccountEquity();
if (gd996 < gd1004) gd996 = gd1004;
else gd996 = AccountEquity();
gd1004 = AccountEquity();
return (gd996);
}
double f017() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f027() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
string f015(string as_0) {
int str_len8 = StringLen(as_0);
bool li_ret12 = FALSE;
for (int li16 = 0; li16 < str_len8; li16++) {
if (StringSubstr(as_0, li16, 1) == "1") li_ret12 = li_ret12 + MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "2") li_ret12 = li_ret12 + 2.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "3") li_ret12 = li_ret12 + 3.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "4") li_ret12 = li_ret12 + 4.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "5") li_ret12 = li_ret12 + 5.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "6") li_ret12 = li_ret12 + 6.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "7") li_ret12 = li_ret12 + 7.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "8") li_ret12 = li_ret12 + 8.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "9") li_ret12 = li_ret12 + 9.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "A") li_ret12 = li_ret12 + 10.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "B") li_ret12 = li_ret12 + 11.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "C") li_ret12 = li_ret12 + 12.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "D") li_ret12 = li_ret12 + 13.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "E") li_ret12 = li_ret12 + 14.0 * MathPow(16, str_len8 - li16 - 1);
else
if (StringSubstr(as_0, li16, 1) == "F") li_ret12 = li_ret12 + 15.0 * MathPow(16, str_len8 - li16 - 1);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return (li_ret12);
}
string MakeDateTime(string strDate, string strTime)
{
// Print("Converting Forex Factory Time into Metatrader time..."); //added by MN
// Converts forexfactory time & date into yyyy.mm.dd hh:mm
int n1stDash = StringFind(strDate, "-");
int n2ndDash = StringFind(strDate, "-", n1stDash+1);
string strMonth = StringSubstr(strDate, 0, 2);
string strDay = StringSubstr(strDate, 3, 2);
string strYear = StringSubstr(strDate, 6, 4);
// strYear = "20" + strYear;
int nTimeColonPos = StringFind(strTime, ":");
string strHour = StringSubstr(strTime, 0, nTimeColonPos);
string strMinute = StringSubstr(strTime, nTimeColonPos+1, 2);
string strAM_PM = StringSubstr(strTime, StringLen(strTime)-2);
int nHour24 = StrToInteger(strHour);
if ((strAM_PM == "pm" || strAM_PM == "PM") && nHour24 != 12)
{
nHour24 += 12;
}
if ((strAM_PM == "am" || strAM_PM == "AM") && nHour24 == 12)
{
nHour24 = 0;
}
string strHourPad = "";
if (nHour24 < 10)
strHourPad = "0";
return(StringConcatenate(strYear, ".", strMonth, ".", strDay, " ", strHourPad, nHour24, ":", strMinute));
}
bool profit_control(int i_0,double takepercent_,double start_balance)
{
double today_profit;
int i1=StrToTime(TimeToStr(TimeCurrent()+86400, TIME_DATE));
today_profit=((GetProfitFromDateInCurrency(i_0)+AccountProfit())/start_balance)*100;
if (today_profit>=takepercent_)
{
return(false);
}
return(true);
}
void displayprofit(int start_p,bool next_in,double start_balance)
{
double today_profit;
string display;
ObjectCreate("percent",OBJ_LABEL,0,0,0);
ObjectSet("percent", OBJPROP_CORNER, 1);
ObjectSet("percent", OBJPROP_COLOR, White);
ObjectSet("percent", OBJPROP_XDISTANCE, 20);
ObjectSet("percent", OBJPROP_YDISTANCE, Pos+30);
ObjectCreate("start_p",OBJ_LABEL,0,0,0);
ObjectSet("start_p", OBJPROP_CORNER, 1);
ObjectSet("start_p", OBJPROP_COLOR, White);
ObjectSet("start_p", OBJPROP_XDISTANCE, 20);
ObjectSet("start_p", OBJPROP_YDISTANCE, Pos+50);
ObjectSetText("start_p","進場經過時間 "+ DoubleToStr((TimeCurrent()-start_p)/60,1)+ " 分鐘"+" ; "+OrdersTotal()+" 兵力在戰場上",10,"微軟正黑體");
if (next_in==true)
{
today_profit=((GetProfitFromDateInCurrency(start_p)+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
GlobalVariableSet("display",today_profit);
ObjectSetText("percent","單次擄獲狂派戰俘"+display+"%"+" ; 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectCreate("takepercent_day",OBJ_LABEL,0,0,0);
ObjectSet("takepercent_day", OBJPROP_CORNER, 1);
ObjectSet("takepercent_day", OBJPROP_COLOR, White);
ObjectSet("takepercent_day", OBJPROP_XDISTANCE, 20);
ObjectSet("takepercent_day", OBJPROP_YDISTANCE, Pos+70);
ObjectSetText("takepercent_day","今日擄獲狂派戰俘累積至"+display+" ; 最大暫時被擄穫兵力 "+DoubleToStr(GlobalVariableGet("MaxEquity"),2)+" %",10,"微軟正黑體");
}
if (next_in==false)
{
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectSetText("percent","今日擄獲狂派戰俘累積至"+display+"%"+" 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
}
}
double GetProfitFromDateInCurrency(int today) {
double profit = 0;
int total = OrdersHistoryTotal();
for (int i = 0; i < total; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL ) {
if (today < OrderCloseTime()) profit += OrderProfit() + OrderCommission() + OrderSwap();
}
}
}
return (profit);
}
bool SLClose (double percent,double start_balance) {
if (AccountProfit()<=0)
{
if ((MathAbs(AccountProfit())/start_balance)*100>=percent)
{
return(true);
}
else
{
return(false);
}
}else
{
return(false);
}
}
void iCloseOrders(string myType,string currency,int id1,int type)
{
if (MyOrderTotal_err(id1)==0) return(0);
int C0_cnt,close_t[],t_cnt;
double percentlots,nd_profit;
if (myType=="Del"&&type==0)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_BUYSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="Del"&&type==1)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_SELLSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="100%")
{
for(C0_cnt=0;C0_cnt<OrdersTotal();C0_cnt++) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false)
{
//Alert(Symbol()+" OrderSelect Error");
continue;
}
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
ArrayResize(close_t,t_cnt+1);
close_t[t_cnt]=OrderTicket();
t_cnt++;
}
}
for(int i=ArraySize(close_t)-1;i>=0;i--)
{
if (OrderSelect(close_t[i],SELECT_BY_TICKET)==false)
{
Alert(Symbol()+" OrderSelect Error By Tickets");continue;
}
else
{
percentlots=OrderLots();
OrderClose(close_t[i],percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="80%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.8;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="50%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.5;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="All") //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderMagicNumber()!=0){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="BUY"&&type==0) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_BUY && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="SELL"&&type==1) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_SELL && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
}
int MyOrderTotal_err(int id1)//訂單總數函式
{
int x=0;//符合條件的BUY單數量(記次變數)
for(int z=0;z<OrdersTotal();z++)//執行N次篩選(N=訂單總數)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);//用"流水號"找訂單
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ))//挑選出同貨幣對 && BUY單 && MagicNumber=本程式 的訂單
{
x++;//符合節選結果的訂單總數
}
}
return(x);//回傳
}
int MyOrderTotal_type(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ) && OrderType()==type)
{
x++;//
}
}
return(x);
}
bool iTimeControl(int myStartHour,int myStopHour)
{
bool EA_Valid=false;
if(myStopHour == myStartHour) EA_Valid = true;
if(myStopHour < myStartHour)
{
if (TimeHour(TimeLocal()) >= myStartHour || TimeHour(TimeLocal()) < myStopHour) EA_Valid = true;
}
if (myStopHour > myStartHour) {
if ((TimeHour(TimeLocal()) >= myStartHour && TimeHour(TimeLocal()) < myStopHour))
EA_Valid = true;
}
return(EA_Valid);
}
bool Week15 (int start,int over,int myStartHour,int myStopHour,string weekday)
{
bool EA_Valid=false;
int Dayweek=TimeDayOfWeek(TimeLocal());
if (
(
(
Dayweek == 1 && TimeHour(TimeLocal()) < start
)
||
(
Dayweek == StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1)) && TimeHour(TimeLocal()) >= over
)
||
(
Dayweek > StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1))
)
)
&& Week15SW) {
EA_Valid=false;
}else {
if (iTimeControl(myStartHour,myStopHour)) {
if (StringFind(weekday,DoubleToStr(Dayweek,0),0) >= 0) {
EA_Valid=true;
}else {
EA_Valid=false;
}
}else {
EA_Valid=false;
}
}
return(EA_Valid);
}
void CheckTimeIn(int MaxTime,int MaxIn,double MaxP,int start_p)
{
int Handle_Log;
int Valid;
int RunTime=(TimeCurrent()-start_p)/60;
if (RunTime>=MaxTime && OrdersTotal() >= MaxIn && GlobalVariableGet("display")>= MaxP)
{
GlobalVariableSet("next_sw",1);
Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by CheckTimeIn");
FileClose(Handle_Log);
}
}
string Base64Decode(string in/*,string &out*/)
{
string out;
int i=0,len=StringLen(in);
int shift=0,accum=0;
while(i<len)
{
int value=ExtBase64Decode[StringGetChar(in,i)];
if(value<0 || value>63) break;
accum<<=6;
shift+=6;
accum|=value;
if(shift>=8)
{
shift-=8;
value=accum >> shift;
out=out+CharToStr(value & 0xFF);
}
i++;
}
//----
return(out);
}
bool ThreeM1(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(g_magic17616,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(g_magic17616,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM2(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17616,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17616,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM3(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
int MyOrderTotal_id(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id1 && OrderType()==type)
{
x++;//
}
}
return(x);
}
#import "wininet.dll"
int InternetAttemptConnect(
int dwReserved=0
);
int InternetOpenA(uchar &lpszAgent[],int dwAccessType,uchar &lpszProxyName[],uchar &lpszProxyBypass[],int dwFlags);
int InternetConnectA(int hInternetSession,uchar &lpszServerName[],int nServerPort,uchar &lpszUserName[],uchar &lpszPassword[],int nService,int nFlags,int dwContext);
bool InternetCloseHandle(
int hInet
);
bool FtpPutFileA (
int hFtpSession,
string lpszLocalFile,
string lpszRemoteFile,
int dwFlags,
int dwContext
);
bool FtpGetFileA (int hFtpSession,uchar &lpszRemoteFile[],uchar &lpszNewFile[],bool fFailIfExists,int dwFlagsAndAttributes,uint dwFlags,int dwContext);
bool FtpCreateDirectoryA(
int hConnect,
string lpszDirectory
);
bool FtpSetCurrentDirectoryA(
int hConnect,
string lpszDirectory
);
#import
#define INTERNET_FLAG_PASSIVE 0x08000000
#define INTERNET_FLAG_RELOAD 0x80000000
#define INTERNET_FLAG_EXISTING_CONNECT 0x20000000
#define INTERNET_SERVICE_FTP 1
#define FTP_TRANSFER_TYPE_ASCII 1
#define FTP_TRANSFER_TYPE_BINARY 2
#define FTP_TRANSFER_TYPE_UNKNOWN 3
#define INTERNET_FLAG_HYPERLINK 0x00000400
static int ExtBase64Encode[64]={ 'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/' };
static int ExtBase64Decode[256]={
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
string t1 = "";
//extern double Account = 1872377.0;
int GMT=8;
extern string T0="-------------ESP戰艦穩定煞車系統------------";
extern bool BrakeSystem=true;
int pSeconds=14;
extern string T1="能量偵測靈敏度";
extern int Energy = 40;
extern string T2="能量煞車引擎啟動時間";
extern int SleepTime=15;
int SleepStop=0;
int Position=0;
extern string T5="-------------保證金比例控制模組--------------";
extern bool MarginSleep=true;
extern double MarginLimit=2000;
extern string T6="-------------浮虧控制模組(以金額計算)-------------";
extern bool FloatEq=true;
extern double FloatAm=-4000;
extern string T7="開始時間,格式為hh";
extern int start_t=00;
extern string T8="結束時間,格式為hh";
extern int stop_t=00;
extern string T9="週一執行,鍵入1即可";
extern string T10="週一週二鍵入12,以下類推";
extern string weekday="12345";
extern bool Week15SW=true;
extern string W1="禮拜一幾點開始";
extern int W1Start=8;
extern string W2="最後一天幾點結束";
extern int W5Over=17;
extern string T11="止盈止損計算本金基準";
extern double I_balance=0;
extern string T12="止損後當日不再出兵";
extern bool SleepLoss=true;
extern string T13="最大總浮虧(以餘額計算)";
extern double SLpercent=60.0;
extern string T14="次止盈,每次最多獲利%,立即平倉歸零重啟新局";
extern double takepercent=1;
string T111="每次止盈開關";
bool next_in=true;
extern string T15="日止盈,每日最多獲利%,立即停止交易,隔日重新啟動";
extern double takepercent_day=100;
extern string T16="每局結束幾分鐘後重新啟動";
extern double NextTime=2;
extern string T9_="-------------------小虧為贏模組-------------";
extern string T17="每局最長時間(分鐘)";
extern int MaxTime=150;
extern string T18="每局最多兵力";
extern int MaxIn=40;
extern string T19="達成以上條件小虧為贏";
extern double MaxP=0.5;
extern string T20="-------------------------------------------";
extern string T21="手數";
extern double Lots = 0.01;
extern string T22="馬丁倍率";
extern double LotExponent = 1.618;
extern string T23="----------------三方向導航-----------------";
extern bool BSB=true;
int gi108 = 2;
double MaxLots = 5.0;
bool MM = FALSE;
extern string T24="獲利點數";
extern double TakeProfit = 100.0;
bool UseEquityStop = FALSE;
double TotalEquityRisk = 20.0;
string t2 = "Time Setting";
bool CloseFriday = false;
int CloseFridayHour = 17;
bool OpenMondey = false;
int OpenMondeyHour = 0;
string t3 = "";
extern string T25="A模組最多單數";
extern int MaxTrades_A=10;
bool gi220 = FALSE;
double gd224 = 48.0;
bool UseTrailingStop_Hilo = FALSE;
double g_pips236 = 500.0;
double TrailStart_Hilo = 10.0;
double TrailStop_Hilo = 5.0;
double PipStep_Hilo = 60.0;
double slip_Hilo = 3.0;
int MagicNumber_Hilo = 11111;
double g_price280;
double gd288;
double gd_unused296;
double gd_unused304;
double g_price312;
double g_bid320;
double g_ask328;
double gd336;
double gd344;
double gd352;
bool gi360;
string gs364 = "";
int gi372 = 0;
int gi376;
int gi380 = 0;
double gd384;
int g_pos392 = 0;
int gi396;
double gd400 = 0.0;
bool gi408 = FALSE;
bool gi412 = FALSE;
bool gi416 = FALSE;
int gi420;
bool gi424 = FALSE;
double gd428;
double gd436;
string t4 = "";
extern string T26="B模組最多單數";
extern int MaxTrades_B=10;
int g_timeframe496 = PERIOD_H1;
bool UseTrailingStop15 = FALSE;
double g_pips508 = 500.0;
double TrailStart15 = 10.0;
double TrailStop15 = 5.0;
bool gi532 = FALSE;
double gd536 = 48.0;
double PipStep15 = 60.0;
double slip15 = 3.0;
int g_magic17615 = 12324;
double g_price564;
double gd572;
double gd_unused580;
double gd_unused588;
double g_price596;
double g_bid604;
double g_ask612;
double gd620;
double gd628;
double gd636;
bool gi644;
string gs648 = "";
int gi656 = 0;
int gi660;
int gi664 = 0;
double gd668;
int g_pos676 = 0;
int gi680;
double gd684 = 0.0;
bool gi692 = FALSE;
bool gi696 = FALSE;
bool gi700 = FALSE;
int gi704;
bool gi708 = FALSE;
double gd712;
double gd720;
int g_datetime728 = 1;
string t5 = "";
extern string T27="C模組最多單數";
extern int MaxTrades_C=10;
int g_timeframe784 = PERIOD_M1;
bool UseTrailingStop16 = FALSE;
double g_pips792 = 500.0;
double TrailStart16 = 10.0;
double TrailStop16 = 5.0;
bool gi816 = FALSE;
double gd820 = 48.0;
double PipStep16 = 60.0;
double slip16 = 3.0;
int g_magic17616 = 16794;
double g_price848;
double gd856;
double gd_unused864;
double gd_unused872;
double g_price880;
double g_bid888;
double g_ask896;
double gd904;
double gd912;
double gd920;
bool gi928;
string gs932 = "";
int gi940 = 0;
int gi944;
int gi948 = 0;
double gd952;
int g_pos960 = 0;
int gi964;
double gd968 = 0.0;
bool gi976 = FALSE;
bool gi980 = FALSE;
bool gi984 = FALSE;
int gi988;
bool gi992 = FALSE;
double gd996;
double gd1004;
int g_datetime1012 = 1;
int g_timeframe1024 = PERIOD_M1;
int g_timeframe1028 = PERIOD_M5;
int g_timeframe1032 = PERIOD_M15;
int g_timeframe1036 = PERIOD_M30;
int g_timeframe1040 = PERIOD_H1;
int g_timeframe1044 = PERIOD_H4;
int g_timeframe1048 = PERIOD_D1;
bool g_corner1052 = TRUE;
int gi1056 = 0;
int gi1060 = 10;
int g_window1064 = 0;
bool gi1068 = TRUE;
bool gi_unused1072 = TRUE;
bool gi1076 = FALSE;
int g_color1080 = Gray;
int g_color1084 = Gray;
int g_color1088 = Gray;
int g_color1092 = DarkOrange;
int gi_unused1096 = 36095;
int g_color1100 = Lime;
int g_color1104 = OrangeRed;
int gi1108 = 65280;
int gi1112 = 17919;
int g_color1116 = Lime;
int g_color1120 = Red;
int g_color1124 = Orange;
int g_period1128 = 8;
int g_period1132 = 17;
int g_period1136 = 9;
int g_applied_price1140 = PRICE_CLOSE;
int g_color1144 = Lime;
int g_color1148 = Tomato;
int g_color1152 = Green;
int g_color1156 = Red;
string gs_unused1160 = "<<<< STR Indicator Settings >>>>>>>>>>>>>";
string gs_unused1168 = "<<<< RSI Settings >>>>>>>>>>>>>";
int g_period1176 = 9;
int g_applied_price1180 = PRICE_CLOSE;
string gs_unused1184 = "<<<< CCI Settings >>>>>>>>>>>>>>";
int g_period1192 = 13;
int g_applied_price1196 = PRICE_CLOSE;
string gs_unused1200 = "<<<< STOCH Settings >>>>>>>>>>>";
int g_period1208 = 5;
int g_period1212 = 3;
int g_slowing1216 = 3;
int g_ma_method1220 = MODE_EMA;
string gs_unused1224 = "<<<< STR Colors >>>>>>>>>>>>>>>>";
int g_color1232 = Lime;
int g_color1236 = Red;
int g_color1240 = Orange;
string gs_unused1244 = "<<<< MA Settings >>>>>>>>>>>>>>";
int g_period1252 = 5;
int g_period1256 = 9;
int g_ma_method1260 = MODE_EMA;
int g_applied_price1264 = PRICE_CLOSE;
string gs_unused1268 = "<<<< MA Colors >>>>>>>>>>>>>>";
int g_color1276 = Lime;
int g_color1280 = Red;
string gs_dummy1292;
string g_text1464;
string g_text1472;
bool gi1480 = TRUE;
string KEY = "";
int gi1492;
int g_str2int1496;
int g_str2int1500;
int g_str2int1504;
int MinPriceShot;
string maindata[300][7];
double start_balance,point;
int start_p,id1,id2,bar2;
int Pos=50;
int hourr=0;
int minutee;
int count;
bool NewsgetSW=false;
double Last_Price=-1.0;
int Last_Time=0;
int init() {
if (IsTesting()==true) {return(0);}
GlobalVariableSet("Dhamar"+Symbol(),WindowHandle(Symbol(),Period()));
ObjectCreate("Expert",OBJ_LABEL,0,0,0);
ObjectSet("Expert", OBJPROP_CORNER, 1);
ObjectSet("Expert", OBJPROP_COLOR, White);
ObjectSet("Expert", OBJPROP_XDISTANCE, 150);
ObjectSet("Expert", OBJPROP_YDISTANCE, 0);
ObjectSetText("Expert", WindowExpertName(),15,"微軟正黑體", White);
//+------------------------------------------------------------------+
MinPriceShot=Energy;
//+------------------------------------------------------------------+
bar2=Bars;
if(Digits == 5 ||Digits == 3)
{
point=Point*10;
}
else
{
point=Point;
}
//+------------------------------------------------------------------+
double Position_L=Bid+Position*point;
ObjectCreate("Light",OBJ_ARROW,0,0,0);
ObjectSet("Light",OBJPROP_ARROWCODE,108);
ObjectSet("Light", OBJPROP_CORNER, 1);
ObjectSet("Light", OBJPROP_COLOR, Lime);
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light",OBJPROP_WIDTH,5);
ObjectCreate("Light2",OBJ_ARROW,0,0,0);
ObjectSet("Light2",OBJPROP_ARROWCODE,161);
ObjectSet("Light2", OBJPROP_CORNER, 1);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_WIDTH,5);
ObjectCreate("lightstatus",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"lightstatus", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"lightstatus", OBJPROP_COLOR, clrGold);
ObjectSetInteger(0,"lightstatus", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"lightstatus", OBJPROP_YDISTANCE, Pos+135);
ObjectSetInteger(0,"lightstatus", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
//+------------------------------------------------------------------+
GlobalVariableSet("next_sw",0);
if (!GlobalVariableCheck("start_balance"))
{
GlobalVariableSet("start_balance",AccountBalance());
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
if (!GlobalVariableCheck("start_p"))
{
GlobalVariableSet("start_p",TimeCurrent());
}
start_p=GlobalVariableGet("start_p");
MathSrand(TimeLocal());
for (int i=1;i<10;i++)
{minutee=1+((59*MathRand())/32768); }
GlobalVariableSet("RUN",0);
GlobalVariableSet("UPSW",0);
GlobalVariableSet("WSW",0);
GlobalVariableSet("RUNEA",0);
GlobalVariableSet("DNSW",0);
if (GlobalVariableCheck("MaxEquity")==false)
{GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);}
ObjectCreate(0,"Newsinfo",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo", OBJPROP_YDISTANCE, Pos+95);
ObjectSetInteger(0,"Newsinfo", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
ObjectCreate(0,"Newsinfo2",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_YDISTANCE, Pos+115);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
string ls4;
string ls12;
string ls20;
string ls28;
string ls36;
string ls44;
gd352 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd636 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd920 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
ObjectCreate("Lable1", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable1", OBJPROP_CORNER, 2);
ObjectSet("Lable1", OBJPROP_XDISTANCE, 23);
ObjectSet("Lable1", OBJPROP_YDISTANCE, 21);
g_text1472 = "";
ObjectSetText("Lable1", g_text1472, 12, "Arial", DeepSkyBlue);
ObjectCreate("Lable", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable", OBJPROP_CORNER, 2);
ObjectSet("Lable", OBJPROP_XDISTANCE, 3);
ObjectSet("Lable", OBJPROP_YDISTANCE, 1);
g_text1464 = "";
ObjectSetText("Lable", g_text1464, 10, "Arial", DeepSkyBlue);
if (false/*gi1480*/) {
if (KEY != "") {
gi1492 = 0;
for (int li_0 = 0; li_0 < StringLen(KEY); li_0++) {
if (StringSubstr(KEY, li_0, 1) != "X") ls4 = ls4 + StringSubstr(KEY, li_0, 1);
else {
ls12 = ls12 + f015(ls4);
ls4 = "";
}
}
for (li_0 = 0; li_0 < StringLen(ls12); li_0 += 2) {
if (StringSubstr(ls12, li_0, 2) == "55") ls20 = ls20 + "0";
else {
if (StringSubstr(ls12, li_0, 2) == "21") ls20 = ls20 + "1";
else {
if (StringSubstr(ls12, li_0, 2) == "98") ls20 = ls20 + "2";
else {
if (StringSubstr(ls12, li_0, 2) == "42") ls20 = ls20 + "3";
else {
if (StringSubstr(ls12, li_0, 2) == "10") ls20 = ls20 + "4";
else {
if (StringSubstr(ls12, li_0, 2) == "14") ls20 = ls20 + "5";
else {
if (StringSubstr(ls12, li_0, 2) == "88") ls20 = ls20 + "6";
else {
if (StringSubstr(ls12, li_0, 2) == "66") ls20 = ls20 + "7";
else {
if (StringSubstr(ls12, li_0, 2) == "33") ls20 = ls20 + "8";
else {
if (StringSubstr(ls12, li_0, 2) == "32") ls20 = ls20 + "9";
else {
if (StringSubstr(ls12, li_0, 2) == "96") ls20 = ls20 + "a";
else {
if (StringSubstr(ls12, li_0, 2) == "30") ls20 = ls20 + "b";
else {
if (StringSubstr(ls12, li_0, 2) == "77") ls20 = ls20 + "c";
else {
if (StringSubstr(ls12, li_0, 2) == "90") ls20 = ls20 + "d";
else {
if (StringSubstr(ls12, li_0, 2) == "24") ls20 = ls20 + "e";
else {
if (StringSubstr(ls12, li_0, 2) == "29") ls20 = ls20 + "f";
else {
if (StringSubstr(ls12, li_0, 2) == "39") ls20 = ls20 + "g";
else {
if (StringSubstr(ls12, li_0, 2) == "48") ls20 = ls20 + "h";
else {
if (StringSubstr(ls12, li_0, 2) == "56") ls20 = ls20 + "i";
else {
if (StringSubstr(ls12, li_0, 2) == "16") ls20 = ls20 + "j";
else {
if (StringSubstr(ls12, li_0, 2) == "62") ls20 = ls20 + "k";
else {
if (StringSubstr(ls12, li_0, 2) == "15") ls20 = ls20 + "l";
else {
if (StringSubstr(ls12, li_0, 2) == "71") ls20 = ls20 + "m";
else {
if (StringSubstr(ls12, li_0, 2) == "81") ls20 = ls20 + "n";
else {
if (StringSubstr(ls12, li_0, 2) == "93") ls20 = ls20 + "o";
else {
if (StringSubstr(ls12, li_0, 2) == "74") ls20 = ls20 + "p";
else {
if (StringSubstr(ls12, li_0, 2) == "83") ls20 = ls20 + "q";
else {
if (StringSubstr(ls12, li_0, 2) == "44") ls20 = ls20 + "r";
else {
if (StringSubstr(ls12, li_0, 2) == "51") ls20 = ls20 + "s";
else {
if (StringSubstr(ls12, li_0, 2) == "69") ls20 = ls20 + "t";
else {
if (StringSubstr(ls12, li_0, 2) == "40") ls20 = ls20 + "u";
else {
if (StringSubstr(ls12, li_0, 2) == "73") ls20 = ls20 + "v";
else {
if (StringSubstr(ls12, li_0, 2) == "59") ls20 = ls20 + "w";
else {
if (StringSubstr(ls12, li_0, 2) == "36") ls20 = ls20 + "x";
else {
if (StringSubstr(ls12, li_0, 2) == "26") ls20 = ls20 + "y";
else {
if (StringSubstr(ls12, li_0, 2) == "25") ls20 = ls20 + "z";
else {
if (StringSubstr(ls12, li_0, 2) == "28") ls20 = ls20 + "!";
else {
if (StringSubstr(ls12, li_0, 2) == "65") ls20 = ls20 + "&";
else {
if (StringSubstr(ls12, li_0, 2) == "52") ls20 = ls20 + "#";
else {
if (StringSubstr(ls12, li_0, 2) == "57") ls20 = ls20 + "$";
else {
if (StringSubstr(ls12, li_0, 2) == "31") ls20 = ls20 + "%";
else {
if (StringSubstr(ls12, li_0, 2) == "91") ls20 = ls20 + "*";
else {
if (StringSubstr(ls12, li_0, 2) == "60") ls20 = ls20 + "+";
else {
if (StringSubstr(ls12, li_0, 2) == "92") ls20 = ls20 + "-";
else {
if (StringSubstr(ls12, li_0, 2) == "34") ls20 = ls20 + "?";
else {
if (StringSubstr(ls12, li_0, 2) == "46") ls20 = ls20 + "^";
else {
if (StringSubstr(ls12, li_0, 2) == "38") ls20 = ls20 + "|";
else {
if (StringSubstr(ls12, li_0, 2) == "37") ls20 = ls20 + "@";
else {
if (StringSubstr(ls12, li_0, 2) == "49") ls20 = ls20 + "_";
else {
if (StringSubstr(ls12, li_0, 2) == "50") ls20 = ls20 + "S";
else
if (StringSubstr(ls12, li_0, 2) == "19") ls20 = ls20 + ".";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
ls28 = StringSubstr(ls20, 1, 2);
ls36 = StringSubstr(ls20, 3, 2);
ls44 = StringSubstr(ls20, 5, 4);
g_str2int1496 = StrToInteger(ls28);
g_str2int1500 = StrToInteger(ls36);
g_str2int1504 = StrToInteger(ls44);
if (Year() > g_str2int1504) gi1492 = 3;
if (Year() == g_str2int1504) {
if (Month() > g_str2int1500) gi1492 = 3;
if (Month() == g_str2int1500)
if (Day() > g_str2int1496) gi1492 = 3;
}
} else gi1492 = 1;
gi1480 = FALSE;
}
//Comment("\n", "License will expire on ", g_str2int1496, "/", g_str2int1500, "/", g_str2int1504);
return (0);
}
int deinit() {
ObjectDelete("cja");
ObjectDelete("Signalprice");
ObjectDelete("SIG_BARS_TF1");
ObjectDelete("SIG_BARS_TF2");
ObjectDelete("SIG_BARS_TF3");
ObjectDelete("SIG_BARS_TF4");
ObjectDelete("SIG_BARS_TF5");
ObjectDelete("SIG_BARS_TF6");
ObjectDelete("SIG_BARS_TF7");
ObjectDelete("SSignalMACD_TEXT");
ObjectDelete("SSignalMACDM1");
ObjectDelete("SSignalMACDM5");
ObjectDelete("SSignalMACDM15");
ObjectDelete("SSignalMACDM30");
ObjectDelete("SSignalMACDH1");
ObjectDelete("SSignalMACDH4");
ObjectDelete("SSignalMACDD1");
ObjectDelete("SSignalSTR_TEXT");
ObjectDelete("SignalSTRM1");
ObjectDelete("SignalSTRM5");
ObjectDelete("SignalSTRM15");
ObjectDelete("SignalSTRM30");
ObjectDelete("SignalSTRH1");
ObjectDelete("SignalSTRH4");
ObjectDelete("SignalSTRD1");
ObjectDelete("SignalEMA_TEXT");
ObjectDelete("SignalEMAM1");
ObjectDelete("SignalEMAM5");
ObjectDelete("SignalEMAM15");
ObjectDelete("SignalEMAM30");
ObjectDelete("SignalEMAH1");
ObjectDelete("SignalEMAH4");
ObjectDelete("SignalEMAD1");
ObjectDelete("SIG_DETAIL1");
ObjectDelete("SIG_DETAIL2");
ObjectDelete("SIG_DETAIL3");
ObjectDelete("SIG_DETAIL4");
ObjectDelete("SIG_DETAIL5");
ObjectDelete("SIG_DETAIL6");
ObjectDelete("SIG_DETAIL7");
ObjectDelete("SIG_DETAIL8");
ObjectDelete("Lable");
ObjectDelete("Lable1");
ObjectDelete("percent");
ObjectDelete("start_p");
ObjectDelete("takepercent_day");
ObjectDelete("run");
ObjectDelete("Newsinfo");
ObjectDelete("Newsinfo2");
ObjectDelete("ERR");
ObjectDelete("ERR2");
ObjectDelete("Expert");
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
ObjectDelete("Margin");
ObjectDelete("Float");
return (0);
}
int start() {
//+------------------------------------------------Author Start--------------------------------------------------------------------------+
GlobalVariableSet("Dhamar"+Symbol()+"TF",Period());
double Position_L=Bid+Position*point;
string outDN,outUP,outtext,outtext2;
if (GlobalVariableGet("RUNEA")==1) //EA控制器
{
Alert("EA is not working");
return;
}
//+------------------------------------------------Author End----------------------------------------------------------------------------+
int Handle_Log,h1;
if ((AccountProfit()/start_balance)*100<GlobalVariableGet("MaxEquity")) GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);
displayprofit(start_p,next_in,start_balance);
//--------------------------------------------------------------------------------------Hydra
if (OrdersTotal()==0)
{
GlobalVariableSet("start_balance",AccountBalance());
GlobalVariableSet("start_p",TimeCurrent());
//GlobalVariableSet("MaxEquity",start_balance);
GlobalVariableSet("next_sw",0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),GlobalVariableGet("start_balance"),"After");
FileClose(h1);*/
Sleep(60000);
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
start_p=GlobalVariableGet("start_p");
if (GlobalVariableGet("next_sw")==1)
{
if (IsTradeContextBusy())
{
Sleep(10000);
return;
}
iCloseOrders("100%",Symbol(),id1,0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(start_p,TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),start_balance,"Before");
FileClose(h1);*/
Sleep(5000);
if (MyOrderTotal_err(id1)!=0)
{
Alert(Symbol()+" 戰場未成功離開");
Sleep(30000);
return;
}else
{
Sleep(NextTime*60*1000);
}
return(0);
}
//--------------------------------------------------------------------------------------Hydra
if (SLClose(SLpercent,start_balance))
{
if (SleepLoss)
{
GlobalVariableSet("RUN",1);
GlobalVariableSet("runtime",StrToTime(TimeToStr(TimeLocal(),TIME_DATE)));
}
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Stop Loss Close");
FileClose(Handle_Log);*/
}
if (takepercent>0){
int ii_0=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE));
if (next_in==false) {
if (profit_control(ii_0,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in flase");
FileClose(Handle_Log);*/
return(0);
}
}
if (next_in==true){
if (profit_control(start_p,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in true");
FileClose(Handle_Log);*/
}
if (profit_control(ii_0,takepercent_day,start_balance)==false)
{
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by day next_in true");
FileClose(Handle_Log);*/
return(0);
}
}
}
CheckTimeIn(MaxTime,MaxIn,MaxP,start_p);
//--------------------------------------------------------------------------------------Hydra
if (Hour()==hourr && Minute()==minutee && bar2!=Bars && GlobalVariableGet("UPSW")==0) {
GlobalVariableSet("UPSW",1);
//makefile_N();
bar2=Bars;
}
if (Hour()==hourr+1 && Minute()==0 && GlobalVariableGet("UPSW")==1)
{
GlobalVariableSet("UPSW",0);
}
//+------------------------------------------------------------------+
if (GlobalVariableGet("RUN")==1 && TimeLocal()<=GlobalVariableGet("runtime")+86400)
{
return;
}
if (GlobalVariableGet("RUN")==1 && TimeLocal()>GlobalVariableGet("runtime")+86400)
{
GlobalVariableSet("RUN",0);
}
ObjectCreate("run",OBJ_LABEL,0,0,0);
ObjectSet("run", OBJPROP_CORNER, 1);
ObjectSet("run", OBJPROP_COLOR, White);
ObjectSet("run", OBJPROP_XDISTANCE, 20);
ObjectSet("run", OBJPROP_YDISTANCE, Pos);
if (!Week15(W1Start,W5Over,start_t,stop_t,weekday) && OrdersTotal() == 0) {
ObjectSetText("run","未在設定時區內,現有戰役達成後將離開戰場",10,"微軟正黑體");
return;
}else {
ObjectSetText("run","已進入作戰時區內,全面啟動執行...",10,"微軟正黑體");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (BrakeSystem)
{
string Active="煞車系統啟動中";
string Deactive="煞車系統待命中";
color Light_status=Gold;
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSetString(0,"lightstatus",OBJPROP_FONT,"微軟正黑體");
ObjectSetInteger(0,"lightstatus",OBJPROP_FONTSIZE,10);
ObjectSetInteger(0,"lightstatus",OBJPROP_COLOR,Light_status);
int Price_Range;
int Time_Range;
int Now_Time = TimeCurrent();
double Now_Price = Close[0];
if (Last_Price != -1.0) {
Price_Range = Now_Price / Point - Last_Price / Point;
Time_Range = Now_Time - Last_Time;
//int Total_Orders = OrdersTotalCountByTypeANDMagic(OP_BUY, BuyMagic) + OrdersTotalCountByTypeANDMagic(OP_SELL, SellMagic);
if (MathAbs(Price_Range) >= MinPriceShot && Time_Range <= pSeconds) {
//if (Total_Orders < MaxOrdersCount) {
if (Now_Price > Last_Price) {
if ( MyOrderTotal_type(id1,1) > MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
if (Now_Price < Last_Price) {
if ( MyOrderTotal_type(id1,1) < MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
//} else {}//Comment("");
Last_Price = Now_Price;
Last_Time = Now_Time;
}else {
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (Time_Range >= pSeconds) {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
} else {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (TimeCurrent()<=SleepStop)
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active+", "+DoubleToStr((SleepStop-TimeCurrent())/60,0)+" 分鐘後啟動");
return;
}
}else {
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (MarginSleep) {
bool Pass=false;
if (AccountMargin() == 0) {Pass=true;}
else{
double Margin_R=(AccountEquity()/AccountMargin())*100;
if (MarginLimit >= Margin_R && !Pass) {
ObjectCreate("Margin",OBJ_LABEL,0,0,0);
ObjectSet("Margin", OBJPROP_CORNER, 1);
ObjectSet("Margin", OBJPROP_COLOR, Gold);
ObjectSet("Margin", OBJPROP_XDISTANCE, 20);
ObjectSet("Margin", OBJPROP_YDISTANCE, Pos+155);
ObjectSetText("Margin", "保證金比例低於 "+DoubleToStr(MarginLimit,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Margin");
}
}
}else {
ObjectDelete("Margin");
}
if (FloatEq) {
double Profit=AccountProfit();
if (Profit <= FloatAm) {
ObjectCreate("Float",OBJ_LABEL,0,0,0);
ObjectSet("Float", OBJPROP_CORNER, 1);
ObjectSet("Float", OBJPROP_COLOR, Gold);
ObjectSet("Float", OBJPROP_XDISTANCE, 20);
ObjectSet("Float", OBJPROP_YDISTANCE, Pos+175);
ObjectSetText("Float", "浮虧大於 "+DoubleToStr(FloatAm,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Float");
}
}else {
ObjectDelete("Float");
}
int li4;
int li8;
int li12;
int li16;
int li20;
int li24;
int li28;
color color32;
color color36;
color color40;
color color44;
color color48;
color color52;
color color56;
string ls_unused60;
color color68;
color color72;
color color76;
color color80;
color color84;
color color88;
color color92;
color color96;
string ls_unused100;
color color108;
int li_unused112;
double ihigh1128;
double ilow1136;
double iclose1144;
double iclose1152;
double ld1192;
double ld1248;
double ld1256;
int li1264;
int count1268;
double ld1316;
double ld1324;
int li1332;
int count1336;
int li992 = 0;
int li996 = 0;
int li1000 = 0;
int li1004 = 0;
int li1008 = 0;
int li1012 = 0;
li992 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
for (li1012 = 1; li1012 <= 5; li1012++) li996 = li996 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 10; li1012++) li1000 = li1000 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 20; li1012++) li1004 = li1004 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
li996 /= 5;
li1000 /= 10;
li1004 /= 20;
li1008 = (li992 + li996 + li1000 + li1004) / 4;
string ls_unused1016 = "";
string ls_unused1024 = "";
string dbl2str1032 = "";
string dbl2str1040 = "";
string dbl2str1048 = "";
string dbl2str1056 = "";
string ls_unused1064 = "";
string ls_unused1072 = "";
string ls1080 = "";
double iopen1088 = iOpen(NULL, PERIOD_D1, 0);
double iclose1096 = iClose(NULL, PERIOD_D1, 0);
double ld1104 = (Ask - Bid) / Point;
double ihigh1112 = iHigh(NULL, PERIOD_D1, 0);
double ilow1120 = iLow(NULL, PERIOD_D1, 0);
dbl2str1040 = DoubleToStr((iclose1096 - iopen1088) / Point, 0);
dbl2str1032 = DoubleToStr(ld1104, Digits - 4);
dbl2str1048 = DoubleToStr(li1008, Digits - 4);
ls1080 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
dbl2str1056 = DoubleToStr((ihigh1112 - ilow1120) / Point, 0);
if (iclose1096 >= iopen1088) {
ls_unused1064 = "-";
color108 = g_color1100;
}
if (iclose1096 < iopen1088) {
ls_unused1064 = "-";
color108 = g_color1104;
}
if (dbl2str1048 >= ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1108;
}
if (dbl2str1048 < ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1112;
}
double ld1160 = LotExponent;
int li1168 = gi108;
double ld1172 = TakeProfit;
bool bool1180 = UseEquityStop;
double ld1184 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1192 = Lots;
else ld1192 = 0.00001 * MathCeil(AccountBalance());
} else ld1192 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop_Hilo) f035(TrailStart_Hilo, TrailStop_Hilo, g_price312);
if (gi220) {
if (TimeCurrent() >= gi376) {
f024();
Print("Closed All due_Hilo to TimeOut");
}
}
if (gi372 == Time[0]) return (0);
gi372 = Time[0];
double ld1200 = f031();
if (bool1180) {
if (ld1200 < 0.0 && MathAbs(ld1200) > ld1184 / 100.0 * f07()) {
f024();
Print("Closed All due_Hilo to Stop Out");
gi424 = FALSE;
}
}
gi396 = f04();
if (gi396 == 0) gi360 = FALSE;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
gi412 = TRUE;
gi416 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
gi412 = FALSE;
gi416 = TRUE;
break;
}
}
}
if (gi396 > 0 && gi396 <= MaxTrades_A) {
RefreshRates();
gd336 = f032();
gd344 = f020();
if (gi412 && gd336 - Ask >= PipStep_Hilo * Point) gi408 = TRUE;
if (gi416 && Bid - gd344 >= PipStep_Hilo * Point) gi408 = TRUE;
}
if (gi396 < 1) {
gi416 = FALSE;
gi412 = FALSE;
gi408 = TRUE;
gd288 = AccountEquity();
}
if (gi408) {
gd336 = f032();
gd344 = f020();
if (gi416) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
RefreshRates();
gi420 = f03(1, gd384, Bid, slip_Hilo, Ask, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi408 = FALSE;
gi424 = TRUE;
} else {
if (gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
gi420 = f03(0, gd384, Ask, slip_Hilo, Bid, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi408 = FALSE;
gi424 = TRUE;
}
}
}
if (gi408 && gi396 < 1) {
ihigh1128 = iHigh(Symbol(), 0, 1);
ilow1136 = iLow(Symbol(), 0, 2);
g_bid320 = Bid;
g_ask328 = Ask;
if ((!gi416) && !gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
if (ihigh1128 > ilow1136) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi420 = f03(1, gd384, g_bid320, slip_Hilo, g_bid320, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi424 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi420 = f03(0, gd384, g_ask328, slip_Hilo, g_ask328, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi424 = TRUE;
}
}
if (gi420 > 0) gi376 = TimeCurrent() + 60.0 * (60.0 * gd224);
gi408 = FALSE;
}
}
gi396 = f04();
g_price312 = 0;
double ld1208 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price312 += OrderOpenPrice() * OrderLots();
ld1208 += OrderLots();
}
}
}
if (gi396 > 0) g_price312 = NormalizeDouble(g_price312 / ld1208, Digits);
if (gi424) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
g_price280 = g_price312 + ld1172 * Point;
gd_unused296 = g_price280;
gd400 = g_price312 - g_pips236 * Point;
gi360 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
g_price280 = g_price312 - ld1172 * Point;
gd_unused304 = g_price280;
gd400 = g_price312 + g_pips236 * Point;
gi360 = TRUE;
}
}
}
}
if (gi424) {
if (gi360 == TRUE) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) OrderModify(OrderTicket(), g_price312, OrderStopLoss(), g_price280, 0, Yellow);
gi424 = FALSE;
}
}
}
double ld1216 = LotExponent;
int li1224 = gi108;
double ld1228 = TakeProfit;
bool bool1236 = UseEquityStop;
double ld1240 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1248 = Lots;
else ld1248 = 0.00001 * MathCeil(AccountBalance());
} else ld1248 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop15) f021(TrailStart15, TrailStop15, g_price596);
if (gi532) {
if (TimeCurrent() >= gi660) {
f018();
Print("Closed All due to TimeOut");
}
}
if (gi656 != Time[0]) {
gi656 = Time[0];
ld1256 = f029();
if (bool1236) {
if (ld1256 < 0.0 && MathAbs(ld1256) > ld1240 / 100.0 * f016()) {
f018();
Print("Closed All due to Stop Out");
gi708 = FALSE;
}
}
gi680 = f05();
if (gi680 == 0) gi644 = FALSE;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
gi696 = TRUE;
gi700 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
gi696 = FALSE;
gi700 = TRUE;
break;
}
}
}
if (gi680 > 0 && gi680 <= MaxTrades_B) {
RefreshRates();
gd620 = f036();
gd628 = f028();
if (gi696 && gd620 - Ask >= PipStep15 * Point) gi692 = TRUE;
if (gi700 && Bid - gd628 >= PipStep15 * Point) gi692 = TRUE;
}
if (gi680 < 1) {
gi700 = FALSE;
gi696 = FALSE;
gi692 = TRUE;
gd572 = AccountEquity();
}
if (gi692) {
gd620 = f036();
gd628 = f028();
if (gi700) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
RefreshRates();
gi704 = f02(1, gd668, Bid, slip15, Ask, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi692 = FALSE;
gi708 = TRUE;
} else {
if (gi696) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
gi704 = f02(0, gd668, Ask, slip15, Bid, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi692 = FALSE;
gi708 = TRUE;
}
}
}
}
if (g_datetime728 != iTime(NULL, g_timeframe496, 0)) {
li1264 = OrdersTotal();
count1268 = 0;
for (int li1272 = li1264; li1272 >= 1; li1272--) {
OrderSelect(li1272 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) count1268++;
}
if (li1264 == 0 || count1268 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid604 = Bid;
g_ask612 = Ask;
gi664 = gi680;
gd668 = ld1248;
if (iclose1144 > iclose1152) {
gi704 = f02(1, gd668, g_bid604, slip15, g_bid604, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi708 = TRUE;
} else {
gi704 = f02(0, gd668, g_ask612, slip15, g_ask612, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi708 = TRUE;
}
if (gi704 > 0) gi660 = TimeCurrent() + 60.0 * (60.0 * gd536);
gi692 = FALSE;
}
g_datetime728 = iTime(NULL, g_timeframe496, 0);
}
gi680 = f05();
g_price596 = 0;
double ld1276 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price596 += OrderOpenPrice() * OrderLots();
ld1276 += OrderLots();
}
}
}
if (gi680 > 0) g_price596 = NormalizeDouble(g_price596 / ld1276, Digits);
if (gi708) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
g_price564 = g_price596 + ld1228 * Point;
gd_unused580 = g_price564;
gd684 = g_price596 - g_pips508 * Point;
gi644 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
g_price564 = g_price596 - ld1228 * Point;
gd_unused588 = g_price564;
gd684 = g_price596 + g_pips508 * Point;
gi644 = TRUE;
}
}
}
}
if (gi708) {
if (gi644 == TRUE) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) OrderModify(OrderTicket(), g_price596, OrderStopLoss(), g_price564, 0, Yellow);
gi708 = FALSE;
}
}
}
double ld1284 = LotExponent;
int li1292 = gi108;
double ld1296 = TakeProfit;
bool bool1304 = UseEquityStop;
double ld1308 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1316 = Lots;
else ld1316 = 0.00001 * MathCeil(AccountBalance());
} else ld1316 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop16) f034(TrailStart16, TrailStop16, g_price880);
if (gi816) {
if (TimeCurrent() >= gi944) {
f0_0();
Print("Closed All due to TimeOut");
}
}
if (gi940 != Time[0]) {
gi940 = Time[0];
ld1324 = f08();
if (bool1304) {
if (ld1324 < 0.0 && MathAbs(ld1324) > ld1308 / 100.0 * f030()) {
f0_0();
Print("Closed All due to Stop Out");
gi992 = FALSE;
}
}
gi964 = f012();
if (gi964 == 0) gi928 = FALSE;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
gi980 = TRUE;
gi984 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
gi980 = FALSE;
gi984 = TRUE;
break;
}
}
}
if (gi964 > 0 && gi964 <= MaxTrades_C) {
RefreshRates();
gd904 = f017();
gd912 = f027();
if (gi980 && gd904 - Ask >= PipStep16 * Point) gi976 = TRUE;
if (gi984 && Bid - gd912 >= PipStep16 * Point) gi976 = TRUE;
}
if (gi964 < 1) {
gi984 = FALSE;
gi980 = FALSE;
gd856 = AccountEquity();
}
if (gi976) {
gd904 = f017();
gd912 = f027();
if (gi984) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
RefreshRates();
gi988 = f06(1, gd952, Bid, slip16, Ask, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi976 = FALSE;
gi992 = TRUE;
} else {
if (gi980) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
gi988 = f06(0, gd952, Ask, slip16, Bid, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi976 = FALSE;
gi992 = TRUE;
}
}
}
}
if (g_datetime1012 != iTime(NULL, g_timeframe784, 0)) {
li1332 = OrdersTotal();
count1336 = 0;
for (int li1340 = li1332; li1340 >= 1; li1340--) {
OrderSelect(li1340 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) count1336++;
}
if (li1332 == 0 || count1336 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid888 = Bid;
g_ask896 = Ask;
gi948 = gi964;
gd952 = ld1316;
if (iclose1144 > iclose1152) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi988 = f06(1, gd952, g_bid888, slip16, g_bid888, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi992 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi988 = f06(0, gd952, g_ask896, slip16, g_ask896, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi992 = TRUE;
}
}
if (gi988 > 0) gi944 = TimeCurrent() + 60.0 * (60.0 * gd820);
gi976 = FALSE;
}
g_datetime1012 = iTime(NULL, g_timeframe784, 0);
}
gi964 = f012();
g_price880 = 0;
double ld1344 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price880 += OrderOpenPrice() * OrderLots();
ld1344 += OrderLots();
}
}
}
if (gi964 > 0) g_price880 = NormalizeDouble(g_price880 / ld1344, Digits);
if (gi992) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
g_price848 = g_price880 + ld1296 * Point;
gd_unused864 = g_price848;
gd968 = g_price880 - g_pips792 * Point;
gi928 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
g_price848 = g_price880 - ld1296 * Point;
gd_unused872 = g_price848;
gd968 = g_price880 + g_pips792 * Point;
gi928 = TRUE;
}
}
}
}
if (gi992) {
if (gi928 == TRUE) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) OrderModify(OrderTicket(), g_price880, OrderStopLoss(), g_price848, 0, Yellow);
gi992 = FALSE;
}
}
}
//Handle_Log=0;
return (0);
}
int f04() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f024() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip_Hilo, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip_Hilo, Red);
}
Sleep(1000);
}
}
}
int f03(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM1(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f022(Bid, ai32), f019(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f011(Ask, ai32), f01(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f022(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f011(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f019(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f01(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f031() {
double ld_ret_0 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f035(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f07() {
if (f04() == 0) gd428 = AccountEquity();
if (gd428 < gd436) gd428 = gd436;
else gd428 = AccountEquity();
gd436 = AccountEquity();
return (gd428);
}
double f032() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f020() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f05() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f018() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip15, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip15, Red);
}
Sleep(1000);
}
}
}
int f02(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM2(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f013(Bid, ai32), f025(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f033(Ask, ai32), f026(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f013(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f033(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f025(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f026(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f029() {
double ld_ret_0 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f021(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f016() {
if (f05() == 0) gd712 = AccountEquity();
if (gd712 < gd720) gd712 = gd720;
else gd712 = AccountEquity();
gd720 = AccountEquity();
return (gd712);
}
double f036() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f028() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f012() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f0_0() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip16, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip16, Red);
}
Sleep(1000);
}
}
}
int f06(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM3(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f014(Bid, ai32), f09(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f023(Ask, ai32), f010(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f014(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f023(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f09(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f010(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f08() {
double ld_ret_0 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f034(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f030() {
if (f012() == 0) gd996 = AccountEquity();
if (gd996 < gd1004) gd996 = gd1004;
else gd996 = AccountEquity();
gd1004 = AccountEquity();
return (gd996);
}
double f017() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f027() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
string f015(string as_0) {
int str_len8 = StringLen(as_0);
bool li_ret12 = FALSE;
for (int li16 = 0; li16 < str_len8; li16++) {
if (StringSubstr(as_0, li16, 1) == "1") li_ret12 = li_ret12 + MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "2") li_ret12 = li_ret12 + 2.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "3") li_ret12 = li_ret12 + 3.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "4") li_ret12 = li_ret12 + 4.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "5") li_ret12 = li_ret12 + 5.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "6") li_ret12 = li_ret12 + 6.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "7") li_ret12 = li_ret12 + 7.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "8") li_ret12 = li_ret12 + 8.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "9") li_ret12 = li_ret12 + 9.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "A") li_ret12 = li_ret12 + 10.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "B") li_ret12 = li_ret12 + 11.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "C") li_ret12 = li_ret12 + 12.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "D") li_ret12 = li_ret12 + 13.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "E") li_ret12 = li_ret12 + 14.0 * MathPow(16, str_len8 - li16 - 1);
else
if (StringSubstr(as_0, li16, 1) == "F") li_ret12 = li_ret12 + 15.0 * MathPow(16, str_len8 - li16 - 1);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return (li_ret12);
}
string MakeDateTime(string strDate, string strTime)
{
// Print("Converting Forex Factory Time into Metatrader time..."); //added by MN
// Converts forexfactory time & date into yyyy.mm.dd hh:mm
int n1stDash = StringFind(strDate, "-");
int n2ndDash = StringFind(strDate, "-", n1stDash+1);
string strMonth = StringSubstr(strDate, 0, 2);
string strDay = StringSubstr(strDate, 3, 2);
string strYear = StringSubstr(strDate, 6, 4);
// strYear = "20" + strYear;
int nTimeColonPos = StringFind(strTime, ":");
string strHour = StringSubstr(strTime, 0, nTimeColonPos);
string strMinute = StringSubstr(strTime, nTimeColonPos+1, 2);
string strAM_PM = StringSubstr(strTime, StringLen(strTime)-2);
int nHour24 = StrToInteger(strHour);
if ((strAM_PM == "pm" || strAM_PM == "PM") && nHour24 != 12)
{
nHour24 += 12;
}
if ((strAM_PM == "am" || strAM_PM == "AM") && nHour24 == 12)
{
nHour24 = 0;
}
string strHourPad = "";
if (nHour24 < 10)
strHourPad = "0";
return(StringConcatenate(strYear, ".", strMonth, ".", strDay, " ", strHourPad, nHour24, ":", strMinute));
}
bool profit_control(int i_0,double takepercent_,double start_balance)
{
double today_profit;
int i1=StrToTime(TimeToStr(TimeCurrent()+86400, TIME_DATE));
today_profit=((GetProfitFromDateInCurrency(i_0)+AccountProfit())/start_balance)*100;
if (today_profit>=takepercent_)
{
return(false);
}
return(true);
}
void displayprofit(int start_p,bool next_in,double start_balance)
{
double today_profit;
string display;
ObjectCreate("percent",OBJ_LABEL,0,0,0);
ObjectSet("percent", OBJPROP_CORNER, 1);
ObjectSet("percent", OBJPROP_COLOR, White);
ObjectSet("percent", OBJPROP_XDISTANCE, 20);
ObjectSet("percent", OBJPROP_YDISTANCE, Pos+30);
ObjectCreate("start_p",OBJ_LABEL,0,0,0);
ObjectSet("start_p", OBJPROP_CORNER, 1);
ObjectSet("start_p", OBJPROP_COLOR, White);
ObjectSet("start_p", OBJPROP_XDISTANCE, 20);
ObjectSet("start_p", OBJPROP_YDISTANCE, Pos+50);
ObjectSetText("start_p","進場經過時間 "+ DoubleToStr((TimeCurrent()-start_p)/60,1)+ " 分鐘"+" ; "+OrdersTotal()+" 兵力在戰場上",10,"微軟正黑體");
if (next_in==true)
{
today_profit=((GetProfitFromDateInCurrency(start_p)+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
GlobalVariableSet("display",today_profit);
ObjectSetText("percent","單次擄獲狂派戰俘"+display+"%"+" ; 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectCreate("takepercent_day",OBJ_LABEL,0,0,0);
ObjectSet("takepercent_day", OBJPROP_CORNER, 1);
ObjectSet("takepercent_day", OBJPROP_COLOR, White);
ObjectSet("takepercent_day", OBJPROP_XDISTANCE, 20);
ObjectSet("takepercent_day", OBJPROP_YDISTANCE, Pos+70);
ObjectSetText("takepercent_day","今日擄獲狂派戰俘累積至"+display+" ; 最大暫時被擄穫兵力 "+DoubleToStr(GlobalVariableGet("MaxEquity"),2)+" %",10,"微軟正黑體");
}
if (next_in==false)
{
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectSetText("percent","今日擄獲狂派戰俘累積至"+display+"%"+" 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
}
}
double GetProfitFromDateInCurrency(int today) {
double profit = 0;
int total = OrdersHistoryTotal();
for (int i = 0; i < total; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL ) {
if (today < OrderCloseTime()) profit += OrderProfit() + OrderCommission() + OrderSwap();
}
}
}
return (profit);
}
bool SLClose (double percent,double start_balance) {
if (AccountProfit()<=0)
{
if ((MathAbs(AccountProfit())/start_balance)*100>=percent)
{
return(true);
}
else
{
return(false);
}
}else
{
return(false);
}
}
void iCloseOrders(string myType,string currency,int id1,int type)
{
if (MyOrderTotal_err(id1)==0) return(0);
int C0_cnt,close_t[],t_cnt;
double percentlots,nd_profit;
if (myType=="Del"&&type==0)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_BUYSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="Del"&&type==1)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_SELLSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="100%")
{
for(C0_cnt=0;C0_cnt<OrdersTotal();C0_cnt++) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false)
{
//Alert(Symbol()+" OrderSelect Error");
continue;
}
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
ArrayResize(close_t,t_cnt+1);
close_t[t_cnt]=OrderTicket();
t_cnt++;
}
}
for(int i=ArraySize(close_t)-1;i>=0;i--)
{
if (OrderSelect(close_t[i],SELECT_BY_TICKET)==false)
{
Alert(Symbol()+" OrderSelect Error By Tickets");continue;
}
else
{
percentlots=OrderLots();
OrderClose(close_t[i],percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="80%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.8;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="50%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.5;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="All") //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderMagicNumber()!=0){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="BUY"&&type==0) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_BUY && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="SELL"&&type==1) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_SELL && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
}
int MyOrderTotal_err(int id1)//訂單總數函式
{
int x=0;//符合條件的BUY單數量(記次變數)
for(int z=0;z<OrdersTotal();z++)//執行N次篩選(N=訂單總數)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);//用"流水號"找訂單
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ))//挑選出同貨幣對 && BUY單 && MagicNumber=本程式 的訂單
{
x++;//符合節選結果的訂單總數
}
}
return(x);//回傳
}
int MyOrderTotal_type(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ) && OrderType()==type)
{
x++;//
}
}
return(x);
}
bool iTimeControl(int myStartHour,int myStopHour)
{
bool EA_Valid=false;
if(myStopHour == myStartHour) EA_Valid = true;
if(myStopHour < myStartHour)
{
if (TimeHour(TimeLocal()) >= myStartHour || TimeHour(TimeLocal()) < myStopHour) EA_Valid = true;
}
if (myStopHour > myStartHour) {
if ((TimeHour(TimeLocal()) >= myStartHour && TimeHour(TimeLocal()) < myStopHour))
EA_Valid = true;
}
return(EA_Valid);
}
bool Week15 (int start,int over,int myStartHour,int myStopHour,string weekday)
{
bool EA_Valid=false;
int Dayweek=TimeDayOfWeek(TimeLocal());
if (
(
(
Dayweek == 1 && TimeHour(TimeLocal()) < start
)
||
(
Dayweek == StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1)) && TimeHour(TimeLocal()) >= over
)
||
(
Dayweek > StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1))
)
)
&& Week15SW) {
EA_Valid=false;
}else {
if (iTimeControl(myStartHour,myStopHour)) {
if (StringFind(weekday,DoubleToStr(Dayweek,0),0) >= 0) {
EA_Valid=true;
}else {
EA_Valid=false;
}
}else {
EA_Valid=false;
}
}
return(EA_Valid);
}
void CheckTimeIn(int MaxTime,int MaxIn,double MaxP,int start_p)
{
int Handle_Log;
int Valid;
int RunTime=(TimeCurrent()-start_p)/60;
if (RunTime>=MaxTime && OrdersTotal() >= MaxIn && GlobalVariableGet("display")>= MaxP)
{
GlobalVariableSet("next_sw",1);
Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by CheckTimeIn");
FileClose(Handle_Log);
}
}
string Base64Decode(string in/*,string &out*/)
{
string out;
int i=0,len=StringLen(in);
int shift=0,accum=0;
while(i<len)
{
int value=ExtBase64Decode[StringGetChar(in,i)];
if(value<0 || value>63) break;
accum<<=6;
shift+=6;
accum|=value;
if(shift>=8)
{
shift-=8;
value=accum >> shift;
out=out+CharToStr(value & 0xFF);
}
i++;
}
//----
return(out);
}
bool ThreeM1(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(g_magic17616,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(g_magic17616,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM2(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17616,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17616,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM3(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
int MyOrderTotal_id(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id1 && OrderType()==type)
{
x++;//
}
}
return(x);
}
#import "wininet.dll"
int InternetAttemptConnect(
int dwReserved=0
);
int InternetOpenA(uchar &lpszAgent[],int dwAccessType,uchar &lpszProxyName[],uchar &lpszProxyBypass[],int dwFlags);
int InternetConnectA(int hInternetSession,uchar &lpszServerName[],int nServerPort,uchar &lpszUserName[],uchar &lpszPassword[],int nService,int nFlags,int dwContext);
bool InternetCloseHandle(
int hInet
);
bool FtpPutFileA (
int hFtpSession,
string lpszLocalFile,
string lpszRemoteFile,
int dwFlags,
int dwContext
);
bool FtpGetFileA (int hFtpSession,uchar &lpszRemoteFile[],uchar &lpszNewFile[],bool fFailIfExists,int dwFlagsAndAttributes,uint dwFlags,int dwContext);
bool FtpCreateDirectoryA(
int hConnect,
string lpszDirectory
);
bool FtpSetCurrentDirectoryA(
int hConnect,
string lpszDirectory
);
#import
#define INTERNET_FLAG_PASSIVE 0x08000000
#define INTERNET_FLAG_RELOAD 0x80000000
#define INTERNET_FLAG_EXISTING_CONNECT 0x20000000
#define INTERNET_SERVICE_FTP 1
#define FTP_TRANSFER_TYPE_ASCII 1
#define FTP_TRANSFER_TYPE_BINARY 2
#define FTP_TRANSFER_TYPE_UNKNOWN 3
#define INTERNET_FLAG_HYPERLINK 0x00000400
static int ExtBase64Encode[64]={ 'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/' };
static int ExtBase64Decode[256]={
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
string t1 = "";
//extern double Account = 1872377.0;
int GMT=8;
extern string T0="-------------ESP戰艦穩定煞車系統------------";
extern bool BrakeSystem=true;
int pSeconds=14;
extern string T1="能量偵測靈敏度";
extern int Energy = 40;
extern string T2="能量煞車引擎啟動時間";
extern int SleepTime=15;
int SleepStop=0;
int Position=0;
extern string T5="-------------保證金比例控制模組--------------";
extern bool MarginSleep=true;
extern double MarginLimit=4000;
extern string T6="-------------浮虧控制模組(以金額計算)-------------";
extern bool FloatEq=true;
extern double FloatAm=-1400;
extern string T7="開始時間,格式為hh";
extern int start_t=00;
extern string T8="結束時間,格式為hh";
extern int stop_t=00;
extern string T9="週一執行,鍵入1即可";
extern string T10="週一週二鍵入12,以下類推";
extern string weekday="12345";
extern bool Week15SW=true;
extern string W1="禮拜一幾點開始";
extern int W1Start=8;
extern string W2="最後一天幾點結束";
extern int W5Over=17;
extern string T11="止盈止損計算本金基準";
extern double I_balance=0;
extern string T12="止損後當日不再出兵";
extern bool SleepLoss=true;
extern string T13="最大總浮虧(以餘額計算)";
extern double SLpercent=20.0;
extern string T14="次止盈,每次最多獲利%,立即平倉歸零重啟新局";
extern double takepercent=1;
string T111="每次止盈開關";
bool next_in=true;
extern string T15="日止盈,每日最多獲利%,立即停止交易,隔日重新啟動";
extern double takepercent_day=100;
extern string T16="每局結束幾分鐘後重新啟動";
extern double NextTime=2;
extern string T9_="-------------------小虧為贏模組-------------";
extern string T17="每局最長時間(分鐘)";
extern int MaxTime=150;
extern string T18="每局最多兵力";
extern int MaxIn=40;
extern string T19="達成以上條件小虧為贏";
extern double MaxP=0.5;
extern string T20="-------------------------------------------";
extern string T21="手數";
extern double Lots = 0.01;
extern string T22="馬丁倍率";
extern double LotExponent = 1.618;
extern string T23="----------------三方向導航-----------------";
extern bool BSB=true;
int gi108 = 2;
double MaxLots = 5.0;
bool MM = FALSE;
extern string T24="獲利點數";
extern double TakeProfit = 100.0;
bool UseEquityStop = FALSE;
double TotalEquityRisk = 20.0;
string t2 = "Time Setting";
bool CloseFriday = false;
int CloseFridayHour = 17;
bool OpenMondey = false;
int OpenMondeyHour = 0;
string t3 = "";
extern string T25="A模組最多單數";
extern int MaxTrades_A=10;
bool gi220 = FALSE;
double gd224 = 48.0;
bool UseTrailingStop_Hilo = FALSE;
double g_pips236 = 500.0;
double TrailStart_Hilo = 10.0;
double TrailStop_Hilo = 5.0;
double PipStep_Hilo = 200.0;
double slip_Hilo = 3.0;
int MagicNumber_Hilo = 11111;
double g_price280;
double gd288;
double gd_unused296;
double gd_unused304;
double g_price312;
double g_bid320;
double g_ask328;
double gd336;
double gd344;
double gd352;
bool gi360;
string gs364 = "";
int gi372 = 0;
int gi376;
int gi380 = 0;
double gd384;
int g_pos392 = 0;
int gi396;
double gd400 = 0.0;
bool gi408 = FALSE;
bool gi412 = FALSE;
bool gi416 = FALSE;
int gi420;
bool gi424 = FALSE;
double gd428;
double gd436;
string t4 = "";
extern string T26="B模組最多單數";
extern int MaxTrades_B=10;
int g_timeframe496 = PERIOD_H1;
bool UseTrailingStop15 = FALSE;
double g_pips508 = 500.0;
double TrailStart15 = 10.0;
double TrailStop15 = 5.0;
bool gi532 = FALSE;
double gd536 = 48.0;
double PipStep15 = 200.0;
double slip15 = 3.0;
int g_magic17615 = 12324;
double g_price564;
double gd572;
double gd_unused580;
double gd_unused588;
double g_price596;
double g_bid604;
double g_ask612;
double gd620;
double gd628;
double gd636;
bool gi644;
string gs648 = "";
int gi656 = 0;
int gi660;
int gi664 = 0;
double gd668;
int g_pos676 = 0;
int gi680;
double gd684 = 0.0;
bool gi692 = FALSE;
bool gi696 = FALSE;
bool gi700 = FALSE;
int gi704;
bool gi708 = FALSE;
double gd712;
double gd720;
int g_datetime728 = 1;
string t5 = "";
extern string T27="C模組最多單數";
extern int MaxTrades_C=10;
int g_timeframe784 = PERIOD_M1;
bool UseTrailingStop16 = FALSE;
double g_pips792 = 500.0;
double TrailStart16 = 10.0;
double TrailStop16 = 5.0;
bool gi816 = FALSE;
double gd820 = 48.0;
double PipStep16 = 200.0;
double slip16 = 3.0;
int g_magic17616 = 16794;
double g_price848;
double gd856;
double gd_unused864;
double gd_unused872;
double g_price880;
double g_bid888;
double g_ask896;
double gd904;
double gd912;
double gd920;
bool gi928;
string gs932 = "";
int gi940 = 0;
int gi944;
int gi948 = 0;
double gd952;
int g_pos960 = 0;
int gi964;
double gd968 = 0.0;
bool gi976 = FALSE;
bool gi980 = FALSE;
bool gi984 = FALSE;
int gi988;
bool gi992 = FALSE;
double gd996;
double gd1004;
int g_datetime1012 = 1;
int g_timeframe1024 = PERIOD_M1;
int g_timeframe1028 = PERIOD_M5;
int g_timeframe1032 = PERIOD_M15;
int g_timeframe1036 = PERIOD_M30;
int g_timeframe1040 = PERIOD_H1;
int g_timeframe1044 = PERIOD_H4;
int g_timeframe1048 = PERIOD_D1;
bool g_corner1052 = TRUE;
int gi1056 = 0;
int gi1060 = 10;
int g_window1064 = 0;
bool gi1068 = TRUE;
bool gi_unused1072 = TRUE;
bool gi1076 = FALSE;
int g_color1080 = Gray;
int g_color1084 = Gray;
int g_color1088 = Gray;
int g_color1092 = DarkOrange;
int gi_unused1096 = 36095;
int g_color1100 = Lime;
int g_color1104 = OrangeRed;
int gi1108 = 65280;
int gi1112 = 17919;
int g_color1116 = Lime;
int g_color1120 = Red;
int g_color1124 = Orange;
int g_period1128 = 8;
int g_period1132 = 17;
int g_period1136 = 9;
int g_applied_price1140 = PRICE_CLOSE;
int g_color1144 = Lime;
int g_color1148 = Tomato;
int g_color1152 = Green;
int g_color1156 = Red;
string gs_unused1160 = "<<<< STR Indicator Settings >>>>>>>>>>>>>";
string gs_unused1168 = "<<<< RSI Settings >>>>>>>>>>>>>";
int g_period1176 = 9;
int g_applied_price1180 = PRICE_CLOSE;
string gs_unused1184 = "<<<< CCI Settings >>>>>>>>>>>>>>";
int g_period1192 = 13;
int g_applied_price1196 = PRICE_CLOSE;
string gs_unused1200 = "<<<< STOCH Settings >>>>>>>>>>>";
int g_period1208 = 5;
int g_period1212 = 3;
int g_slowing1216 = 3;
int g_ma_method1220 = MODE_EMA;
string gs_unused1224 = "<<<< STR Colors >>>>>>>>>>>>>>>>";
int g_color1232 = Lime;
int g_color1236 = Red;
int g_color1240 = Orange;
string gs_unused1244 = "<<<< MA Settings >>>>>>>>>>>>>>";
int g_period1252 = 5;
int g_period1256 = 9;
int g_ma_method1260 = MODE_EMA;
int g_applied_price1264 = PRICE_CLOSE;
string gs_unused1268 = "<<<< MA Colors >>>>>>>>>>>>>>";
int g_color1276 = Lime;
int g_color1280 = Red;
string gs_dummy1292;
string g_text1464;
string g_text1472;
bool gi1480 = TRUE;
string KEY = "";
int gi1492;
int g_str2int1496;
int g_str2int1500;
int g_str2int1504;
int MinPriceShot;
string maindata[300][7];
double start_balance,point;
int start_p,id1,id2,bar2;
int Pos=50;
int hourr=0;
int minutee;
int count;
bool NewsgetSW=false;
double Last_Price=-1.0;
int Last_Time=0;
int init() {
if (IsTesting()==true) {return(0);}
GlobalVariableSet("Dhamar"+Symbol(),WindowHandle(Symbol(),Period()));
ObjectCreate("Expert",OBJ_LABEL,0,0,0);
ObjectSet("Expert", OBJPROP_CORNER, 1);
ObjectSet("Expert", OBJPROP_COLOR, White);
ObjectSet("Expert", OBJPROP_XDISTANCE, 150);
ObjectSet("Expert", OBJPROP_YDISTANCE, 0);
ObjectSetText("Expert", WindowExpertName(),15,"微軟正黑體", White);
//+------------------------------------------------------------------+
MinPriceShot=Energy;
//+------------------------------------------------------------------+
bar2=Bars;
if(Digits == 5 ||Digits == 3)
{
point=Point*10;
}
else
{
point=Point;
}
//+------------------------------------------------------------------+
double Position_L=Bid+Position*point;
ObjectCreate("Light",OBJ_ARROW,0,0,0);
ObjectSet("Light",OBJPROP_ARROWCODE,108);
ObjectSet("Light", OBJPROP_CORNER, 1);
ObjectSet("Light", OBJPROP_COLOR, Lime);
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light",OBJPROP_WIDTH,5);
ObjectCreate("Light2",OBJ_ARROW,0,0,0);
ObjectSet("Light2",OBJPROP_ARROWCODE,161);
ObjectSet("Light2", OBJPROP_CORNER, 1);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_WIDTH,5);
ObjectCreate("lightstatus",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"lightstatus", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"lightstatus", OBJPROP_COLOR, clrGold);
ObjectSetInteger(0,"lightstatus", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"lightstatus", OBJPROP_YDISTANCE, Pos+135);
ObjectSetInteger(0,"lightstatus", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
//+------------------------------------------------------------------+
GlobalVariableSet("next_sw",0);
if (!GlobalVariableCheck("start_balance"))
{
GlobalVariableSet("start_balance",AccountBalance());
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
if (!GlobalVariableCheck("start_p"))
{
GlobalVariableSet("start_p",TimeCurrent());
}
start_p=GlobalVariableGet("start_p");
MathSrand(TimeLocal());
for (int i=1;i<10;i++)
{minutee=1+((59*MathRand())/32768); }
GlobalVariableSet("RUN",0);
GlobalVariableSet("UPSW",0);
GlobalVariableSet("WSW",0);
GlobalVariableSet("RUNEA",0);
GlobalVariableSet("DNSW",0);
if (GlobalVariableCheck("MaxEquity")==false)
{GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);}
ObjectCreate(0,"Newsinfo",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo", OBJPROP_YDISTANCE, Pos+95);
ObjectSetInteger(0,"Newsinfo", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
ObjectCreate(0,"Newsinfo2",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_YDISTANCE, Pos+115);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
string ls4;
string ls12;
string ls20;
string ls28;
string ls36;
string ls44;
gd352 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd636 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd920 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
ObjectCreate("Lable1", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable1", OBJPROP_CORNER, 2);
ObjectSet("Lable1", OBJPROP_XDISTANCE, 23);
ObjectSet("Lable1", OBJPROP_YDISTANCE, 21);
g_text1472 = "";
ObjectSetText("Lable1", g_text1472, 12, "Arial", DeepSkyBlue);
ObjectCreate("Lable", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable", OBJPROP_CORNER, 2);
ObjectSet("Lable", OBJPROP_XDISTANCE, 3);
ObjectSet("Lable", OBJPROP_YDISTANCE, 1);
g_text1464 = "";
ObjectSetText("Lable", g_text1464, 10, "Arial", DeepSkyBlue);
if (false/*gi1480*/) {
if (KEY != "") {
gi1492 = 0;
for (int li_0 = 0; li_0 < StringLen(KEY); li_0++) {
if (StringSubstr(KEY, li_0, 1) != "X") ls4 = ls4 + StringSubstr(KEY, li_0, 1);
else {
ls12 = ls12 + f015(ls4);
ls4 = "";
}
}
for (li_0 = 0; li_0 < StringLen(ls12); li_0 += 2) {
if (StringSubstr(ls12, li_0, 2) == "55") ls20 = ls20 + "0";
else {
if (StringSubstr(ls12, li_0, 2) == "21") ls20 = ls20 + "1";
else {
if (StringSubstr(ls12, li_0, 2) == "98") ls20 = ls20 + "2";
else {
if (StringSubstr(ls12, li_0, 2) == "42") ls20 = ls20 + "3";
else {
if (StringSubstr(ls12, li_0, 2) == "10") ls20 = ls20 + "4";
else {
if (StringSubstr(ls12, li_0, 2) == "14") ls20 = ls20 + "5";
else {
if (StringSubstr(ls12, li_0, 2) == "88") ls20 = ls20 + "6";
else {
if (StringSubstr(ls12, li_0, 2) == "66") ls20 = ls20 + "7";
else {
if (StringSubstr(ls12, li_0, 2) == "33") ls20 = ls20 + "8";
else {
if (StringSubstr(ls12, li_0, 2) == "32") ls20 = ls20 + "9";
else {
if (StringSubstr(ls12, li_0, 2) == "96") ls20 = ls20 + "a";
else {
if (StringSubstr(ls12, li_0, 2) == "30") ls20 = ls20 + "b";
else {
if (StringSubstr(ls12, li_0, 2) == "77") ls20 = ls20 + "c";
else {
if (StringSubstr(ls12, li_0, 2) == "90") ls20 = ls20 + "d";
else {
if (StringSubstr(ls12, li_0, 2) == "24") ls20 = ls20 + "e";
else {
if (StringSubstr(ls12, li_0, 2) == "29") ls20 = ls20 + "f";
else {
if (StringSubstr(ls12, li_0, 2) == "39") ls20 = ls20 + "g";
else {
if (StringSubstr(ls12, li_0, 2) == "48") ls20 = ls20 + "h";
else {
if (StringSubstr(ls12, li_0, 2) == "56") ls20 = ls20 + "i";
else {
if (StringSubstr(ls12, li_0, 2) == "16") ls20 = ls20 + "j";
else {
if (StringSubstr(ls12, li_0, 2) == "62") ls20 = ls20 + "k";
else {
if (StringSubstr(ls12, li_0, 2) == "15") ls20 = ls20 + "l";
else {
if (StringSubstr(ls12, li_0, 2) == "71") ls20 = ls20 + "m";
else {
if (StringSubstr(ls12, li_0, 2) == "81") ls20 = ls20 + "n";
else {
if (StringSubstr(ls12, li_0, 2) == "93") ls20 = ls20 + "o";
else {
if (StringSubstr(ls12, li_0, 2) == "74") ls20 = ls20 + "p";
else {
if (StringSubstr(ls12, li_0, 2) == "83") ls20 = ls20 + "q";
else {
if (StringSubstr(ls12, li_0, 2) == "44") ls20 = ls20 + "r";
else {
if (StringSubstr(ls12, li_0, 2) == "51") ls20 = ls20 + "s";
else {
if (StringSubstr(ls12, li_0, 2) == "69") ls20 = ls20 + "t";
else {
if (StringSubstr(ls12, li_0, 2) == "40") ls20 = ls20 + "u";
else {
if (StringSubstr(ls12, li_0, 2) == "73") ls20 = ls20 + "v";
else {
if (StringSubstr(ls12, li_0, 2) == "59") ls20 = ls20 + "w";
else {
if (StringSubstr(ls12, li_0, 2) == "36") ls20 = ls20 + "x";
else {
if (StringSubstr(ls12, li_0, 2) == "26") ls20 = ls20 + "y";
else {
if (StringSubstr(ls12, li_0, 2) == "25") ls20 = ls20 + "z";
else {
if (StringSubstr(ls12, li_0, 2) == "28") ls20 = ls20 + "!";
else {
if (StringSubstr(ls12, li_0, 2) == "65") ls20 = ls20 + "&";
else {
if (StringSubstr(ls12, li_0, 2) == "52") ls20 = ls20 + "#";
else {
if (StringSubstr(ls12, li_0, 2) == "57") ls20 = ls20 + "$";
else {
if (StringSubstr(ls12, li_0, 2) == "31") ls20 = ls20 + "%";
else {
if (StringSubstr(ls12, li_0, 2) == "91") ls20 = ls20 + "*";
else {
if (StringSubstr(ls12, li_0, 2) == "60") ls20 = ls20 + "+";
else {
if (StringSubstr(ls12, li_0, 2) == "92") ls20 = ls20 + "-";
else {
if (StringSubstr(ls12, li_0, 2) == "34") ls20 = ls20 + "?";
else {
if (StringSubstr(ls12, li_0, 2) == "46") ls20 = ls20 + "^";
else {
if (StringSubstr(ls12, li_0, 2) == "38") ls20 = ls20 + "|";
else {
if (StringSubstr(ls12, li_0, 2) == "37") ls20 = ls20 + "@";
else {
if (StringSubstr(ls12, li_0, 2) == "49") ls20 = ls20 + "_";
else {
if (StringSubstr(ls12, li_0, 2) == "50") ls20 = ls20 + "S";
else
if (StringSubstr(ls12, li_0, 2) == "19") ls20 = ls20 + ".";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
ls28 = StringSubstr(ls20, 1, 2);
ls36 = StringSubstr(ls20, 3, 2);
ls44 = StringSubstr(ls20, 5, 4);
g_str2int1496 = StrToInteger(ls28);
g_str2int1500 = StrToInteger(ls36);
g_str2int1504 = StrToInteger(ls44);
if (Year() > g_str2int1504) gi1492 = 3;
if (Year() == g_str2int1504) {
if (Month() > g_str2int1500) gi1492 = 3;
if (Month() == g_str2int1500)
if (Day() > g_str2int1496) gi1492 = 3;
}
} else gi1492 = 1;
gi1480 = FALSE;
}
//Comment("\n", "License will expire on ", g_str2int1496, "/", g_str2int1500, "/", g_str2int1504);
return (0);
}
int deinit() {
ObjectDelete("cja");
ObjectDelete("Signalprice");
ObjectDelete("SIG_BARS_TF1");
ObjectDelete("SIG_BARS_TF2");
ObjectDelete("SIG_BARS_TF3");
ObjectDelete("SIG_BARS_TF4");
ObjectDelete("SIG_BARS_TF5");
ObjectDelete("SIG_BARS_TF6");
ObjectDelete("SIG_BARS_TF7");
ObjectDelete("SSignalMACD_TEXT");
ObjectDelete("SSignalMACDM1");
ObjectDelete("SSignalMACDM5");
ObjectDelete("SSignalMACDM15");
ObjectDelete("SSignalMACDM30");
ObjectDelete("SSignalMACDH1");
ObjectDelete("SSignalMACDH4");
ObjectDelete("SSignalMACDD1");
ObjectDelete("SSignalSTR_TEXT");
ObjectDelete("SignalSTRM1");
ObjectDelete("SignalSTRM5");
ObjectDelete("SignalSTRM15");
ObjectDelete("SignalSTRM30");
ObjectDelete("SignalSTRH1");
ObjectDelete("SignalSTRH4");
ObjectDelete("SignalSTRD1");
ObjectDelete("SignalEMA_TEXT");
ObjectDelete("SignalEMAM1");
ObjectDelete("SignalEMAM5");
ObjectDelete("SignalEMAM15");
ObjectDelete("SignalEMAM30");
ObjectDelete("SignalEMAH1");
ObjectDelete("SignalEMAH4");
ObjectDelete("SignalEMAD1");
ObjectDelete("SIG_DETAIL1");
ObjectDelete("SIG_DETAIL2");
ObjectDelete("SIG_DETAIL3");
ObjectDelete("SIG_DETAIL4");
ObjectDelete("SIG_DETAIL5");
ObjectDelete("SIG_DETAIL6");
ObjectDelete("SIG_DETAIL7");
ObjectDelete("SIG_DETAIL8");
ObjectDelete("Lable");
ObjectDelete("Lable1");
ObjectDelete("percent");
ObjectDelete("start_p");
ObjectDelete("takepercent_day");
ObjectDelete("run");
ObjectDelete("Newsinfo");
ObjectDelete("Newsinfo2");
ObjectDelete("ERR");
ObjectDelete("ERR2");
ObjectDelete("Expert");
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
ObjectDelete("Margin");
ObjectDelete("Float");
return (0);
}
int start() {
//+------------------------------------------------Author Start--------------------------------------------------------------------------+
GlobalVariableSet("Dhamar"+Symbol()+"TF",Period());
double Position_L=Bid+Position*point;
string outDN,outUP,outtext,outtext2;
if (GlobalVariableGet("RUNEA")==1) //EA控制器
{
Alert("EA is not working");
return;
}
//+------------------------------------------------Author End----------------------------------------------------------------------------+
int Handle_Log,h1;
if ((AccountProfit()/start_balance)*100<GlobalVariableGet("MaxEquity")) GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);
displayprofit(start_p,next_in,start_balance);
//--------------------------------------------------------------------------------------Hydra
if (OrdersTotal()==0)
{
GlobalVariableSet("start_balance",AccountBalance());
GlobalVariableSet("start_p",TimeCurrent());
//GlobalVariableSet("MaxEquity",start_balance);
GlobalVariableSet("next_sw",0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),GlobalVariableGet("start_balance"),"After");
FileClose(h1);*/
Sleep(60000);
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
start_p=GlobalVariableGet("start_p");
if (GlobalVariableGet("next_sw")==1)
{
if (IsTradeContextBusy())
{
Sleep(10000);
return;
}
iCloseOrders("100%",Symbol(),id1,0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(start_p,TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),start_balance,"Before");
FileClose(h1);*/
Sleep(5000);
if (MyOrderTotal_err(id1)!=0)
{
Alert(Symbol()+" 戰場未成功離開");
Sleep(30000);
return;
}else
{
Sleep(NextTime*60*1000);
}
return(0);
}
//--------------------------------------------------------------------------------------Hydra
if (SLClose(SLpercent,start_balance))
{
if (SleepLoss)
{
GlobalVariableSet("RUN",1);
GlobalVariableSet("runtime",StrToTime(TimeToStr(TimeLocal(),TIME_DATE)));
}
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Stop Loss Close");
FileClose(Handle_Log);*/
}
if (takepercent>0){
int ii_0=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE));
if (next_in==false) {
if (profit_control(ii_0,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in flase");
FileClose(Handle_Log);*/
return(0);
}
}
if (next_in==true){
if (profit_control(start_p,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in true");
FileClose(Handle_Log);*/
}
if (profit_control(ii_0,takepercent_day,start_balance)==false)
{
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by day next_in true");
FileClose(Handle_Log);*/
return(0);
}
}
}
CheckTimeIn(MaxTime,MaxIn,MaxP,start_p);
//--------------------------------------------------------------------------------------Hydra
if (Hour()==hourr && Minute()==minutee && bar2!=Bars && GlobalVariableGet("UPSW")==0) {
GlobalVariableSet("UPSW",1);
//makefile_N();
bar2=Bars;
}
if (Hour()==hourr+1 && Minute()==0 && GlobalVariableGet("UPSW")==1)
{
GlobalVariableSet("UPSW",0);
}
//+------------------------------------------------------------------+
if (GlobalVariableGet("RUN")==1 && TimeLocal()<=GlobalVariableGet("runtime")+86400)
{
return;
}
if (GlobalVariableGet("RUN")==1 && TimeLocal()>GlobalVariableGet("runtime")+86400)
{
GlobalVariableSet("RUN",0);
}
ObjectCreate("run",OBJ_LABEL,0,0,0);
ObjectSet("run", OBJPROP_CORNER, 1);
ObjectSet("run", OBJPROP_COLOR, White);
ObjectSet("run", OBJPROP_XDISTANCE, 20);
ObjectSet("run", OBJPROP_YDISTANCE, Pos);
if (!Week15(W1Start,W5Over,start_t,stop_t,weekday) && OrdersTotal() == 0) {
ObjectSetText("run","未在設定時區內,現有戰役達成後將離開戰場",10,"微軟正黑體");
return;
}else {
ObjectSetText("run","已進入作戰時區內,全面啟動執行...",10,"微軟正黑體");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (BrakeSystem)
{
string Active="煞車系統啟動中";
string Deactive="煞車系統待命中";
color Light_status=Gold;
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSetString(0,"lightstatus",OBJPROP_FONT,"微軟正黑體");
ObjectSetInteger(0,"lightstatus",OBJPROP_FONTSIZE,10);
ObjectSetInteger(0,"lightstatus",OBJPROP_COLOR,Light_status);
int Price_Range;
int Time_Range;
int Now_Time = TimeCurrent();
double Now_Price = Close[0];
if (Last_Price != -1.0) {
Price_Range = Now_Price / Point - Last_Price / Point;
Time_Range = Now_Time - Last_Time;
//int Total_Orders = OrdersTotalCountByTypeANDMagic(OP_BUY, BuyMagic) + OrdersTotalCountByTypeANDMagic(OP_SELL, SellMagic);
if (MathAbs(Price_Range) >= MinPriceShot && Time_Range <= pSeconds) {
//if (Total_Orders < MaxOrdersCount) {
if (Now_Price > Last_Price) {
if ( MyOrderTotal_type(id1,1) > MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
if (Now_Price < Last_Price) {
if ( MyOrderTotal_type(id1,1) < MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
//} else {}//Comment("");
Last_Price = Now_Price;
Last_Time = Now_Time;
}else {
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (Time_Range >= pSeconds) {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
} else {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (TimeCurrent()<=SleepStop)
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active+", "+DoubleToStr((SleepStop-TimeCurrent())/60,0)+" 分鐘後啟動");
return;
}
}else {
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (MarginSleep) {
bool Pass=false;
if (AccountMargin() == 0) {Pass=true;}
else{
double Margin_R=(AccountEquity()/AccountMargin())*100;
if (MarginLimit >= Margin_R && !Pass) {
ObjectCreate("Margin",OBJ_LABEL,0,0,0);
ObjectSet("Margin", OBJPROP_CORNER, 1);
ObjectSet("Margin", OBJPROP_COLOR, Gold);
ObjectSet("Margin", OBJPROP_XDISTANCE, 20);
ObjectSet("Margin", OBJPROP_YDISTANCE, Pos+155);
ObjectSetText("Margin", "保證金比例低於 "+DoubleToStr(MarginLimit,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Margin");
}
}
}else {
ObjectDelete("Margin");
}
if (FloatEq) {
double Profit=AccountProfit();
if (Profit <= FloatAm) {
ObjectCreate("Float",OBJ_LABEL,0,0,0);
ObjectSet("Float", OBJPROP_CORNER, 1);
ObjectSet("Float", OBJPROP_COLOR, Gold);
ObjectSet("Float", OBJPROP_XDISTANCE, 20);
ObjectSet("Float", OBJPROP_YDISTANCE, Pos+175);
ObjectSetText("Float", "浮虧大於 "+DoubleToStr(FloatAm,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Float");
}
}else {
ObjectDelete("Float");
}
int li4;
int li8;
int li12;
int li16;
int li20;
int li24;
int li28;
color color32;
color color36;
color color40;
color color44;
color color48;
color color52;
color color56;
string ls_unused60;
color color68;
color color72;
color color76;
color color80;
color color84;
color color88;
color color92;
color color96;
string ls_unused100;
color color108;
int li_unused112;
double ihigh1128;
double ilow1136;
double iclose1144;
double iclose1152;
double ld1192;
double ld1248;
double ld1256;
int li1264;
int count1268;
double ld1316;
double ld1324;
int li1332;
int count1336;
int li992 = 0;
int li996 = 0;
int li1000 = 0;
int li1004 = 0;
int li1008 = 0;
int li1012 = 0;
li992 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
for (li1012 = 1; li1012 <= 5; li1012++) li996 = li996 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 10; li1012++) li1000 = li1000 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 20; li1012++) li1004 = li1004 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
li996 /= 5;
li1000 /= 10;
li1004 /= 20;
li1008 = (li992 + li996 + li1000 + li1004) / 4;
string ls_unused1016 = "";
string ls_unused1024 = "";
string dbl2str1032 = "";
string dbl2str1040 = "";
string dbl2str1048 = "";
string dbl2str1056 = "";
string ls_unused1064 = "";
string ls_unused1072 = "";
string ls1080 = "";
double iopen1088 = iOpen(NULL, PERIOD_D1, 0);
double iclose1096 = iClose(NULL, PERIOD_D1, 0);
double ld1104 = (Ask - Bid) / Point;
double ihigh1112 = iHigh(NULL, PERIOD_D1, 0);
double ilow1120 = iLow(NULL, PERIOD_D1, 0);
dbl2str1040 = DoubleToStr((iclose1096 - iopen1088) / Point, 0);
dbl2str1032 = DoubleToStr(ld1104, Digits - 4);
dbl2str1048 = DoubleToStr(li1008, Digits - 4);
ls1080 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
dbl2str1056 = DoubleToStr((ihigh1112 - ilow1120) / Point, 0);
if (iclose1096 >= iopen1088) {
ls_unused1064 = "-";
color108 = g_color1100;
}
if (iclose1096 < iopen1088) {
ls_unused1064 = "-";
color108 = g_color1104;
}
if (dbl2str1048 >= ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1108;
}
if (dbl2str1048 < ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1112;
}
double ld1160 = LotExponent;
int li1168 = gi108;
double ld1172 = TakeProfit;
bool bool1180 = UseEquityStop;
double ld1184 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1192 = Lots;
else ld1192 = 0.00001 * MathCeil(AccountBalance());
} else ld1192 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop_Hilo) f035(TrailStart_Hilo, TrailStop_Hilo, g_price312);
if (gi220) {
if (TimeCurrent() >= gi376) {
f024();
Print("Closed All due_Hilo to TimeOut");
}
}
if (gi372 == Time[0]) return (0);
gi372 = Time[0];
double ld1200 = f031();
if (bool1180) {
if (ld1200 < 0.0 && MathAbs(ld1200) > ld1184 / 100.0 * f07()) {
f024();
Print("Closed All due_Hilo to Stop Out");
gi424 = FALSE;
}
}
gi396 = f04();
if (gi396 == 0) gi360 = FALSE;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
gi412 = TRUE;
gi416 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
gi412 = FALSE;
gi416 = TRUE;
break;
}
}
}
if (gi396 > 0 && gi396 <= MaxTrades_A) {
RefreshRates();
gd336 = f032();
gd344 = f020();
if (gi412 && gd336 - Ask >= PipStep_Hilo * Point) gi408 = TRUE;
if (gi416 && Bid - gd344 >= PipStep_Hilo * Point) gi408 = TRUE;
}
if (gi396 < 1) {
gi416 = FALSE;
gi412 = FALSE;
gi408 = TRUE;
gd288 = AccountEquity();
}
if (gi408) {
gd336 = f032();
gd344 = f020();
if (gi416) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
RefreshRates();
gi420 = f03(1, gd384, Bid, slip_Hilo, Ask, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi408 = FALSE;
gi424 = TRUE;
} else {
if (gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
gi420 = f03(0, gd384, Ask, slip_Hilo, Bid, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi408 = FALSE;
gi424 = TRUE;
}
}
}
if (gi408 && gi396 < 1) {
ihigh1128 = iHigh(Symbol(), 0, 1);
ilow1136 = iLow(Symbol(), 0, 2);
g_bid320 = Bid;
g_ask328 = Ask;
if ((!gi416) && !gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
if (ihigh1128 > ilow1136) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi420 = f03(1, gd384, g_bid320, slip_Hilo, g_bid320, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi424 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi420 = f03(0, gd384, g_ask328, slip_Hilo, g_ask328, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi424 = TRUE;
}
}
if (gi420 > 0) gi376 = TimeCurrent() + 60.0 * (60.0 * gd224);
gi408 = FALSE;
}
}
gi396 = f04();
g_price312 = 0;
double ld1208 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price312 += OrderOpenPrice() * OrderLots();
ld1208 += OrderLots();
}
}
}
if (gi396 > 0) g_price312 = NormalizeDouble(g_price312 / ld1208, Digits);
if (gi424) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
g_price280 = g_price312 + ld1172 * Point;
gd_unused296 = g_price280;
gd400 = g_price312 - g_pips236 * Point;
gi360 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
g_price280 = g_price312 - ld1172 * Point;
gd_unused304 = g_price280;
gd400 = g_price312 + g_pips236 * Point;
gi360 = TRUE;
}
}
}
}
if (gi424) {
if (gi360 == TRUE) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) OrderModify(OrderTicket(), g_price312, OrderStopLoss(), g_price280, 0, Yellow);
gi424 = FALSE;
}
}
}
double ld1216 = LotExponent;
int li1224 = gi108;
double ld1228 = TakeProfit;
bool bool1236 = UseEquityStop;
double ld1240 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1248 = Lots;
else ld1248 = 0.00001 * MathCeil(AccountBalance());
} else ld1248 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop15) f021(TrailStart15, TrailStop15, g_price596);
if (gi532) {
if (TimeCurrent() >= gi660) {
f018();
Print("Closed All due to TimeOut");
}
}
if (gi656 != Time[0]) {
gi656 = Time[0];
ld1256 = f029();
if (bool1236) {
if (ld1256 < 0.0 && MathAbs(ld1256) > ld1240 / 100.0 * f016()) {
f018();
Print("Closed All due to Stop Out");
gi708 = FALSE;
}
}
gi680 = f05();
if (gi680 == 0) gi644 = FALSE;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
gi696 = TRUE;
gi700 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
gi696 = FALSE;
gi700 = TRUE;
break;
}
}
}
if (gi680 > 0 && gi680 <= MaxTrades_B) {
RefreshRates();
gd620 = f036();
gd628 = f028();
if (gi696 && gd620 - Ask >= PipStep15 * Point) gi692 = TRUE;
if (gi700 && Bid - gd628 >= PipStep15 * Point) gi692 = TRUE;
}
if (gi680 < 1) {
gi700 = FALSE;
gi696 = FALSE;
gi692 = TRUE;
gd572 = AccountEquity();
}
if (gi692) {
gd620 = f036();
gd628 = f028();
if (gi700) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
RefreshRates();
gi704 = f02(1, gd668, Bid, slip15, Ask, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi692 = FALSE;
gi708 = TRUE;
} else {
if (gi696) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
gi704 = f02(0, gd668, Ask, slip15, Bid, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi692 = FALSE;
gi708 = TRUE;
}
}
}
}
if (g_datetime728 != iTime(NULL, g_timeframe496, 0)) {
li1264 = OrdersTotal();
count1268 = 0;
for (int li1272 = li1264; li1272 >= 1; li1272--) {
OrderSelect(li1272 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) count1268++;
}
if (li1264 == 0 || count1268 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid604 = Bid;
g_ask612 = Ask;
gi664 = gi680;
gd668 = ld1248;
if (iclose1144 > iclose1152) {
gi704 = f02(1, gd668, g_bid604, slip15, g_bid604, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi708 = TRUE;
} else {
gi704 = f02(0, gd668, g_ask612, slip15, g_ask612, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi708 = TRUE;
}
if (gi704 > 0) gi660 = TimeCurrent() + 60.0 * (60.0 * gd536);
gi692 = FALSE;
}
g_datetime728 = iTime(NULL, g_timeframe496, 0);
}
gi680 = f05();
g_price596 = 0;
double ld1276 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price596 += OrderOpenPrice() * OrderLots();
ld1276 += OrderLots();
}
}
}
if (gi680 > 0) g_price596 = NormalizeDouble(g_price596 / ld1276, Digits);
if (gi708) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
g_price564 = g_price596 + ld1228 * Point;
gd_unused580 = g_price564;
gd684 = g_price596 - g_pips508 * Point;
gi644 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
g_price564 = g_price596 - ld1228 * Point;
gd_unused588 = g_price564;
gd684 = g_price596 + g_pips508 * Point;
gi644 = TRUE;
}
}
}
}
if (gi708) {
if (gi644 == TRUE) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) OrderModify(OrderTicket(), g_price596, OrderStopLoss(), g_price564, 0, Yellow);
gi708 = FALSE;
}
}
}
double ld1284 = LotExponent;
int li1292 = gi108;
double ld1296 = TakeProfit;
bool bool1304 = UseEquityStop;
double ld1308 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1316 = Lots;
else ld1316 = 0.00001 * MathCeil(AccountBalance());
} else ld1316 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop16) f034(TrailStart16, TrailStop16, g_price880);
if (gi816) {
if (TimeCurrent() >= gi944) {
f0_0();
Print("Closed All due to TimeOut");
}
}
if (gi940 != Time[0]) {
gi940 = Time[0];
ld1324 = f08();
if (bool1304) {
if (ld1324 < 0.0 && MathAbs(ld1324) > ld1308 / 100.0 * f030()) {
f0_0();
Print("Closed All due to Stop Out");
gi992 = FALSE;
}
}
gi964 = f012();
if (gi964 == 0) gi928 = FALSE;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
gi980 = TRUE;
gi984 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
gi980 = FALSE;
gi984 = TRUE;
break;
}
}
}
if (gi964 > 0 && gi964 <= MaxTrades_C) {
RefreshRates();
gd904 = f017();
gd912 = f027();
if (gi980 && gd904 - Ask >= PipStep16 * Point) gi976 = TRUE;
if (gi984 && Bid - gd912 >= PipStep16 * Point) gi976 = TRUE;
}
if (gi964 < 1) {
gi984 = FALSE;
gi980 = FALSE;
gd856 = AccountEquity();
}
if (gi976) {
gd904 = f017();
gd912 = f027();
if (gi984) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
RefreshRates();
gi988 = f06(1, gd952, Bid, slip16, Ask, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi976 = FALSE;
gi992 = TRUE;
} else {
if (gi980) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
gi988 = f06(0, gd952, Ask, slip16, Bid, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi976 = FALSE;
gi992 = TRUE;
}
}
}
}
if (g_datetime1012 != iTime(NULL, g_timeframe784, 0)) {
li1332 = OrdersTotal();
count1336 = 0;
for (int li1340 = li1332; li1340 >= 1; li1340--) {
OrderSelect(li1340 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) count1336++;
}
if (li1332 == 0 || count1336 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid888 = Bid;
g_ask896 = Ask;
gi948 = gi964;
gd952 = ld1316;
if (iclose1144 > iclose1152) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi988 = f06(1, gd952, g_bid888, slip16, g_bid888, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi992 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi988 = f06(0, gd952, g_ask896, slip16, g_ask896, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi992 = TRUE;
}
}
if (gi988 > 0) gi944 = TimeCurrent() + 60.0 * (60.0 * gd820);
gi976 = FALSE;
}
g_datetime1012 = iTime(NULL, g_timeframe784, 0);
}
gi964 = f012();
g_price880 = 0;
double ld1344 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price880 += OrderOpenPrice() * OrderLots();
ld1344 += OrderLots();
}
}
}
if (gi964 > 0) g_price880 = NormalizeDouble(g_price880 / ld1344, Digits);
if (gi992) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
g_price848 = g_price880 + ld1296 * Point;
gd_unused864 = g_price848;
gd968 = g_price880 - g_pips792 * Point;
gi928 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
g_price848 = g_price880 - ld1296 * Point;
gd_unused872 = g_price848;
gd968 = g_price880 + g_pips792 * Point;
gi928 = TRUE;
}
}
}
}
if (gi992) {
if (gi928 == TRUE) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) OrderModify(OrderTicket(), g_price880, OrderStopLoss(), g_price848, 0, Yellow);
gi992 = FALSE;
}
}
}
//Handle_Log=0;
return (0);
}
int f04() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f024() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip_Hilo, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip_Hilo, Red);
}
Sleep(1000);
}
}
}
int f03(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM1(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f022(Bid, ai32), f019(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f011(Ask, ai32), f01(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f022(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f011(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f019(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f01(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f031() {
double ld_ret_0 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f035(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f07() {
if (f04() == 0) gd428 = AccountEquity();
if (gd428 < gd436) gd428 = gd436;
else gd428 = AccountEquity();
gd436 = AccountEquity();
return (gd428);
}
double f032() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f020() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f05() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f018() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip15, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip15, Red);
}
Sleep(1000);
}
}
}
int f02(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM2(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f013(Bid, ai32), f025(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f033(Ask, ai32), f026(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f013(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f033(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f025(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f026(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f029() {
double ld_ret_0 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f021(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f016() {
if (f05() == 0) gd712 = AccountEquity();
if (gd712 < gd720) gd712 = gd720;
else gd712 = AccountEquity();
gd720 = AccountEquity();
return (gd712);
}
double f036() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f028() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f012() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f0_0() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip16, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip16, Red);
}
Sleep(1000);
}
}
}
int f06(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM3(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f014(Bid, ai32), f09(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f023(Ask, ai32), f010(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f014(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f023(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f09(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f010(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f08() {
double ld_ret_0 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f034(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f030() {
if (f012() == 0) gd996 = AccountEquity();
if (gd996 < gd1004) gd996 = gd1004;
else gd996 = AccountEquity();
gd1004 = AccountEquity();
return (gd996);
}
double f017() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f027() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
string f015(string as_0) {
int str_len8 = StringLen(as_0);
bool li_ret12 = FALSE;
for (int li16 = 0; li16 < str_len8; li16++) {
if (StringSubstr(as_0, li16, 1) == "1") li_ret12 = li_ret12 + MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "2") li_ret12 = li_ret12 + 2.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "3") li_ret12 = li_ret12 + 3.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "4") li_ret12 = li_ret12 + 4.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "5") li_ret12 = li_ret12 + 5.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "6") li_ret12 = li_ret12 + 6.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "7") li_ret12 = li_ret12 + 7.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "8") li_ret12 = li_ret12 + 8.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "9") li_ret12 = li_ret12 + 9.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "A") li_ret12 = li_ret12 + 10.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "B") li_ret12 = li_ret12 + 11.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "C") li_ret12 = li_ret12 + 12.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "D") li_ret12 = li_ret12 + 13.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "E") li_ret12 = li_ret12 + 14.0 * MathPow(16, str_len8 - li16 - 1);
else
if (StringSubstr(as_0, li16, 1) == "F") li_ret12 = li_ret12 + 15.0 * MathPow(16, str_len8 - li16 - 1);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return (li_ret12);
}
string MakeDateTime(string strDate, string strTime)
{
// Print("Converting Forex Factory Time into Metatrader time..."); //added by MN
// Converts forexfactory time & date into yyyy.mm.dd hh:mm
int n1stDash = StringFind(strDate, "-");
int n2ndDash = StringFind(strDate, "-", n1stDash+1);
string strMonth = StringSubstr(strDate, 0, 2);
string strDay = StringSubstr(strDate, 3, 2);
string strYear = StringSubstr(strDate, 6, 4);
// strYear = "20" + strYear;
int nTimeColonPos = StringFind(strTime, ":");
string strHour = StringSubstr(strTime, 0, nTimeColonPos);
string strMinute = StringSubstr(strTime, nTimeColonPos+1, 2);
string strAM_PM = StringSubstr(strTime, StringLen(strTime)-2);
int nHour24 = StrToInteger(strHour);
if ((strAM_PM == "pm" || strAM_PM == "PM") && nHour24 != 12)
{
nHour24 += 12;
}
if ((strAM_PM == "am" || strAM_PM == "AM") && nHour24 == 12)
{
nHour24 = 0;
}
string strHourPad = "";
if (nHour24 < 10)
strHourPad = "0";
return(StringConcatenate(strYear, ".", strMonth, ".", strDay, " ", strHourPad, nHour24, ":", strMinute));
}
bool profit_control(int i_0,double takepercent_,double start_balance)
{
double today_profit;
int i1=StrToTime(TimeToStr(TimeCurrent()+86400, TIME_DATE));
today_profit=((GetProfitFromDateInCurrency(i_0)+AccountProfit())/start_balance)*100;
if (today_profit>=takepercent_)
{
return(false);
}
return(true);
}
void displayprofit(int start_p,bool next_in,double start_balance)
{
double today_profit;
string display;
ObjectCreate("percent",OBJ_LABEL,0,0,0);
ObjectSet("percent", OBJPROP_CORNER, 1);
ObjectSet("percent", OBJPROP_COLOR, White);
ObjectSet("percent", OBJPROP_XDISTANCE, 20);
ObjectSet("percent", OBJPROP_YDISTANCE, Pos+30);
ObjectCreate("start_p",OBJ_LABEL,0,0,0);
ObjectSet("start_p", OBJPROP_CORNER, 1);
ObjectSet("start_p", OBJPROP_COLOR, White);
ObjectSet("start_p", OBJPROP_XDISTANCE, 20);
ObjectSet("start_p", OBJPROP_YDISTANCE, Pos+50);
ObjectSetText("start_p","進場經過時間 "+ DoubleToStr((TimeCurrent()-start_p)/60,1)+ " 分鐘"+" ; "+OrdersTotal()+" 兵力在戰場上",10,"微軟正黑體");
if (next_in==true)
{
today_profit=((GetProfitFromDateInCurrency(start_p)+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
GlobalVariableSet("display",today_profit);
ObjectSetText("percent","單次擄獲狂派戰俘"+display+"%"+" ; 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectCreate("takepercent_day",OBJ_LABEL,0,0,0);
ObjectSet("takepercent_day", OBJPROP_CORNER, 1);
ObjectSet("takepercent_day", OBJPROP_COLOR, White);
ObjectSet("takepercent_day", OBJPROP_XDISTANCE, 20);
ObjectSet("takepercent_day", OBJPROP_YDISTANCE, Pos+70);
ObjectSetText("takepercent_day","今日擄獲狂派戰俘累積至"+display+" ; 最大暫時被擄穫兵力 "+DoubleToStr(GlobalVariableGet("MaxEquity"),2)+" %",10,"微軟正黑體");
}
if (next_in==false)
{
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectSetText("percent","今日擄獲狂派戰俘累積至"+display+"%"+" 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
}
}
double GetProfitFromDateInCurrency(int today) {
double profit = 0;
int total = OrdersHistoryTotal();
for (int i = 0; i < total; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL ) {
if (today < OrderCloseTime()) profit += OrderProfit() + OrderCommission() + OrderSwap();
}
}
}
return (profit);
}
bool SLClose (double percent,double start_balance) {
if (AccountProfit()<=0)
{
if ((MathAbs(AccountProfit())/start_balance)*100>=percent)
{
return(true);
}
else
{
return(false);
}
}else
{
return(false);
}
}
void iCloseOrders(string myType,string currency,int id1,int type)
{
if (MyOrderTotal_err(id1)==0) return(0);
int C0_cnt,close_t[],t_cnt;
double percentlots,nd_profit;
if (myType=="Del"&&type==0)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_BUYSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="Del"&&type==1)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_SELLSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="100%")
{
for(C0_cnt=0;C0_cnt<OrdersTotal();C0_cnt++) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false)
{
//Alert(Symbol()+" OrderSelect Error");
continue;
}
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
ArrayResize(close_t,t_cnt+1);
close_t[t_cnt]=OrderTicket();
t_cnt++;
}
}
for(int i=ArraySize(close_t)-1;i>=0;i--)
{
if (OrderSelect(close_t[i],SELECT_BY_TICKET)==false)
{
Alert(Symbol()+" OrderSelect Error By Tickets");continue;
}
else
{
percentlots=OrderLots();
OrderClose(close_t[i],percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="80%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.8;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="50%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.5;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="All") //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderMagicNumber()!=0){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="BUY"&&type==0) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_BUY && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="SELL"&&type==1) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_SELL && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
}
int MyOrderTotal_err(int id1)//訂單總數函式
{
int x=0;//符合條件的BUY單數量(記次變數)
for(int z=0;z<OrdersTotal();z++)//執行N次篩選(N=訂單總數)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);//用"流水號"找訂單
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ))//挑選出同貨幣對 && BUY單 && MagicNumber=本程式 的訂單
{
x++;//符合節選結果的訂單總數
}
}
return(x);//回傳
}
int MyOrderTotal_type(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ) && OrderType()==type)
{
x++;//
}
}
return(x);
}
bool iTimeControl(int myStartHour,int myStopHour)
{
bool EA_Valid=false;
if(myStopHour == myStartHour) EA_Valid = true;
if(myStopHour < myStartHour)
{
if (TimeHour(TimeLocal()) >= myStartHour || TimeHour(TimeLocal()) < myStopHour) EA_Valid = true;
}
if (myStopHour > myStartHour) {
if ((TimeHour(TimeLocal()) >= myStartHour && TimeHour(TimeLocal()) < myStopHour))
EA_Valid = true;
}
return(EA_Valid);
}
bool Week15 (int start,int over,int myStartHour,int myStopHour,string weekday)
{
bool EA_Valid=false;
int Dayweek=TimeDayOfWeek(TimeLocal());
if (
(
(
Dayweek == 1 && TimeHour(TimeLocal()) < start
)
||
(
Dayweek == StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1)) && TimeHour(TimeLocal()) >= over
)
||
(
Dayweek > StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1))
)
)
&& Week15SW) {
EA_Valid=false;
}else {
if (iTimeControl(myStartHour,myStopHour)) {
if (StringFind(weekday,DoubleToStr(Dayweek,0),0) >= 0) {
EA_Valid=true;
}else {
EA_Valid=false;
}
}else {
EA_Valid=false;
}
}
return(EA_Valid);
}
void CheckTimeIn(int MaxTime,int MaxIn,double MaxP,int start_p)
{
int Handle_Log;
int Valid;
int RunTime=(TimeCurrent()-start_p)/60;
if (RunTime>=MaxTime && OrdersTotal() >= MaxIn && GlobalVariableGet("display")>= MaxP)
{
GlobalVariableSet("next_sw",1);
Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by CheckTimeIn");
FileClose(Handle_Log);
}
}
string Base64Decode(string in/*,string &out*/)
{
string out;
int i=0,len=StringLen(in);
int shift=0,accum=0;
while(i<len)
{
int value=ExtBase64Decode[StringGetChar(in,i)];
if(value<0 || value>63) break;
accum<<=6;
shift+=6;
accum|=value;
if(shift>=8)
{
shift-=8;
value=accum >> shift;
out=out+CharToStr(value & 0xFF);
}
i++;
}
//----
return(out);
}
bool ThreeM1(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(g_magic17616,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(g_magic17616,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM2(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17616,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17616,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM3(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
int MyOrderTotal_id(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id1 && OrderType()==type)
{
x++;//
}
}
return(x);
}
#import "wininet.dll"
int InternetAttemptConnect(
int dwReserved=0
);
int InternetOpenA(uchar &lpszAgent[],int dwAccessType,uchar &lpszProxyName[],uchar &lpszProxyBypass[],int dwFlags);
int InternetConnectA(int hInternetSession,uchar &lpszServerName[],int nServerPort,uchar &lpszUserName[],uchar &lpszPassword[],int nService,int nFlags,int dwContext);
bool InternetCloseHandle(
int hInet
);
bool FtpPutFileA (
int hFtpSession,
string lpszLocalFile,
string lpszRemoteFile,
int dwFlags,
int dwContext
);
bool FtpGetFileA (int hFtpSession,uchar &lpszRemoteFile[],uchar &lpszNewFile[],bool fFailIfExists,int dwFlagsAndAttributes,uint dwFlags,int dwContext);
bool FtpCreateDirectoryA(
int hConnect,
string lpszDirectory
);
bool FtpSetCurrentDirectoryA(
int hConnect,
string lpszDirectory
);
#import
#define INTERNET_FLAG_PASSIVE 0x08000000
#define INTERNET_FLAG_RELOAD 0x80000000
#define INTERNET_FLAG_EXISTING_CONNECT 0x20000000
#define INTERNET_SERVICE_FTP 1
#define FTP_TRANSFER_TYPE_ASCII 1
#define FTP_TRANSFER_TYPE_BINARY 2
#define FTP_TRANSFER_TYPE_UNKNOWN 3
#define INTERNET_FLAgHYPERLINK 0x00000400
static int ExtBase64Encode[64]={ 'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/' };
static int ExtBase64Decode[256]={
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
string t1 = "";
//extern double Account = 1872377.0;
int GMT=8;
extern string T0="-------------ESP戰艦穩定煞車系統------------";
extern bool BrakeSystem=true;
int pSeconds=14;
extern string T1="能量偵測靈敏度";
extern int Energy = 40;
extern string T2="能量煞車引擎啟動時間";
extern int SleepTime=15;
int SleepStop=0;
int Position=0;
extern string T5="-------------保證金比例控制模組--------------";
extern bool MarginSleep=true;
extern double MarginLimit=5000;
extern string T6="-------------浮虧控制模組(以金額計算)-------------";
extern bool FloatEq=true;
extern double FloatAm=-800;
extern string T7="開始時間,格式為hh";
extern int start_t=00;
extern string T8="結束時間,格式為hh";
extern int stop_t=00;
extern string T9="週一執行,鍵入1即可";
extern string T10="週一週二鍵入12,以下類推";
extern string weekday="12345";
extern bool Week15SW=true;
extern string W1="禮拜一幾點開始";
extern int W1Start=8;
extern string W2="最後一天幾點結束";
extern int W5Over=17;
extern string T11="止盈止損計算本金基準";
extern double I_balance=0;
extern string T12="止損後當日不再出兵";
extern bool SleepLoss=true;
extern string T13="最大總浮虧(以餘額計算)";
extern double SLpercent=15.0;
extern string T14="次止盈,每次最多獲利%,立即平倉歸零重啟新局";
extern double takepercent=1;
string T111="每次止盈開關";
bool next_in=true;
extern string T15="日止盈,每日最多獲利%,立即停止交易,隔日重新啟動";
extern double takepercent_day=100;
extern string T16="每局結束幾分鐘後重新啟動";
extern double NextTime=2;
extern string T9_="-------------------小虧為贏模組-------------";
extern string T17="每局最長時間(分鐘)";
extern int MaxTime=150;
extern string T18="每局最多兵力";
extern int MaxIn=40;
extern string T19="達成以上條件小虧為贏";
extern double MaxP=0.5;
extern string T20="-------------------------------------------";
extern string T21="手數";
extern double Lots = 0.01;
extern string T22="馬丁倍率";
extern double LotExponent = 1.618;
extern string T23="----------------三方向導航-----------------";
extern bool BSB=true;
int gi108 = 2;
double MaxLots = 5.0;
bool MM = FALSE;
extern string T24="獲利點數";
extern double TakeProfit = 100.0;
bool UseEquityStop = FALSE;
double TotalEquityRisk = 20.0;
string t2 = "Time Setting";
bool CloseFriday = false;
int CloseFridayHour = 17;
bool OpenMondey = false;
int OpenMondeyHour = 0;
string t3 = "";
extern string T25="A模組最多單數";
extern int MaxTrades_A=10;
bool gi220 = FALSE;
double gd224 = 48.0;
bool UseTrailingStop_Hilo = FALSE;
double gpips236 = 500.0;
double TrailStart_Hilo = 10.0;
double TrailStop_Hilo = 5.0;
double PipStep_Hilo = 300.0;
double slip_Hilo = 3.0;
int MagicNumber_Hilo = 11111;
double gprice280;
double gd288;
double gd_unused296;
double gd_unused304;
double gprice312;
double gbid320;
double gask328;
double gd336;
double gd344;
double gd352;
bool gi360;
string gs364 = "";
int gi372 = 0;
int gi376;
int gi380 = 0;
double gd384;
int gpos392 = 0;
int gi396;
double gd400 = 0.0;
bool gi408 = FALSE;
bool gi412 = FALSE;
bool gi416 = FALSE;
int gi420;
bool gi424 = FALSE;
double gd428;
double gd436;
string t4 = "";
extern string T26="B模組最多單數";
extern int MaxTrades_B=10;
int gtimeframe496 = PERIOD_H1;
bool UseTrailingStop15 = FALSE;
double gpips508 = 500.0;
double TrailStart15 = 10.0;
double TrailStop15 = 5.0;
bool gi532 = FALSE;
double gd536 = 48.0;
double PipStep15 = 300.0;
double slip15 = 3.0;
int gmagic17615 = 12324;
double gprice564;
double gd572;
double gd_unused580;
double gd_unused588;
double gprice596;
double gbid604;
double gask612;
double gd620;
double gd628;
double gd636;
bool gi644;
string gs648 = "";
int gi656 = 0;
int gi660;
int gi664 = 0;
double gd668;
int gpos676 = 0;
int gi680;
double gd684 = 0.0;
bool gi692 = FALSE;
bool gi696 = FALSE;
bool gi700 = FALSE;
int gi704;
bool gi708 = FALSE;
double gd712;
double gd720;
int gdatetime728 = 1;
string t5 = "";
extern string T27="C模組最多單數";
extern int MaxTrades_C=10;
int gtimeframe784 = PERIOD_M1;
bool UseTrailingStop16 = FALSE;
double gpips792 = 500.0;
double TrailStart16 = 10.0;
double TrailStop16 = 5.0;
bool gi816 = FALSE;
double gd820 = 48.0;
double PipStep16 = 300.0;
double slip16 = 3.0;
int gmagic17616 = 16794;
double gprice848;
double gd856;
double gd_unused864;
double gd_unused872;
double gprice880;
double gbid888;
double gask896;
double gd904;
double gd912;
double gd920;
bool gi928;
string gs932 = "";
int gi940 = 0;
int gi944;
int gi948 = 0;
double gd952;
int gpos960 = 0;
int gi964;
double gd968 = 0.0;
bool gi976 = FALSE;
bool gi980 = FALSE;
bool gi984 = FALSE;
int gi988;
bool gi992 = FALSE;
double gd996;
double gd1004;
int gdatetime1012 = 1;
int gtimeframe1024 = PERIOD_M1;
int gtimeframe1028 = PERIOD_M5;
int gtimeframe1032 = PERIOD_M15;
int gtimeframe1036 = PERIOD_M30;
int gtimeframe1040 = PERIOD_H1;
int gtimeframe1044 = PERIOD_H4;
int gtimeframe1048 = PERIOD_D1;
bool gcorner1052 = TRUE;
int gi1056 = 0;
int gi1060 = 10;
int gwindow1064 = 0;
bool gi1068 = TRUE;
bool gi_unused1072 = TRUE;
bool gi1076 = FALSE;
int gcolor1080 = Gray;
int gcolor1084 = Gray;
int gcolor1088 = Gray;
int gcolor1092 = DarkOrange;
int gi_unused1096 = 36095;
int gcolor1100 = Lime;
int gcolor1104 = OrangeRed;
int gi1108 = 65280;
int gi1112 = 17919;
int gcolor1116 = Lime;
int gcolor1120 = Red;
int gcolor1124 = Orange;
int gperiod1128 = 8;
int gperiod1132 = 17;
int gperiod1136 = 9;
int gapplied_price1140 = PRICE_CLOSE;
int gcolor1144 = Lime;
int gcolor1148 = Tomato;
int gcolor1152 = Green;
int gcolor1156 = Red;
string gs_unused1160 = "<<<< STR Indicator Settings >>>>>>>>>>>>>";
string gs_unused1168 = "<<<< RSI Settings >>>>>>>>>>>>>";
int gperiod1176 = 9;
int gapplied_price1180 = PRICE_CLOSE;
string gs_unused1184 = "<<<< CCI Settings >>>>>>>>>>>>>>";
int gperiod1192 = 13;
int gapplied_price1196 = PRICE_CLOSE;
string gs_unused1200 = "<<<< STOCH Settings >>>>>>>>>>>";
int gperiod1208 = 5;
int gperiod1212 = 3;
int gslowing1216 = 3;
int gma_method1220 = MODE_EMA;
string gs_unused1224 = "<<<< STR Colors >>>>>>>>>>>>>>>>";
int gcolor1232 = Lime;
int gcolor1236 = Red;
int gcolor1240 = Orange;
string gs_unused1244 = "<<<< MA Settings >>>>>>>>>>>>>>";
int gperiod1252 = 5;
int gperiod1256 = 9;
int gma_method1260 = MODE_EMA;
int gapplied_price1264 = PRICE_CLOSE;
string gs_unused1268 = "<<<< MA Colors >>>>>>>>>>>>>>";
int gcolor1276 = Lime;
int gcolor1280 = Red;
string gs_dummy1292;
string gtext1464;
string gtext1472;
bool gi1480 = TRUE;
string KEY = "";
int gi1492;
int gstr2int1496;
int gstr2int1500;
int gstr2int1504;
int MinPriceShot;
string maindata[300][7];
double start_balance,point;
int start_p,id1,id2,bar2;
int Pos=50;
int hourr=0;
int minutee;
int count;
bool NewsgetSW=false;
double Last_Price=-1.0;
int Last_Time=0;
int init() {
if (IsTesting()==true) {return(0);}
GlobalVariableSet("Dhamar"+Symbol(),WindowHandle(Symbol(),Period()));
ObjectCreate("Expert",OBJ_LABEL,0,0,0);
ObjectSet("Expert", OBJPROP_CORNER, 1);
ObjectSet("Expert", OBJPROP_COLOR, White);
ObjectSet("Expert", OBJPROP_XDISTANCE, 150);
ObjectSet("Expert", OBJPROP_YDISTANCE, 0);
ObjectSetText("Expert", WindowExpertName(),15,"微軟正黑體", White);
//+------------------------------------------------------------------+
MinPriceShot=Energy;
//+------------------------------------------------------------------+
bar2=Bars;
if(Digits == 5 ||Digits == 3)
{
point=Point*10;
}
else
{
point=Point;
}
//+------------------------------------------------------------------+
double Position_L=Bid+Position*point;
ObjectCreate("Light",OBJ_ARROW,0,0,0);
ObjectSet("Light",OBJPROP_ARROWCODE,108);
ObjectSet("Light", OBJPROP_CORNER, 1);
ObjectSet("Light", OBJPROP_COLOR, Lime);
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light",OBJPROP_WIDTH,5);
ObjectCreate("Light2",OBJ_ARROW,0,0,0);
ObjectSet("Light2",OBJPROP_ARROWCODE,161);
ObjectSet("Light2", OBJPROP_CORNER, 1);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_WIDTH,5);
ObjectCreate("lightstatus",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"lightstatus", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"lightstatus", OBJPROP_COLOR, clrGold);
ObjectSetInteger(0,"lightstatus", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"lightstatus", OBJPROP_YDISTANCE, Pos+135);
ObjectSetInteger(0,"lightstatus", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
//+------------------------------------------------------------------+
GlobalVariableSet("next_sw",0);
if (!GlobalVariableCheck("start_balance"))
{
GlobalVariableSet("start_balance",AccountBalance());
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
if (!GlobalVariableCheck("start_p"))
{
GlobalVariableSet("start_p",TimeCurrent());
}
start_p=GlobalVariableGet("start_p");
MathSrand(TimeLocal());
for (int i=1;i<10;i++)
{minutee=1+((59*MathRand())/32768); }
GlobalVariableSet("RUN",0);
GlobalVariableSet("UPSW",0);
GlobalVariableSet("WSW",0);
GlobalVariableSet("RUNEA",0);
GlobalVariableSet("DNSW",0);
if (GlobalVariableCheck("MaxEquity")==false)
{GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);}
ObjectCreate(0,"Newsinfo",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo", OBJPROP_YDISTANCE, Pos+95);
ObjectSetInteger(0,"Newsinfo", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
ObjectCreate(0,"Newsinfo2",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_YDISTANCE, Pos+115);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
string ls4;
string ls12;
string ls20;
string ls28;
string ls36;
string ls44;
gd352 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd636 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd920 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
ObjectCreate("Lable1", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable1", OBJPROP_CORNER, 2);
ObjectSet("Lable1", OBJPROP_XDISTANCE, 23);
ObjectSet("Lable1", OBJPROP_YDISTANCE, 21);
gtext1472 = "";
ObjectSetText("Lable1", gtext1472, 12, "Arial", DeepSkyBlue);
ObjectCreate("Lable", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable", OBJPROP_CORNER, 2);
ObjectSet("Lable", OBJPROP_XDISTANCE, 3);
ObjectSet("Lable", OBJPROP_YDISTANCE, 1);
gtext1464 = "";
ObjectSetText("Lable", gtext1464, 10, "Arial", DeepSkyBlue);
if (false/*gi1480*/) {
if (KEY != "") {
gi1492 = 0;
for (int li_0 = 0; li_0 < StringLen(KEY); li_0++) {
if (StringSubstr(KEY, li_0, 1) != "X") ls4 = ls4 + StringSubstr(KEY, li_0, 1);
else {
ls12 = ls12 + f015(ls4);
ls4 = "";
}
}
for (li_0 = 0; li_0 < StringLen(ls12); li_0 += 2) {
if (StringSubstr(ls12, li_0, 2) == "55") ls20 = ls20 + "0";
else {
if (StringSubstr(ls12, li_0, 2) == "21") ls20 = ls20 + "1";
else {
if (StringSubstr(ls12, li_0, 2) == "98") ls20 = ls20 + "2";
else {
if (StringSubstr(ls12, li_0, 2) == "42") ls20 = ls20 + "3";
else {
if (StringSubstr(ls12, li_0, 2) == "10") ls20 = ls20 + "4";
else {
if (StringSubstr(ls12, li_0, 2) == "14") ls20 = ls20 + "5";
else {
if (StringSubstr(ls12, li_0, 2) == "88") ls20 = ls20 + "6";
else {
if (StringSubstr(ls12, li_0, 2) == "66") ls20 = ls20 + "7";
else {
if (StringSubstr(ls12, li_0, 2) == "33") ls20 = ls20 + "8";
else {
if (StringSubstr(ls12, li_0, 2) == "32") ls20 = ls20 + "9";
else {
if (StringSubstr(ls12, li_0, 2) == "96") ls20 = ls20 + "a";
else {
if (StringSubstr(ls12, li_0, 2) == "30") ls20 = ls20 + "b";
else {
if (StringSubstr(ls12, li_0, 2) == "77") ls20 = ls20 + "c";
else {
if (StringSubstr(ls12, li_0, 2) == "90") ls20 = ls20 + "d";
else {
if (StringSubstr(ls12, li_0, 2) == "24") ls20 = ls20 + "e";
else {
if (StringSubstr(ls12, li_0, 2) == "29") ls20 = ls20 + "f";
else {
if (StringSubstr(ls12, li_0, 2) == "39") ls20 = ls20 + "g";
else {
if (StringSubstr(ls12, li_0, 2) == "48") ls20 = ls20 + "h";
else {
if (StringSubstr(ls12, li_0, 2) == "56") ls20 = ls20 + "i";
else {
if (StringSubstr(ls12, li_0, 2) == "16") ls20 = ls20 + "j";
else {
if (StringSubstr(ls12, li_0, 2) == "62") ls20 = ls20 + "k";
else {
if (StringSubstr(ls12, li_0, 2) == "15") ls20 = ls20 + "l";
else {
if (StringSubstr(ls12, li_0, 2) == "71") ls20 = ls20 + "m";
else {
if (StringSubstr(ls12, li_0, 2) == "81") ls20 = ls20 + "n";
else {
if (StringSubstr(ls12, li_0, 2) == "93") ls20 = ls20 + "o";
else {
if (StringSubstr(ls12, li_0, 2) == "74") ls20 = ls20 + "p";
else {
if (StringSubstr(ls12, li_0, 2) == "83") ls20 = ls20 + "q";
else {
if (StringSubstr(ls12, li_0, 2) == "44") ls20 = ls20 + "r";
else {
if (StringSubstr(ls12, li_0, 2) == "51") ls20 = ls20 + "s";
else {
if (StringSubstr(ls12, li_0, 2) == "69") ls20 = ls20 + "t";
else {
if (StringSubstr(ls12, li_0, 2) == "40") ls20 = ls20 + "u";
else {
if (StringSubstr(ls12, li_0, 2) == "73") ls20 = ls20 + "v";
else {
if (StringSubstr(ls12, li_0, 2) == "59") ls20 = ls20 + "w";
else {
if (StringSubstr(ls12, li_0, 2) == "36") ls20 = ls20 + "x";
else {
if (StringSubstr(ls12, li_0, 2) == "26") ls20 = ls20 + "y";
else {
if (StringSubstr(ls12, li_0, 2) == "25") ls20 = ls20 + "z";
else {
if (StringSubstr(ls12, li_0, 2) == "28") ls20 = ls20 + "!";
else {
if (StringSubstr(ls12, li_0, 2) == "65") ls20 = ls20 + "&";
else {
if (StringSubstr(ls12, li_0, 2) == "52") ls20 = ls20 + "#";
else {
if (StringSubstr(ls12, li_0, 2) == "57") ls20 = ls20 + "$";
else {
if (StringSubstr(ls12, li_0, 2) == "31") ls20 = ls20 + "%";
else {
if (StringSubstr(ls12, li_0, 2) == "91") ls20 = ls20 + "*";
else {
if (StringSubstr(ls12, li_0, 2) == "60") ls20 = ls20 + "+";
else {
if (StringSubstr(ls12, li_0, 2) == "92") ls20 = ls20 + "-";
else {
if (StringSubstr(ls12, li_0, 2) == "34") ls20 = ls20 + "?";
else {
if (StringSubstr(ls12, li_0, 2) == "46") ls20 = ls20 + "^";
else {
if (StringSubstr(ls12, li_0, 2) == "38") ls20 = ls20 + "|";
else {
if (StringSubstr(ls12, li_0, 2) == "37") ls20 = ls20 + "@";
else {
if (StringSubstr(ls12, li_0, 2) == "49") ls20 = ls20 + "_";
else {
if (StringSubstr(ls12, li_0, 2) == "50") ls20 = ls20 + "S";
else
if (StringSubstr(ls12, li_0, 2) == "19") ls20 = ls20 + ".";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
ls28 = StringSubstr(ls20, 1, 2);
ls36 = StringSubstr(ls20, 3, 2);
ls44 = StringSubstr(ls20, 5, 4);
gstr2int1496 = StrToInteger(ls28);
gstr2int1500 = StrToInteger(ls36);
gstr2int1504 = StrToInteger(ls44);
if (Year() > gstr2int1504) gi1492 = 3;
if (Year() == gstr2int1504) {
if (Month() > gstr2int1500) gi1492 = 3;
if (Month() == gstr2int1500)
if (Day() > gstr2int1496) gi1492 = 3;
}
} else gi1492 = 1;
gi1480 = FALSE;
}
//Comment("\n", "License will expire on ", gstr2int1496, "/", gstr2int1500, "/", gstr2int1504);
return (0);
}
int deinit() {
ObjectDelete("cja");
ObjectDelete("Signalprice");
ObjectDelete("SIgBARS_TF1");
ObjectDelete("SIgBARS_TF2");
ObjectDelete("SIgBARS_TF3");
ObjectDelete("SIgBARS_TF4");
ObjectDelete("SIgBARS_TF5");
ObjectDelete("SIgBARS_TF6");
ObjectDelete("SIgBARS_TF7");
ObjectDelete("SSignalMACD_TEXT");
ObjectDelete("SSignalMACDM1");
ObjectDelete("SSignalMACDM5");
ObjectDelete("SSignalMACDM15");
ObjectDelete("SSignalMACDM30");
ObjectDelete("SSignalMACDH1");
ObjectDelete("SSignalMACDH4");
ObjectDelete("SSignalMACDD1");
ObjectDelete("SSignalSTR_TEXT");
ObjectDelete("SignalSTRM1");
ObjectDelete("SignalSTRM5");
ObjectDelete("SignalSTRM15");
ObjectDelete("SignalSTRM30");
ObjectDelete("SignalSTRH1");
ObjectDelete("SignalSTRH4");
ObjectDelete("SignalSTRD1");
ObjectDelete("SignalEMA_TEXT");
ObjectDelete("SignalEMAM1");
ObjectDelete("SignalEMAM5");
ObjectDelete("SignalEMAM15");
ObjectDelete("SignalEMAM30");
ObjectDelete("SignalEMAH1");
ObjectDelete("SignalEMAH4");
ObjectDelete("SignalEMAD1");
ObjectDelete("SIgDETAIL1");
ObjectDelete("SIgDETAIL2");
ObjectDelete("SIgDETAIL3");
ObjectDelete("SIgDETAIL4");
ObjectDelete("SIgDETAIL5");
ObjectDelete("SIgDETAIL6");
ObjectDelete("SIgDETAIL7");
ObjectDelete("SIgDETAIL8");
ObjectDelete("Lable");
ObjectDelete("Lable1");
ObjectDelete("percent");
ObjectDelete("start_p");
ObjectDelete("takepercent_day");
ObjectDelete("run");
ObjectDelete("Newsinfo");
ObjectDelete("Newsinfo2");
ObjectDelete("ERR");
ObjectDelete("ERR2");
ObjectDelete("Expert");
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
ObjectDelete("Margin");
ObjectDelete("Float");
return (0);
}
int start() {
//+------------------------------------------------Author Start--------------------------------------------------------------------------+
GlobalVariableSet("Dhamar"+Symbol()+"TF",Period());
double Position_L=Bid+Position*point;
string outDN,outUP,outtext,outtext2;
if (GlobalVariableGet("RUNEA")==1) //EA控制器
{
Alert("EA is not working");
return;
}
//+------------------------------------------------Author End----------------------------------------------------------------------------+
int Handle_Log,h1;
if ((AccountProfit()/start_balance)*100<GlobalVariableGet("MaxEquity")) GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);
displayprofit(start_p,next_in,start_balance);
//--------------------------------------------------------------------------------------Hydra
if (OrdersTotal()==0)
{
GlobalVariableSet("start_balance",AccountBalance());
GlobalVariableSet("start_p",TimeCurrent());
//GlobalVariableSet("MaxEquity",start_balance);
GlobalVariableSet("next_sw",0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),GlobalVariableGet("start_balance"),"After");
FileClose(h1);*/
Sleep(60000);
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
start_p=GlobalVariableGet("start_p");
if (GlobalVariableGet("next_sw")==1)
{
if (IsTradeContextBusy())
{
Sleep(10000);
return;
}
iCloseOrders("100%",Symbol(),id1,0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(start_p,TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),start_balance,"Before");
FileClose(h1);*/
Sleep(5000);
if (MyOrderTotal_err(id1)!=0)
{
Alert(Symbol()+" 戰場未成功離開");
Sleep(30000);
return;
}else
{
Sleep(NextTime*60*1000);
}
return(0);
}
//--------------------------------------------------------------------------------------Hydra
if (SLClose(SLpercent,start_balance))
{
if (SleepLoss)
{
GlobalVariableSet("RUN",1);
GlobalVariableSet("runtime",StrToTime(TimeToStr(TimeLocal(),TIME_DATE)));
}
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Stop Loss Close");
FileClose(Handle_Log);*/
}
if (takepercent>0){
int ii_0=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE));
if (next_in==false) {
if (profit_control(ii_0,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in flase");
FileClose(Handle_Log);*/
return(0);
}
}
if (next_in==true){
if (profit_control(start_p,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in true");
FileClose(Handle_Log);*/
}
if (profit_control(ii_0,takepercent_day,start_balance)==false)
{
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by day next_in true");
FileClose(Handle_Log);*/
return(0);
}
}
}
CheckTimeIn(MaxTime,MaxIn,MaxP,start_p);
//--------------------------------------------------------------------------------------Hydra
if (Hour()==hourr && Minute()==minutee && bar2!=Bars && GlobalVariableGet("UPSW")==0) {
GlobalVariableSet("UPSW",1);
//makefile_N();
bar2=Bars;
}
if (Hour()==hourr+1 && Minute()==0 && GlobalVariableGet("UPSW")==1)
{
GlobalVariableSet("UPSW",0);
}
//+------------------------------------------------------------------+
if (GlobalVariableGet("RUN")==1 && TimeLocal()<=GlobalVariableGet("runtime")+86400)
{
return;
}
if (GlobalVariableGet("RUN")==1 && TimeLocal()>GlobalVariableGet("runtime")+86400)
{
GlobalVariableSet("RUN",0);
}
ObjectCreate("run",OBJ_LABEL,0,0,0);
ObjectSet("run", OBJPROP_CORNER, 1);
ObjectSet("run", OBJPROP_COLOR, White);
ObjectSet("run", OBJPROP_XDISTANCE, 20);
ObjectSet("run", OBJPROP_YDISTANCE, Pos);
if (!Week15(W1Start,W5Over,start_t,stop_t,weekday) && OrdersTotal() == 0) {
ObjectSetText("run","未在設定時區內,現有戰役達成後將離開戰場",10,"微軟正黑體");
return;
}else {
ObjectSetText("run","已進入作戰時區內,全面啟動執行...",10,"微軟正黑體");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (BrakeSystem)
{
string Active="煞車系統啟動中";
string Deactive="煞車系統待命中";
color Light_status=Gold;
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSetString(0,"lightstatus",OBJPROP_FONT,"微軟正黑體");
ObjectSetInteger(0,"lightstatus",OBJPROP_FONTSIZE,10);
ObjectSetInteger(0,"lightstatus",OBJPROP_COLOR,Light_status);
int Price_Range;
int Time_Range;
int Now_Time = TimeCurrent();
double Now_Price = Close[0];
if (Last_Price != -1.0) {
Price_Range = Now_Price / Point - Last_Price / Point;
Time_Range = Now_Time - Last_Time;
//int Total_Orders = OrdersTotalCountByTypeANDMagic(OP_BUY, BuyMagic) + OrdersTotalCountByTypeANDMagic(OP_SELL, SellMagic);
if (MathAbs(Price_Range) >= MinPriceShot && Time_Range <= pSeconds) {
//if (Total_Orders < MaxOrdersCount) {
if (Now_Price > Last_Price) {
if ( MyOrderTotal_type(id1,1) > MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
if (Now_Price < Last_Price) {
if ( MyOrderTotal_type(id1,1) < MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
//} else {}//Comment("");
Last_Price = Now_Price;
Last_Time = Now_Time;
}else {
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (Time_Range >= pSeconds) {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
} else {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (TimeCurrent()<=SleepStop)
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active+", "+DoubleToStr((SleepStop-TimeCurrent())/60,0)+" 分鐘後啟動");
return;
}
}else {
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (MarginSleep) {
bool Pass=false;
if (AccountMargin() == 0) {Pass=true;}
else{
double Margin_R=(AccountEquity()/AccountMargin())*100;
if (MarginLimit >= Margin_R && !Pass) {
ObjectCreate("Margin",OBJ_LABEL,0,0,0);
ObjectSet("Margin", OBJPROP_CORNER, 1);
ObjectSet("Margin", OBJPROP_COLOR, Gold);
ObjectSet("Margin", OBJPROP_XDISTANCE, 20);
ObjectSet("Margin", OBJPROP_YDISTANCE, Pos+155);
ObjectSetText("Margin", "保證金比例低於 "+DoubleToStr(MarginLimit,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Margin");
}
}
}else {
ObjectDelete("Margin");
}
if (FloatEq) {
double Profit=AccountProfit();
if (Profit <= FloatAm) {
ObjectCreate("Float",OBJ_LABEL,0,0,0);
ObjectSet("Float", OBJPROP_CORNER, 1);
ObjectSet("Float", OBJPROP_COLOR, Gold);
ObjectSet("Float", OBJPROP_XDISTANCE, 20);
ObjectSet("Float", OBJPROP_YDISTANCE, Pos+175);
ObjectSetText("Float", "浮虧大於 "+DoubleToStr(FloatAm,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Float");
}
}else {
ObjectDelete("Float");
}
int li4;
int li8;
int li12;
int li16;
int li20;
int li24;
int li28;
color color32;
color color36;
color color40;
color color44;
color color48;
color color52;
color color56;
string ls_unused60;
color color68;
color color72;
color color76;
color color80;
color color84;
color color88;
color color92;
color color96;
string ls_unused100;
color color108;
int li_unused112;
double ihigh1128;
double ilow1136;
double iclose1144;
double iclose1152;
double ld1192;
double ld1248;
double ld1256;
int li1264;
int count1268;
double ld1316;
double ld1324;
int li1332;
int count1336;
int li992 = 0;
int li996 = 0;
int li1000 = 0;
int li1004 = 0;
int li1008 = 0;
int li1012 = 0;
li992 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
for (li1012 = 1; li1012 <= 5; li1012++) li996 = li996 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 10; li1012++) li1000 = li1000 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 20; li1012++) li1004 = li1004 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
li996 /= 5;
li1000 /= 10;
li1004 /= 20;
li1008 = (li992 + li996 + li1000 + li1004) / 4;
string ls_unused1016 = "";
string ls_unused1024 = "";
string dbl2str1032 = "";
string dbl2str1040 = "";
string dbl2str1048 = "";
string dbl2str1056 = "";
string ls_unused1064 = "";
string ls_unused1072 = "";
string ls1080 = "";
double iopen1088 = iOpen(NULL, PERIOD_D1, 0);
double iclose1096 = iClose(NULL, PERIOD_D1, 0);
double ld1104 = (Ask - Bid) / Point;
double ihigh1112 = iHigh(NULL, PERIOD_D1, 0);
double ilow1120 = iLow(NULL, PERIOD_D1, 0);
dbl2str1040 = DoubleToStr((iclose1096 - iopen1088) / Point, 0);
dbl2str1032 = DoubleToStr(ld1104, Digits - 4);
dbl2str1048 = DoubleToStr(li1008, Digits - 4);
ls1080 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
dbl2str1056 = DoubleToStr((ihigh1112 - ilow1120) / Point, 0);
if (iclose1096 >= iopen1088) {
ls_unused1064 = "-";
color108 = gcolor1100;
}
if (iclose1096 < iopen1088) {
ls_unused1064 = "-";
color108 = gcolor1104;
}
if (dbl2str1048 >= ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1108;
}
if (dbl2str1048 < ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1112;
}
double ld1160 = LotExponent;
int li1168 = gi108;
double ld1172 = TakeProfit;
bool bool1180 = UseEquityStop;
double ld1184 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1192 = Lots;
else ld1192 = 0.00001 * MathCeil(AccountBalance());
} else ld1192 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop_Hilo) f035(TrailStart_Hilo, TrailStop_Hilo, gprice312);
if (gi220) {
if (TimeCurrent() >= gi376) {
f024();
Print("Closed All due_Hilo to TimeOut");
}
}
if (gi372 == Time[0]) return (0);
gi372 = Time[0];
double ld1200 = f031();
if (bool1180) {
if (ld1200 < 0.0 && MathAbs(ld1200) > ld1184 / 100.0 * f07()) {
f024();
Print("Closed All due_Hilo to Stop Out");
gi424 = FALSE;
}
}
gi396 = f04();
if (gi396 == 0) gi360 = FALSE;
for (gpos392 = OrdersTotal() - 1; gpos392 >= 0; gpos392--) {
OrderSelect(gpos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
gi412 = TRUE;
gi416 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
gi412 = FALSE;
gi416 = TRUE;
break;
}
}
}
if (gi396 > 0 && gi396 <= MaxTrades_A) {
RefreshRates();
gd336 = f032();
gd344 = f020();
if (gi412 && gd336 - Ask >= PipStep_Hilo * Point) gi408 = TRUE;
if (gi416 && Bid - gd344 >= PipStep_Hilo * Point) gi408 = TRUE;
}
if (gi396 < 1) {
gi416 = FALSE;
gi412 = FALSE;
gi408 = TRUE;
gd288 = AccountEquity();
}
if (gi408) {
gd336 = f032();
gd344 = f020();
if (gi416) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
RefreshRates();
gi420 = f03(1, gd384, Bid, slip_Hilo, Ask, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi408 = FALSE;
gi424 = TRUE;
} else {
if (gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
gi420 = f03(0, gd384, Ask, slip_Hilo, Bid, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi408 = FALSE;
gi424 = TRUE;
}
}
}
if (gi408 && gi396 < 1) {
ihigh1128 = iHigh(Symbol(), 0, 1);
ilow1136 = iLow(Symbol(), 0, 2);
gbid320 = Bid;
gask328 = Ask;
if ((!gi416) && !gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
if (ihigh1128 > ilow1136) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi420 = f03(1, gd384, gbid320, slip_Hilo, gbid320, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi424 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi420 = f03(0, gd384, gask328, slip_Hilo, gask328, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi424 = TRUE;
}
}
if (gi420 > 0) gi376 = TimeCurrent() + 60.0 * (60.0 * gd224);
gi408 = FALSE;
}
}
gi396 = f04();
gprice312 = 0;
double ld1208 = 0;
for (gpos392 = OrdersTotal() - 1; gpos392 >= 0; gpos392--) {
OrderSelect(gpos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
gprice312 += OrderOpenPrice() * OrderLots();
ld1208 += OrderLots();
}
}
}
if (gi396 > 0) gprice312 = NormalizeDouble(gprice312 / ld1208, Digits);
if (gi424) {
for (gpos392 = OrdersTotal() - 1; gpos392 >= 0; gpos392--) {
OrderSelect(gpos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
gprice280 = gprice312 + ld1172 * Point;
gd_unused296 = gprice280;
gd400 = gprice312 - gpips236 * Point;
gi360 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
gprice280 = gprice312 - ld1172 * Point;
gd_unused304 = gprice280;
gd400 = gprice312 + gpips236 * Point;
gi360 = TRUE;
}
}
}
}
if (gi424) {
if (gi360 == TRUE) {
for (gpos392 = OrdersTotal() - 1; gpos392 >= 0; gpos392--) {
OrderSelect(gpos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) OrderModify(OrderTicket(), gprice312, OrderStopLoss(), gprice280, 0, Yellow);
gi424 = FALSE;
}
}
}
double ld1216 = LotExponent;
int li1224 = gi108;
double ld1228 = TakeProfit;
bool bool1236 = UseEquityStop;
double ld1240 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1248 = Lots;
else ld1248 = 0.00001 * MathCeil(AccountBalance());
} else ld1248 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop15) f021(TrailStart15, TrailStop15, gprice596);
if (gi532) {
if (TimeCurrent() >= gi660) {
f018();
Print("Closed All due to TimeOut");
}
}
if (gi656 != Time[0]) {
gi656 = Time[0];
ld1256 = f029();
if (bool1236) {
if (ld1256 < 0.0 && MathAbs(ld1256) > ld1240 / 100.0 * f016()) {
f018();
Print("Closed All due to Stop Out");
gi708 = FALSE;
}
}
gi680 = f05();
if (gi680 == 0) gi644 = FALSE;
for (gpos676 = OrdersTotal() - 1; gpos676 >= 0; gpos676--) {
OrderSelect(gpos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615) {
if (OrderType() == OP_BUY) {
gi696 = TRUE;
gi700 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615) {
if (OrderType() == OP_SELL) {
gi696 = FALSE;
gi700 = TRUE;
break;
}
}
}
if (gi680 > 0 && gi680 <= MaxTrades_B) {
RefreshRates();
gd620 = f036();
gd628 = f028();
if (gi696 && gd620 - Ask >= PipStep15 * Point) gi692 = TRUE;
if (gi700 && Bid - gd628 >= PipStep15 * Point) gi692 = TRUE;
}
if (gi680 < 1) {
gi700 = FALSE;
gi696 = FALSE;
gi692 = TRUE;
gd572 = AccountEquity();
}
if (gi692) {
gd620 = f036();
gd628 = f028();
if (gi700) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
RefreshRates();
gi704 = f02(1, gd668, Bid, slip15, Ask, 0, 0, gs648 + "-" + gi664, gmagic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi692 = FALSE;
gi708 = TRUE;
} else {
if (gi696) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
gi704 = f02(0, gd668, Ask, slip15, Bid, 0, 0, gs648 + "-" + gi664, gmagic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi692 = FALSE;
gi708 = TRUE;
}
}
}
}
if (gdatetime728 != iTime(NULL, gtimeframe496, 0)) {
li1264 = OrdersTotal();
count1268 = 0;
for (int li1272 = li1264; li1272 >= 1; li1272--) {
OrderSelect(li1272 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615) count1268++;
}
if (li1264 == 0 || count1268 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
gbid604 = Bid;
gask612 = Ask;
gi664 = gi680;
gd668 = ld1248;
if (iclose1144 > iclose1152) {
gi704 = f02(1, gd668, gbid604, slip15, gbid604, 0, 0, gs648 + "-" + gi664, gmagic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi708 = TRUE;
} else {
gi704 = f02(0, gd668, gask612, slip15, gask612, 0, 0, gs648 + "-" + gi664, gmagic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi708 = TRUE;
}
if (gi704 > 0) gi660 = TimeCurrent() + 60.0 * (60.0 * gd536);
gi692 = FALSE;
}
gdatetime728 = iTime(NULL, gtimeframe496, 0);
}
gi680 = f05();
gprice596 = 0;
double ld1276 = 0;
for (gpos676 = OrdersTotal() - 1; gpos676 >= 0; gpos676--) {
OrderSelect(gpos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
gprice596 += OrderOpenPrice() * OrderLots();
ld1276 += OrderLots();
}
}
}
if (gi680 > 0) gprice596 = NormalizeDouble(gprice596 / ld1276, Digits);
if (gi708) {
for (gpos676 = OrdersTotal() - 1; gpos676 >= 0; gpos676--) {
OrderSelect(gpos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615) {
if (OrderType() == OP_BUY) {
gprice564 = gprice596 + ld1228 * Point;
gd_unused580 = gprice564;
gd684 = gprice596 - gpips508 * Point;
gi644 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615) {
if (OrderType() == OP_SELL) {
gprice564 = gprice596 - ld1228 * Point;
gd_unused588 = gprice564;
gd684 = gprice596 + gpips508 * Point;
gi644 = TRUE;
}
}
}
}
if (gi708) {
if (gi644 == TRUE) {
for (gpos676 = OrdersTotal() - 1; gpos676 >= 0; gpos676--) {
OrderSelect(gpos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615) OrderModify(OrderTicket(), gprice596, OrderStopLoss(), gprice564, 0, Yellow);
gi708 = FALSE;
}
}
}
double ld1284 = LotExponent;
int li1292 = gi108;
double ld1296 = TakeProfit;
bool bool1304 = UseEquityStop;
double ld1308 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1316 = Lots;
else ld1316 = 0.00001 * MathCeil(AccountBalance());
} else ld1316 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop16) f034(TrailStart16, TrailStop16, gprice880);
if (gi816) {
if (TimeCurrent() >= gi944) {
f0_0();
Print("Closed All due to TimeOut");
}
}
if (gi940 != Time[0]) {
gi940 = Time[0];
ld1324 = f08();
if (bool1304) {
if (ld1324 < 0.0 && MathAbs(ld1324) > ld1308 / 100.0 * f030()) {
f0_0();
Print("Closed All due to Stop Out");
gi992 = FALSE;
}
}
gi964 = f012();
if (gi964 == 0) gi928 = FALSE;
for (gpos960 = OrdersTotal() - 1; gpos960 >= 0; gpos960--) {
OrderSelect(gpos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616) {
if (OrderType() == OP_BUY) {
gi980 = TRUE;
gi984 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616) {
if (OrderType() == OP_SELL) {
gi980 = FALSE;
gi984 = TRUE;
break;
}
}
}
if (gi964 > 0 && gi964 <= MaxTrades_C) {
RefreshRates();
gd904 = f017();
gd912 = f027();
if (gi980 && gd904 - Ask >= PipStep16 * Point) gi976 = TRUE;
if (gi984 && Bid - gd912 >= PipStep16 * Point) gi976 = TRUE;
}
if (gi964 < 1) {
gi984 = FALSE;
gi980 = FALSE;
gd856 = AccountEquity();
}
if (gi976) {
gd904 = f017();
gd912 = f027();
if (gi984) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
RefreshRates();
gi988 = f06(1, gd952, Bid, slip16, Ask, 0, 0, gs932 + "-" + gi948, gmagic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi976 = FALSE;
gi992 = TRUE;
} else {
if (gi980) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
gi988 = f06(0, gd952, Ask, slip16, Bid, 0, 0, gs932 + "-" + gi948, gmagic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi976 = FALSE;
gi992 = TRUE;
}
}
}
}
if (gdatetime1012 != iTime(NULL, gtimeframe784, 0)) {
li1332 = OrdersTotal();
count1336 = 0;
for (int li1340 = li1332; li1340 >= 1; li1340--) {
OrderSelect(li1340 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616) count1336++;
}
if (li1332 == 0 || count1336 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
gbid888 = Bid;
gask896 = Ask;
gi948 = gi964;
gd952 = ld1316;
if (iclose1144 > iclose1152) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi988 = f06(1, gd952, gbid888, slip16, gbid888, 0, 0, gs932 + "-" + gi948, gmagic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi992 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi988 = f06(0, gd952, gask896, slip16, gask896, 0, 0, gs932 + "-" + gi948, gmagic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi992 = TRUE;
}
}
if (gi988 > 0) gi944 = TimeCurrent() + 60.0 * (60.0 * gd820);
gi976 = FALSE;
}
gdatetime1012 = iTime(NULL, gtimeframe784, 0);
}
gi964 = f012();
gprice880 = 0;
double ld1344 = 0;
for (gpos960 = OrdersTotal() - 1; gpos960 >= 0; gpos960--) {
OrderSelect(gpos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
gprice880 += OrderOpenPrice() * OrderLots();
ld1344 += OrderLots();
}
}
}
if (gi964 > 0) gprice880 = NormalizeDouble(gprice880 / ld1344, Digits);
if (gi992) {
for (gpos960 = OrdersTotal() - 1; gpos960 >= 0; gpos960--) {
OrderSelect(gpos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616) {
if (OrderType() == OP_BUY) {
gprice848 = gprice880 + ld1296 * Point;
gd_unused864 = gprice848;
gd968 = gprice880 - gpips792 * Point;
gi928 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616) {
if (OrderType() == OP_SELL) {
gprice848 = gprice880 - ld1296 * Point;
gd_unused872 = gprice848;
gd968 = gprice880 + gpips792 * Point;
gi928 = TRUE;
}
}
}
}
if (gi992) {
if (gi928 == TRUE) {
for (gpos960 = OrdersTotal() - 1; gpos960 >= 0; gpos960--) {
OrderSelect(gpos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616) OrderModify(OrderTicket(), gprice880, OrderStopLoss(), gprice848, 0, Yellow);
gi992 = FALSE;
}
}
}
//Handle_Log=0;
return (0);
}
int f04() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f024() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip_Hilo, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip_Hilo, Red);
}
Sleep(1000);
}
}
}
int f03(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM1(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f022(Bid, ai32), f019(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f011(Ask, ai32), f01(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f022(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f011(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f019(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f01(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f031() {
double ld_ret_0 = 0;
for (gpos392 = OrdersTotal() - 1; gpos392 >= 0; gpos392--) {
OrderSelect(gpos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f035(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f07() {
if (f04() == 0) gd428 = AccountEquity();
if (gd428 < gd436) gd428 = gd436;
else gd428 = AccountEquity();
gd436 = AccountEquity();
return (gd428);
}
double f032() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f020() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f05() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f018() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip15, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip15, Red);
}
Sleep(1000);
}
}
}
int f02(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM2(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f013(Bid, ai32), f025(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f033(Ask, ai32), f026(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f013(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f033(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f025(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f026(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f029() {
double ld_ret_0 = 0;
for (gpos676 = OrdersTotal() - 1; gpos676 >= 0; gpos676--) {
OrderSelect(gpos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f021(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == gmagic17615) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f016() {
if (f05() == 0) gd712 = AccountEquity();
if (gd712 < gd720) gd712 = gd720;
else gd712 = AccountEquity();
gd720 = AccountEquity();
return (gd712);
}
double f036() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f028() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17615 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f012() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f0_0() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip16, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip16, Red);
}
Sleep(1000);
}
}
}
int f06(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM3(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f014(Bid, ai32), f09(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f023(Ask, ai32), f010(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f014(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f023(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f09(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f010(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f08() {
double ld_ret_0 = 0;
for (gpos960 = OrdersTotal() - 1; gpos960 >= 0; gpos960--) {
OrderSelect(gpos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f034(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == gmagic17616) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f030() {
if (f012() == 0) gd996 = AccountEquity();
if (gd996 < gd1004) gd996 = gd1004;
else gd996 = AccountEquity();
gd1004 = AccountEquity();
return (gd996);
}
double f017() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f027() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != gmagic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == gmagic17616 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
string f015(string as_0) {
int str_len8 = StringLen(as_0);
bool li_ret12 = FALSE;
for (int li16 = 0; li16 < str_len8; li16++) {
if (StringSubstr(as_0, li16, 1) == "1") li_ret12 = li_ret12 + MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "2") li_ret12 = li_ret12 + 2.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "3") li_ret12 = li_ret12 + 3.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "4") li_ret12 = li_ret12 + 4.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "5") li_ret12 = li_ret12 + 5.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "6") li_ret12 = li_ret12 + 6.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "7") li_ret12 = li_ret12 + 7.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "8") li_ret12 = li_ret12 + 8.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "9") li_ret12 = li_ret12 + 9.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "A") li_ret12 = li_ret12 + 10.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "B") li_ret12 = li_ret12 + 11.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "C") li_ret12 = li_ret12 + 12.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "D") li_ret12 = li_ret12 + 13.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "E") li_ret12 = li_ret12 + 14.0 * MathPow(16, str_len8 - li16 - 1);
else
if (StringSubstr(as_0, li16, 1) == "F") li_ret12 = li_ret12 + 15.0 * MathPow(16, str_len8 - li16 - 1);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return (li_ret12);
}
string MakeDateTime(string strDate, string strTime)
{
// Print("Converting Forex Factory Time into Metatrader time..."); //added by MN
// Converts forexfactory time & date into yyyy.mm.dd hh:mm
int n1stDash = StringFind(strDate, "-");
int n2ndDash = StringFind(strDate, "-", n1stDash+1);
string strMonth = StringSubstr(strDate, 0, 2);
string strDay = StringSubstr(strDate, 3, 2);
string strYear = StringSubstr(strDate, 6, 4);
// strYear = "20" + strYear;
int nTimeColonPos = StringFind(strTime, ":");
string strHour = StringSubstr(strTime, 0, nTimeColonPos);
string strMinute = StringSubstr(strTime, nTimeColonPos+1, 2);
string strAM_PM = StringSubstr(strTime, StringLen(strTime)-2);
int nHour24 = StrToInteger(strHour);
if ((strAM_PM == "pm" || strAM_PM == "PM") && nHour24 != 12)
{
nHour24 += 12;
}
if ((strAM_PM == "am" || strAM_PM == "AM") && nHour24 == 12)
{
nHour24 = 0;
}
string strHourPad = "";
if (nHour24 < 10)
strHourPad = "0";
return(StringConcatenate(strYear, ".", strMonth, ".", strDay, " ", strHourPad, nHour24, ":", strMinute));
}
bool profit_control(int i_0,double takepercent_,double start_balance)
{
double today_profit;
int i1=StrToTime(TimeToStr(TimeCurrent()+86400, TIME_DATE));
today_profit=((GetProfitFromDateInCurrency(i_0)+AccountProfit())/start_balance)*100;
if (today_profit>=takepercent_)
{
return(false);
}
return(true);
}
void displayprofit(int start_p,bool next_in,double start_balance)
{
double today_profit;
string display;
ObjectCreate("percent",OBJ_LABEL,0,0,0);
ObjectSet("percent", OBJPROP_CORNER, 1);
ObjectSet("percent", OBJPROP_COLOR, White);
ObjectSet("percent", OBJPROP_XDISTANCE, 20);
ObjectSet("percent", OBJPROP_YDISTANCE, Pos+30);
ObjectCreate("start_p",OBJ_LABEL,0,0,0);
ObjectSet("start_p", OBJPROP_CORNER, 1);
ObjectSet("start_p", OBJPROP_COLOR, White);
ObjectSet("start_p", OBJPROP_XDISTANCE, 20);
ObjectSet("start_p", OBJPROP_YDISTANCE, Pos+50);
ObjectSetText("start_p","進場經過時間 "+ DoubleToStr((TimeCurrent()-start_p)/60,1)+ " 分鐘"+" ; "+OrdersTotal()+" 兵力在戰場上",10,"微軟正黑體");
if (next_in==true)
{
today_profit=((GetProfitFromDateInCurrency(start_p)+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
GlobalVariableSet("display",today_profit);
ObjectSetText("percent","單次擄獲狂派戰俘"+display+"%"+" ; 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectCreate("takepercent_day",OBJ_LABEL,0,0,0);
ObjectSet("takepercent_day", OBJPROP_CORNER, 1);
ObjectSet("takepercent_day", OBJPROP_COLOR, White);
ObjectSet("takepercent_day", OBJPROP_XDISTANCE, 20);
ObjectSet("takepercent_day", OBJPROP_YDISTANCE, Pos+70);
ObjectSetText("takepercent_day","今日擄獲狂派戰俘累積至"+display+" ; 最大暫時被擄穫兵力 "+DoubleToStr(GlobalVariableGet("MaxEquity"),2)+" %",10,"微軟正黑體");
}
if (next_in==false)
{
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectSetText("percent","今日擄獲狂派戰俘累積至"+display+"%"+" 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
}
}
double GetProfitFromDateInCurrency(int today) {
double profit = 0;
int total = OrdersHistoryTotal();
for (int i = 0; i < total; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL ) {
if (today < OrderCloseTime()) profit += OrderProfit() + OrderCommission() + OrderSwap();
}
}
}
return (profit);
}
bool SLClose (double percent,double start_balance) {
if (AccountProfit()<=0)
{
if ((MathAbs(AccountProfit())/start_balance)*100>=percent)
{
return(true);
}
else
{
return(false);
}
}else
{
return(false);
}
}
void iCloseOrders(string myType,string currency,int id1,int type)
{
if (MyOrderTotal_err(id1)==0) return(0);
int C0_cnt,close_t[],t_cnt;
double percentlots,nd_profit;
if (myType=="Del"&&type==0)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_BUYSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==gmagic17615 || OrderMagicNumber()==gmagic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="Del"&&type==1)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_SELLSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==gmagic17615 || OrderMagicNumber()==gmagic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="100%")
{
for(C0_cnt=0;C0_cnt<OrdersTotal();C0_cnt++) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false)
{
//Alert(Symbol()+" OrderSelect Error");
continue;
}
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==gmagic17615 || OrderMagicNumber()==gmagic17616 )){
ArrayResize(close_t,t_cnt+1);
close_t[t_cnt]=OrderTicket();
t_cnt++;
}
}
for(int i=ArraySize(close_t)-1;i>=0;i--)
{
if (OrderSelect(close_t[i],SELECT_BY_TICKET)==false)
{
Alert(Symbol()+" OrderSelect Error By Tickets");continue;
}
else
{
percentlots=OrderLots();
OrderClose(close_t[i],percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="80%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==gmagic17615 || OrderMagicNumber()==gmagic17616 )){
percentlots=OrderLots()*0.8;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="50%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==gmagic17615 || OrderMagicNumber()==gmagic17616 )){
percentlots=OrderLots()*0.5;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="All") //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderMagicNumber()!=0){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="BUY"&&type==0) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_BUY && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==gmagic17615 || OrderMagicNumber()==gmagic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="SELL"&&type==1) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_SELL && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==gmagic17615 || OrderMagicNumber()==gmagic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
}
int MyOrderTotal_err(int id1)//訂單總數函式
{
int x=0;//符合條件的BUY單數量(記次變數)
for(int z=0;z<OrdersTotal();z++)//執行N次篩選(N=訂單總數)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);//用"流水號"找訂單
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==gmagic17615 || OrderMagicNumber()==gmagic17616 ))//挑選出同貨幣對 && BUY單 && MagicNumber=本程式 的訂單
{
x++;//符合節選結果的訂單總數
}
}
return(x);//回傳
}
int MyOrderTotal_type(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==gmagic17615 || OrderMagicNumber()==gmagic17616 ) && OrderType()==type)
{
x++;//
}
}
return(x);
}
bool iTimeControl(int myStartHour,int myStopHour)
{
bool EA_Valid=false;
if(myStopHour == myStartHour) EA_Valid = true;
if(myStopHour < myStartHour)
{
if (TimeHour(TimeLocal()) >= myStartHour || TimeHour(TimeLocal()) < myStopHour) EA_Valid = true;
}
if (myStopHour > myStartHour) {
if ((TimeHour(TimeLocal()) >= myStartHour && TimeHour(TimeLocal()) < myStopHour))
EA_Valid = true;
}
return(EA_Valid);
}
bool Week15 (int start,int over,int myStartHour,int myStopHour,string weekday)
{
bool EA_Valid=false;
int Dayweek=TimeDayOfWeek(TimeLocal());
if (
(
(
Dayweek == 1 && TimeHour(TimeLocal()) < start
)
||
(
Dayweek == StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1)) && TimeHour(TimeLocal()) >= over
)
||
(
Dayweek > StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1))
)
)
&& Week15SW) {
EA_Valid=false;
}else {
if (iTimeControl(myStartHour,myStopHour)) {
if (StringFind(weekday,DoubleToStr(Dayweek,0),0) >= 0) {
EA_Valid=true;
}else {
EA_Valid=false;
}
}else {
EA_Valid=false;
}
}
return(EA_Valid);
}
void CheckTimeIn(int MaxTime,int MaxIn,double MaxP,int start_p)
{
int Handle_Log;
int Valid;
int RunTime=(TimeCurrent()-start_p)/60;
if (RunTime>=MaxTime && OrdersTotal() >= MaxIn && GlobalVariableGet("display")>= MaxP)
{
GlobalVariableSet("next_sw",1);
Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by CheckTimeIn");
FileClose(Handle_Log);
}
}
string Base64Decode(string in/*,string &out*/)
{
string out;
int i=0,len=StringLen(in);
int shift=0,accum=0;
while(i<len)
{
int value=ExtBase64Decode[StringGetChar(in,i)];
if(value<0 || value>63) break;
accum<<=6;
shift+=6;
accum|=value;
if(shift>=8)
{
shift-=8;
value=accum >> shift;
out=out+CharToStr(value & 0xFF);
}
i++;
}
//----
return(out);
}
bool ThreeM1(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(gmagic17615,0) >0 && MyOrderTotal_id(gmagic17616,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(gmagic17615,1) >0 && MyOrderTotal_id(gmagic17616,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM2(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(gmagic17616,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(gmagic17616,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM3(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(gmagic17615,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(gmagic17615,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
int MyOrderTotal_id(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id1 && OrderType()==type)
{
x++;//
}
}
return(x);
}
#import "wininet.dll"
int InternetAttemptConnect(
int dwReserved=0
);
int InternetOpenA(uchar &lpszAgent[],int dwAccessType,uchar &lpszProxyName[],uchar &lpszProxyBypass[],int dwFlags);
int InternetConnectA(int hInternetSession,uchar &lpszServerName[],int nServerPort,uchar &lpszUserName[],uchar &lpszPassword[],int nService,int nFlags,int dwContext);
bool InternetCloseHandle(
int hInet
);
bool FtpPutFileA (
int hFtpSession,
string lpszLocalFile,
string lpszRemoteFile,
int dwFlags,
int dwContext
);
bool FtpGetFileA (int hFtpSession,uchar &lpszRemoteFile[],uchar &lpszNewFile[],bool fFailIfExists,int dwFlagsAndAttributes,uint dwFlags,int dwContext);
bool FtpCreateDirectoryA(
int hConnect,
string lpszDirectory
);
bool FtpSetCurrentDirectoryA(
int hConnect,
string lpszDirectory
);
#import
#define INTERNET_FLAG_PASSIVE 0x08000000
#define INTERNET_FLAG_RELOAD 0x80000000
#define INTERNET_FLAG_EXISTING_CONNECT 0x20000000
#define INTERNET_SERVICE_FTP 1
#define FTP_TRANSFER_TYPE_ASCII 1
#define FTP_TRANSFER_TYPE_BINARY 2
#define FTP_TRANSFER_TYPE_UNKNOWN 3
#define INTERNET_FLAG_HYPERLINK 0x00000400
static int ExtBase64Encode[64]={ 'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/' };
static int ExtBase64Decode[256]={
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
string t1 = "";
//extern double Account = 1872377.0;
int GMT=8;
extern string T0="-------------ESP戰艦穩定煞車系統------------";
extern bool BrakeSystem=true;
int pSeconds=14;
extern string T1="能量偵測靈敏度";
extern int Energy = 40;
extern string T2="能量煞車引擎啟動時間";
extern int SleepTime=15;
int SleepStop=0;
int Position=0;
extern string T5="-------------保證金比例控制模組--------------";
extern bool MarginSleep=true;
extern double MarginLimit=3000;
extern string T6="-------------浮虧控制模組(以金額計算)-------------";
extern bool FloatEq=true;
extern double FloatAm=-2000;
extern string T7="開始時間,格式為hh";
extern int start_t=00;
extern string T8="結束時間,格式為hh";
extern int stop_t=00;
extern string T9="週一執行,鍵入1即可";
extern string T10="週一週二鍵入12,以下類推";
extern string weekday="12345";
extern bool Week15SW=true;
extern string W1="禮拜一幾點開始";
extern int W1Start=8;
extern string W2="最後一天幾點結束";
extern int W5Over=17;
extern string T11="止盈止損計算本金基準";
extern double I_balance=0;
extern string T12="止損後當日不再出兵";
extern bool SleepLoss=true;
extern string T13="最大總浮虧(以餘額計算)";
extern double SLpercent=30.0;
extern string T14="次止盈,每次最多獲利%,立即平倉歸零重啟新局";
extern double takepercent=1;
string T111="每次止盈開關";
bool next_in=true;
extern string T15="日止盈,每日最多獲利%,立即停止交易,隔日重新啟動";
extern double takepercent_day=100;
extern string T16="每局結束幾分鐘後重新啟動";
extern double NextTime=2;
extern string T9_="-------------------小虧為贏模組-------------";
extern string T17="每局最長時間(分鐘)";
extern int MaxTime=150;
extern string T18="每局最多兵力";
extern int MaxIn=40;
extern string T19="達成以上條件小虧為贏";
extern double MaxP=0.5;
extern string T20="-------------------------------------------";
extern string T21="手數";
extern double Lots = 0.01;
extern string T22="馬丁倍率";
extern double LotExponent = 1.618;
extern string T23="----------------三方向導航-----------------";
extern bool BSB=true;
int gi108 = 2;
double MaxLots = 5.0;
bool MM = FALSE;
extern string T24="獲利點數";
extern double TakeProfit = 100.0;
bool UseEquityStop = FALSE;
double TotalEquityRisk = 20.0;
string t2 = "Time Setting";
bool CloseFriday = false;
int CloseFridayHour = 17;
bool OpenMondey = false;
int OpenMondeyHour = 0;
string t3 = "";
extern string T25="A模組最多單數";
extern int MaxTrades_A=10;
bool gi220 = FALSE;
double gd224 = 48.0;
bool UseTrailingStop_Hilo = FALSE;
double g_pips236 = 500.0;
double TrailStart_Hilo = 10.0;
double TrailStop_Hilo = 5.0;
double PipStep_Hilo = 100.0;
double slip_Hilo = 3.0;
int MagicNumber_Hilo = 11111;
double g_price280;
double gd288;
double gd_unused296;
double gd_unused304;
double g_price312;
double g_bid320;
double g_ask328;
double gd336;
double gd344;
double gd352;
bool gi360;
string gs364 = "";
int gi372 = 0;
int gi376;
int gi380 = 0;
double gd384;
int g_pos392 = 0;
int gi396;
double gd400 = 0.0;
bool gi408 = FALSE;
bool gi412 = FALSE;
bool gi416 = FALSE;
int gi420;
bool gi424 = FALSE;
double gd428;
double gd436;
string t4 = "";
extern string T26="B模組最多單數";
extern int MaxTrades_B=10;
int g_timeframe496 = PERIOD_H1;
bool UseTrailingStop15 = FALSE;
double g_pips508 = 500.0;
double TrailStart15 = 10.0;
double TrailStop15 = 5.0;
bool gi532 = FALSE;
double gd536 = 48.0;
double PipStep15 = 100.0;
double slip15 = 3.0;
int g_magic17615 = 12324;
double g_price564;
double gd572;
double gd_unused580;
double gd_unused588;
double g_price596;
double g_bid604;
double g_ask612;
double gd620;
double gd628;
double gd636;
bool gi644;
string gs648 = "";
int gi656 = 0;
int gi660;
int gi664 = 0;
double gd668;
int g_pos676 = 0;
int gi680;
double gd684 = 0.0;
bool gi692 = FALSE;
bool gi696 = FALSE;
bool gi700 = FALSE;
int gi704;
bool gi708 = FALSE;
double gd712;
double gd720;
int g_datetime728 = 1;
string t5 = "";
extern string T27="C模組最多單數";
extern int MaxTrades_C=10;
int g_timeframe784 = PERIOD_M1;
bool UseTrailingStop16 = FALSE;
double g_pips792 = 500.0;
double TrailStart16 = 10.0;
double TrailStop16 = 5.0;
bool gi816 = FALSE;
double gd820 = 48.0;
double PipStep16 = 100.0;
double slip16 = 3.0;
int g_magic17616 = 16794;
double g_price848;
double gd856;
double gd_unused864;
double gd_unused872;
double g_price880;
double g_bid888;
double g_ask896;
double gd904;
double gd912;
double gd920;
bool gi928;
string gs932 = "";
int gi940 = 0;
int gi944;
int gi948 = 0;
double gd952;
int g_pos960 = 0;
int gi964;
double gd968 = 0.0;
bool gi976 = FALSE;
bool gi980 = FALSE;
bool gi984 = FALSE;
int gi988;
bool gi992 = FALSE;
double gd996;
double gd1004;
int g_datetime1012 = 1;
int g_timeframe1024 = PERIOD_M1;
int g_timeframe1028 = PERIOD_M5;
int g_timeframe1032 = PERIOD_M15;
int g_timeframe1036 = PERIOD_M30;
int g_timeframe1040 = PERIOD_H1;
int g_timeframe1044 = PERIOD_H4;
int g_timeframe1048 = PERIOD_D1;
bool g_corner1052 = TRUE;
int gi1056 = 0;
int gi1060 = 10;
int g_window1064 = 0;
bool gi1068 = TRUE;
bool gi_unused1072 = TRUE;
bool gi1076 = FALSE;
int g_color1080 = Gray;
int g_color1084 = Gray;
int g_color1088 = Gray;
int g_color1092 = DarkOrange;
int gi_unused1096 = 36095;
int g_color1100 = Lime;
int g_color1104 = OrangeRed;
int gi1108 = 65280;
int gi1112 = 17919;
int g_color1116 = Lime;
int g_color1120 = Red;
int g_color1124 = Orange;
int g_period1128 = 8;
int g_period1132 = 17;
int g_period1136 = 9;
int g_applied_price1140 = PRICE_CLOSE;
int g_color1144 = Lime;
int g_color1148 = Tomato;
int g_color1152 = Green;
int g_color1156 = Red;
string gs_unused1160 = "<<<< STR Indicator Settings >>>>>>>>>>>>>";
string gs_unused1168 = "<<<< RSI Settings >>>>>>>>>>>>>";
int g_period1176 = 9;
int g_applied_price1180 = PRICE_CLOSE;
string gs_unused1184 = "<<<< CCI Settings >>>>>>>>>>>>>>";
int g_period1192 = 13;
int g_applied_price1196 = PRICE_CLOSE;
string gs_unused1200 = "<<<< STOCH Settings >>>>>>>>>>>";
int g_period1208 = 5;
int g_period1212 = 3;
int g_slowing1216 = 3;
int g_ma_method1220 = MODE_EMA;
string gs_unused1224 = "<<<< STR Colors >>>>>>>>>>>>>>>>";
int g_color1232 = Lime;
int g_color1236 = Red;
int g_color1240 = Orange;
string gs_unused1244 = "<<<< MA Settings >>>>>>>>>>>>>>";
int g_period1252 = 5;
int g_period1256 = 9;
int g_ma_method1260 = MODE_EMA;
int g_applied_price1264 = PRICE_CLOSE;
string gs_unused1268 = "<<<< MA Colors >>>>>>>>>>>>>>";
int g_color1276 = Lime;
int g_color1280 = Red;
string gs_dummy1292;
string g_text1464;
string g_text1472;
bool gi1480 = TRUE;
string KEY = "";
int gi1492;
int g_str2int1496;
int g_str2int1500;
int g_str2int1504;
int MinPriceShot;
string maindata[300][7];
double start_balance,point;
int start_p,id1,id2,bar2;
int Pos=50;
int hourr=0;
int minutee;
int count;
bool NewsgetSW=false;
double Last_Price=-1.0;
int Last_Time=0;
int init() {
if (IsTesting()==true) {return(0);}
GlobalVariableSet("Dhamar"+Symbol(),WindowHandle(Symbol(),Period()));
ObjectCreate("Expert",OBJ_LABEL,0,0,0);
ObjectSet("Expert", OBJPROP_CORNER, 1);
ObjectSet("Expert", OBJPROP_COLOR, White);
ObjectSet("Expert", OBJPROP_XDISTANCE, 150);
ObjectSet("Expert", OBJPROP_YDISTANCE, 0);
ObjectSetText("Expert", WindowExpertName(),15,"微軟正黑體", White);
//+------------------------------------------------------------------+
MinPriceShot=Energy;
//+------------------------------------------------------------------+
bar2=Bars;
if(Digits == 5 ||Digits == 3)
{
point=Point*10;
}
else
{
point=Point;
}
//+------------------------------------------------------------------+
double Position_L=Bid+Position*point;
ObjectCreate("Light",OBJ_ARROW,0,0,0);
ObjectSet("Light",OBJPROP_ARROWCODE,108);
ObjectSet("Light", OBJPROP_CORNER, 1);
ObjectSet("Light", OBJPROP_COLOR, Lime);
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light",OBJPROP_WIDTH,5);
ObjectCreate("Light2",OBJ_ARROW,0,0,0);
ObjectSet("Light2",OBJPROP_ARROWCODE,161);
ObjectSet("Light2", OBJPROP_CORNER, 1);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_WIDTH,5);
ObjectCreate("lightstatus",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"lightstatus", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"lightstatus", OBJPROP_COLOR, clrGold);
ObjectSetInteger(0,"lightstatus", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"lightstatus", OBJPROP_YDISTANCE, Pos+135);
ObjectSetInteger(0,"lightstatus", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
//+------------------------------------------------------------------+
GlobalVariableSet("next_sw",0);
if (!GlobalVariableCheck("start_balance"))
{
GlobalVariableSet("start_balance",AccountBalance());
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
if (!GlobalVariableCheck("start_p"))
{
GlobalVariableSet("start_p",TimeCurrent());
}
start_p=GlobalVariableGet("start_p");
MathSrand(TimeLocal());
for (int i=1;i<10;i++)
{minutee=1+((59*MathRand())/32768); }
GlobalVariableSet("RUN",0);
GlobalVariableSet("UPSW",0);
GlobalVariableSet("WSW",0);
GlobalVariableSet("RUNEA",0);
GlobalVariableSet("DNSW",0);
if (GlobalVariableCheck("MaxEquity")==false)
{GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);}
ObjectCreate(0,"Newsinfo",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo", OBJPROP_YDISTANCE, Pos+95);
ObjectSetInteger(0,"Newsinfo", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
ObjectCreate(0,"Newsinfo2",OBJ_LABEL,0,0,0);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_CORNER, 1);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_XDISTANCE, 20);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_YDISTANCE, Pos+115);
ObjectSetInteger(0,"Newsinfo2", OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
string ls4;
string ls12;
string ls20;
string ls28;
string ls36;
string ls44;
gd352 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd636 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
gd920 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
ObjectCreate("Lable1", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable1", OBJPROP_CORNER, 2);
ObjectSet("Lable1", OBJPROP_XDISTANCE, 23);
ObjectSet("Lable1", OBJPROP_YDISTANCE, 21);
g_text1472 = "";
ObjectSetText("Lable1", g_text1472, 12, "Arial", DeepSkyBlue);
ObjectCreate("Lable", OBJ_LABEL, 0, 0, 1.0);
ObjectSet("Lable", OBJPROP_CORNER, 2);
ObjectSet("Lable", OBJPROP_XDISTANCE, 3);
ObjectSet("Lable", OBJPROP_YDISTANCE, 1);
g_text1464 = "";
ObjectSetText("Lable", g_text1464, 10, "Arial", DeepSkyBlue);
if (false/*gi1480*/) {
if (KEY != "") {
gi1492 = 0;
for (int li_0 = 0; li_0 < StringLen(KEY); li_0++) {
if (StringSubstr(KEY, li_0, 1) != "X") ls4 = ls4 + StringSubstr(KEY, li_0, 1);
else {
ls12 = ls12 + f015(ls4);
ls4 = "";
}
}
for (li_0 = 0; li_0 < StringLen(ls12); li_0 += 2) {
if (StringSubstr(ls12, li_0, 2) == "55") ls20 = ls20 + "0";
else {
if (StringSubstr(ls12, li_0, 2) == "21") ls20 = ls20 + "1";
else {
if (StringSubstr(ls12, li_0, 2) == "98") ls20 = ls20 + "2";
else {
if (StringSubstr(ls12, li_0, 2) == "42") ls20 = ls20 + "3";
else {
if (StringSubstr(ls12, li_0, 2) == "10") ls20 = ls20 + "4";
else {
if (StringSubstr(ls12, li_0, 2) == "14") ls20 = ls20 + "5";
else {
if (StringSubstr(ls12, li_0, 2) == "88") ls20 = ls20 + "6";
else {
if (StringSubstr(ls12, li_0, 2) == "66") ls20 = ls20 + "7";
else {
if (StringSubstr(ls12, li_0, 2) == "33") ls20 = ls20 + "8";
else {
if (StringSubstr(ls12, li_0, 2) == "32") ls20 = ls20 + "9";
else {
if (StringSubstr(ls12, li_0, 2) == "96") ls20 = ls20 + "a";
else {
if (StringSubstr(ls12, li_0, 2) == "30") ls20 = ls20 + "b";
else {
if (StringSubstr(ls12, li_0, 2) == "77") ls20 = ls20 + "c";
else {
if (StringSubstr(ls12, li_0, 2) == "90") ls20 = ls20 + "d";
else {
if (StringSubstr(ls12, li_0, 2) == "24") ls20 = ls20 + "e";
else {
if (StringSubstr(ls12, li_0, 2) == "29") ls20 = ls20 + "f";
else {
if (StringSubstr(ls12, li_0, 2) == "39") ls20 = ls20 + "g";
else {
if (StringSubstr(ls12, li_0, 2) == "48") ls20 = ls20 + "h";
else {
if (StringSubstr(ls12, li_0, 2) == "56") ls20 = ls20 + "i";
else {
if (StringSubstr(ls12, li_0, 2) == "16") ls20 = ls20 + "j";
else {
if (StringSubstr(ls12, li_0, 2) == "62") ls20 = ls20 + "k";
else {
if (StringSubstr(ls12, li_0, 2) == "15") ls20 = ls20 + "l";
else {
if (StringSubstr(ls12, li_0, 2) == "71") ls20 = ls20 + "m";
else {
if (StringSubstr(ls12, li_0, 2) == "81") ls20 = ls20 + "n";
else {
if (StringSubstr(ls12, li_0, 2) == "93") ls20 = ls20 + "o";
else {
if (StringSubstr(ls12, li_0, 2) == "74") ls20 = ls20 + "p";
else {
if (StringSubstr(ls12, li_0, 2) == "83") ls20 = ls20 + "q";
else {
if (StringSubstr(ls12, li_0, 2) == "44") ls20 = ls20 + "r";
else {
if (StringSubstr(ls12, li_0, 2) == "51") ls20 = ls20 + "s";
else {
if (StringSubstr(ls12, li_0, 2) == "69") ls20 = ls20 + "t";
else {
if (StringSubstr(ls12, li_0, 2) == "40") ls20 = ls20 + "u";
else {
if (StringSubstr(ls12, li_0, 2) == "73") ls20 = ls20 + "v";
else {
if (StringSubstr(ls12, li_0, 2) == "59") ls20 = ls20 + "w";
else {
if (StringSubstr(ls12, li_0, 2) == "36") ls20 = ls20 + "x";
else {
if (StringSubstr(ls12, li_0, 2) == "26") ls20 = ls20 + "y";
else {
if (StringSubstr(ls12, li_0, 2) == "25") ls20 = ls20 + "z";
else {
if (StringSubstr(ls12, li_0, 2) == "28") ls20 = ls20 + "!";
else {
if (StringSubstr(ls12, li_0, 2) == "65") ls20 = ls20 + "&";
else {
if (StringSubstr(ls12, li_0, 2) == "52") ls20 = ls20 + "#";
else {
if (StringSubstr(ls12, li_0, 2) == "57") ls20 = ls20 + "$";
else {
if (StringSubstr(ls12, li_0, 2) == "31") ls20 = ls20 + "%";
else {
if (StringSubstr(ls12, li_0, 2) == "91") ls20 = ls20 + "*";
else {
if (StringSubstr(ls12, li_0, 2) == "60") ls20 = ls20 + "+";
else {
if (StringSubstr(ls12, li_0, 2) == "92") ls20 = ls20 + "-";
else {
if (StringSubstr(ls12, li_0, 2) == "34") ls20 = ls20 + "?";
else {
if (StringSubstr(ls12, li_0, 2) == "46") ls20 = ls20 + "^";
else {
if (StringSubstr(ls12, li_0, 2) == "38") ls20 = ls20 + "|";
else {
if (StringSubstr(ls12, li_0, 2) == "37") ls20 = ls20 + "@";
else {
if (StringSubstr(ls12, li_0, 2) == "49") ls20 = ls20 + "_";
else {
if (StringSubstr(ls12, li_0, 2) == "50") ls20 = ls20 + "S";
else
if (StringSubstr(ls12, li_0, 2) == "19") ls20 = ls20 + ".";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
ls28 = StringSubstr(ls20, 1, 2);
ls36 = StringSubstr(ls20, 3, 2);
ls44 = StringSubstr(ls20, 5, 4);
g_str2int1496 = StrToInteger(ls28);
g_str2int1500 = StrToInteger(ls36);
g_str2int1504 = StrToInteger(ls44);
if (Year() > g_str2int1504) gi1492 = 3;
if (Year() == g_str2int1504) {
if (Month() > g_str2int1500) gi1492 = 3;
if (Month() == g_str2int1500)
if (Day() > g_str2int1496) gi1492 = 3;
}
} else gi1492 = 1;
gi1480 = FALSE;
}
//Comment("\n", "License will expire on ", g_str2int1496, "/", g_str2int1500, "/", g_str2int1504);
return (0);
}
int deinit() {
ObjectDelete("cja");
ObjectDelete("Signalprice");
ObjectDelete("SIG_BARS_TF1");
ObjectDelete("SIG_BARS_TF2");
ObjectDelete("SIG_BARS_TF3");
ObjectDelete("SIG_BARS_TF4");
ObjectDelete("SIG_BARS_TF5");
ObjectDelete("SIG_BARS_TF6");
ObjectDelete("SIG_BARS_TF7");
ObjectDelete("SSignalMACD_TEXT");
ObjectDelete("SSignalMACDM1");
ObjectDelete("SSignalMACDM5");
ObjectDelete("SSignalMACDM15");
ObjectDelete("SSignalMACDM30");
ObjectDelete("SSignalMACDH1");
ObjectDelete("SSignalMACDH4");
ObjectDelete("SSignalMACDD1");
ObjectDelete("SSignalSTR_TEXT");
ObjectDelete("SignalSTRM1");
ObjectDelete("SignalSTRM5");
ObjectDelete("SignalSTRM15");
ObjectDelete("SignalSTRM30");
ObjectDelete("SignalSTRH1");
ObjectDelete("SignalSTRH4");
ObjectDelete("SignalSTRD1");
ObjectDelete("SignalEMA_TEXT");
ObjectDelete("SignalEMAM1");
ObjectDelete("SignalEMAM5");
ObjectDelete("SignalEMAM15");
ObjectDelete("SignalEMAM30");
ObjectDelete("SignalEMAH1");
ObjectDelete("SignalEMAH4");
ObjectDelete("SignalEMAD1");
ObjectDelete("SIG_DETAIL1");
ObjectDelete("SIG_DETAIL2");
ObjectDelete("SIG_DETAIL3");
ObjectDelete("SIG_DETAIL4");
ObjectDelete("SIG_DETAIL5");
ObjectDelete("SIG_DETAIL6");
ObjectDelete("SIG_DETAIL7");
ObjectDelete("SIG_DETAIL8");
ObjectDelete("Lable");
ObjectDelete("Lable1");
ObjectDelete("percent");
ObjectDelete("start_p");
ObjectDelete("takepercent_day");
ObjectDelete("run");
ObjectDelete("Newsinfo");
ObjectDelete("Newsinfo2");
ObjectDelete("ERR");
ObjectDelete("ERR2");
ObjectDelete("Expert");
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
ObjectDelete("Margin");
ObjectDelete("Float");
return (0);
}
int start() {
//+------------------------------------------------Author Start--------------------------------------------------------------------------+
GlobalVariableSet("Dhamar"+Symbol()+"TF",Period());
double Position_L=Bid+Position*point;
string outDN,outUP,outtext,outtext2;
if (GlobalVariableGet("RUNEA")==1) //EA控制器
{
Alert("EA is not working");
return;
}
//+------------------------------------------------Author End----------------------------------------------------------------------------+
int Handle_Log,h1;
if ((AccountProfit()/start_balance)*100<GlobalVariableGet("MaxEquity")) GlobalVariableSet("MaxEquity",(AccountProfit()/start_balance)*100);
displayprofit(start_p,next_in,start_balance);
//--------------------------------------------------------------------------------------Hydra
if (OrdersTotal()==0)
{
GlobalVariableSet("start_balance",AccountBalance());
GlobalVariableSet("start_p",TimeCurrent());
//GlobalVariableSet("MaxEquity",start_balance);
GlobalVariableSet("next_sw",0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),GlobalVariableGet("start_balance"),"After");
FileClose(h1);*/
Sleep(60000);
}
if (I_balance==0)
{start_balance=GlobalVariableGet("start_balance"); }
else
{start_balance=I_balance;}
start_p=GlobalVariableGet("start_p");
if (GlobalVariableGet("next_sw")==1)
{
if (IsTradeContextBusy())
{
Sleep(10000);
return;
}
iCloseOrders("100%",Symbol(),id1,0);
/*h1=FileOpen("Start_P",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(h1,0,SEEK_END);
FileWrite(h1,TimeToStr(start_p,TIME_DATE|TIME_MINUTES),GlobalVariableGet("MaxEquity"),start_balance,"Before");
FileClose(h1);*/
Sleep(5000);
if (MyOrderTotal_err(id1)!=0)
{
Alert(Symbol()+" 戰場未成功離開");
Sleep(30000);
return;
}else
{
Sleep(NextTime*60*1000);
}
return(0);
}
//--------------------------------------------------------------------------------------Hydra
if (SLClose(SLpercent,start_balance))
{
if (SleepLoss)
{
GlobalVariableSet("RUN",1);
GlobalVariableSet("runtime",StrToTime(TimeToStr(TimeLocal(),TIME_DATE)));
}
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Stop Loss Close");
FileClose(Handle_Log);*/
}
if (takepercent>0){
int ii_0=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE));
if (next_in==false) {
if (profit_control(ii_0,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in flase");
FileClose(Handle_Log);*/
return(0);
}
}
if (next_in==true){
if (profit_control(start_p,takepercent,start_balance)==false) {
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by next_in true");
FileClose(Handle_Log);*/
}
if (profit_control(ii_0,takepercent_day,start_balance)==false)
{
GlobalVariableSet("next_sw",1);
/*Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by day next_in true");
FileClose(Handle_Log);*/
return(0);
}
}
}
CheckTimeIn(MaxTime,MaxIn,MaxP,start_p);
//--------------------------------------------------------------------------------------Hydra
if (Hour()==hourr && Minute()==minutee && bar2!=Bars && GlobalVariableGet("UPSW")==0) {
GlobalVariableSet("UPSW",1);
//makefile_N();
bar2=Bars;
}
if (Hour()==hourr+1 && Minute()==0 && GlobalVariableGet("UPSW")==1)
{
GlobalVariableSet("UPSW",0);
}
//+------------------------------------------------------------------+
if (GlobalVariableGet("RUN")==1 && TimeLocal()<=GlobalVariableGet("runtime")+86400)
{
return;
}
if (GlobalVariableGet("RUN")==1 && TimeLocal()>GlobalVariableGet("runtime")+86400)
{
GlobalVariableSet("RUN",0);
}
ObjectCreate("run",OBJ_LABEL,0,0,0);
ObjectSet("run", OBJPROP_CORNER, 1);
ObjectSet("run", OBJPROP_COLOR, White);
ObjectSet("run", OBJPROP_XDISTANCE, 20);
ObjectSet("run", OBJPROP_YDISTANCE, Pos);
if (!Week15(W1Start,W5Over,start_t,stop_t,weekday) && OrdersTotal() == 0) {
ObjectSetText("run","未在設定時區內,現有戰役達成後將離開戰場",10,"微軟正黑體");
return;
}else {
ObjectSetText("run","已進入作戰時區內,全面啟動執行...",10,"微軟正黑體");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (BrakeSystem)
{
string Active="煞車系統啟動中";
string Deactive="煞車系統待命中";
color Light_status=Gold;
ObjectSet("Light",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light",OBJPROP_PRICE1,Position_L);
ObjectSet("Light2",OBJPROP_TIME1,TimeCurrent()+300);
ObjectSet("Light2",OBJPROP_PRICE1,Position_L);
ObjectSetString(0,"lightstatus",OBJPROP_FONT,"微軟正黑體");
ObjectSetInteger(0,"lightstatus",OBJPROP_FONTSIZE,10);
ObjectSetInteger(0,"lightstatus",OBJPROP_COLOR,Light_status);
int Price_Range;
int Time_Range;
int Now_Time = TimeCurrent();
double Now_Price = Close[0];
if (Last_Price != -1.0) {
Price_Range = Now_Price / Point - Last_Price / Point;
Time_Range = Now_Time - Last_Time;
//int Total_Orders = OrdersTotalCountByTypeANDMagic(OP_BUY, BuyMagic) + OrdersTotalCountByTypeANDMagic(OP_SELL, SellMagic);
if (MathAbs(Price_Range) >= MinPriceShot && Time_Range <= pSeconds) {
//if (Total_Orders < MaxOrdersCount) {
if (Now_Price > Last_Price) {
if ( MyOrderTotal_type(id1,1) > MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
if (Now_Price < Last_Price) {
if ( MyOrderTotal_type(id1,1) < MyOrderTotal_type(id1,0) )
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active);
SleepStop=TimeCurrent()+SleepTime*60;
}
}
//} else {}//Comment("");
Last_Price = Now_Price;
Last_Time = Now_Time;
}else {
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (Time_Range >= pSeconds) {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
} else {
Last_Price = Now_Price;
Last_Time = Now_Time;
ObjectSet("Light",OBJPROP_COLOR, Lime);
ObjectSet("Light2", OBJPROP_COLOR, LawnGreen);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Deactive);
}
if (TimeCurrent()<=SleepStop)
{
ObjectSet("Light", OBJPROP_COLOR, Red);
ObjectSet("Light2", OBJPROP_COLOR, Crimson);
ObjectSetString(0,"lightstatus",OBJPROP_TEXT,Active+", "+DoubleToStr((SleepStop-TimeCurrent())/60,0)+" 分鐘後啟動");
return;
}
}else {
ObjectDelete("Light");
ObjectDelete("Light2");
ObjectDelete("lightstatus");
}
//+------------------------------------------------Brake_System---------------------------------------------------------------------+
if (MarginSleep) {
bool Pass=false;
if (AccountMargin() == 0) {Pass=true;}
else{
double Margin_R=(AccountEquity()/AccountMargin())*100;
if (MarginLimit >= Margin_R && !Pass) {
ObjectCreate("Margin",OBJ_LABEL,0,0,0);
ObjectSet("Margin", OBJPROP_CORNER, 1);
ObjectSet("Margin", OBJPROP_COLOR, Gold);
ObjectSet("Margin", OBJPROP_XDISTANCE, 20);
ObjectSet("Margin", OBJPROP_YDISTANCE, Pos+155);
ObjectSetText("Margin", "保證金比例低於 "+DoubleToStr(MarginLimit,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Margin");
}
}
}else {
ObjectDelete("Margin");
}
if (FloatEq) {
double Profit=AccountProfit();
if (Profit <= FloatAm) {
ObjectCreate("Float",OBJ_LABEL,0,0,0);
ObjectSet("Float", OBJPROP_CORNER, 1);
ObjectSet("Float", OBJPROP_COLOR, Gold);
ObjectSet("Float", OBJPROP_XDISTANCE, 20);
ObjectSet("Float", OBJPROP_YDISTANCE, Pos+175);
ObjectSetText("Float", "浮虧大於 "+DoubleToStr(FloatAm,2)+" 達摩暫停出兵",10,"微軟正黑體", Gold);
return;
}else {
ObjectDelete("Float");
}
}else {
ObjectDelete("Float");
}
int li4;
int li8;
int li12;
int li16;
int li20;
int li24;
int li28;
color color32;
color color36;
color color40;
color color44;
color color48;
color color52;
color color56;
string ls_unused60;
color color68;
color color72;
color color76;
color color80;
color color84;
color color88;
color color92;
color color96;
string ls_unused100;
color color108;
int li_unused112;
double ihigh1128;
double ilow1136;
double iclose1144;
double iclose1152;
double ld1192;
double ld1248;
double ld1256;
int li1264;
int count1268;
double ld1316;
double ld1324;
int li1332;
int count1336;
int li992 = 0;
int li996 = 0;
int li1000 = 0;
int li1004 = 0;
int li1008 = 0;
int li1012 = 0;
li992 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
for (li1012 = 1; li1012 <= 5; li1012++) li996 = li996 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 10; li1012++) li1000 = li1000 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
for (li1012 = 1; li1012 <= 20; li1012++) li1004 = li1004 + (iHigh(NULL, PERIOD_D1, li1012) - iLow(NULL, PERIOD_D1, li1012)) / Point;
li996 /= 5;
li1000 /= 10;
li1004 /= 20;
li1008 = (li992 + li996 + li1000 + li1004) / 4;
string ls_unused1016 = "";
string ls_unused1024 = "";
string dbl2str1032 = "";
string dbl2str1040 = "";
string dbl2str1048 = "";
string dbl2str1056 = "";
string ls_unused1064 = "";
string ls_unused1072 = "";
string ls1080 = "";
double iopen1088 = iOpen(NULL, PERIOD_D1, 0);
double iclose1096 = iClose(NULL, PERIOD_D1, 0);
double ld1104 = (Ask - Bid) / Point;
double ihigh1112 = iHigh(NULL, PERIOD_D1, 0);
double ilow1120 = iLow(NULL, PERIOD_D1, 0);
dbl2str1040 = DoubleToStr((iclose1096 - iopen1088) / Point, 0);
dbl2str1032 = DoubleToStr(ld1104, Digits - 4);
dbl2str1048 = DoubleToStr(li1008, Digits - 4);
ls1080 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point;
dbl2str1056 = DoubleToStr((ihigh1112 - ilow1120) / Point, 0);
if (iclose1096 >= iopen1088) {
ls_unused1064 = "-";
color108 = g_color1100;
}
if (iclose1096 < iopen1088) {
ls_unused1064 = "-";
color108 = g_color1104;
}
if (dbl2str1048 >= ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1108;
}
if (dbl2str1048 < ls1080) {
ls_unused1072 = "-";
li_unused112 = gi1112;
}
double ld1160 = LotExponent;
int li1168 = gi108;
double ld1172 = TakeProfit;
bool bool1180 = UseEquityStop;
double ld1184 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1192 = Lots;
else ld1192 = 0.00001 * MathCeil(AccountBalance());
} else ld1192 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop_Hilo) f035(TrailStart_Hilo, TrailStop_Hilo, g_price312);
if (gi220) {
if (TimeCurrent() >= gi376) {
f024();
Print("Closed All due_Hilo to TimeOut");
}
}
if (gi372 == Time[0]) return (0);
gi372 = Time[0];
double ld1200 = f031();
if (bool1180) {
if (ld1200 < 0.0 && MathAbs(ld1200) > ld1184 / 100.0 * f07()) {
f024();
Print("Closed All due_Hilo to Stop Out");
gi424 = FALSE;
}
}
gi396 = f04();
if (gi396 == 0) gi360 = FALSE;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
gi412 = TRUE;
gi416 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
gi412 = FALSE;
gi416 = TRUE;
break;
}
}
}
if (gi396 > 0 && gi396 <= MaxTrades_A) {
RefreshRates();
gd336 = f032();
gd344 = f020();
if (gi412 && gd336 - Ask >= PipStep_Hilo * Point) gi408 = TRUE;
if (gi416 && Bid - gd344 >= PipStep_Hilo * Point) gi408 = TRUE;
}
if (gi396 < 1) {
gi416 = FALSE;
gi412 = FALSE;
gi408 = TRUE;
gd288 = AccountEquity();
}
if (gi408) {
gd336 = f032();
gd344 = f020();
if (gi416) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
RefreshRates();
gi420 = f03(1, gd384, Bid, slip_Hilo, Ask, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi408 = FALSE;
gi424 = TRUE;
} else {
if (gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
gi420 = f03(0, gd384, Ask, slip_Hilo, Bid, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi408 = FALSE;
gi424 = TRUE;
}
}
}
if (gi408 && gi396 < 1) {
ihigh1128 = iHigh(Symbol(), 0, 1);
ilow1136 = iLow(Symbol(), 0, 2);
g_bid320 = Bid;
g_ask328 = Ask;
if ((!gi416) && !gi412) {
gi380 = gi396;
gd384 = NormalizeDouble(ld1192 * MathPow(ld1160, gi380), li1168);
if (ihigh1128 > ilow1136) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi420 = f03(1, gd384, g_bid320, slip_Hilo, g_bid320, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, HotPink);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd336 = f032();
gi424 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi420 = f03(0, gd384, g_ask328, slip_Hilo, g_ask328, 0, 0, gs364 + "-" + gi380, MagicNumber_Hilo, 0, Lime);
if (gi420 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd344 = f020();
gi424 = TRUE;
}
}
if (gi420 > 0) gi376 = TimeCurrent() + 60.0 * (60.0 * gd224);
gi408 = FALSE;
}
}
gi396 = f04();
g_price312 = 0;
double ld1208 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price312 += OrderOpenPrice() * OrderLots();
ld1208 += OrderLots();
}
}
}
if (gi396 > 0) g_price312 = NormalizeDouble(g_price312 / ld1208, Digits);
if (gi424) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
g_price280 = g_price312 + ld1172 * Point;
gd_unused296 = g_price280;
gd400 = g_price312 - g_pips236 * Point;
gi360 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_SELL) {
g_price280 = g_price312 - ld1172 * Point;
gd_unused304 = g_price280;
gd400 = g_price312 + g_pips236 * Point;
gi360 = TRUE;
}
}
}
}
if (gi424) {
if (gi360 == TRUE) {
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) OrderModify(OrderTicket(), g_price312, OrderStopLoss(), g_price280, 0, Yellow);
gi424 = FALSE;
}
}
}
double ld1216 = LotExponent;
int li1224 = gi108;
double ld1228 = TakeProfit;
bool bool1236 = UseEquityStop;
double ld1240 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1248 = Lots;
else ld1248 = 0.00001 * MathCeil(AccountBalance());
} else ld1248 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop15) f021(TrailStart15, TrailStop15, g_price596);
if (gi532) {
if (TimeCurrent() >= gi660) {
f018();
Print("Closed All due to TimeOut");
}
}
if (gi656 != Time[0]) {
gi656 = Time[0];
ld1256 = f029();
if (bool1236) {
if (ld1256 < 0.0 && MathAbs(ld1256) > ld1240 / 100.0 * f016()) {
f018();
Print("Closed All due to Stop Out");
gi708 = FALSE;
}
}
gi680 = f05();
if (gi680 == 0) gi644 = FALSE;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
gi696 = TRUE;
gi700 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
gi696 = FALSE;
gi700 = TRUE;
break;
}
}
}
if (gi680 > 0 && gi680 <= MaxTrades_B) {
RefreshRates();
gd620 = f036();
gd628 = f028();
if (gi696 && gd620 - Ask >= PipStep15 * Point) gi692 = TRUE;
if (gi700 && Bid - gd628 >= PipStep15 * Point) gi692 = TRUE;
}
if (gi680 < 1) {
gi700 = FALSE;
gi696 = FALSE;
gi692 = TRUE;
gd572 = AccountEquity();
}
if (gi692) {
gd620 = f036();
gd628 = f028();
if (gi700) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
RefreshRates();
gi704 = f02(1, gd668, Bid, slip15, Ask, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi692 = FALSE;
gi708 = TRUE;
} else {
if (gi696) {
gi664 = gi680;
gd668 = NormalizeDouble(ld1248 * MathPow(ld1216, gi664), li1224);
gi704 = f02(0, gd668, Ask, slip15, Bid, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi692 = FALSE;
gi708 = TRUE;
}
}
}
}
if (g_datetime728 != iTime(NULL, g_timeframe496, 0)) {
li1264 = OrdersTotal();
count1268 = 0;
for (int li1272 = li1264; li1272 >= 1; li1272--) {
OrderSelect(li1272 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) count1268++;
}
if (li1264 == 0 || count1268 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid604 = Bid;
g_ask612 = Ask;
gi664 = gi680;
gd668 = ld1248;
if (iclose1144 > iclose1152) {
gi704 = f02(1, gd668, g_bid604, slip15, g_bid604, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, HotPink);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd620 = f036();
gi708 = TRUE;
} else {
gi704 = f02(0, gd668, g_ask612, slip15, g_ask612, 0, 0, gs648 + "-" + gi664, g_magic17615, 0, Lime);
if (gi704 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd628 = f028();
gi708 = TRUE;
}
if (gi704 > 0) gi660 = TimeCurrent() + 60.0 * (60.0 * gd536);
gi692 = FALSE;
}
g_datetime728 = iTime(NULL, g_timeframe496, 0);
}
gi680 = f05();
g_price596 = 0;
double ld1276 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price596 += OrderOpenPrice() * OrderLots();
ld1276 += OrderLots();
}
}
}
if (gi680 > 0) g_price596 = NormalizeDouble(g_price596 / ld1276, Digits);
if (gi708) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
g_price564 = g_price596 + ld1228 * Point;
gd_unused580 = g_price564;
gd684 = g_price596 - g_pips508 * Point;
gi644 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_SELL) {
g_price564 = g_price596 - ld1228 * Point;
gd_unused588 = g_price564;
gd684 = g_price596 + g_pips508 * Point;
gi644 = TRUE;
}
}
}
}
if (gi708) {
if (gi644 == TRUE) {
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) OrderModify(OrderTicket(), g_price596, OrderStopLoss(), g_price564, 0, Yellow);
gi708 = FALSE;
}
}
}
double ld1284 = LotExponent;
int li1292 = gi108;
double ld1296 = TakeProfit;
bool bool1304 = UseEquityStop;
double ld1308 = TotalEquityRisk;
if (MM == TRUE) {
if (MathCeil(AccountBalance()) < 2000.0) ld1316 = Lots;
else ld1316 = 0.00001 * MathCeil(AccountBalance());
} else ld1316 = Lots;
if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
":00"))) return (0);
if (UseTrailingStop16) f034(TrailStart16, TrailStop16, g_price880);
if (gi816) {
if (TimeCurrent() >= gi944) {
f0_0();
Print("Closed All due to TimeOut");
}
}
if (gi940 != Time[0]) {
gi940 = Time[0];
ld1324 = f08();
if (bool1304) {
if (ld1324 < 0.0 && MathAbs(ld1324) > ld1308 / 100.0 * f030()) {
f0_0();
Print("Closed All due to Stop Out");
gi992 = FALSE;
}
}
gi964 = f012();
if (gi964 == 0) gi928 = FALSE;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
gi980 = TRUE;
gi984 = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
gi980 = FALSE;
gi984 = TRUE;
break;
}
}
}
if (gi964 > 0 && gi964 <= MaxTrades_C) {
RefreshRates();
gd904 = f017();
gd912 = f027();
if (gi980 && gd904 - Ask >= PipStep16 * Point) gi976 = TRUE;
if (gi984 && Bid - gd912 >= PipStep16 * Point) gi976 = TRUE;
}
if (gi964 < 1) {
gi984 = FALSE;
gi980 = FALSE;
gd856 = AccountEquity();
}
if (gi976) {
gd904 = f017();
gd912 = f027();
if (gi984) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
RefreshRates();
gi988 = f06(1, gd952, Bid, slip16, Ask, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi976 = FALSE;
gi992 = TRUE;
} else {
if (gi980) {
gi948 = gi964;
gd952 = NormalizeDouble(ld1316 * MathPow(ld1284, gi948), li1292);
gi988 = f06(0, gd952, Ask, slip16, Bid, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi976 = FALSE;
gi992 = TRUE;
}
}
}
}
if (g_datetime1012 != iTime(NULL, g_timeframe784, 0)) {
li1332 = OrdersTotal();
count1336 = 0;
for (int li1340 = li1332; li1340 >= 1; li1340--) {
OrderSelect(li1340 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) count1336++;
}
if (li1332 == 0 || count1336 < 1) {
iclose1144 = iClose(Symbol(), 0, 2);
iclose1152 = iClose(Symbol(), 0, 1);
g_bid888 = Bid;
g_ask896 = Ask;
gi948 = gi964;
gd952 = ld1316;
if (iclose1144 > iclose1152) {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) {
gi988 = f06(1, gd952, g_bid888, slip16, g_bid888, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, HotPink);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd904 = f017();
gi992 = TRUE;
}
} else {
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) {
gi988 = f06(0, gd952, g_ask896, slip16, g_ask896, 0, 0, gs932 + "-" + gi948, g_magic17616, 0, Lime);
if (gi988 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd912 = f027();
gi992 = TRUE;
}
}
if (gi988 > 0) gi944 = TimeCurrent() + 60.0 * (60.0 * gd820);
gi976 = FALSE;
}
g_datetime1012 = iTime(NULL, g_timeframe784, 0);
}
gi964 = f012();
g_price880 = 0;
double ld1344 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price880 += OrderOpenPrice() * OrderLots();
ld1344 += OrderLots();
}
}
}
if (gi964 > 0) g_price880 = NormalizeDouble(g_price880 / ld1344, Digits);
if (gi992) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
g_price848 = g_price880 + ld1296 * Point;
gd_unused864 = g_price848;
gd968 = g_price880 - g_pips792 * Point;
gi928 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_SELL) {
g_price848 = g_price880 - ld1296 * Point;
gd_unused872 = g_price848;
gd968 = g_price880 + g_pips792 * Point;
gi928 = TRUE;
}
}
}
}
if (gi992) {
if (gi928 == TRUE) {
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) OrderModify(OrderTicket(), g_price880, OrderStopLoss(), g_price848, 0, Yellow);
gi992 = FALSE;
}
}
}
//Handle_Log=0;
return (0);
}
int f04() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f024() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip_Hilo, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip_Hilo, Red);
}
Sleep(1000);
}
}
}
int f03(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM1(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f022(ad24, ai32), f019(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f022(Bid, ai32), f019(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f011(ad24, ai32), f01(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f011(Ask, ai32), f01(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("jaipong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f022(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f011(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f019(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f01(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f031() {
double ld_ret_0 = 0;
for (g_pos392 = OrdersTotal() - 1; g_pos392 >= 0; g_pos392--) {
OrderSelect(g_pos392, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f035(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber_Hilo) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f07() {
if (f04() == 0) gd428 = AccountEquity();
if (gd428 < gd436) gd428 = gd436;
else gd428 = AccountEquity();
gd436 = AccountEquity();
return (gd428);
}
double f032() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f020() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f05() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f018() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip15, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip15, Red);
}
Sleep(1000);
}
}
}
int f02(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM2(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f013(ad24, ai32), f025(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f013(Bid, ai32), f025(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f033(ad24, ai32), f026(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f033(Ask, ai32), f026(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("keroncong.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f013(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f033(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f025(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f026(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f029() {
double ld_ret_0 = 0;
for (g_pos676 = OrdersTotal() - 1; g_pos676 >= 0; g_pos676--) {
OrderSelect(g_pos676, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f021(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17615) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f016() {
if (f05() == 0) gd712 = AccountEquity();
if (gd712 < gd720) gd712 = gd720;
else gd712 = AccountEquity();
gd720 = AccountEquity();
return (gd712);
}
double f036() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f028() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17615) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17615 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
int f012() {
int count_0 = 0;
for (int pos4 = OrdersTotal() - 1; pos4 >= 0; pos4--) {
OrderSelect(pos4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
void f0_0() {
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip16, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip16, Red);
}
Sleep(1000);
}
}
}
int f06(int ai_0, double a_lots4, double a_price12, int a_slippage20, double ad24, int ai32, int ai36, string a_comment40, int a_magic48, int a_datetime52, color a_color56) {
int ticket60 = 0;
int error64 = 0;
int count68 = 0;
int li72 = 100;
if (!ThreeM3(ai_0) && BSB) {return;}
switch (ai_0) {
case 2:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots4, a_price12, a_slippage20, f014(ad24, ai32), f09(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (count68 = 0; count68 < li72; count68++) {
RefreshRates();
ticket60 = OrderSend(Symbol(), OP_BUY, a_lots4, Ask, a_slippage20, f014(Bid, ai32), f09(Ask, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots4, a_price12, a_slippage20, f023(ad24, ai32), f010(a_price12, ai36), a_comment40, a_magic48, a_datetime52,
a_color56);
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (count68 = 0; count68 < li72; count68++) {
ticket60 = OrderSend(Symbol(), OP_SELL, a_lots4, Bid, a_slippage20, f023(Ask, ai32), f010(Bid, ai36), a_comment40, a_magic48, a_datetime52, a_color56);
//PlaySound("tortor.wav");
error64 = GetLastError();
if (error64 == 0/* NO_ERROR */) break;
if (!((error64 == 4/* SERVER_BUSY */ || error64 == 137/* BROKER_BUSY */ || error64 == 146/* TRADE_CONTEXT_BUSY */ || error64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (ticket60);
}
double f014(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f023(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f09(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 + ai8 * Point);
}
double f010(double ad_0, int ai8) {
if (ai8 == 0) return (0);
return (ad_0 - ai8 * Point);
}
double f08() {
double ld_ret_0 = 0;
for (g_pos960 = OrdersTotal() - 1; g_pos960 >= 0; g_pos960--) {
OrderSelect(g_pos960, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void f034(int ai_0, int ai4, double a_price8) {
int li16;
double order_stoploss20;
double price28;
if (ai4 != 0) {
for (int pos36 = OrdersTotal() - 1; pos36 >= 0; pos36--) {
if (OrderSelect(pos36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic17616) {
if (OrderType() == OP_BUY) {
li16 = NormalizeDouble((Bid - a_price8) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Bid - ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 > order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li16 = NormalizeDouble((a_price8 - Ask) / Point, 0);
if (li16 < ai_0) continue;
order_stoploss20 = OrderStopLoss();
price28 = Ask + ai4 * Point;
if (order_stoploss20 == 0.0 || (order_stoploss20 != 0.0 && price28 < order_stoploss20)) OrderModify(OrderTicket(), a_price8, price28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double f030() {
if (f012() == 0) gd996 = AccountEquity();
if (gd996 < gd1004) gd996 = gd1004;
else gd996 = AccountEquity();
gd1004 = AccountEquity();
return (gd996);
}
double f017() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_BUY) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
double f027() {
double order_open_price_0;
int ticket8;
double ld_unused12 = 0;
int ticket20 = 0;
for (int pos24 = OrdersTotal() - 1; pos24 >= 0; pos24--) {
OrderSelect(pos24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic17616) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic17616 && OrderType() == OP_SELL) {
ticket8 = OrderTicket();
if (ticket8 > ticket20) {
order_open_price_0 = OrderOpenPrice();
ld_unused12 = order_open_price_0;
ticket20 = ticket8;
}
}
}
return (order_open_price_0);
}
string f015(string as_0) {
int str_len8 = StringLen(as_0);
bool li_ret12 = FALSE;
for (int li16 = 0; li16 < str_len8; li16++) {
if (StringSubstr(as_0, li16, 1) == "1") li_ret12 = li_ret12 + MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "2") li_ret12 = li_ret12 + 2.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "3") li_ret12 = li_ret12 + 3.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "4") li_ret12 = li_ret12 + 4.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "5") li_ret12 = li_ret12 + 5.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "6") li_ret12 = li_ret12 + 6.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "7") li_ret12 = li_ret12 + 7.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "8") li_ret12 = li_ret12 + 8.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "9") li_ret12 = li_ret12 + 9.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "A") li_ret12 = li_ret12 + 10.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "B") li_ret12 = li_ret12 + 11.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "C") li_ret12 = li_ret12 + 12.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "D") li_ret12 = li_ret12 + 13.0 * MathPow(16, str_len8 - li16 - 1);
else {
if (StringSubstr(as_0, li16, 1) == "E") li_ret12 = li_ret12 + 14.0 * MathPow(16, str_len8 - li16 - 1);
else
if (StringSubstr(as_0, li16, 1) == "F") li_ret12 = li_ret12 + 15.0 * MathPow(16, str_len8 - li16 - 1);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return (li_ret12);
}
string MakeDateTime(string strDate, string strTime)
{
// Print("Converting Forex Factory Time into Metatrader time..."); //added by MN
// Converts forexfactory time & date into yyyy.mm.dd hh:mm
int n1stDash = StringFind(strDate, "-");
int n2ndDash = StringFind(strDate, "-", n1stDash+1);
string strMonth = StringSubstr(strDate, 0, 2);
string strDay = StringSubstr(strDate, 3, 2);
string strYear = StringSubstr(strDate, 6, 4);
// strYear = "20" + strYear;
int nTimeColonPos = StringFind(strTime, ":");
string strHour = StringSubstr(strTime, 0, nTimeColonPos);
string strMinute = StringSubstr(strTime, nTimeColonPos+1, 2);
string strAM_PM = StringSubstr(strTime, StringLen(strTime)-2);
int nHour24 = StrToInteger(strHour);
if ((strAM_PM == "pm" || strAM_PM == "PM") && nHour24 != 12)
{
nHour24 += 12;
}
if ((strAM_PM == "am" || strAM_PM == "AM") && nHour24 == 12)
{
nHour24 = 0;
}
string strHourPad = "";
if (nHour24 < 10)
strHourPad = "0";
return(StringConcatenate(strYear, ".", strMonth, ".", strDay, " ", strHourPad, nHour24, ":", strMinute));
}
bool profit_control(int i_0,double takepercent_,double start_balance)
{
double today_profit;
int i1=StrToTime(TimeToStr(TimeCurrent()+86400, TIME_DATE));
today_profit=((GetProfitFromDateInCurrency(i_0)+AccountProfit())/start_balance)*100;
if (today_profit>=takepercent_)
{
return(false);
}
return(true);
}
void displayprofit(int start_p,bool next_in,double start_balance)
{
double today_profit;
string display;
ObjectCreate("percent",OBJ_LABEL,0,0,0);
ObjectSet("percent", OBJPROP_CORNER, 1);
ObjectSet("percent", OBJPROP_COLOR, White);
ObjectSet("percent", OBJPROP_XDISTANCE, 20);
ObjectSet("percent", OBJPROP_YDISTANCE, Pos+30);
ObjectCreate("start_p",OBJ_LABEL,0,0,0);
ObjectSet("start_p", OBJPROP_CORNER, 1);
ObjectSet("start_p", OBJPROP_COLOR, White);
ObjectSet("start_p", OBJPROP_XDISTANCE, 20);
ObjectSet("start_p", OBJPROP_YDISTANCE, Pos+50);
ObjectSetText("start_p","進場經過時間 "+ DoubleToStr((TimeCurrent()-start_p)/60,1)+ " 分鐘"+" ; "+OrdersTotal()+" 兵力在戰場上",10,"微軟正黑體");
if (next_in==true)
{
today_profit=((GetProfitFromDateInCurrency(start_p)+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
GlobalVariableSet("display",today_profit);
ObjectSetText("percent","單次擄獲狂派戰俘"+display+"%"+" ; 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectCreate("takepercent_day",OBJ_LABEL,0,0,0);
ObjectSet("takepercent_day", OBJPROP_CORNER, 1);
ObjectSet("takepercent_day", OBJPROP_COLOR, White);
ObjectSet("takepercent_day", OBJPROP_XDISTANCE, 20);
ObjectSet("takepercent_day", OBJPROP_YDISTANCE, Pos+70);
ObjectSetText("takepercent_day","今日擄獲狂派戰俘累積至"+display+" ; 最大暫時被擄穫兵力 "+DoubleToStr(GlobalVariableGet("MaxEquity"),2)+" %",10,"微軟正黑體");
}
if (next_in==false)
{
today_profit=((GetProfitFromDateInCurrency(StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)))+AccountProfit())/start_balance)*100;
display=DoubleToStr(today_profit,2);
ObjectSetText("percent","今日擄獲狂派戰俘累積至"+display+"%"+" 進場起始兵力: "+DoubleToStr(start_balance,2),10,"微軟正黑體");
}
}
double GetProfitFromDateInCurrency(int today) {
double profit = 0;
int total = OrdersHistoryTotal();
for (int i = 0; i < total; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL ) {
if (today < OrderCloseTime()) profit += OrderProfit() + OrderCommission() + OrderSwap();
}
}
}
return (profit);
}
bool SLClose (double percent,double start_balance) {
if (AccountProfit()<=0)
{
if ((MathAbs(AccountProfit())/start_balance)*100>=percent)
{
return(true);
}
else
{
return(false);
}
}else
{
return(false);
}
}
void iCloseOrders(string myType,string currency,int id1,int type)
{
if (MyOrderTotal_err(id1)==0) return(0);
int C0_cnt,close_t[],t_cnt;
double percentlots,nd_profit;
if (myType=="Del"&&type==0)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_BUYSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="Del"&&type==1)
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency&&OrderType()==OP_SELLSTOP && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderDelete(OrderTicket());
}
}
}
if (myType=="100%")
{
for(C0_cnt=0;C0_cnt<OrdersTotal();C0_cnt++) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false)
{
//Alert(Symbol()+" OrderSelect Error");
continue;
}
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
ArrayResize(close_t,t_cnt+1);
close_t[t_cnt]=OrderTicket();
t_cnt++;
}
}
for(int i=ArraySize(close_t)-1;i>=0;i--)
{
if (OrderSelect(close_t[i],SELECT_BY_TICKET)==false)
{
Alert(Symbol()+" OrderSelect Error By Tickets");continue;
}
else
{
percentlots=OrderLots();
OrderClose(close_t[i],percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="80%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.8;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="50%")
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
percentlots=OrderLots()*0.5;
OrderClose(OrderTicket(),percentlots,OrderClosePrice(),2,Blue);
}
}
}
if (myType=="All") //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if (OrderMagicNumber()!=0){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="BUY"&&type==0) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_BUY && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
if (myType=="SELL"&&type==1) //所有單
{
for(C0_cnt=OrdersTotal();C0_cnt>=0;C0_cnt--) //從最近一張單開始
{
if (OrderSelect(C0_cnt,SELECT_BY_POS)==false) continue;
else if ( OrderType()==OP_SELL && OrderSymbol()==currency && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 )){
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),2,Blue);
}
}
}
}
int MyOrderTotal_err(int id1)//訂單總數函式
{
int x=0;//符合條件的BUY單數量(記次變數)
for(int z=0;z<OrdersTotal();z++)//執行N次篩選(N=訂單總數)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);//用"流水號"找訂單
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ))//挑選出同貨幣對 && BUY單 && MagicNumber=本程式 的訂單
{
x++;//符合節選結果的訂單總數
}
}
return(x);//回傳
}
int MyOrderTotal_type(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && ( OrderMagicNumber()==MagicNumber_Hilo || OrderMagicNumber()==g_magic17615 || OrderMagicNumber()==g_magic17616 ) && OrderType()==type)
{
x++;//
}
}
return(x);
}
bool iTimeControl(int myStartHour,int myStopHour)
{
bool EA_Valid=false;
if(myStopHour == myStartHour) EA_Valid = true;
if(myStopHour < myStartHour)
{
if (TimeHour(TimeLocal()) >= myStartHour || TimeHour(TimeLocal()) < myStopHour) EA_Valid = true;
}
if (myStopHour > myStartHour) {
if ((TimeHour(TimeLocal()) >= myStartHour && TimeHour(TimeLocal()) < myStopHour))
EA_Valid = true;
}
return(EA_Valid);
}
bool Week15 (int start,int over,int myStartHour,int myStopHour,string weekday)
{
bool EA_Valid=false;
int Dayweek=TimeDayOfWeek(TimeLocal());
if (
(
(
Dayweek == 1 && TimeHour(TimeLocal()) < start
)
||
(
Dayweek == StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1)) && TimeHour(TimeLocal()) >= over
)
||
(
Dayweek > StrToDouble(StringSubstr(weekday,StringLen(weekday)-1,1))
)
)
&& Week15SW) {
EA_Valid=false;
}else {
if (iTimeControl(myStartHour,myStopHour)) {
if (StringFind(weekday,DoubleToStr(Dayweek,0),0) >= 0) {
EA_Valid=true;
}else {
EA_Valid=false;
}
}else {
EA_Valid=false;
}
}
return(EA_Valid);
}
void CheckTimeIn(int MaxTime,int MaxIn,double MaxP,int start_p)
{
int Handle_Log;
int Valid;
int RunTime=(TimeCurrent()-start_p)/60;
if (RunTime>=MaxTime && OrdersTotal() >= MaxIn && GlobalVariableGet("display")>= MaxP)
{
GlobalVariableSet("next_sw",1);
Handle_Log=FileOpen("IOLog.txt",FILE_CSV|FILE_WRITE|FILE_SHARE_READ,',');
FileSeek(Handle_Log,0,SEEK_END);
FileWrite(Handle_Log,TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES),"Profit Close by CheckTimeIn");
FileClose(Handle_Log);
}
}
string Base64Decode(string in/*,string &out*/)
{
string out;
int i=0,len=StringLen(in);
int shift=0,accum=0;
while(i<len)
{
int value=ExtBase64Decode[StringGetChar(in,i)];
if(value<0 || value>63) break;
accum<<=6;
shift+=6;
accum|=value;
if(shift>=8)
{
shift-=8;
value=accum >> shift;
out=out+CharToStr(value & 0xFF);
}
i++;
}
//----
return(out);
}
bool ThreeM1(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(g_magic17616,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(g_magic17616,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM2(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17616,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17616,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
bool ThreeM3(int type)
{
if (type == 2 || type == 4 || type == 0)
{
if (MyOrderTotal_id(g_magic17615,0) >0 && MyOrderTotal_id(MagicNumber_Hilo,0) >0)
{
return(false);
}else
{
return(true);
}
}
if (type==3 || type == 5 || type == 1)
{
if (MyOrderTotal_id(g_magic17615,1) >0 && MyOrderTotal_id(MagicNumber_Hilo,1) >0)
{
return(false);
}else
{
return(true);
}
}
}
int MyOrderTotal_id(int id1,int type)
{
int x=0;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==id1 && OrderType()==type)
{
x++;//
}
}
return(x);
}
//+------------------------------------------------------------------+
//| DHAMAR-Control.mq4 |
//| APP Wargame-Hydra |
//| http://www.facebook.com/groups/moneywargame/ |
//+------------------------------------------------------------------+
#include <mt4gui2.mqh>
extern string M="常駐時區";
extern int Period_D=1;
extern string A="馬丁單數控制";
extern bool MTicket=false;
extern string B="任意模組馬幾張,切換至M5時區";
extern int SumA=3;
extern string C="任意模組馬幾張,切換至M15時區";
extern int SumB=5;
extern string D="任意模組馬幾張,切換至M30時區";
extern int SumC=7;
extern string E="任意模組馬幾張,切換至H1時區";
extern int SumD=10;
extern string F="任意模組馬幾張,切換至H4時區";
extern int SumE=13;
extern string G="保證金控制";
extern bool Margin=false;
extern string H="保證金比例低於?,切換至M5時區";
extern double RatioA=20000;
extern string I="保證金比例低於?,切換至M15時區";
extern double RatioB=10000;
extern string J="保證金比例低於?,切換至M30時區";
extern double RatioC=5000;
extern string K="保證金比例低於?,切換至H1時區";
extern double RatioD=2500;
extern string L="保證金比例低於?,切換至H4時區";
extern double RatioE=1000;
int Change_SW;
int MagicA=11111;
int MagicB=12324;
int MagicC=16794;
int hwnd,hwnd2;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int button1,button2,button3,button4;
bool pass=false;
long ID = 0;
int init()
{
//----
long prevID = ChartFirst();
for (int i=0;i<CHARTS_MAX;i++)
{
if (ChartSymbol(prevID) == Symbol())
{
if (ChartID() == prevID)
{
prevID = ChartNext(prevID);
continue;
}else
{
ID = prevID;
break;
}
}
prevID = ChartNext(prevID);
}
hwnd = WindowHandle(Symbol(),Period());
guiRemoveAll(hwnd);
button1 = guiAdd(hwnd,"button",100,80,150,30,"START");
button2 = guiAdd(hwnd,"button",100,110,150,30,"STOP");
pass=false;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
if (hwnd>0) { guiRemoveAll(hwnd); guiCleanup(hwnd); }
//----
ObjectDelete("Margin");
ObjectDelete("MTicket");
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
hwnd2 = GlobalVariableGet("Dhamar"+Symbol());
if (guiIsClicked(hwnd,button1)) {pass=true;}
while(!IsStopped() && pass)
{
if (guiIsClicked(hwnd,button2)) {pass=false;}
if (pass){Comment("\n\n DhamarControl START");}
else {Comment("\n\n DhamarControl OVER");}
//int T_TF=GlobalVariableGet("Dhamar"+Symbol()+"TF");
int T_TF=ChartPeriod(ID);
if(T_TF!=Period_D && OrdersTotal()==0)
{
ChangePeriod(hwnd2,Period_D);
}
if (Margin) {
bool Pass=false;
if (AccountMargin() == 0) {Pass=true;}
else{
double Margin_R=(AccountEquity()/AccountMargin())*100;
double MarginLimit=0;
if (RatioB < Margin_R && Margin_R <= RatioA )
{
if(T_TF!=5)
{
ChangePeriod(hwnd2,5);
}
MarginLimit=RatioA;
}
else if (RatioC < Margin_R && Margin_R <= RatioB )
{
if(T_TF!=15)
{
ChangePeriod(hwnd2,15);
}
MarginLimit=RatioB;
}
else if (RatioD < Margin_R && Margin_R <= RatioC )
{
if(T_TF!=30)
{
ChangePeriod(hwnd2,30);
}
MarginLimit=RatioC;
}
else if (RatioE < Margin_R && Margin_R <= RatioD )
{
if(T_TF!=60)
{
ChangePeriod(hwnd2,60);
}
MarginLimit=RatioD;
}
else if (Margin_R <= RatioE )
{
if(T_TF!=240)
{
ChangePeriod(hwnd2,240);
}
MarginLimit=RatioE;
}else
{
if(T_TF!=Period_D)
{
ChangePeriod(hwnd2,Period_D);
}
}
if (MarginLimit >= Margin_R && !Pass) {
ObjectCreate("Margin",OBJ_LABEL,0,0,0);
ObjectSet("Margin", OBJPROP_CORNER, 1);
ObjectSet("Margin", OBJPROP_COLOR, Gold);
ObjectSet("Margin", OBJPROP_XDISTANCE, 20);
ObjectSet("Margin", OBJPROP_YDISTANCE, 150+155);
ObjectSetText("Margin", "保證金比例低於 "+DoubleToStr(MarginLimit,2)+" %達摩切換時區",10,"微軟正黑體", Gold);
return(0);
}else {
ObjectDelete("Margin");
}
}
}else {
ObjectDelete("Margin");
}
if (MTicket) {
int Ticket_A=MyOrderTotal(MagicA);
int Ticket_B=MyOrderTotal(MagicB);
int Ticket_C=MyOrderTotal(MagicC);
int MaxTicket;
int Ticket[];
ArrayResize(Ticket,3);
Ticket[0]=Ticket_A;
Ticket[1]=Ticket_B;
Ticket[2]=Ticket_C;
MaxTicket=Ticket[ArrayMaximum(Ticket)];
int MartinTicket;
if (MaxTicket >= SumA && MaxTicket < SumB)
{
if(T_TF!=5)
{
ChangePeriod(hwnd2,5);
}
MartinTicket=SumA;
}
else if (MaxTicket >= SumB && MaxTicket < SumC)
{
if(T_TF!=15)
{
ChangePeriod(hwnd2,15);
}
MartinTicket=SumB;
}
else if (MaxTicket >= SumC && MaxTicket < SumD)
{
if(T_TF!=30)
{
ChangePeriod(hwnd2,30);
}
MartinTicket=SumC;
}
else if (MaxTicket >= SumD && MaxTicket < SumE)
{
if(T_TF!=60)
{
ChangePeriod(hwnd2,60);
}
MartinTicket=SumD;
}
else if (MaxTicket >= SumE)
{
if(T_TF!=240)
{
ChangePeriod(hwnd2,240);
}
MartinTicket=SumE;
}else
{
if(T_TF!=Period_D)
{
ChangePeriod(hwnd2,Period_D);
}
}
if (Ticket_A >= MartinTicket || Ticket_B >= MartinTicket || Ticket_C >= MartinTicket ) {
ObjectCreate("MTicket",OBJ_LABEL,0,0,0);
ObjectSet("MTicket", OBJPROP_CORNER, 1);
ObjectSet("MTicket", OBJPROP_COLOR, Gold);
ObjectSet("MTicket", OBJPROP_XDISTANCE, 20);
ObjectSet("MTicket", OBJPROP_YDISTANCE, 170+155);
ObjectSetText("MTicket", "馬丁單數 > "+DoubleToStr(MartinTicket,0)+" 達摩切換時區",10,"微軟正黑體", Gold);
//return;
}else {
ObjectDelete("MTicket");
}
}else {
ObjectDelete("MTicket");
}
Sleep(1000);
}
//----
if (pass){Comment("\n\n DhamarControl START");}
else {Comment("\n\n DhamarControl OVER");}
return(0);
}
//+------------------------------------------------------------------+
void ChangePeriod(int ihwnd,int period)
{
//guiChangeSymbol(ihwnd,DoubleToStr(period,0));
ChartSetSymbolPeriod(ID,Symbol(),period);
Change_SW=1;
}
int MyOrderTotal(int id_1)//訂單總數函式
{
int x=0;//符合條件的BUY單數量(記次變數)
for(int z=0;z<OrdersTotal();z++)//執行N次篩選(N=訂單總數)
{
OrderSelect(z,SELECT_BY_POS,MODE_TRADES);//用"流水號"找訂單
if(OrderMagicNumber()==id_1)//挑選出同貨幣對 && BUY單 && MagicNumber=本程式 的訂單
{
x++;//符合節選結果的訂單總數
}
}
return(x);//回傳
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment