FM-SETKA
FM-SETKA

FM-SETKA

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

27 人已下载 手机查看

FM-SETKA

//+——————————————————————+
//| FM-SETKA.mq4 |
//| FxMoment |
//| https://fxmoment.ru |
//+——————————————————————+
#property copyright “FxMoment”
#property link “https://fxmoment.ru”
//———————–相疣戾蝠?———————————–+
extern string c0=”————————“;
extern double Risk =0.5; //需耜 ?镳铞屙蜞?
extern double MaxRisk =3; //锑犟桁嚯 痂耜 ?镳铞屙蜞?
extern int TakeProfit =10; //义殛 镳铘栩
extern double StopMinus =10; //锑犟桁嚯 疣珈屦 筢赅
extern string c1=”————————“;
extern double UpLot =1.2; //羊屣屙?筲咫梓屙? 腩蜞
extern int Step =10; //剜?皴蜿?
extern int MaxOrders =30; //锑犟桁嚯铄 觐腓麇耱忸 铕溴痤??皴蜿?
extern string c2=”————————“;
extern int TimeStart =0; //吗屐 磬鬣豚 蝾疸钼腓
extern int TimeEnd =9; //吗屐 铌铐鬣龛 蝾疸钼腓
extern string c3=”————————“;
extern int KodActivacii =12345678; //锣?觐?嚓蜩忄鲨?
extern int Magic =7777; //锑痍屦 铕溴痤?
//——————————————————————–+
string CommentEA =”FM-SETKA”;
double OpPric =0;
int D;
string Name;
bool Buy,Sell;
int Ticket;
double NewTP,NewSL;
int init()
{
D=1;
if (Digits==5 || Digits==3)D=10;
Name=WindowExpertName();
return(0);
}
//——————————————————————–+
int start()
{
int Key=NormalizeDouble((AccountNumber()*2)-(AccountNumber()/23), 0); // 蔓麒耠屐 觌

if (KodActivacii>Key || KodActivacii<Key)
{Comment(“”
+ “\n”
+ “团屡型凵 饰?朗胰吕秩?!!! 碾 镱牦镪?腓鲥礴梃 镥疱殇栩?磬 耱疣龛鲶 fxmoment.ru/?p=51”);}
if (KodActivacii==Key)
{
Comment(“”
+ “\n”
+ “扬囫栳?玎 桉镱朦珙忄龛?耦忮蝽桕?FM-SETKA. 燕轵 耦忮蝽桕?FXMOMENT.RU”);

double Lot=0;
Lot=NormalizeDouble(AccountBalance()/100*Risk/(MarketInfo(Symbol(),MODE_TICKVALUE)*100*D),2);
if (Lot<MarketInfo(Symbol(),MODE_MINLOT))Lot=MarketInfo(Symbol(),MODE_MINLOT);

double MaxLot=0;
MaxLot=NormalizeDouble(AccountBalance()/100*MaxRisk/(MarketInfo(Symbol(),MODE_TICKVALUE)*100*D),2);
if (MaxLot<MarketInfo(Symbol(),MODE_MINLOT))MaxLot=MarketInfo(Symbol(),MODE_MINLOT);

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;
//——————————————————————–+
int OB,OS;
double PipBuy,PipSell;
for (int i=0; i<OrdersTotal(); i++)
{
bool sel1=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if (OrderType()==0){OB++;PipBuy=Bid-OrderOpenPrice();}
if (OrderType()==1){OS++;PipSell=OrderOpenPrice()-Ask;}
}
}
//——————————————————————–+
Buy=false;Sell=false;
if (Open[1]<Close[1] && Open[2]<Close[2] && Open[3]>Close[3] && Open[4]>Close[4] && Open[5]>Close[5])Buy=true;
if (Open[1]>Close[1] && Open[2]>Close[2] && Open[3]<Close[3] && Open[4]<Close[4] && Open[5]<Close[5])Sell=true;

double NLot=Lot*(MathPow(UpLot,OB+OS));
if(NLot>=MaxLot){double NewLot=MaxLot;}
if(NLot<MaxLot){NewLot=NLot;}
//——————————————————————–+
double lots=0;
double sum=0;
for (i=0; i<OrdersTotal(); i++)
{if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()==OP_BUY)
{lots=lots+OrderLots();
sum=sum+OrderLots()*OrderOpenPrice();}
if (OrderType()==OP_SELL)
{lots=lots-OrderLots();
sum=sum-OrderLots()*OrderOpenPrice();}}

double price=0;
if (lots!=0) price=sum/lots;
if (price>0) OpPric=NormalizeDouble(price,Digits);
//——————————————————————–+
if(TimeHour(TimeCurrent())>=TimeStart && TimeHour(TimeCurrent())<TimeEnd)
{
if (OB+OS==0)
{
if (Buy)
{Ticket=OpenOrder(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask,Digits),0,0,CommentEA,Magic);
NewTP=OpPric+TakeProfit*D*Point;
for (i=0; i<OrdersTotal(); i++)
{
bool sel21=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==0)
{
ModifyOrder(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NewTP);
}
}}
if (Sell)
{Ticket=OpenOrder(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),0,0,CommentEA,Magic);
NewTP=OpPric-TakeProfit*D*Point;
for (i=0; i<OrdersTotal(); i++)
{
bool sel31=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==1)
{
ModifyOrder(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NewTP);
}
}}
}}
//——————————————————————–+
if (OB>0 && OB<MaxOrders && PipBuy/D/Point<=-Step)
{OpenOrder(Symbol(),OP_BUY,NewLot,NormalizeDouble(Ask,Digits),0,0,CommentEA,Magic);
OB++;
NewTP=OpPric+TakeProfit*D*Point;
for (i=0; i<OrdersTotal(); i++)
{
bool sel2=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==0)
{
ModifyOrder(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NewTP);
}
}
}
//——————————————————————–+
if (OS>0 && OS<MaxOrders && PipSell/D/Point<=-Step)
{OpenOrder(Symbol(),OP_SELL,NewLot,NormalizeDouble(Bid,Digits),0,0,CommentEA,Magic);
OS++;
NewTP=OpPric-TakeProfit*D*Point;
for (i=0; i<OrdersTotal(); i++)
{
bool sel3=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==1)
{
ModifyOrder(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NewTP);
}
}
}
//——————————————————————–+
double S_Max=(AccountBalance()/100)*StopMinus*(-1);

if(OB+OS>=(MaxOrders/2) && Profit(-1)>=S_Max && S_Max!=0)
{CloserB();
CloserS();}
//——————————————————————–+
}
//——————————————————————–+
return(0);}
//——————————————————————–+
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<MaxOrders)
{
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);
}
//——————痒栩噱?镳栳黒筢铌 —————————-+
double Profit(int type)
{double Profit = 0;
for (int cnt = OrdersTotal() – 1; cnt >= 0; cnt–) {
if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
{if (OrderSymbol() == Symbol() && (OrderType() == type || type==-1)) Profit += OrderProfit()+OrderSwap()+OrderCommission();}}
return (Profit);}

//——————–青牮桢—————————————–+
void CloserS()
{for(int i=OrdersTotal()-1;i>=0;i–)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(Symbol()==OrderSymbol())
if(OrderType()==OP_SELL) bool sel8=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())
if(OrderType()==OP_BUY) bool sel9=OrderClose(OrderTicket(),OrderLots(),Bid,1000,0);}}

如果你对文件有了解,请帮助投票!

If you are familiar with the file, please help vote!

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位投票人。

相关资源

暂无评论

none
暂无评论...