I want this variable to hold information like a switch

 

I'm not sure how much sense that makes. I was under the impression that a boolean variable will hold its value until it is changed but that it wouldn't change automatically. Is this true? If when a specific criteria is met and a bool becomes TRUE, does it remain true until I tell it to become FALSE or does it automatically become FALSE as soon as the criteria is no longer met? 

Just to save on space I didn't write everything. I think everyone can tell that macdMain is the value of the MACD Line and macdSignal is the value of the MACD Signal Line. This is how I wrote it but I'm not getting the result I want. 

The goal is that once the histogram reaches is above 0.001 than the condition is met to create a signal. However, the signal will likely come on one of the following candles when other criteria is met. Once the MACD line crosses over the signal line and is lower than the signal line again, then the conditions can no longer be met so I want this bool to become FALSE again until the histogram level goes above that minimum again. I also tried to make the bool a static variable but still didn't seem to work. Not sure what I'm doing wrong.

Thanks in advance for any help.

bool bHistogramLevelHit;

if( (macdMain - macdSignal) > 0.001 ){

   bHistogramLevelHit = TRUE;

}

if( macdMain < macdSignal ){

   bHistogramLevelHit = FALSE;

}
 
dasilvja: . I was under the impression that a boolean variable will hold its value until it is changed but that it wouldn't change automatically. Is this true?

That is what all variables of any type does, until it goes out of scope (as in your example code).  If you want it to remember between calls you must make it static (or globally declared).

Reason: