Algorithm help: open 1 order only on the 1st break.

 

I have not been coding for 8 years and I need professional help. This is my 1st EA

This picture will easily explain my needs

My purpose is to only open 1 position on the first candle that breaks the Bollinger band. Lets say on that 1st candle, the position is open and then closed as the profit price is reached (now the total order is 0).

When the 4th candle breaks the Bollinger band again, I don’t want to open position as it is way too far from the breaking point.

Another position will be open after the trend ends and the band is narrowing then breaks the band.

--------------------------------

In start(), I do this:

While (true)

{

if (total order < 1)

if (price breaks and new candle opens above upper Bollinger band)

open one position

Return 0;

}

----------------------------------

Could anyone please point me in the right direction as to how I define this logically, what functions and methods that I could & should use.

Awaiting eagerly…thanks guys!