[HandlerName("SVE RSI IFT")] [HandlerCategory("vvTSLtools")] public class SVE_RSI_IFT : IDouble2DoubleHandler, IContextUses { /* Smoothed RSI Inverse Fisher Transform by Sylvain Vervoort * * http://codebase.mql4.com/7651 * http://blog.traderslibrary.com/sylvain_vervoort/2010/09/smoothed-rsi-inverse-fisher-transform-excerpt-from-sc-magazine.html * * converted by vito333, 2012 * */ [HandlerParameter(true, "4", Min = "3", Max = "25", Step = "1")] public int RSI_Period { get; set; } [HandlerParameter(true, "4", Min = "3", Max = "50", Step = "1")] public int MA_Period { get; set; } public static IList GenSRSI(IList src, int _RSI_Period, int _MA_Period) { int maxperiod = Math.Max(_RSI_Period, _MA_Period); var SRSI = new double[src.Count]; var rainbow = new double[src.Count]; //---- prepare partial averages var wma0 = LWMA.GenWMA(src, 2); var wma1 = LWMA.GenWMA(wma0, 2); var wma2 = LWMA.GenWMA(wma1, 2); var wma3 = LWMA.GenWMA(wma2, 2); var wma4 = LWMA.GenWMA(wma3, 2); var wma5 = LWMA.GenWMA(wma4, 2); var wma6 = LWMA.GenWMA(wma5, 2); var wma7 = LWMA.GenWMA(wma6, 2); var wma8 = LWMA.GenWMA(wma7, 2); var wma9 = LWMA.GenWMA(wma8, 2); //---- double rb_val = 0; for (int i = 0; i < src.Count; i++) { rb_val = 5 * wma0[i] + 4 * wma1[i] + 3 * wma2[i] + 2 * wma3[i] + wma4[i] + wma5[i] + wma6[i] + wma7[i] + wma8[i] + wma9[i]; rb_val /= 20; rainbow[i] = rb_val; } //---- calculate rsi from rainbow smoothed price curve var rsi = Series.RSI(rainbow, _RSI_Period); double[] rsi2 = new double[src.Count]; for (int i = 0; i < src.Count; i++) rsi2[i] = 0.1 * (rsi[i] - 50); //---- smooth the rsi with Vervoort zero lag MA var ema0 = EMA.EMA_TSLab(rsi2, _MA_Period); var ema1 = EMA.EMA_TSLab(ema0, _MA_Period); var srsi = new double[src.Count]; for (int i = 0; i < src.Count; i++) srsi[i] = ema0[i] + (ema0[i] - ema1[i]); //---- основной цикл расчета индикатора for (int i = 2; i < src.Count; i++) { SRSI[i] = ((Math.Exp(2 * srsi[i]) - 1) / (Math.Exp(2 * srsi[i]) + 1) + 1) * 50; } // return SRSI; } public IList Execute(IList src) { return GenSRSI(src, RSI_Period, MA_Period); } public IContext Context { get; set; } }