How do I use flags in my Expert Advisor?

 

I am trying to trade the bollinger bounce with my EA.

The BUY logic occurs when the price hits the lower bb (bollinger band).

The aim is to EXIT Buy when the price crosses above the upper bb.

But if the price continues to cut below the lower bb for two bearish candles, then Buy is Exited as a stop loss.

No more Buy Order Should be opened until the Price has Crossed back above the Middle BB.

FlagLowerBB is set to False initially.

When A Buy Order after price crosses below the Lower BB, The FlagLowerBB is set to True so that no further trades will be opened.

When the price crosses above the middle BB, FlagLowerBB is set to False again so that Buy Orders can be opened when the price goes below the Lower BB again.

This is the reason why I need a flag. How do I set such a flag properly?

 
Just use bool variables and call them flags. https://book.mql4.com/basics/types#11