//+------------------------------------------------------------------+ //| ytg_Def_RSI.mq4 | //| Yuriy Tokman | //| yuriytokman@gmail.com | //+------------------------------------------------------------------+ #property copyright "Yuriy Tokman" #property link "yuriytokman@gmail.com" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_level1 0 extern int RSI_1_Period = 14;//период первого индикатора РСИ extern int RSI_2_Period = 28;//период второго индикатора РСИ extern int applied_price = 0;//используемая цена 0-6 extern int ma_period = 14;//период сглаживания extern int ma_method = 0;//метод сглаживания 0-3 double buf[]; double MA_buf[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2); SetIndexBuffer(0, buf); SetIndexStyle(1,DRAW_NONE); SetIndexBuffer(1,MA_buf); IndicatorShortName("ytg_Def_RSI"); Comment("yuriytokman@gmail.com"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- Comment(""); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- double RSI_1,RSI_2; int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; if(counted_bars==0) limit--; for(int i=limit; i>=0; i--) { RSI_1 = iRSI(NULL,0,RSI_1_Period,applied_price,i); RSI_2 = iRSI(NULL,0,RSI_2_Period,applied_price,i); MA_buf[i] = (RSI_1-RSI_2); } for(i=limit; i>=0; i--) { buf[i] = iMAOnArray(MA_buf,0,ma_period,0,ma_method,i); } //---- return(0); } //+------------------------------------------------------------------+