The current code is.
if (AverageDownSet && !AverageDownExecuted)
{
Print("Current Ask" + GetCurrentAsk());
Print("Current Bid" + GetCurrentBid());
Print("Supplied Price" + AverageDownTP);
if (Position.MarketPosition == MarketPosition.Short)
{
SetProfitTarget("Short", CalculationMode.Price, AverageDownTP);
}
if (Position.MarketPosition == MarketPosition.Long)
{
SetProfitTarget("Long", CalculationMode.Price, AverageDownTP);
}
AverageDownExecuted = true;
}
ShortEntryPrice = Closes[1][0] - TickSize;
SetStopLoss(CalculationMode.Ticks, (StopLossValueShort));
SetProfitTarget("Short", CalculationMode.Ticks, 99999);
// Enter Short
if (GetCurrentBid() > ShortEntryPrice)
{
EnterShortStopMarket(0, false, Qty, ShortEntryPrice, "Short");
}
if (Position.MarketPosition == MarketPosition.Short)
{
if (Closes[0][0] > ShortEntryPrice && AllowAverageDownShort && !AverageDownSet)
{
AverageDownEntry = ###
AverageDownSL = ###
AverageDownTP = ###
SetStopLoss("Average Down Short", CalculationMode.Ticks, AverageDownSL, false);
SetProfitTarget("Average Down Short", CalculationMode.Price, AverageDownTP);
EnterShortLimit(0, false, ReentryQty, AverageDownEntry, "Average Down Short");
}
}
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
/* We advise monitoring OnExecution() to trigger submission of stop/target orders instead of OnOrderUpdate() since OnExecution() is called after OnOrderUpdate()
which ensures your strategy has received the execution which is used for internal signal tracking.
This first if-statement is in place to deal only with the long entry. */
if (execution.Order.Name == "Average Down Long" || execution.Order.Name == "Average Down Short")
{
AverageDownSet = true;
}
}

Comment