//+------------------------------------------------------------------+ //| TARZAN ALERT.mq4 | //| Yuriy Tokman (YTG) | //| https://www.mql5.com/ru/users/satop/seller | //+------------------------------------------------------------------+ #property copyright "Yuriy Tokman (YTG)" #property link "https://www.mql5.com/ru/users/satop/seller" #property version "1.00" #property strict #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Yellow #property indicator_color3 Aqua #property indicator_color4 Aqua #property indicator_color5 Lime #property indicator_color6 Red #property indicator_width1 3 #property indicator_level1 15.0 #property indicator_level2 85.0 //----+ extern bool Alert_ = true; extern int TimeSleep_Alert = 120; //----+ input ENUM_TIMEFRAMES TimeFrame = PERIOD_H1; input int RSI=5; input int applied_RSI=0; input int MA=50; input int method_MA=0; input int koridor = 5; //---- buffers double BU0[]; double BU1[]; double BU2[]; double BU3[]; double BU4[]; double BU5[]; string name = ""; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping name = "TARZAN+ALERT "+GetNameTF(TimeFrame)+" "+Symbol()+" RSI="+DoubleToStr(RSI,0)+" MA="+DoubleToStr(MA,0); IndicatorShortName(name); SetIndexBuffer(0, BU0); SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(1, BU1); SetIndexStyle(1,DRAW_NONE); //---- SetIndexBuffer(2, BU2); SetIndexStyle(2, DRAW_LINE); SetIndexBuffer(3, BU3); SetIndexStyle(3,DRAW_LINE); //---- SetIndexBuffer(4, BU4); SetIndexStyle(4, DRAW_ARROW); SetIndexArrow(4,110); SetIndexBuffer(5, BU5); SetIndexStyle(5,DRAW_ARROW); SetIndexArrow(5,110); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //---- int limit,b_sh; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- if(TimeFrame>=Period()){ for(int i=0; i0)koef = TimeFrame/Period(); //---- for(int i=0; iBU1[i]) BU4[i]= iMAOnArray(BU0,0,MA*koef,0,method_MA,i); else BU5[i]= iMAOnArray(BU0,0,MA*koef,0,method_MA,i); } //---- if(Alert_ && NewTime()) { if(BU0[0]>BU1[0])Alert(name+" BUY TREND"); else Alert(name+" SELL TREND"); } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //----+ bool NewTime() { static datetime time0 = -1; datetime time1 = TimeCurrent(); if(time1-time0>TimeSleep_Alert) { time0 = TimeCurrent(); return(true); } else return(false); } //---- string GetNameTF(int _TimeFrame=0) { if (_TimeFrame==0) _TimeFrame=Period(); switch (_TimeFrame) { case PERIOD_M1: return("M1"); case PERIOD_M5: return("M5"); case PERIOD_M15: return("M15"); case PERIOD_M30: return("M30"); case PERIOD_H1: return("H1"); case PERIOD_H4: return("H4"); case PERIOD_D1: return("Daily"); case PERIOD_W1: return("Weekly"); case PERIOD_MN1: return("Monthly"); default: return("UnknownPeriod"); } } //----+