For example:
if (//my myTakeProfit condition)
{
myTakeProfit = true; // a boolean variable I previously created called myTakeProfit that was set to false.
mySavedBar = CurrentBar; // an Int variable I previously created called mySavedBar to hold the bar number when the "Profit target" is reached.
}
later in the code:
if (myTakeProfit && CurrentBar - mySavedBar >= 10) // wait for 10 bars
{
// Reset myTakeProfit Boolean
myTakeProfit = false; // So this only executes once per condition.
}
Comment