Коллеги, добрый день!
Прошу подсказать где ошибка.
Есть кусок кода, в котором открывается позиция лонг, а далее ставится лимитный ордер на выход. При выполнении функции ExitLongLimit соответствующий объект iOrder остается в значении null. Также при вызове свойства AvgFillPrice присвоенного ранее объекта iOrder всегда получается 0.
public class SKS001v1 : Strategy
{
#region Variables
// Wizard generated variables
private double sL = 100; // Default setting for SL
private int contracts = 2; // Default setting for Contracts
private IOrder entryOrder = null; //рыночный ордер
private IOrder entryOrdersL = null; //ордер стоп-лос
// User defined variables (add any user defined variables below)
double oppos_price = 0; // цена открытия позиции
double stlos_price = 0; // цена стоп-лоса
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
Add(SMA(N));
SetProfitTarget("", CalculationMode.Ticks, TP);
SetStopLoss("", CalculationMode.Ticks, SL, false);
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
entryOrder = EnterLong(contracts); //значение entryOrder присваивается
oppos_price = entryOrder.AvgFillPrice; // но AvgFillPrice дает почему-то всегда 0 ???
stlos_price = oppos_price - sL;
entryOrdersL = ExitLongLimit(contracts,stlos_price); // значение entryOrdersL остается null ???
}
}
Прошу подсказать где ошибка.
Есть кусок кода, в котором открывается позиция лонг, а далее ставится лимитный ордер на выход. При выполнении функции ExitLongLimit соответствующий объект iOrder остается в значении null. Также при вызове свойства AvgFillPrice присвоенного ранее объекта iOrder всегда получается 0.
public class SKS001v1 : Strategy
{
#region Variables
// Wizard generated variables
private double sL = 100; // Default setting for SL
private int contracts = 2; // Default setting for Contracts
private IOrder entryOrder = null; //рыночный ордер
private IOrder entryOrdersL = null; //ордер стоп-лос
// User defined variables (add any user defined variables below)
double oppos_price = 0; // цена открытия позиции
double stlos_price = 0; // цена стоп-лоса
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
Add(SMA(N));
SetProfitTarget("", CalculationMode.Ticks, TP);
SetStopLoss("", CalculationMode.Ticks, SL, false);
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
entryOrder = EnterLong(contracts); //значение entryOrder присваивается
oppos_price = entryOrder.AvgFillPrice; // но AvgFillPrice дает почему-то всегда 0 ???
stlos_price = oppos_price - sL;
entryOrdersL = ExitLongLimit(contracts,stlos_price); // значение entryOrdersL остается null ???
}
}