//+------------------------------------------------------------------+ //| Volatile action.mq4 | //| Alexey Zykov | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Alexey Zykov" #property link "https://www.mql5.com" #property version "1.00" #property strict input double VolN=3; // Volatility coef. input int Magic=7101; // Magic Number input double Risk=0; // Leverage input double Fix_Lot=0.01; // Fix_Lot input double ns=0.6; // Coefloss input double np=1.0; // Coefprof input int ATR=23; // ATR datetime ct; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { int OpenOrd=0; bool static Error=true; // Flag fatal Error if(Error==false) { Comment("Fatal error, EA does not work!"); return; } //--- Orders int OrderBuy=0,OrderSell=0; for(int i=0;i0 && SignalVol()>0) { if(ct!=Time[0]) { ct=Time[0]; int Sign=1; OpenOrd=OpenOrder(Sign); if(OpenOrd<0) Error=Error(); } } if(SignalGator()<0 && SignalVol()<0) { if(ct!=Time[0]) { ct=Time[0]; int Sign=-1; OpenOrd=OpenOrder(Sign); if(OpenOrd<0) Error=Error(); } } } //+------------------------------------------------------------------+ //| Function SignalVolatility | //+------------------------------------------------------------------+ int SignalVol() { int SignalVol=0; double Min=1000,Max=0; double Vol_140=iATR(_Symbol,PERIOD_CURRENT,ATR,1); double Vol_1=iATR(_Symbol,PERIOD_CURRENT,1,1); double HL=MathAbs(High[1]-Low[1]); double HC=MathAbs(High[1]-Close[1]); double LC=MathAbs(Low[1]-Close[1]); for(int i=20;i>0;i--) { if(Low[i]<=Min) Min=Low[i]; } for(int i=24;i>0;i--) { if(High[i]>=Max) Max=High[i]; } //--- Buy position if(Vol_1>VolN*Vol_140 && Close[1]>Open[1] && Max==High[1] && 0.3*HL>=HC) SignalVol=1; //--- Sell position if(Vol_1>VolN*Vol_140 && Close[1]LC) SignalVol=-1; return(SignalVol); } //+------------------------------------------------------------------+ //| Function SignalGator | //+------------------------------------------------------------------+ int SignalGator() { int SignalGator=0; double Gator_Jaw=iAlligator(_Symbol,PERIOD_H4,13,8,8,5,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_GATORJAW,1); // Blue line Alligator double Gator_Teeth=iAlligator(_Symbol,PERIOD_H4,13,8,8,5,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_GATORTEETH,1); // Red line Alligator double Gator_Lips=iAlligator(_Symbol,PERIOD_H4,13,8,8,5,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_GATORLIPS,1); // Green line Alligator //--- Buy position if(Gator_Lips>Gator_Teeth && Gator_Lips>Gator_Jaw && Gator_Teeth>Gator_Jaw && iClose(_Symbol,PERIOD_H4,1)>Gator_Teeth && iOpen(_Symbol,PERIOD_H4,1)>Gator_Teeth) SignalGator=1; //--- Sell position if(Gator_LipsMarketInfo(_Symbol,MODE_MAXLOT)) Lot=MarketInfo(_Symbol,MODE_MAXLOT); if(AccountFreeMargin()0) { TP=OrderOpenPrice()+np*NormalizeDouble(Vol_1,_Digits); SL=OrderOpenPrice()-ns*NormalizeDouble(Vol_1,_Digits); int Ticket=OrderTicket(); OrderMod=OrderModify(Ticket,OrderOpenPrice(),SL,TP,0,clrGreen); } if(ordsell>0) { TP=OrderOpenPrice()-np*NormalizeDouble(Vol_1,_Digits); SL=OrderOpenPrice()+ns*NormalizeDouble(Vol_1,_Digits); int Ticket=OrderTicket(); OrderMod=OrderModify(Ticket,OrderOpenPrice(),SL,TP,0,clrRed); } return(OrderMod); } //+------------------------------------------------------------------+