//+------------------------------------------------------------------+ //| Abo 3atrees.mq4 | //| Copyright © 2007 , dr_waleed | //| www.moneyexpertsclub.net | //| www.arabtraderacademy.com | //| dr_waleed@msn.com | //| 00966501917706 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, dr_waleed" #property link "http://www.moneyexpertsclub.net/forum/forumdisplay.php?f=48" //---- Trades Limits extern double TakeProfit = 150; extern double StopLoss = 80; extern double TrailingStop = 70; //---- Hour Trades extern bool UseHourTrade = false; extern int FromHourTrade = 4; extern int ToHourTrade = 10; //---- Money Monagement extern string MM_Parameters = "Money Management"; extern int MaxTrades = 1; extern double Lots = 1; extern bool MM = false, AccountIsMicro = false; extern int Risk = 10; //---- Global variables int ID1 = 12893; int ID2 = 13498; string eaComment = "Abo 3atrees"; //+------------------------------------------------------------------+ //| Initialation function | //+------------------------------------------------------------------+ int init() { return(0); } int orderscnt() { int cnt=0; for(int i =0;i=FromHourTrade&&Hour()<=ToHourTrade)) { Comment("Non-Trading Hours!"); return(0); } } double m51, m52 ,m81 ,m82; m51 = iMA (NULL,PERIOD_M30,5,0,MODE_LWMA,PRICE_CLOSE,1); m52 = iMA (NULL,PERIOD_M30,5,0,MODE_LWMA,PRICE_CLOSE,2); m81 = iMA (NULL,PERIOD_M30,8,0,MODE_LWMA,PRICE_CLOSE,1); m82 = iMA (NULL,PERIOD_M30,8,0,MODE_LWMA,PRICE_CLOSE,2); total=OrdersTotal(); if(total<1 || isNewSymbol(Symbol())) { if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if ( m52m81 ) //---- Buy2 { if(orderscnt()m82 && m510) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()-Point*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } } return(0); } //+------------------------------------------------------------------+ //| Money Management | //+------------------------------------------------------------------+ 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); } //------------------------------------------------------------------------- The End.