Вот код, реализующий простейшую стратегию Moving Average Crossover (предустановленную в WL) с перегрузкой методов класса StrategyHelper.
[CODE]using System;
using WealthLab.Indicators;
using System.Drawing;
namespace WealthLab.Strategies
{
public class SampleStrategy : WealthLab.WealthScript
{
//Create parameters
private StrategyParameter slowPeriod;
private StrategyParameter fastPeriod;
public SampleStrategy()
{
fastPeriod = CreateParameter("Fast Period", 20, 1, 100, 1);
slowPeriod = CreateParameter("Slow Period", 50, 20, 300, 5);
}
protected override void Execute()
{
//Obtain periods from parameters
int fastPer = fastPeriod.ValueInt;
int slowPer = slowPeriod.ValueInt;
SMA smaFast = SMA.Series(Close, fastPer);
SMA smaSlow = SMA.Series(Close, slowPer);
PlotSeries(PricePane, smaFast, Color.Green, LineStyle.Solid, 2);
PlotSeries(PricePane, smaSlow, Color.Red, LineStyle.Solid, 2);
for (int bar = Math.Max(fastPer, slowPer); bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
if (CrossUnder(bar, smaFast, smaSlow))
SellAtMarket(bar + 1, LastPosition);
}
else
{
if (CrossOver(bar, smaFast, smaSlow))
BuyAtMarket(bar + 1);
}
}
}
}
public class SampleStrategyHelper : WealthLab.StrategyHelper
{
public override string Name
{
get { return "StrategyName"; }
}
public override Guid ID
{
get { return new Guid("71EB0EDE-7448-4f01-9AFB-443367C854AB"); }
}
public override string Author
{
get { return "StrategyAuthor"; }
}
public override Type WealthScriptType
{
get { return typeof(WealthLab.Strategies.SampleStrategy); }
}
public override string Description
{
get { return "StrategyDescription"; }
}
public override DateTime CreationDate
{
get { return new DateTime(1990, 1, 1); }
}
public override DateTime LastModifiedDate
{
get { return new DateTime(1990, 1, 1); }
}
}
}[/CODE]
Сгенерировать GUID можно из Visual Studio (Tools -> Create GUID -> Registry Format).
Ссылка на описание отладки стратегий на WealthWiki: http://wl4.wealth-lab.com/cgi-bin/WealthLab.DLL/getpage?page=AskGlitch.htm