protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 3)
return;
// Set 1
if (CCI1[2] > CCI1[1]
&& CCI1[1] < CCI1[0]
&& CCI1[1] < -100)
{
EnterLong(3000, "long");
c =1;
SetProfitTarget("long",CalculationMode.Pips, 30);
SetStopLoss("long", CalculationMode.Pips, 30, false);
}
// Set 2
if (CCI1[2] < CCI1[1]
&& CCI1[1] > CCI1[0]
&& CCI1[1] > 100)
{
EnterShort(3000, "short");
c=1;
SetProfitTarget("short",CalculationMode.Pips, 30);
SetStopLoss("short", CalculationMode.Pips, 30, false);
}
// Set 3
if (SystemPerformance.AllTrades.Count > 1)
{
Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
if ( lastTrade.ProfitPips <0 && lastTrade.Entry.Name == "short" && c==1)
{
EnterLong(3000,"RLong");
SetTrailStop("RLong",CalculationMode.Pips, 30,false);
c--;
}
if ( lastTrade.ProfitPips <0 && lastTrade.Entry.Name== "long")
{
EnterShort(3000,"RShort");
SetTrailStop("RShort",CalculationMode.Pips, 30,false);
c--;
}
}
}
}
}
Comment