//+------------------------------------------------------------------ #property copyright "© mladen, 2018" #property link "mladenfx@gmail.com" #property version "1.00" #property description "Wilson Relative Price Channel" //+------------------------------------------------------------------ #property indicator_chart_window #property indicator_buffers 10 #property indicator_plots 6 #property indicator_label1 "Upper filling" #property indicator_type1 DRAW_FILLING #property indicator_color1 clrPaleGreen,clrPaleGreen, #property indicator_label2 "Lower filling" #property indicator_type2 DRAW_FILLING #property indicator_color2 clrLinen,clrLinen #property indicator_type3 DRAW_LINE #property indicator_color3 clrSilver #property indicator_type4 DRAW_LINE #property indicator_color4 clrSilver #property indicator_type5 DRAW_LINE #property indicator_color5 clrSilver #property indicator_type6 DRAW_LINE #property indicator_color6 clrSilver // //--- input parameters // input int inpRsiPeriod = 14; // RSI period input ENUM_APPLIED_PRICE inpPrice = PRICE_CLOSE; // RSI price input int inpSmoothing = 14; // Smoothing period for RSI and EMA input double inpOverbought = 70; // Overbought level % input double inpOversold = 30; // Oversold level % input double inpUpperNeutral = 55; // Upper neutral level % input double inpLowerNeutral = 45; // Lower neutral level % input int inpAtrPeriod = 100; // ATR period input double inpAtrMultuplicator = 25; // ATR multiplicator // //--- buffers declarations // double filluu[],fillud[],filldu[],filldd[],bupu[],bupd[],bdnu[],bdnd[],rsi[],atr[]; // //--- indicator handles // int _rsiHandle,_atrHandle; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,filluu,INDICATOR_DATA); SetIndexBuffer(1,fillud,INDICATOR_DATA); SetIndexBuffer(2,filldu,INDICATOR_DATA); SetIndexBuffer(3,filldd,INDICATOR_DATA); SetIndexBuffer(4,bupu,INDICATOR_DATA); SetIndexBuffer(5,bupd,INDICATOR_DATA); SetIndexBuffer(6,bdnu,INDICATOR_DATA); SetIndexBuffer(7,bdnd,INDICATOR_DATA); SetIndexBuffer(8,rsi,INDICATOR_CALCULATIONS); SetIndexBuffer(9,atr,INDICATOR_CALCULATIONS); //--- indicator short name assignment _rsiHandle=iRSI(_Symbol,0,inpRsiPeriod,inpPrice); if(_rsiHandle==INVALID_HANDLE) return(INIT_FAILED); _atrHandle=iATR(_Symbol,0,inpAtrPeriod); if(_atrHandle==INVALID_HANDLE) { IndicatorRelease(_rsiHandle); return(INIT_FAILED); } IndicatorSetString(INDICATOR_SHORTNAME,"Wilson rpc ("+(string)inpRsiPeriod+")"); //--- return (INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator de-initialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| 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[]) { if(BarsCalculated(_rsiHandle)0 && period>1) workEma[_indC][_inst]=workEma[_indP][_inst]+(2.0/(1.0+period))*(price-workEma[_indP][_inst]); else workEma[_indC][_inst]=price; return(workEma[_indC][_inst]); }