Например, можно будет задать кол-во баров на повышение и\или понижении.
Пример с возможностью задать кол-во баров повышения \ понижения по индикатору HeikenAshi:
Код: Выделить всё
/**
**/
function Initialize()
{
StrategyName = "HA";
AddParameter("Bars", 5, "", 1);
AddInput("Input1", Inputs.Candle, 1, true, "");
LongLimit = 5;
ShortLimit = -5;
AddChartIndicator("MY.HeikenAshi", new Dictionary <string, double>{});
}
function OnUpdate()
{
var H = MY.HeikenAshi(Input1);
var HO = H["Open"];
var HC = H["Close"];
bool isLong = true, isShort = true;
for (int x = 0; x <= Bars; x++)
{
if (HO[x] > HC[x]) isLong = false;
if (HO[x] < HC[x]) isShort = false;
if (!isLong && !isShort) break;
}
if ( isLong )
{
EnterLong();
}
if ( isShort )
{
EnterShort();
}
}