I wrote a small custom function for a common problem:
Often you want to know if a variable is changed since last tick or so.
Usually you start tricking around with myVal and myOldVal or something crappy. If it comes to a handful values you want to compare this way becomes ugly.
We need a short time memory and so I wrote this:
bool isChanged(int index, double value)
{
static double memory[];
if ((index +1) > ArraySize(memory)){
ArrayResize(memory, (index+1));
memory[index] = EMPTY_VALUE;
}
if (memory[index] != value){
memory[index] = value;
return (true);
}
return (false);
}
now you can use it like ```
isChanged(MY_INDEX, myJumpingValue)
it automagically stores and compares the value and returns true if the value is changed.
And I use constants for the indices because mql4 has no associative arrays like php -> you can not use a string as index.
To know if one of the values changed i can do something like this:
const CHANNEL_HIGH = 0;
const CHANNEL_LOW = 1;
const TRIGGER_HIGH = 2;
const TRIGGER_LOW = 3;
double hi, lo, thi, tlo;
// some code / blocks for setting the variables
if (isChanged(CHANNEL_HIGH, hi) || isChanged(CHANNEL_LOW, lo) || isChanged(TRIGGER_HIGH, thi) || isChanged(TRIGGER_LOW, tlo){
do_some_magic();
}
of course you can use the same in dreema's condition block.
leftValue Boolean true und in the adjust
&& isChanged(CHANNEL_HIGH, hi) || isChanged(CHANNEL_LOW, lo) || isChanged(TRIGGER_HIGH, thi) || isChanged(TRIGGER_LOW, tlo
Thats why I asked for the constants ;) But I understand your reasons and I will switch extern to const in my code before I compile the production version.