I have a strategy which uses one condition to enter a trade and one to exit.
However when the trade exits, occasionally the entry condition is triggered in the same bar and immediately enters the trade again. I think a solution would be for the strategy to wait 1 bar after the exit, so I have been trying to use the‘BarsSinceExit’ command.
It says in your guide that a value of -1 is returned if a previous exits does not exist, so this is what I have done……
When the strategy starts and there are no previous trades I have Conditions 1 & 2 (below). After an exit has been executed, Conditions 3 & 4 would take the place of 1 & 2.
Can you point me in the right direction, as this does not work….
CalculateOnBarClose = false
Protected override void OnBarUpdate()
// Condition set 1 When a previous exit does not exist
If BarsSinceExit () > -1
{
EnterLong(“”,””);
}
// Condition set 2 When a previous exit does not exist
If BarsSinceExit () > -1
{
EnterShort(“”,””);
}
//Condition set 3 When an exit does exist (superceeds 1)
If BarsSinceExit () > 1
{
EnterLong(“”,””);
}
//Condition set 4 When an exit does exist (superceeds 2)
If BarsSinceExit () > 1
{
EnterShort(“”,””);
}
Thanks in advance...
Comment