// Make 'log_long' item data
System.Collections.Generic.IList<bool> log_long;
try
{
int count = nRange.Count;
bool[] list = new bool[count];
if ((Source.IsLastBarUsed == false))
{
count--;
}
for (int bar = 1; (bar < count); bar++)
{
list[bar] = "условие";
}
log_long = list;
}
catch (System.ArgumentOutOfRangeException)
{
throw new TSLab.Script.ScriptException("Ошибка при вычислении блока \'log_long\'. Индекс за пределам диапазона.");
}
// Make 'log_short' item data
System.Collections.Generic.IList<bool> log_short;
try
{
int count = nRange.Count;
bool[] list = new bool[count];
if ((source.IsLastBarUsed == false))
{
count--;
}
for (int bar = 1; (bar < count); bar++)
{
list[bar] = "условие";
}
log_short = list;
}
catch (System.ArgumentOutOfRangeException)
{
throw new TSLab.Script.ScriptException("Ошибка при вычислении блока \'log_short\'. Индекс за пределам диапазона.");
}
.........................
//Декомпрессия индикаторов
.........................
//Проход по барам
if ((source.IsLastBarUsed == false))
{
barsCount--;
}
for (int bar = ctx.TradeFromBar; bar < barsCount; bar++)
{
LongPos = source.Positions.GetLastActiveForSignal("LN");
ShortPos = source.Positions.GetLastActiveForSignal("SN");
// Торговля
if (LongPos == null)
{
if (log_long[bar])
{
source.Positions.BuyAtMarket(bar + 1, 1, "LN");
}
}
else
{
if ((LongPos.EntryBarNum <= bar))
{
if (log_short[bar])
{
LongPos.CloseAtMarket(bar + 1, "LX");
}
}
}
if (ShortPos == null)
{
if (log_short[bar])
{
source.Positions.SellAtMarket(bar + 1, 1, "SN");
}
}
else
{
if ((ShortPos.EntryBarNum <= bar))
{
if (log_long[bar])
{
ShortPos.CloseAtMarket(bar + 1, "SX");
}
}
}
}