public HV(DataSeries source, int period, int span, string description) public static HV Series(DataSeries source, int period, int span)
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { DataSeries Average = (High+Low)/2; DataSeries HV1 = HV.Series( Average, 20, 262 ); HV1.Description = "HV of Average Price"; double stop = 0; double profit = 0; for(int bar = 262; bar < Bars.Count; bar++) { if (!IsLastPositionActive) { if( HV1[bar] > 100 ) if( ROC.Series( Close, 30 )[bar] > 0 ) ShortAtMarket( bar+1 ); else BuyAtMarket( bar+1 ); } else { Position p = LastPosition; stop = (p.PositionType == PositionType.Long) ? p.EntryPrice * 0.6 : profit = p.EntryPrice * 1.4; profit = (p.PositionType == PositionType.Long) ? p.EntryPrice * 1.15 : profit = p.EntryPrice * 0.85; if( !ExitAtStop( bar, p, stop ) ) ExitAtLimit( bar, p, profit ); } } ChartPane HVPane = CreatePane( 35, true, true ); PlotSeries( HVPane, HV1, Color.Teal, WealthLab.LineStyle.Solid, 2); } } }