//+——————————————————————+
//| FM-MULTIVALUT.mq4 |
//| FxMoment |
//| https://fxmoment.ru |
//+——————————————————————+
#property copyright “FxMoment”
#property link “https://fxmoment.ru”
//———————–相疣戾蝠?———————————–+
extern string c0=”————————“;
extern double Risk =0.1; //需耜 ?镳铞屙蜞?铗 徉豚眈?
extern double MaxRisk =3; //锑犟桁嚯 痂耜
extern double ProfitProcent =0.02; //橡铘栩 ?镳铞屙蜞?磬 赅驿簋 铗牮簋 皲咫牦
extern string c1=”————————“;
extern double UpLot =1.1; //羊屣屙?筲咫梓屙? 腩蜞
extern int Step =3; //剜?皴蜿?
extern string c2=”————————“;
extern int TimeStart =0; //吗屐 磬鬣豚 疣犷螓
extern int TimeEnd =9; //吗屐 铌铐鬣龛 疣犷螓
extern string c3=”————————“;
extern string SYMBOL_1 =”EURUSD”; //翌疸钼? 镟疣
extern string SYMBOL_2 =”GBPUSD”; //翌疸钼? 镟疣
extern string SYMBOL_3 =”NZDUSD”; //翌疸钼? 镟疣
extern string SYMBOL_4 =”AUDUSD”; //翌疸钼? 镟疣
extern string SYMBOL_5 =”USDCAD”; //翌疸钼? 镟疣
extern string c4=”————————“;
extern int TF =5; //亦殪 麴彘??扈眢蜞? 锐镱朦珞? 珥圜屙? 1,5,15,30,60,240,1440
extern int Magic =7777; //锑痍屦 铕溴痤?耦忮蝽桕?
//——————————————————————–+
string CommentEA =”FM-MULTIVALUT”;
int D;
bool Buy1,Sell1,Buy2,Sell2,Buy3,Sell3,Buy4,Sell4,Buy5,Sell5;
int init()
{D=1;
if (Digits==5 || Digits==3)D=10;
return(0);}
//——————————————————————–+
int start(){
//——————————————————————–+
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;
//——————————————————————–+
double allorders=Count(-1,SYMBOL_1)+Count(-1,SYMBOL_2)+Count(-1,SYMBOL_3)+Count(-1,SYMBOL_4)+Count(-1,SYMBOL_5);
//——————————————————————–+
double NLot1=Lot*(MathPow(UpLot,Count(-1,SYMBOL_1)));
if(NLot1>=MaxLot){double NewLot1=MaxLot;}
if(NLot1<MaxLot){NewLot1=NLot1;}double NLot2=Lot*(MathPow(UpLot,Count(-1,SYMBOL_2)));
if(NLot2>=MaxLot){double NewLot2=MaxLot;}
if(NLot2<MaxLot){NewLot2=NLot2;}double NLot3=Lot*(MathPow(UpLot,Count(-1,SYMBOL_3)));
if(NLot3>=MaxLot){double NewLot3=MaxLot;}
if(NLot3<MaxLot){NewLot3=NLot3;}double NLot4=Lot*(MathPow(UpLot,Count(-1,SYMBOL_4)));
if(NLot4>=MaxLot){double NewLot4=MaxLot;}
if(NLot4<MaxLot){NewLot4=NLot4;}double NLot5=Lot*(MathPow(UpLot,Count(-1,SYMBOL_5)));
if(NLot5>=MaxLot){double NewLot5=MaxLot;}
if(NLot5<MaxLot){NewLot5=NLot5;}
//——————————————————————–+
Buy1=false;Sell1=false;
if (iOpen(SYMBOL_1,TF,1)<iClose(SYMBOL_1,TF,1) && iOpen(SYMBOL_1,TF,2)<iClose(SYMBOL_1,TF,2) && iOpen(SYMBOL_1,TF,3)>iClose(SYMBOL_1,TF,3))Buy1=true;
if (iOpen(SYMBOL_1,TF,1)>iClose(SYMBOL_1,TF,1) && iOpen(SYMBOL_1,TF,2)>iClose(SYMBOL_1,TF,2) && iOpen(SYMBOL_1,TF,3)<iClose(SYMBOL_1,TF,3))Sell1=true;Buy2=false;Sell2=false;
if (iOpen(SYMBOL_2,TF,1)<iClose(SYMBOL_2,TF,1) && iOpen(SYMBOL_2,TF,2)<iClose(SYMBOL_2,TF,2) && iOpen(SYMBOL_2,TF,3)>iClose(SYMBOL_2,TF,3))Buy2=true;
if (iOpen(SYMBOL_2,TF,1)>iClose(SYMBOL_2,TF,1) && iOpen(SYMBOL_2,TF,2)>iClose(SYMBOL_2,TF,2) && iOpen(SYMBOL_2,TF,3)<iClose(SYMBOL_2,TF,3))Sell2=true;Buy3=false;Sell3=false;
if (iOpen(SYMBOL_3,TF,1)<iClose(SYMBOL_3,TF,1) && iOpen(SYMBOL_3,TF,2)<iClose(SYMBOL_3,TF,2) && iOpen(SYMBOL_3,TF,3)>iClose(SYMBOL_3,TF,3))Buy3=true;
if (iOpen(SYMBOL_3,TF,1)>iClose(SYMBOL_3,TF,1) && iOpen(SYMBOL_3,TF,2)>iClose(SYMBOL_3,TF,2) && iOpen(SYMBOL_3,TF,3)<iClose(SYMBOL_3,TF,3))Sell3=true;Buy4=false;Sell4=false;
if (iOpen(SYMBOL_4,TF,1)<iClose(SYMBOL_4,TF,1) && iOpen(SYMBOL_4,TF,2)<iClose(SYMBOL_4,TF,2) && iOpen(SYMBOL_4,TF,3)>iClose(SYMBOL_4,TF,3))Buy4=true;
if (iOpen(SYMBOL_4,TF,1)>iClose(SYMBOL_4,TF,1) && iOpen(SYMBOL_4,TF,2)>iClose(SYMBOL_4,TF,2) && iOpen(SYMBOL_4,TF,3)<iClose(SYMBOL_4,TF,3))Sell4=true;Buy5=false;Sell5=false;
if (iOpen(SYMBOL_5,TF,1)<iClose(SYMBOL_5,TF,1) && iOpen(SYMBOL_5,TF,2)<iClose(SYMBOL_5,TF,2) && iOpen(SYMBOL_5,TF,3)>iClose(SYMBOL_5,TF,3))Buy5=true;
if (iOpen(SYMBOL_5,TF,1)>iClose(SYMBOL_5,TF,1) && iOpen(SYMBOL_5,TF,2)>iClose(SYMBOL_5,TF,2) && iOpen(SYMBOL_5,TF,3)<iClose(SYMBOL_5,TF,3))Sell5=true;
//——————————————————————–+
if(TimeHour(TimeCurrent())>=TimeStart && TimeHour(TimeCurrent())<TimeEnd)
{if (Count(-1,SYMBOL_1)==0 && Buy1)
{int op1=OrderSend(SYMBOL_1,OP_BUY,Lot,NormalizeDouble(MarketInfo(SYMBOL_1,MODE_ASK), Digits),100,0,0,CommentEA,Magic,0,Green);}
if (Count(-1,SYMBOL_1)==0 && Sell1)
{int op2=OrderSend(SYMBOL_1,OP_SELL,Lot,NormalizeDouble(MarketInfo(SYMBOL_1,MODE_BID), Digits),100,0,0,CommentEA,Magic,0,Red);}if (Count(-1,SYMBOL_2)==0 && Buy2)
{int op3=OrderSend(SYMBOL_2,OP_BUY,Lot,NormalizeDouble(MarketInfo(SYMBOL_2,MODE_ASK), Digits),200,0,0,CommentEA,Magic,0,Green);}
if (Count(-1,SYMBOL_2)==0 && Sell2)
{int op4=OrderSend(SYMBOL_2,OP_SELL,Lot,NormalizeDouble(MarketInfo(SYMBOL_2,MODE_BID), Digits),200,0,0,CommentEA,Magic,0,Red);}if (Count(-1,SYMBOL_3)==0 && Buy3)
{int op5=OrderSend(SYMBOL_3,OP_BUY,Lot,NormalizeDouble(MarketInfo(SYMBOL_3,MODE_ASK), Digits),300,0,0,CommentEA,Magic,0,Green);}
if (Count(-1,SYMBOL_3)==0 && Sell3)
{int op6=OrderSend(SYMBOL_3,OP_SELL,Lot,NormalizeDouble(MarketInfo(SYMBOL_3,MODE_BID), Digits),300,0,0,CommentEA,Magic,0,Red);}if (Count(-1,SYMBOL_4)==0 && Buy4)
{int op7=OrderSend(SYMBOL_4,OP_BUY,Lot,NormalizeDouble(MarketInfo(SYMBOL_4,MODE_ASK), Digits),400,0,0,CommentEA,Magic,0,Green);}
if (Count(-1,SYMBOL_4)==0 && Sell4)
{int op8=OrderSend(SYMBOL_4,OP_SELL,Lot,NormalizeDouble(MarketInfo(SYMBOL_4,MODE_BID), Digits),400,0,0,CommentEA,Magic,0,Red);}if (Count(-1,SYMBOL_5)==0 && Buy5)
{int op9=OrderSend(SYMBOL_5,OP_BUY,Lot,NormalizeDouble(MarketInfo(SYMBOL_5,MODE_ASK), Digits),500,0,0,CommentEA,Magic,0,Green);}
if (Count(-1,SYMBOL_5)==0 && Sell5)
{int op10=OrderSend(SYMBOL_5,OP_SELL,Lot,NormalizeDouble(MarketInfo(SYMBOL_5,MODE_BID), Digits),500,0,0,CommentEA,Magic,0,Red);}}
//——————————————————————–+
if(Count(OP_BUY,SYMBOL_1)>0 && NormalizeDouble((MarketInfo(SYMBOL_1,MODE_ASK)+Step*D*(MarketInfo(SYMBOL_1,MODE_POINT))), Digits)<=OldPricB(SYMBOL_1))
{int send1=OrderSend(SYMBOL_1,OP_BUY,NewLot1,NormalizeDouble(MarketInfo(SYMBOL_1,MODE_ASK), Digits),100,0,0,CommentEA,Magic,0,Green);}
if(Count(OP_SELL,SYMBOL_1)>0 && NormalizeDouble((MarketInfo(SYMBOL_1,MODE_BID)-Step*D*(MarketInfo(SYMBOL_1,MODE_POINT))), Digits)>=OldPricS(SYMBOL_1))
{int send2=OrderSend(SYMBOL_1,OP_SELL,NewLot1,NormalizeDouble(MarketInfo(SYMBOL_1,MODE_BID), Digits),100,0,0,CommentEA,Magic,0,Red);}if(Count(OP_BUY,SYMBOL_2)>0 && NormalizeDouble((MarketInfo(SYMBOL_2,MODE_ASK)+Step*D*(MarketInfo(SYMBOL_2,MODE_POINT))), Digits)<=OldPricB(SYMBOL_2))
{int send3=OrderSend(SYMBOL_2,OP_BUY,NewLot2,NormalizeDouble(MarketInfo(SYMBOL_2,MODE_ASK), Digits),100,0,0,CommentEA,Magic,0,Green);}
if(Count(OP_SELL,SYMBOL_2)>0 && NormalizeDouble((MarketInfo(SYMBOL_2,MODE_BID)-Step*D*(MarketInfo(SYMBOL_2,MODE_POINT))), Digits)>=OldPricS(SYMBOL_2))
{int send4=OrderSend(SYMBOL_2,OP_SELL,NewLot2,NormalizeDouble(MarketInfo(SYMBOL_2,MODE_BID), Digits),100,0,0,CommentEA,Magic,0,Red);}if(Count(OP_BUY,SYMBOL_3)>0 && NormalizeDouble((MarketInfo(SYMBOL_3,MODE_ASK)+Step*D*(MarketInfo(SYMBOL_3,MODE_POINT))), Digits)<=OldPricB(SYMBOL_3))
{int send5=OrderSend(SYMBOL_3,OP_BUY,NewLot3,NormalizeDouble(MarketInfo(SYMBOL_3,MODE_ASK), Digits),100,0,0,CommentEA,Magic,0,Green);}
if(Count(OP_SELL,SYMBOL_3)>0 && NormalizeDouble((MarketInfo(SYMBOL_3,MODE_BID)-Step*D*(MarketInfo(SYMBOL_3,MODE_POINT))), Digits)>=OldPricS(SYMBOL_3))
{int send6=OrderSend(SYMBOL_3,OP_SELL,NewLot3,NormalizeDouble(MarketInfo(SYMBOL_3,MODE_BID), Digits),100,0,0,CommentEA,Magic,0,Red);}if(Count(OP_BUY,SYMBOL_4)>0 && NormalizeDouble((MarketInfo(SYMBOL_4,MODE_ASK)+Step*D*(MarketInfo(SYMBOL_4,MODE_POINT))), Digits)<=OldPricB(SYMBOL_4))
{int send7=OrderSend(SYMBOL_4,OP_BUY,NewLot4,NormalizeDouble(MarketInfo(SYMBOL_4,MODE_ASK), Digits),100,0,0,CommentEA,Magic,0,Green);}
if(Count(OP_SELL,SYMBOL_4)>0 && NormalizeDouble((MarketInfo(SYMBOL_4,MODE_BID)-Step*D*(MarketInfo(SYMBOL_4,MODE_POINT))), Digits)>=OldPricS(SYMBOL_4))
{int send8=OrderSend(SYMBOL_4,OP_SELL,NewLot4,NormalizeDouble(MarketInfo(SYMBOL_4,MODE_BID), Digits),100,0,0,CommentEA,Magic,0,Red);}if(Count(OP_BUY,SYMBOL_5)>0 && NormalizeDouble((MarketInfo(SYMBOL_5,MODE_ASK)+Step*D*(MarketInfo(SYMBOL_5,MODE_POINT))), Digits)<=OldPricB(SYMBOL_5))
{int send9=OrderSend(SYMBOL_5,OP_BUY,NewLot5,NormalizeDouble(MarketInfo(SYMBOL_5,MODE_ASK), Digits),100,0,0,CommentEA,Magic,0,Green);}
if(Count(OP_SELL,SYMBOL_5)>0 && NormalizeDouble((MarketInfo(SYMBOL_5,MODE_BID)-Step*D*(MarketInfo(SYMBOL_5,MODE_POINT))), Digits)>=OldPricS(SYMBOL_5))
{int send10=OrderSend(SYMBOL_5,OP_SELL,NewLot5,NormalizeDouble(MarketInfo(SYMBOL_5,MODE_BID), Digits),100,0,0,CommentEA,Magic,0,Red);}
//——————————————————————–+
double ProfProc=(AccountBalance()/100)*(ProfitProcent*allorders);
if(Profit(-1)>=ProfProc && ProfProc!=0)
{CloserB(); CloserS();}
//——————————————————————–+
return(0);}
//——————————————————————–+
int Count(int type,string sy)
{int count=0;
for(int i=OrdersTotal()-1;i>=0;i–){
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(sy==OrderSymbol() && OrderMagicNumber()==Magic && (type==-1 || OrderType()==type)) count++;}}
return(count);}
//——————————————————————–+
double OldPricB(string sy)
{double oldorderopenpriceB;
int oldticketnumberB;
double unusedB = 0;
int ticketnumberB = 0;
for (int cnt = OrdersTotal() – 1; cnt >= 0; cnt–)
{if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
{if (OrderSymbol() == sy && OrderType() == OP_BUY && OrderMagicNumber()==Magic)
{oldticketnumberB = OrderTicket();
if (oldticketnumberB > ticketnumberB)
{ticketnumberB = oldticketnumberB;
oldorderopenpriceB = OrderOpenPrice();
unusedB = oldorderopenpriceB;}}}}
return (oldorderopenpriceB);}
//——————————————————————–+
double OldPricS(string sy)
{double oldorderopenpriceS;
int oldticketnumberS;
double unusedS = 0;
int ticketnumberS = 0;
for (int cnt = OrdersTotal() – 1; cnt >= 0; cnt–)
{if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
{if (OrderSymbol() == sy && OrderType() == OP_SELL && OrderMagicNumber()==Magic)
{oldticketnumberS = OrderTicket();
if (oldticketnumberS > ticketnumberS)
{ticketnumberS = oldticketnumberS;
oldorderopenpriceS = OrderOpenPrice();
unusedS = oldorderopenpriceS;}}}}
return (oldorderopenpriceS);}
//——————————————————————–+
double Profit(int type)
{double Profit = 0;
for (int cnt = OrdersTotal() – 1; cnt >= 0; cnt–) {
if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
{if (OrderMagicNumber()==Magic && (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(OrderMagicNumber()==Magic && OrderType()==OP_SELL)
bool sel8=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK), Digits),1000,0);}}void CloserB()
{for(int i=OrdersTotal()-1;i>=0;i–)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(OrderMagicNumber()==Magic && OrderType()==OP_BUY)
bool sel9=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID), Digits),1000,0);}}
相关资源
暂无评论...