Для улучшения результатов, скорее всего, надо добавлять фильтры для входов.
по сберу на параметрах по умолчанию протестировал на H1.
Код: Выделить всё
/**
**/
function Initialize()
{
StrategyName = "VStop";
AddParameter("Length", 20, "", 1);
AddParameter("Mult", 2, "", 1);
AddParameter("Period", 1, "", 1);
AddParameter("SL", 2, "StopLoss %", 1);
AddInput("I", Inputs.Candle, 60, true, "");
LongLimit = 1000;
ShortLimit = -1000;
AddChartIndicator("MY.VStop", new Dictionary <string, string>{{"length", "Length"},{"mult", "Mult"},{"period", "Period"},{"O", "0"},{"H", "0"},{"L", "0"},{"C", "1"}});
}
function OnUpdate()
{
// evge 22.07.2018 http://alfadirect4.ru
var VS = MY.VStop(I, Length, Mult, Period, 0, 0, 0, 1);
var VSUp = VS["Up"];
var VSDn = VS["Dn"];
if (VSUp[0] > 0 && VSDn[1] > 0)
{
EnterLong();
StopLoss(SL, SignalPriceType.DeltaInPercentFromAveragePrice);
}
if (VSDn[0] > 0 && VSUp[1] > 0)
{
EnterShort();
StopLoss(SL, SignalPriceType.DeltaInPercentFromAveragePrice);
}
}