رد: لماذا هذا الكود لا يعمل
هناك خطأ أضن في تعريف MM
و AccountIsMicro التي يجب أن تعرف متغير منطقي bool
هذا الكود يعمل إن شاء الله و قد جربته .
//+------------------------------------------------------------------+
//| My Own Expert |
//| Copyright, created 20 may 2006 |
//| www.forex.com.sa |
//| Desined by Dr. Waleed |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "My Own Expert"
#property link "www.forex.com.sa"
extern int MaxTrades = 1;
extern int stoploss = 25;
extern int takeprofit = 50;
extern double TrailingStop =10;
extern bool UseHourTrade = true;
extern int FromHourTrade = 7;
extern int ToHourTrade = 17;
extern string MM_Parameters = "---------- Money Management";
extern double Lots = 1;
extern bool MM = true ;
extern bool AccountIsMicro = false;
extern int Risk = 10;
int ID=148;
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS deinitialization function |
//+------------------------------------------------------------------+
void deinit() {
Comment("");
}
int orderscnt(){
int cnt=0;
for(int i =0;i<OrdersTotal();i++){
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
if(OrderSymbol()==Symbol() && ID==OrderMagicNumber()){
cnt++;
}
}
}
return(cnt);
}
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS Start function |
//+------------------------------------------------------------------+
int start()
{
if (UseHourTrade){
if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){
Comment("Non-Trading Hours!");
return(0);
}
}
double EMA5cr, EMA5pr, EMA8cr, EMA8pr;
EMA5cr=iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE,0);
EMA5pr=iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE,1);
EMA8cr=iMA(NULL, 0, 8, 0, MODE_EMA, PRICE_CLOSE,0);
EMA8pr=iMA(NULL, 0, 8, 0, MODE_EMA, PRICE_CLOSE,1);
double sl,tp;
if(MM) Lots = subLotSize();
if (EMA5cr>EMA8cr && EMA5pr<EMA8pr){
if(orderscnt()<MaxTrades){
if(stoploss==0){sl=0;}else{sl=Ask-stoploss*Point;}
if(takeprofit==0){tp=0;}else{tp=Ask+takeprofit*Poi nt;}
OrderSend(Symbol(),OP_BUY,Lots,Ask,2,sl,tp,"My Own Expert",ID,0,Blue);
PlaySound("Alert.wav");
}
}
if (EMA5cr<EMA8cr && EMA5pr>EMA8pr){
if(orderscnt()<MaxTrades){
if(stoploss==0){sl=0;}else{sl=Bid+stoploss*Point;}
if(takeprofit==0){tp=0;}else{tp=Bid-takeprofit*Point;}
OrderSend(Symbol(),OP_SELL,Lots,Bid,2,sl,tp,"My Own Expert",ID,0,Red);
PlaySound("Alert.wav");
}
}
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS TrailingStop |
//+------------------------------------------------------------------+
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,
OrderTakeProfit(),0,Green);
return(0);
}
}
}
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,
OrderTakeProfit(),0,Red);
return(0);
}
}
}
return(0);
}
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS Money Managment |
//+------------------------------------------------------------------+
double subLotSize()
{
double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100;
if(AccountIsMicro==false)
{
if(lotMM < 0.1) lotMM = Lots;
if((lotMM > 0.5) && (lotMM < 1)) lotMM = 0.5;
if(lotMM > 1.0) lotMM = MathCeil(lotMM);
if(lotMM > 100) lotMM = 100;
}
else
{
if(lotMM < 0.01) lotMM = Lots;
if(lotMM > 1.0) lotMM = MathCeil(lotMM);
if(lotMM > 100) lotMM = 100;
}
return (lotMM);
}
رد: لماذا هذا الكود لا يعمل
مشكور اخوي ابو راقي
اذا ممكن تشرح التغيير الي سويته
رد: لماذا هذا الكود لا يعمل
اخوي ابو راقي اذا ممكن تحط الاكسربيت بملف احسن لان في اكثر من خطاء في الكود الي كتبته
مشكوووووووووووور
رد: لماذا هذا الكود لا يعمل
extern bool MM = true,
AccountIsMicro = false;
هنا يكمن الخطأ
السطر الأول ينتهي ب ; ; وليس ,
المتغير المنطقي accountismicro يجب أن يعرف على أنه bool لكي يقبل true و false
و ينقصه أن يكون متغير خارجي extern
extern bool MM = true ;
extern bool AccountIsMicro = false;
رد: لماذا هذا الكود لا يعمل
ابو راقي هل في خاصيه البك تست للاكسربيت
لاني حاولت سويت له فيجول باك تست وما اشتغل
رد: لماذا هذا الكود لا يعمل
رد: لماذا هذا الكود لا يعمل
اخوي ابو راقي هل له علاقه باخانات العشريه للسعر يمكن من البرنامج الي شغال عليه انا
اخوي ابو راقي ممكن ترفق الاكسربيت على شكل ملف
متعبك معاي
1 مرفق
رد: لماذا هذا الكود لا يعمل
هذا هو الأكسبيرت في المرفقات
بالتوفيق
رد: لماذا هذا الكود لا يعمل