FM-MorningFlat

FM-MorningFlat

官方版 无广告 135

更新日期:2022-11-08 分类标签: 语言:中文 平台:没限制

32 人已下载 手机查看

FM-MorningFlat FM-MorningFlat

//+------------------------------------------------------------------+
//| FM-MorningFlat.mq4 |
//| FXMOMENT.RU |
//| https://fxmoment.ru |
//+------------------------------------------------------------------+
#property copyright "FXMOMENT.RU"
#property link "https://fxmoment.ru"
//-----------------------相疣戾蝠?-----------------------------------+
extern string c0="------------------------";
extern double Lot =0.1; //朽犷麒?腩?
extern string c1="------------------------";
extern int StartHour = 0; //相疣戾蝠?桧滂赅蝾疣
extern int StartMinute = 0; //相疣戾蝠?桧滂赅蝾疣
extern int EndHour = 8; //相疣戾蝠?桧滂赅蝾疣
extern int EndMinute = 0; //相疣戾蝠?桧滂赅蝾疣
extern double TargetLevel = 150; //相疣戾蝠?桧滂赅蝾疣
extern int SizeKanal =70; //锑犟桁嚯? 痂磬 赅磬豚 篁疱礤泐 綦弪?
extern string c2="------------------------";
extern int UpLotNewDay =0; //篷腓 =0, 腩?磬 眍恹?溴睃 礤 筲咫梓桠噱蝰. 篷腓 =1 腩?磬 眍恹?溴睃 镳钿铍驵弪 筲咫梓屙桢.
extern int UpLotMetod =0; //篷腓 =0, 腩?筲咫梓桠噱蝰 ?囵梏戾蜩麇耜铋 镳钽疱耨梃. 篷腓 =1 镱 耧铐屙蝈
extern double UpLot =2; //蓐耧铐屙蜞 筲咫梓屙? 腩蜞
extern int MaxLossDay =4; //锑犟桁嚯铄 麒耠?筢觐?镱漯?玎 溴睃
extern int Magic =7777; //锑痍屦 铕溴痤?
//--------------------------------------------------------------------+
string CommentEA ="FM-MorningFlat";
int D;
string Name;
bool Buy,Sell;
int Ticket;
double NewLot;
int init()
{D=1;
if (Digits==5 || Digits==3)D=10;
Name=WindowExpertName();
return(0);}
//--------------------------------------------------------------------+
int start()
{
//--------------------------------------------------------------------+
if(MarketInfo(Symbol(),MODE_LOTSTEP)==0.01) int dig =2;
if(MarketInfo(Symbol(),MODE_LOTSTEP)==0.10) dig =1;
if(MarketInfo(Symbol(),MODE_LOTSTEP)==1.00) dig =0;
//--------------------------------------------------------------------+
double lotp=0;
double profitp=0;
for(int y=OrdersHistoryTotal()-1; y>=0;y--)
if(OrderSelect(y,SELECT_BY_POS,MODE_HISTORY))
{if(Symbol()==OrderSymbol() && OrderMagicNumber()==Magic && OrderOpenTime()>=iTime(Symbol(),1440,0))
{lotp=OrderLots();
profitp=OrderProfit();
break;}}

double lotp1=0;
double profitp1=0;
for(y=OrdersHistoryTotal()-1; y>=0;y--)
if(OrderSelect(y,SELECT_BY_POS,MODE_HISTORY))
{if(Symbol()==OrderSymbol() && OrderMagicNumber()==Magic)
{lotp1=OrderLots();
profitp1=OrderProfit();
break;}}
//--------------------------------------------------------------------+
double v0 = iCustom(NULL,0,"MorningFlat_V3",StartHour,StartMinute,EndHour,EndMinute,100,Turquoise,Red,Gold,Silver,2,1);
double v1 = iCustom(NULL,0,"MorningFlat_V3",StartHour,StartMinute,EndHour,EndMinute,100,Turquoise,Red,Gold,Silver,3,1);
double v2 = iCustom(NULL,0,"MorningFlat_V3",StartHour,StartMinute,EndHour,EndMinute,TargetLevel,Turquoise,Red,Gold,Silver,2,1);
double v3 = iCustom(NULL,0,"MorningFlat_V3",StartHour,StartMinute,EndHour,EndMinute,TargetLevel,Turquoise,Red,Gold,Silver,3,1);
//--------------------------------------------------------------------+
Buy=false;Sell=false;
if (v0>0 && v0<=Ask)Buy=true;
if (v1>0 && v1>=Bid)Sell=true;
//--------------------------------------------------------------------+
double skanal=(v0-v1)/D/Point;
//--------------------------------------------------------------------+
if(UpLotNewDay==0)
{
if(profitp>=0) {NewLot=Lot;}
if(profitp<0 && UpLotMetod==0) {NewLot=NormalizeDouble(lotp+Lot, dig);}
if(profitp<0 && UpLotMetod==1) {NewLot=NormalizeDouble(lotp*UpLot, dig);}}

if(UpLotNewDay==1)
{
if(profitp1>=0) {NewLot=Lot;}
if(profitp1<0 && UpLotMetod==0) {NewLot=NormalizeDouble(lotp1+Lot, dig);}
if(profitp1<0 && UpLotMetod==1) {NewLot=NormalizeDouble(lotp1*UpLot, dig);}}
//--------------------------------------------------------------------+
if(TimeHour(TimeCurrent())>=EndHour && TimeMinute(TimeCurrent())>=EndMinute && TimeHour(TimeCurrent())<23)
{
if((v2-Ask)/Point<MarketInfo(Symbol(),MODE_STOPLEVEL))
{double tpb=Ask+(MarketInfo(Symbol(),MODE_STOPLEVEL)+1)*D*Point;}
if((v2-Ask)/Point>MarketInfo(Symbol(),MODE_STOPLEVEL))
{tpb=v2;}

if((Bid-v3)/Point<MarketInfo(Symbol(),MODE_STOPLEVEL))
{double tps=Bid-(MarketInfo(Symbol(),MODE_STOPLEVEL)+1)*D*Point;}
if((Bid-v3)/Point>MarketInfo(Symbol(),MODE_STOPLEVEL))
{tps=v3;}
//--------------------------------------------------------------------+
if(Count(-1)==0 && Buy && profitp<=0 && CountLoss()<MaxLossDay && skanal<=SizeKanal)
{Ticket=OpenOrder(Symbol(),OP_BUY,NewLot,NormalizeDouble(Ask,Digits),0,0,CommentEA,Magic);
for (int i=0; i<OrdersTotal(); i++)
{bool sel1=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==0)
{ModifyOrder(OrderTicket(),OrderOpenPrice(),v1,tpb);}}}

if(Count(-1)==0 && Sell && profitp<=0 && CountLoss()<MaxLossDay && skanal<=SizeKanal)
{Ticket=OpenOrder(Symbol(),OP_SELL,NewLot,NormalizeDouble(Bid,Digits),0,0,CommentEA,Magic);
for (i=0; i<OrdersTotal(); i++)
{bool sel2=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==1)
{ModifyOrder(OrderTicket(),OrderOpenPrice(),v0,tps);}}}
}
//--------------------------------------------------------------------+
if(TimeHour(TimeCurrent())>=(EndHour-1) && TimeHour(TimeCurrent())<EndHour)
{if(Count(-1)>0)
{CloserB(); CloserS();}}
//--------------------------------------------------------------------+
return(0);}
//----------------物疱溴?屐 蜩?铕溴疣--------------------------------+
int Count(int type)
{int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(Symbol()==OrderSymbol() && OrderMagicNumber()==Magic && (type==-1 || OrderType()==type)) count++;}
return(count);}
//--------------------青牮桢-----------------------------------------+
void CloserS()
{for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(Symbol()==OrderSymbol() && OrderMagicNumber()==Magic)
if(OrderType()==OP_SELL) bool se8=OrderClose(OrderTicket(),OrderLots(),Ask,1000,0);}}

