Description
This is Jurik's "noise free" version of RSI, with no added lag. See http://www.jurikres.com/catalog1/ms_rsx.htm for more information. Use this indicator just like the normal RSI.
The code was converted from tradingview (author: LazyBear).
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Levels(70, 30)]
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class RSX : Indicator
{
[Parameter(DefaultValue = 14)]
public int Period { get; set; }
[Output("RSX", LineColor = "Yellow", PlotType = PlotType.Line, Thickness = 2)]
public IndicatorDataSeries Result { get; set; }
private double f8, f10, f18, f20, f28, f30, f38, f40, f48, f50,
f58, f60, f68, f70, f78, f80, f88, f90;
protected override void Initialize()
{
f8 = 0.0;
f10 = 0.0;
f18 = 3.0 / (Period + 2.0);
f20 = 1.0 - f18;
f28 = 0.0;
f30 = 0.0;
f38 = 0.0;
f40 = 0.0;
f48 = 0.0;
f50 = 0.0;
f58 = 0.0;
f60 = 0.0;
f68 = 0.0;
f70 = 0.0;
f78 = 0.0;
f80 = 0.0;
f88 = (Period - 1 >= 5) ? Period - 1 : 5;
f90 = 1.0;
}
public override void Calculate(int index)
{
if (index < 1)
return;
f10 = f8;
f8 = 100.0 * Bars.ClosePrices[index];
double v8 = f8 - f10;
f28 = f20 * f28 + f18 * v8;
f30 = f18 * f28 + f20 * f30;
double vC = f28 * 1.5 - f30 * 0.5;
f38 = f20 * f38 + f18 * vC;
f40 = f18 * f38 + f20 * f40;
double v10 = f38 * 1.5 - f40 * 0.5;
f48 = f20 * f48 + f18 * v10;
f50 = f18 * f48 + f20 * f50;
double v14 = f48 * 1.5 - f50 * 0.5;
f58 = f20 * f58 + f18 * Math.Abs(v8);
f60 = f18 * f58 + f20 * f60;
double v18 = f58 * 1.5 - f60 * 0.5;
f68 = f20 * f68 + f18 * v18;
f70 = f18 * f68 + f20 * f70;
double v1C = f68 * 1.5 - f70 * 0.5;
f78 = f20 * f78 + f18 * v1C;
f80 = f18 * f78 + f20 * f80;
double v20 = f78 * 1.5 - f80 * 0.5;
f90 = f90 == 0 ? 1.0 : (f88 <= f90 ? f88 + 1.0 : f90 + 1.0);
double f0 = f88 >= f90 && f8 != f10 ? 1.0 : 0.0;
double f90_ = f88 == f90 && f0 == 0 ? 0 : f90;
Result[index] = f88 < f90_ && v20 > 0.0 ? Math.Min(Math.Max((v14 / v20 + 1.0) * 50.0, 0.0), 100) : 50.0;
}
}
}
CW
cW22Trader
Joined on 16.03.2021
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: RSX.algo
- Rating: 0
- Installs: 1302
- Modified: 13/10/2021 09:54
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.