FM-BB NEW

FM-BB NEW

官方版 无广告 75

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

13 人已下载 手机查看

FM-BB NEW

//+------------------------------------------------------------------+
//| FM-BlackBox NEW.mq4 |
//| FxMoment |
//| |
//+------------------------------------------------------------------+
#property copyright "FxMoment"
#property link ""
//-----------------------相疣戾蝠?-----------------------------------+
extern string c0="------------------------";
extern double Risk =25; //需耜 ?镳铞屙蜞?铗 徉豚眈?
extern string c1="------------------------";
extern string SYMBOL_1 ="EURUSD"; //翌疸钼? 镟疣
extern string SYMBOL_2 ="GBPUSD"; //翌疸钼? 镟疣
extern string SYMBOL_3 ="USDJPY"; //翌疸钼? 镟疣
extern string SYMBOL_4 ="EURJPY"; //翌疸钼? 镟疣
extern string SYMBOL_5 ="USDCAD"; //翌疸钼? 镟疣
extern string c2="------------------------";
extern int Tral =30; //茵嚯 ?矬黻蜞?
extern int TF =15; //亦殪 麴彘??扈眢蜞? 锐镱朦珞? 珥圜屙? 1,5,15,30,60,240,1440
extern int Magic =7777; //锑痍屦 铕溴痤?耦忮蝽桕?
//--------------------------------------------------------------------+
string CommentEA ="FM-BlackBox NEW";
int TralStep =0;
double UpLot =3; //羊屣屙?筲咫梓屙? 腩蜞
int Step =50; //剜?皴蜿?
int D;
bool Buy1,Sell1,Buy2,Sell2,Buy3,Sell3,Buy4,Sell4,Buy5,Sell5,mod;
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);

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 NewLot1=Lot*(MathPow(UpLot,Count(-1,SYMBOL_1)));
double NewLot2=Lot*(MathPow(UpLot,Count(-1,SYMBOL_2)));
double NewLot3=Lot*(MathPow(UpLot,Count(-1,SYMBOL_3)));
double NewLot4=Lot*(MathPow(UpLot,Count(-1,SYMBOL_4)));
double NewLot5=Lot*(MathPow(UpLot,Count(-1,SYMBOL_5)));
//--------------------------茵彘腓磴 耱铒------------------------------+
if(Count(-1,SYMBOL_1)==1)
{Trail(Magic,SYMBOL_1); }
if(Count(-1,SYMBOL_2)==1)
{Trail(Magic,SYMBOL_2); }
if(Count(-1,SYMBOL_3)==1)
{Trail(Magic,SYMBOL_3); }
if(Count(-1,SYMBOL_4)==1)
{Trail(Magic,SYMBOL_4); }
if(Count(-1,SYMBOL_5)==1)
{Trail(Magic,SYMBOL_5); }
//--------------------------------------------------------------------+
Buy1=false;Sell1=false;
if (iCustom(SYMBOL_1,TF,"FM_TrendSignal","",0,0.5,2,2)>iLow(SYMBOL_1,TF,2) &&
iCustom(SYMBOL_1,TF,"FM_TrendSignal","",0,0.5,2,1)>iCustom(SYMBOL_1,TF,"FM_TrendSignal","",0,0.5,2,2) && iOpen(SYMBOL_1,TF,1)<iClose(SYMBOL_1,TF,1))Sell1=true;
if (iCustom(SYMBOL_1,TF,"FM_TrendSignal","",0,0.5,1,2)<iHigh(SYMBOL_1,TF,2) &&
iCustom(SYMBOL_1,TF,"FM_TrendSignal","",0,0.5,1,1)<iCustom(SYMBOL_1,TF,"FM_TrendSignal","",0,0.5,1,2) && iOpen(SYMBOL_1,TF,1)>iClose(SYMBOL_1,TF,1))Buy1=true;

Buy2=false;Sell2=false;
if (iCustom(SYMBOL_2,TF,"FM_TrendSignal","",0,0.5,2,2)>iLow(SYMBOL_2,TF,2) &&
iCustom(SYMBOL_2,TF,"FM_TrendSignal","",0,0.5,2,1)>iCustom(SYMBOL_2,TF,"FM_TrendSignal","",0,0.5,2,2) && iOpen(SYMBOL_2,TF,1)<iClose(SYMBOL_2,TF,1))Sell2=true;
if (iCustom(SYMBOL_2,TF,"FM_TrendSignal","",0,0.5,1,2)<iHigh(SYMBOL_2,TF,2) &&
iCustom(SYMBOL_2,TF,"FM_TrendSignal","",0,0.5,1,1)<iCustom(SYMBOL_2,TF,"FM_TrendSignal","",0,0.5,1,2) && iOpen(SYMBOL_2,TF,1)>iClose(SYMBOL_2,TF,1))Buy2=true;