void CloserB()
{for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(Symbol()==OrderSymbol() && OrderMagicNumber()==Magic)
if(OrderType()==OP_BUY) bool se9=OrderClose(OrderTicket(),OrderLots(),Bid,1000,0);}}
//--------------------------------------------------------------------+
int CountLoss()
{int count=0;
for(int trade=OrdersHistoryTotal()-1;trade>=0; trade--)
{bool se15=OrderSelect(trade,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderOpenTime()>=iTime(Symbol(),1440,0))
{if(OrderProfit()<0) count++;
else break;}}
return(count);}
//--------------------------------------------------------------------+
int OpenOrder(string symbol,int cmd,double volume,double price,double stoploss,double takeprofit,string comment,int magic)
{
int err,i,ticket;
while(i<10)
{
RefreshRates();
if (cmd==0)price=Ask;
if (cmd==1)price=Bid;
ticket=OrderSend(symbol,cmd,volume,NormalizeDouble(price,Digits),1000*D,NormalizeDouble(stoploss,Digits),NormalizeDouble(takeprofit,Digits),comment,magic);
err = GetLastError();
if (err == 0) break;
Print(Name,Symbol(),Error(err)," 镳?铗牮梃 铕溴疣");
Sleep(1000);
i++;
}
return(ticket);
}
//--------------------------------------------------------------------+
int ModifyOrder(int ticket,double price,double stoploss,double takeprofit)
{
int err,i;

while(i<10)
{
RefreshRates();
bool sel7=OrderModify(ticket,NormalizeDouble(price,Digits),NormalizeDouble(stoploss,Digits),NormalizeDouble(takeprofit,Digits),0,CLR_NONE);
err = GetLastError();
if (err == 0) break;
Print(Name,Symbol(),Error(err)," 镳?祛滂翳赅鲨?铕溴疣");
Sleep(1000);
i++;
}
return(0);
}
//--------------------------------------------------------------------+
string Error(int error_code)
{
string error_string;
switch(error_code)
{
case 0: error_string="湾?铠栳铌"; break;
case 1: error_string="湾?铠栳觇, 眍 疱珞朦蜞?礤桤忮耱屙"; break;
case 2: error_string="吾 铠栳赅"; break;
case 3: error_string="湾镳噔桦 镟疣戾蝠?; break;
case 4: error_string="翌疸钼 皴疴屦 玎??; break;
case 5: error_string="羊囵? 忮瘃? 觌桢眚耜钽?蝈痨桧嚯?; break;
case 6: error_string="湾?疋玷 ?蝾疸钼 皴疴屦铎"; break;
case 7: error_string="湾漕耱囹铟眍 镳噔"; break;
case 8: error_string="央桫觐?鬣耱 玎镳铖?; break;
case 9: error_string="湾漕矬耱桁? 铒屦圉? 磬痼? 趔黻鲨铐桊钼囗桢 皴疴屦?; break;
case 64: error_string="痒弪 玎犭铌桊钼囗"; break;
case 65: error_string="湾镳噔桦 眍戾?聍弪?; break;
case 128: error_string="锐蝈?耩铌 铈桎囗? 耦忮瘌屙? 皲咫觇"; break;
case 129: error_string="湾镳噔桦? 鲥磬"; break;
case 130: error_string="湾镳噔桦 耱铒?; break;
case 131: error_string="湾镳噔桦 钺?; break;
case 132: error_string="宣眍?玎牮"; break;
case 133: error_string="翌疸钼? 玎镳妁屙?; break;
case 134: error_string="湾漕耱囹铟眍 溴礤?潆 耦忮瘌屙? 铒屦圉梃"; break;
case 135: error_string="皱磬 桤戾龛豚顸"; break;
case 136: error_string="湾?鲥?; break;
case 137: error_string="琉铌屦 玎??; break;
case 138: error_string="皖恹?鲥睇"; break;
case 139: error_string="勿溴?玎犭铌桊钼囗 ?箧?钺疣徉螓忄弪?"; break;
case 140: error_string="朽琊屮屙?蝾朦觐 镱牦镪?; break;
case 141: error_string="央桫觐?祉钽?玎镳铖钼"; break;
case 145: error_string="填滂翳赅鲨 玎镳妁屙? 蜞?赅?铕溴?耠桫觐?犭桤铌 ?瘥黻?; break;
case 146: error_string="项漶桉蝈爨 蝾疸钼腓 玎?蜞"; break;
case 147: error_string="锐镱朦珙忄龛?溧螓 桉蝈麇龛 铕溴疣 玎镳妁屙?狃铌屦铎"; break;
case 148: error_string="暑腓麇耱忸 铗牮 ?铗腩驽眄 铕溴痤?漕耱桡腩 镳邃咫? 篑蜞眍怆屙眍泐 狃铌屦铎.";break;
case 4000: error_string="湾?铠栳觇"; break;
case 4001: error_string="湾镳噔桦 箨噻囹咫?趔黻鲨?; break;
case 4002: error_string="软溴犟 爨耨桠?- 忭?滂囡噻铐?; break;
case 4003: error_string="湾?镟?蜩 潆 耱尻?趔黻鲨?; break;
case 4004: error_string="襄疱镱腠屙桢 耱尻?镱耠?疱牦瘃桠眍泐 恹珙忄"; break;
case 4005: error_string="袜 耱尻?礤?镟?蜩 潆 镥疱溧麒 镟疣戾蝠钼"; break;
case 4006: error_string="湾?镟?蜩 潆 耱痤觐忸泐 镟疣戾蝠?; break;
case 4007: error_string="湾?镟?蜩 潆 怵屐屙眍?耱痤觇"; break;
case 4008: error_string="湾桧桷栲腓玷痤忄眄? 耱痤赅"; break;
case 4009: error_string="湾桧桷栲腓玷痤忄眄? 耱痤赅 ?爨耨桠?; break;
case 4010: error_string="湾?镟?蜩 潆 耱痤觐忸泐 爨耨桠?; break;
case 4011: error_string="央桫觐?潆桧磬 耱痤赅"; break;
case 4012: error_string="务蜞蝾?铗 溴脲龛 磬 眍朦"; break;
case 4013: error_string="腻脲龛?磬 眍朦"; break;
case 4014: error_string="湾桤忮耱磬 觐爨礓?; break;
case 4015: error_string="湾镳噔桦 镥疱躅?; break;
case 4016: error_string="湾桧桷栲腓玷痤忄眄 爨耨桠"; break;
case 4017: error_string="蔓珙恹 DLL 礤 疣琊屮屙?; break;
case 4018: error_string="湾忸珈铈眍 玎沭箸栩?徼犭桀蝈牦"; break;
case 4019: error_string="湾忸珈铈眍 恹玮囹?趔黻鲨?; break;
case 4020: error_string="蔓珙恹 忭屮龛?徼犭桀蝈黜 趔黻鲨?礤 疣琊屮屙?; break;
case 4021: error_string="湾漕耱囹铟眍 镟?蜩 潆 耱痤觇, 忸玮疣屐铋 桤 趔黻鲨?; break;
case 4022: error_string="谚耱屐?玎?蜞"; break;
case 4050: error_string="湾镳噔桦铄 觐腓麇耱忸 镟疣戾蝠钼 趔黻鲨?; break;
case 4051: error_string="湾漕矬耱桁铄 珥圜屙桢 镟疣戾蝠?趔黻鲨?; break;
case 4052: error_string="马篁疱眄 铠栳赅 耱痤觐忸?趔黻鲨?; break;
case 4053: error_string="硒栳赅 爨耨桠?; break;
case 4054: error_string="湾镳噔桦铄 桉镱朦珙忄龛?爨耨桠?蜞殪皴痂?; break;
case 4055: error_string="硒栳赅 镱朦珙忄蝈朦耜钽?桧滂赅蝾疣"; break;
case 4056: error_string="锑耨桠?礤耦忪羼蜩禧"; break;
case 4057: error_string="硒栳赅 钺疣犷蜿?汶钺嚯?镥疱戾眄"; break;
case 4058: error_string="秒钺嚯? 镥疱戾眄? 礤 钺磬痼驽磬"; break;
case 4059: error_string="泽黻鲨 礤 疣琊屮屙??蝈耱钼铎 疱骅戾"; break;
case 4060: error_string="泽黻鲨 礤 疣琊屮屙?; break;
case 4061: error_string="硒栳赅 铗镳噔觇 镱黩?; break;
case 4062: error_string="捂桎噱蝰 镟疣戾蝠 蜩镟 string"; break;
case 4063: error_string="捂桎噱蝰 镟疣戾蝠 蜩镟 integer"; break;
case 4064: error_string="捂桎噱蝰 镟疣戾蝠 蜩镟 double"; break;
case 4065: error_string="?赅麇耱忮 镟疣戾蝠?铈桎噱蝰 爨耨桠"; break;
case 4066: error_string="青镳铠屙睇?桉蝾痂麇耜桢 溧眄 ?耦耱?龛?钺眍怆屙?"; break;
case 4067: error_string="硒栳赅 镳?恹镱腠屙梃 蝾疸钼铋 铒屦圉梃"; break;
case 4099: error_string="暑礤?羿殡?; break;
case 4100: error_string="硒栳赅 镳?疣犷蝈 ?羿殡铎"; break;
case 4101: error_string="湾镳噔桦铄 桁 羿殡?; break;
case 4102: error_string="央桫觐?祉钽?铗牮 羿殡钼"; break;
case 4103: error_string="湾忸珈铈眍 铗牮?羿殡"; break;
case 4104: error_string="湾耦忪羼蜩禧?疱骅?漕耱箫??羿殡?; break;
case 4105: error_string="丸 钿桧 铕溴?礤 恹狃囗"; break;
case 4106: error_string="湾桤忮耱睇?耔焘铍"; break;
case 4107: error_string="湾镳噔桦 镟疣戾蝠 鲥睇 潆 蝾疸钼铋 趔黻鲨?; break;
case 4108: error_string="湾忮痦 眍戾?蜩赍蜞"; break;
case 4109: error_string="翌疸钼? 礤 疣琊屮屙? 湾钺躅滂祛 怅膻麒螯 铒鲨?朽琊屮栩?耦忮蝽桕?蝾疸钼囹??疋铋耱忄?耧屦蜞."; break;
case 4110: error_string="碾桧睇?镱玷鲨?礤 疣琊屮屙? 湾钺躅滂祛 镳钼屦栩?疋铋耱忄 耧屦蜞."; break;
case 4111: error_string="暑痤蜿桢 镱玷鲨?礤 疣琊屮屙? 湾钺躅滂祛 镳钼屦栩?疋铋耱忄 耧屦蜞."; break;
case 4200: error_string="吾牝 箧?耋耱怏弪"; break;
case 4201: error_string="青镳铠屙?礤桤忮耱眍?疋铋耱忸 钺牝?; break;
case 4202: error_string="吾牝 礤 耋耱怏弪"; break;
case 4203: error_string="湾桤忮耱睇?蜩?钺牝?; break;
case 4204: error_string="湾?桁屙?钺牝?; break;
case 4205: error_string="硒栳赅 觐铕滂磬?钺牝?; break;
case 4206: error_string="湾 磬殇屙?箨噻囗眍?镱漕觏?; break;
default: error_string="硒栳赅 镳?疣犷蝈 ?钺牝铎";
}
return(error_string);
}

相关资源

暂无评论

暂无评论...