public EMV(Bars source, int period, string description) public static EMV Series(Bars source, 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 { StrategyParameter period; public MyStrategy() { period = CreateParameter("EMV Period", 1, 1, 20, 1); } protected override void Execute() { int per = period.ValueInt; if (per < 1) per = 1; DataSeries av = (Highest.Series(Bars.High, per) + Lowest.Series(Bars.Low, per)) / 2d; DataSeries midPoint = av - (av >> per); DataSeries boxRatio = (Sum.Series(Volume, per) /1.0e6) / (Highest.Series(Bars.High, per) - Lowest.Series(Bars.Low, per)); DataSeries emv = new DataSeries(Bars, "EMV(" + per + ")"); for(int bar = per; bar < Bars.Count; bar++) { if (boxRatio[bar] == 0) { emv[bar] = emv[bar-1]; // use the value from the previous bar } else { emv[bar] = midPoint[bar] / boxRatio[bar]; } } ChartPane cp = CreatePane(40, true, true); PlotSeries(cp, emv, Color.Black, LineStyle.Solid, 1); } } }