public static Volatility Series(Bars bars, int emaPeriod, int rocPeriod) public Volatility(Bars bars, int emaPeriod, int rocPeriod, string description)
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() { // Colors bars with higher intensity red as volatility increases DataSeries vlty = Volatility.Series( Bars, 14, 10 ); double v = 0; double n = 0; ChartPane VolPane = CreatePane( 50, true, true ); PlotSeries( VolPane, vlty, Color.DarkBlue, LineStyle.Solid, 2 ); SetBarColors( Color.Silver, Color.Silver ); // Volatility is an unstable indicator for(int bar = 45; bar < Bars.Count; bar++) { v = vlty[bar]; n = Math.Round( v ) % 10; if( ( n < 0 ) || ( n > 9 ) ) n = 0; SetBarColor( bar, WS4ColorToNET( n * 100 ) ); } } } }