//+------------------------------------------------------------------+ //| iEpsilone-1.mq4 | //| Valeriy Korobeynik | //| https://www.mql5.com/ru/users/valeryk | //+------------------------------------------------------------------+ #property copyright "Valeriy Korobeynik" #property link "https://www.mql5.com/ru/users/valeryk" #property version "1.00" #property strict #property indicator_chart_window //--- #property indicator_buffers 2 #property indicator_plots 2 //--- #property indicator_label1 "Buy" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrLime #property indicator_width1 3 //--- #property indicator_label2 "Sell" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrRed #property indicator_width2 3 //--- enum Edir { DIR_UP = 0, //buy only DIR_DN = 1, //sell only DIR_ALL = 2 //all }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ sinput int MaxBars = 300; //Max Bars ( 0 = unlim ) sinput Edir Dir = DIR_ALL; //Direction sinput string FXRprop = "----- Current FXR properties -----"; //----- Current FXR properties ----- input int FXRlenghtF = 12; //Fast input int FXRlenghtS = 24; //Slow sinput string FXRprop1 = "----- High FXR properties -----"; //----- High FXR properties ----- sinput ENUM_TIMEFRAMES FXRtf1 = PERIOD_H4; //Timeframe input int FXRlenghtF1 = 12; //Fast input int FXRlenghtS1 = 24; //Slow sinput string FXRprop2 = "----- Higher FXR properties -----"; //----- Higher FXR properties ----- input bool FXRuse2 = false; //Use sinput ENUM_TIMEFRAMES FXRtf2 = PERIOD_D1; //Timeframe input int FXRlenghtF2 = 12; //Fast input int FXRlenghtS2 = 24; //Slow sinput string ALprop = "----- Alerts properties -----"; //----- Alerts properties ----- sinput bool ALalert = true; //Alert sinput bool ALmail = false; //Mail sinput bool ALpush = false; //Push Notification //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ string expname; double Buy[], Sel[]; double Fast[], Slow[], FastH[], SlowH[], FastHH[], SlowHH[]; //--- #resource "\\Indicators\\FXR_overbought_oversold.ex4" //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { Comment(""); expname = MQLInfoString(MQL_PROGRAM_NAME); ObjectsDeleteAll(0, expname); if(!LicenseValidation()) return(INIT_FAILED); //--- IndicatorBuffers(8); int cnt = 0; SetIndexArrow(cnt, 159); SetBuffer(cnt, Buy, INDICATOR_DATA, true); SetIndexArrow(cnt, 159); SetBuffer(cnt, Sel, INDICATOR_DATA, true); SetBuffer(cnt, Fast, INDICATOR_CALCULATIONS, true); SetBuffer(cnt, Slow, INDICATOR_CALCULATIONS, true); SetBuffer(cnt, FastH, INDICATOR_CALCULATIONS, true); SetBuffer(cnt, SlowH, INDICATOR_CALCULATIONS, true); SetBuffer(cnt, FastHH, INDICATOR_CALCULATIONS, true); SetBuffer(cnt, SlowHH, INDICATOR_CALCULATIONS, true); //--- 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 = rates_total - prev_calculated; if(limit > 1 || limit < 0) { for(int i = 0; i < rates_total; i++) { Buy[i] = EMPTY_VALUE; Sel[i] = EMPTY_VALUE; Fast[i] = EMPTY_VALUE; Slow[i] = EMPTY_VALUE; FastH[i] = EMPTY_VALUE; SlowH[i] = EMPTY_VALUE; FastHH[i] = EMPTY_VALUE; SlowHH[i] = EMPTY_VALUE; } limit = (MaxBars > 0) ? fmin(rates_total - 2, MaxBars) : rates_total - 2; } else limit = fmax(iBarShift(Symbol(), PERIOD_CURRENT, iTime(Symbol(), FXRtf1, 0)), iBarShift(Symbol(), PERIOD_CURRENT, iTime(Symbol(), FXRtf2, 0))) + 1; for(int i = limit; i >= 0 && !IsStopped(); i--) { Fast[i] = GetLine(PERIOD_CURRENT, FXRlenghtF, i); Slow[i] = GetLine(PERIOD_CURRENT, FXRlenghtS, i); int sh = iBarShift(Symbol(), FXRtf1, time[i]); FastH[i] = GetLine(FXRtf1, FXRlenghtF1, sh); SlowH[i] = GetLine(FXRtf1, FXRlenghtS1, sh); Buy[i] = (Dir == DIR_DN) ? EMPTY_VALUE : (Fast[i] <= Slow[i]) ? EMPTY_VALUE : (Fast[i + 1] > Slow[i + 1]) ? EMPTY_VALUE : (FastH[i] <= SlowH[i]) ? EMPTY_VALUE : low[i] - 50 * _Point; Sel[i] = (Dir == DIR_UP) ? EMPTY_VALUE : (Fast[i] >= Slow[i]) ? EMPTY_VALUE : (Fast[i + 1] < Slow[i + 1]) ? EMPTY_VALUE : (FastH[i] >= SlowH[i]) ? EMPTY_VALUE : high[i] + 50 * _Point; if(FXRuse2) { sh = iBarShift(Symbol(), FXRtf2, time[i]); FastHH[i] = GetLine(FXRtf2, FXRlenghtF2, sh); SlowHH[i] = GetLine(FXRtf2, FXRlenghtS2, sh); if(Buy[i] != EMPTY_VALUE) if(FastHH[i] <= SlowHH[i]) Buy[i] = EMPTY_VALUE; if(Sel[i] != EMPTY_VALUE) if(FastHH[i] >= SlowHH[i]) Sel[i] = EMPTY_VALUE; } } //--- static bool nb; if(rates_total != prev_calculated) nb=true; if(nb) { string txt = (Buy[0] !=EMPTY_VALUE) ? "[SIGNAL BUY #1]" : (Sel[0] !=EMPTY_VALUE) ? "[SIGNAL SELL #1]" : NULL; if(txt != NULL) { nb=false; txt = "[" + Symbol() + "] [TF:" + StringSubstr(EnumToString(ChartPeriod()), StringLen("PERIOD_")) + "] " + txt + " " + DoubleToString(close[0],Digits()); if(ALalert) Alert(txt); if(ALpush) SendNotification(txt); if(ALmail) SendMail(txt, txt); } } return(rates_total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double GetLine(const ENUM_TIMEFRAMES vTf, const int vPeriod, const int vPos) { return(iCustom(Symbol(), vTf, "::Indicators\\FXR_overbought_oversold.ex4", vPeriod, 100, 0, false, false, 0, vPos)); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int SetBuffer(int &vCnt, double &vBuf[], const ENUM_INDEXBUFFER_TYPE vType, const bool vSetAsSeries) { ArraySetAsSeries(vBuf, vSetAsSeries); SetIndexBuffer(vCnt, vBuf, vType); vCnt++; return(vCnt); } //+------------------------------------------------------------------+ //--- //--- //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #define LIC_NAME "" #define LIC_TEST false #define LIC_MAXIMAL_DATE D'29.10.2220' // Максимальная дата работы советника, если 0=откл | Maximum date of the expert advisor, 0 = off #define LIC_KEY 0 // Ключ, если 0=откл | The key, 0 = off #define LIC_ACCOUNT_NUMBER 0 // Номер счёта, если 0=откл | Account number, 0 = off //--- bool LicenseValidation(int mag = 0, int key = 0) { bool ru = (StringFind(TerminalInfoString(TERMINAL_LANGUAGE), "Russian", 0) > -1) ? true : false; string title = (MQLInfoString(MQL_PROGRAM_NAME) + " (" + Symbol() + ((mag > 0) ? (", ID-" + IntegerToString(mag)) : ("")) + ")"); if(LIC_TEST && !MQLInfoInteger(MQL_OPTIMIZATION) && !MQLInfoInteger(MQL_TESTER)) { Alert(title, ((ru) ? " Только для тестера!" : " Only for tester!")); ObjectsDeleteAll(0, MQLInfoString(MQL_PROGRAM_NAME)); return(false); } if(LIC_MAXIMAL_DATE > 0 && TimeLocal() > LIC_MAXIMAL_DATE) { Alert(title, ((ru) ? " Время демонстрации истекло!" : " The demonstration has expired!")); ObjectsDeleteAll(0, MQLInfoString(MQL_PROGRAM_NAME)); return(false); } if(LIC_KEY > 0 && LIC_KEY != key) { Alert(title, ((ru) ? " Неверный ключ лицензии!" : " Invalid license key!")); ObjectsDeleteAll(0, MQLInfoString(MQL_PROGRAM_NAME)); return(false); } if(LIC_ACCOUNT_NUMBER > 0 && LIC_ACCOUNT_NUMBER != AccountInfoInteger(ACCOUNT_LOGIN)) { Alert(title, ((ru) ? " Нелицензированный аккаунт!" : " Invalid account number!")); ObjectsDeleteAll(0, MQLInfoString(MQL_PROGRAM_NAME)); return(false); } if(StringLen(IntegerToString(mag)) > 6) { Alert(title, ((ru) ? " Некорректное значение ID советника, установите значение не более 6 цифр!" : " Incorrect value ID Advisor, set this value to no more than 6 digits!")); ObjectsDeleteAll(0, MQLInfoString(MQL_PROGRAM_NAME)); return(false); } if(!MQLInfoInteger(MQL_OPTIMIZATION) && !MQLInfoInteger(MQL_TESTER) && LIC_NAME != "" && StringFind(AccountInfoString(ACCOUNT_NAME), LIC_NAME) < 0) { Alert(title, ((ru) ? " Нелицензированный владелец!" : " Invalid account nick name!")); ObjectsDeleteAll(0, MQLInfoString(MQL_PROGRAM_NAME)); return(false); } return(true); } //+------------------------------------------------------------------+ //--- //---