I'd like to find a work around for doing Boolean operations on integers.
When a short-term and long-term SMA are rising, I'm doing something. However sometimes when the longer-term SMA turns to rising, the short term SMA is in the middle of rising.
I don't want signals where the short-term SMA is in the middle of a rise when the longterm SMA turns to rise. I only want full signals where the short-term SMA turns to rise while the longterm SMA is rising also.
So I'm creating logic that:
- checks if the longterm SMA has turned to rise & the shortterm SMA is NOT rising at the turn:
- sets a value to 1
For example:
if (SMA(200)[0] > SMA(200)[1] && SMA(200)[1] < SMA(200)[2] && SMA(14)[0] < SMA(14)[1])
{
value = 1;
}
if (value = 1 && SMA(14)[0] > SMA(14)[1] && SMA(14)[1] < SMA(14)[2])
{
do something;
}
Value stays at 1 until longterm SMA changes direction, then recalculate.
----
Trouble is I can't use "value = 1" with "&&" Boolean operators. With some languages just changing the "&&" to "&" works, but this didn't happen either.
Is there any way I can work around using Boolean logic with integers?
Thanks,
Jeremy
Comment