//+------------------------------------------------------------------------+ //| CAP_ZoneRecovery_Plugin.mq4 | //| Copyright © 2010-2014, Capilta.com | //| https://www.Capilta.com | //| | //| This custom indicator is template of CAP Zone Recovery EA's plugin | //| It is a sample code to make entry logic for initial open trade. | //| | //+------------------------------------------------------------------------+ #property copyright "Copyright © 2010-2015, Capilta Business Solutions" #property link "http://www.capilta.com" #property version "1.00" #property strict //| Main Product : https://www.mql5.com/en/market/product/20160 //| Details information : https://www.Capilta.com //| For customize mql coding : https://www.capilta.com/post-job #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 0 //--- input parameters input string PluginInputSetting = ""; //+------------------------------------------------------------------+ //| Buffer for send signal to main EA //| ExtEntryBuffer - // 1 - Value for BUY Signal //| 2 - Value for SELL Signal //+------------------------------------------------------------------+ double ExtEntryBuffer[]; //+------------------------------------------------------------------+ //| Variable for Indicator | //+------------------------------------------------------------------+ int RSIPeriod = 14; ENUM_APPLIED_PRICE RSIPrice = PRICE_CLOSE; int RSISellLevel = 70; int RSIBuyLevel = 50; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ExtEntryBuffer,INDICATOR_CALCULATIONS); //--- change the order of accessing elements of the indicator buffer ArraySetAsSeries(ExtEntryBuffer,true); //--- get indicator setting data from EA by input "PluginInputSetting" //--- split data and separate value by ";" if(PluginInputSetting!="") { string value[]; StringSplit(PluginInputSetting,StringGetCharacter(";",0),value); if(ArraySize(value)>0) { if(value[0]!="") RSIPeriod = (int)value[0]; } if(ArraySize(value)>1) { if(value[1]=="PRICE_CLOSE") RSIPrice = PRICE_CLOSE; else if(value[1]=="PRICE_HIGH") RSIPrice = PRICE_HIGH; else if(value[1]=="PRICE_LOW") RSIPrice = PRICE_LOW; else if(value[1]=="PRICE_MEDIAN") RSIPrice = PRICE_MEDIAN; else if(value[1]=="PRICE_OPEN") RSIPrice = PRICE_OPEN; else if(value[1]=="PRICE_TYPICAL") RSIPrice = PRICE_TYPICAL; else if(value[1]=="PRICE_WEIGHTED") RSIPrice = PRICE_WEIGHTED; } if(ArraySize(value)>2) { if(value[2]!="") RSISellLevel = (int)value[2]; } if(ArraySize(value)>3) { if(value[3]!="") RSIBuyLevel = (int)value[3]; } } //--- 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[]) { ExtEntryBuffer[0] = 0; ExtEntryBuffer[0] = Signal_Entry(Symbol(),PERIOD_CURRENT); return(rates_total); } //+------------------------------------------------------------------+ int Signal_Entry(string Sym,ENUM_TIMEFRAMES TF) { double RSI_Value=iRSI(Sym,TF,RSIPeriod,RSIPrice,0); if( RSI_Value < RSIBuyLevel ) return(1); if( RSI_Value > RSISellLevel ) return(2); return(0); } //+------------------------------------------------------------------+