Could anybody confirm that this code would do the job?
Code: Select all
protected override void Create()
{
_buyOrder = OrderCreator.MarketNextBar(
new SOrderParameters(Contracts.Default, "Buy", EOrderAction.Buy));
_shortOrder = OrderCreator.MarketNextBar(
new SOrderParameters(Contracts.Default, "Short", EOrderAction.SellShort));
}
protected override void CalcBar()
{
// some code
if (trendDirection)
{
_buyOrder.Send(1);
double currentPosition = Bars.Close[0];
GenerateStopLoss(currentPosition - _sl);
GenerateProfitTarget(currentPosition + _tp);
}
else
{
_shortOrder.Send(1);
double currentPosition = Bars.Close[0];
GenerateStopLoss(currentPosition + _sl);
GenerateProfitTarget(currentPosition - _tp);
}
}