-
ممكن شرح هذا الكود
السسلام عليكم والرحمة
قام برمجت هذا الاكسبيرت دكتور وليد لاحد الأخوه
بس احب افهم طريقه عمله وطريقه اضافه اداراه راس المال له
بس ياريت شرح مفصل له :inlove:
كود PHP:
//+------------------------------------------------------------------+
//| Tamer v1.mq4 |
//| Copyright © 2007 , Dr. Waleed Soliman |
//| [email protected] |
//| 0020122327320 / 00966501917706 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, dr_waleed"
#property link "[email protected]"
//---- Trades Limits
extern int TakeProfit = 100;
extern int StopLoss = 100;
extern double TrailingStop = 0;
extern bool SmartClose = true;
//---- Money Monagement
extern bool MoneyManagment = false;
extern int Risk = 5;
extern double Lots = 1;
extern int MaxTrades = 5;
//---- Hour Trades
extern bool UseHourTrade = false;
extern int FromHourTrade = 0;
extern int ToHourTrade = 0;
//---- Global variables
int Magic = 841;
string eaComment = "Tamer v1";
//+------------------------------------------------------------------+
//| Initialation function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
int orderscnt()
{
int cnt=0;
for(int i =0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()== Symbol() && Magic==OrderMagicNumber())
{
cnt++;
}
}
}
return(cnt);
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
int start()
{
if(Bars<100)
{
Print("bars less than 100");
return(0); // check Bars
}
if(TakeProfit < 10)
{
Print("TakeProfit less than 10");
return(0); // check Take Profit
}
double Stop, Limit;
int cnt, total ,ticket;
if(MoneyManagment) Lots = subLotSize();
double ej1, ej2;
ej1 = iCustom(NULL, 0, "EJ_Signal", 3, 300, 0, 1);
ej2 = iCustom(NULL, 0, "EJ_Signal", 3, 300, 1, 1);
total=OrdersTotal();
if(total<1)
{
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ",AccountFreeMargin());
return(0);
}
//+------------------------------------------------------------------+
//| Buy & Sell |
//+------------------------------------------------------------------+
if (Bid>ej2) //------------------ Buy
{
if(orderscnt()<MaxTrades)
{
if(StopLoss==0)
{Stop=0;TrailingStop=0;}
else
{Stop=Ask-StopLoss*Point;}
if(TakeProfit==0)
{Limit=0;}
else
{Limit=Ask+TakeProfit*Point;}
ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Stop,Limit,eaComment,Magic,0,Blue);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
PlaySound("Alert.wav");
}
else Alert("Tamer v1 >> Error opening BUY order : ",GetLastError());
}
}
if (Bid<ej1) //------------------ Sell
{
if(orderscnt()<MaxTrades)
{
if(StopLoss==0)
{Stop=0;TrailingStop=0;}
else
{Stop=Bid+StopLoss*Point;}
if(TakeProfit==0)
{Limit=0;}
else
{Limit=Bid-TakeProfit*Point;}
ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Stop,Limit,eaComment,Magic,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
PlaySound("Alert.wav");
}
else Alert("Tamer v1 >> Error opening SELL order : ",GetLastError());
}
}
return(0);
}
//+------------------------------------------------------------------+
//| Smart Close |
//+------------------------------------------------------------------+
if (SmartClose)
{
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
if (Bid<ej1) //-----------------Cloes Buy
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Yellow);
return(0);
}
}
else
{
if (Bid>ej2) //------------------Close Sell
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Yellow);
return(0);
}
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
//| Money Management |
//+------------------------------------------------------------------+
double subLotSize()
{
double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100;
{
if(lotMM < 0.01) lotMM = Lots;
if(lotMM > 1.0) lotMM = MathCeil(lotMM);
if(lotMM > 100) lotMM = 100;
return (lotMM);
}
}
//------------------------------------------------------------------------- The End.
-
اكيد مستر دولار سيفيدك اخي