Buy3=false;Sell3=false;
if (iCustom(SYMBOL_3,TF,"FM_TrendSignal","",0,0.5,2,2)>iLow(SYMBOL_3,TF,2) &&
iCustom(SYMBOL_3,TF,"FM_TrendSignal","",0,0.5,2,1)>iCustom(SYMBOL_3,TF,"FM_TrendSignal","",0,0.5,2,2) && iOpen(SYMBOL_3,TF,1)<iClose(SYMBOL_3,TF,1))Sell3=true;
if (iCustom(SYMBOL_3,TF,"FM_TrendSignal","",0,0.5,1,2)<iHigh(SYMBOL_3,TF,2) &&
iCustom(SYMBOL_3,TF,"FM_TrendSignal","",0,0.5,1,1)<iCustom(SYMBOL_3,TF,"FM_TrendSignal","",0,0.5,1,2) && iOpen(SYMBOL_3,TF,1)>iClose(SYMBOL_3,TF,1))Buy3=true;

Buy4=false;Sell4=false;
if (iCustom(SYMBOL_4,TF,"FM_TrendSignal","",0,0.5,2,2)>iLow(SYMBOL_4,TF,2) &&
iCustom(SYMBOL_4,TF,"FM_TrendSignal","",0,0.5,2,1)>iCustom(SYMBOL_4,TF,"FM_TrendSignal","",0,0.5,2,2) && iOpen(SYMBOL_4,TF,1)<iClose(SYMBOL_4,TF,1))Sell4=true;
if (iCustom(SYMBOL_4,TF,"FM_TrendSignal","",0,0.5,1,2)<iHigh(SYMBOL_4,TF,2) &&
iCustom(SYMBOL_4,TF,"FM_TrendSignal","",0,0.5,1,1)<iCustom(SYMBOL_4,TF,"FM_TrendSignal","",0,0.5,1,2) && iOpen(SYMBOL_4,TF,1)>iClose(SYMBOL_4,TF,1))Buy4=true;

Buy5=false;Sell5=false;
if (iCustom(SYMBOL_5,TF,"FM_TrendSignal","",0,0.5,2,2)>iLow(SYMBOL_5,TF,2) &&
iCustom(SYMBOL_5,TF,"FM_TrendSignal","",0,0.5,2,1)>iCustom(SYMBOL_5,TF,"FM_TrendSignal","",0,0.5,2,2) && iOpen(SYMBOL_5,TF,1)<iClose(SYMBOL_5,TF,1))Sell5=true;
if (iCustom(SYMBOL_5,TF,"FM_TrendSignal","",0,0.5,1,2)<iHigh(SYMBOL_5,TF,2) &&
iCustom(SYMBOL_5,TF,"FM_TrendSignal","",0,0.5,1,1)<iCustom(SYMBOL_5,TF,"FM_TrendSignal","",0,0.5,1,2) && iOpen(SYMBOL_5,TF,1)>iClose(SYMBOL_5,TF,1))Buy5=true;
//--------------------------------------------------------------------+
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) && Buy1)
{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) && Sell1)
{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) && Buy2)
{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) && Sell2)
{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) && Buy3)
{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) && Sell3)
{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) && Buy4)
{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) && Sell4)
{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) && Buy5)
{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) && Sell5)
{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)*(Risk/10);
if((Count(-1,SYMBOL_1)>1 || Count(-1,SYMBOL_2)>1 || Count(-1,SYMBOL_3)>1 || Count(-1,SYMBOL_4)>1 || Count(-1,SYMBOL_5)>1) &&
Profit(-1)>=ProfProc && ProfProc!=0)
{CloserB(); CloserS();}

double ProfProc2=(AccountBalance()/100)*(Risk/2);
if(Profit(-1)>=ProfProc2 && ProfProc2!=0)
{CloserB(); CloserS();}
//--------------------------------------------------------------------+
return(0);}
//--------------------------茵彘腓磴 耱铒------------------------------+
void Trail(int _key, string sy)
{double _bid, _ask, _point;
if(Tral!=0)
{for(int i=0; i<OrdersTotal(); i++)
{if (OrderSelect(i,SELECT_BY_POS) && OrderSymbol()==sy && OrderMagicNumber()==_key)
{_point=MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType()==OP_BUY)
{_bid=MarketInfo(OrderSymbol(), MODE_BID);
if(_bid>MathMax(OrderOpenPrice(),OrderStopLoss())+(Tral+TralStep)*_point*D)
{mod=OrderModify(OrderTicket(),OrderOpenPrice(),_bid-Tral*_point*D,OrderTakeProfit(),0);}}
if (OrderType()==OP_SELL)
{_ask=MarketInfo(OrderSymbol(), MODE_ASK);
if((_ask<MathMin(OrderOpenPrice(),OrderStopLoss())-(Tral+TralStep)*_point*D && OrderStopLoss()!=0)||(_ask<OrderOpenPrice()-(Tral+TralStep)*_point*D && OrderStopLoss()==0))
{mod=OrderModify(OrderTicket(),OrderOpenPrice(),_ask+Tral*_point*D,OrderTakeProfit(),0);}}}}}
return;}
//--------------------------------------------------------------------+
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 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);}}
//--------------------------------------------------------------------+
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);}

相关资源

暂无评论

暂无评论...