indicator - can you tell me what is wrong with this cycle?

 

I'm a newbie and I've been trying hard to code an idea of a custom indicator that I have...

But everytime I add a cycle operation to the code, I can't get Meta to load it, it blocks, my processor speeds, and I have to shutdown Meta.


(...)
 
if (MA_fast_last > MA_medium_last && MA_medium_last > MA_slow_last)
{
if (MA_fast < MA_medium)
{
while (MA_fast < MA_medium)
{
if (Delta_medium <= 0 && Delta_slow <= 0)
{
Alert("Go short!");
Buf_0[i] = -1;
break;
}
}
 
}
 
(...)

The idea behind this piece of coding is:

Check if in the previous candle the 3 MAs were by that order;

than, check if the fast one is crossing the medium one;

if so, while it maintains itself down, keep checking if the medium and slow MAs are turning horizontal;

if so, give signal to go short, indicator turns to -1, and exit cycle.


If it's not so obvious to you, I can attach the all code... since I'm a newbie, maybe the idea isn't being correctly coded... what I know is that removing the cycle it works.

Thank you all in advance.

 
Reason: