In my strategy I have
EntryHandling = EntryHandling.UniqueEntries;
and I am submitting 2 unique entries.
I have profit target for 1 and stop loss for both.
As the strategy triggers all orders are submitted fine.
If for some reason I need to stop the strategy and need to re-enable it, only one of the stops is submitted.
Please explain why and how to get around the problem.
Some clips of my code below.
rgrs
Ioannis
-----------------------------------
protected override void OnBarUpdate()
{
if (CurrentBar < LongPeriod)
return;
if (AllowLong)
{
if (IsFlat && longMomentum[0] > 0 && longMomentum[1] <= 0 )
{
Buy();
}
}
if (IsLong) ManageLong();
if (IsFlat) stopPrice = 0;
}
private void Buy()
{
double PriceTarget = Close[0] + ATR(LongPeriod)[0] * ATRTarget;
stopPrice = Low[0] - ATR(LongPeriod)[0] * ATRTrail;
SetStopLoss("L1", CalculationMode.Price, stopPrice, false );
SetStopLoss("L2", CalculationMode.Price, stopPrice, false );
EnterLong(lots, "L1");
EnterLong(lots, "L2");
SetProfitTarget("L1", CalculationMode.Price, PriceTarget);
counter = 0;
}
private void ManageLong()
{
double ratchedval = (1 - (counter * Ratchet));
double longStopPrice = Low[0] - ATR(LongPeriod)[0] * ATRTrail * ratchedval;
if( (longStopPrice > stopPrice) || (stopPrice == 0) ) stopPrice = longStopPrice ;
SetStopLoss("L1", CalculationMode.Price, stopPrice, false);
SetStopLoss("L2", CalculationMode.Price, stopPrice, false);
Values[0][0] = stopPrice;
counter++;
}

Comment