//+------------------------------------------------------------------+ //| FMW_1.mq4 | //| * | //| * | //+------------------------------------------------------------------+ #property copyright "FMW_1" #property link "fraktalis@gmail.com" //---- input parameters extern double Lots=0.2; extern bool RiskManagement=true; extern double RiskPercent=20; extern int StopLose=0; extern int TakeProfit=12; extern int TrailingStop=0; extern int WPRSell=10; extern int WPRBuy=90; extern int S=80; // EMA extern int B=40; // EMA int start() { double SL,TP; int Total=0; for(int cnt=0;cnt0 && Bid-OrderOpenPrice()>Point*TrailingStop && OrderStopLoss()0 && OrderOpenPrice()-Ask>Point*TrailingStop && (OrderStopLoss()>Ask+Point*TrailingStop || OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0); return(0); } } } } if(OrdersTotal()==1)return(0); if(RiskManagement) { if(RiskPercent<0.1||RiskPercent>100) { Comment("Invalid Risk Value."); return(0); } else { Lots=MathFloor((AccountFreeMargin()*AccountLeverage()*RiskPercent*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)* MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT); } } if(Lots<0.01)Lots=0.01;//My min lots if(Lots>100)Lots=100;//My max lots if(RiskManagement==false){Lots=Lots;} double SellMA=iMA(NULL,0,S,0,MODE_EMA,PRICE_OPEN,1); double BuyMA=iMA(NULL,0,B,0,MODE_EMA,PRICE_OPEN,1); double hight=iFractals(NULL,0,MODE_UPPER,3); double low=iFractals(NULL,0,MODE_LOWER,3); double R=iWPR(NULL,0,21,1); if(SellMA>BuyMA && R>-WPRSell) { if (TakeProfit>0) TP=Bid-TakeProfit*Point; if (StopLose>0) SL=Bid+StopLose*Point; OrderSend(Symbol(),OP_SELL,Lots,Bid,2,SL,TP,NULL,0,0); return(0); } if(SellMA0) TP=Ask+TakeProfit*Point; if (StopLose>0) SL=Ask-StopLose*Point; OrderSend(Symbol(),OP_BUY,Lots,Ask,2,SL,TP,NULL,0,0); return(0); } return(0); } //+------------------------------------------------------------------+