Код: Выделить всё
function Initialize()
{
StrategyName = "AA";
AddParameter("TakeProfit", 0.1, "", 1);
AddInput("Input1", Inputs.Candle, 1, true, "");
LongLimit = 1;
ShortLimit = -1;
}
function OnUpdate()
{
if (CurrentPosition() > 0)
{
CloseLongLimit(AverPrice() * (1 + 0.01 * TakeProfit));
}
if (CurrentPosition() == 0)
{
EnterLong();
}
}
а теперь вариант команд подряд:
Код: Выделить всё
function Initialize()
{
StrategyName = "AA";
AddParameter("TakeProfit", 0.1, "", 1);
AddInput("Input1", Inputs.Candle, 1, true, "RIU9=ФОРТС");
LongLimit = 1;
ShortLimit = -1;
}
function OnUpdate()
{
if (CurrentPosition() == 0)
{
EnterLong();
CloseLongLimit(AverPrice() * (1 + 0.01 * TakeProfit));
}
}
и вариант с BreakingStop() и большим, "маловероятно" исполнимым стопом:
Код: Выделить всё
function Initialize()
{
StrategyName = "AA";
AddParameter("TakeProfit", 0.1, "", 1);
AddInput("Input1", Inputs.Candle, 1, true, "RIU9=ФОРТС");
LongLimit = 1;
ShortLimit = -1;
}
function OnUpdate()
{
if (CurrentPosition() == 0)
{
EnterLong();
BreakingStop(10, TakeProfit, SignalPriceType.DeltaInPercentFromAveragePrice);
}
}