public RSI(DataSeries ds, int period, string description) public static RSI Series(WealthLab.DataSeries ds, int period)
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { // Thank you fundtimer public Color WS4ColorToNET( double WS4Color ) { return Color.FromArgb( (int)Math.Floor( ( WS4Color % 1000 ) / 100 * 28.4 ), (int)Math.Floor( ( WS4Color % 100 ) / 10 * 28.4 ), (int)Math.Floor( WS4Color % 10 * 28.4 ) ); } protected override void Execute() { // This script colors each bar based on the RSI oversold/overbought level DataSeries rsi = RSI.Series( Close, 14 ); double x = 0; double col = 0; // RSI is an "unstable" indicator; consult Language Guide for(int bar = 14*3; bar < Bars.Count; bar++) { x = rsibar; if( x > 50 ) { x -= 50; x *= 2; x /= 9; col = Math.Truncate( x ) * 100; } else { x = 50 - x; x *= 2; x /= 9; col = Math.Truncate( x ) * 10; } SetBarColor( bar, WS4ColorToNET(col) ); } ChartPane RSIPane = CreatePane( 35, true, true ); SetPaneMinMax( RSIPane, 0, 100 ); PlotSeries( RSIPane, rsi, Color.Red, WealthLab.LineStyle.Solid, 1 ); } } }