Hi coders, seeking for your help. Sorry, the subject title above is wrong (cannot be amended), but it should be "Output = 0 Without a Value"
I have two loops to calculate.
When come to signal stage, I want to get the ratio by a division, so that I can use this ratio for other purposes, let's say I want to have 90% of red bars out of total bars to get a signal :-
Now, the output message appeared to be ZERO, why ? Any solution ?
Is it due to problem of both cnBars and cnRedBars are integer values, therefore the MT4 terminal cannot recognise a int / int >= 0.9, ended up with a Zero ? Any solution so that a ratio value can be alerted ? Thanks
I have two loops to calculate.
Inserted Code
int cnBars=0; for(int i=AA; i>=BB; i--) {
double Hi=iHigh(symbol,5,i), Lo=iLow(symbol,5,i);
if(Hi>=Lo) cnBars++;
}
// to count total number of bars for a length from shift AA to BB backward
// No worry, I do understand that AA-BB+1 would be the total number of
// bars, but this loop is just for illustration only
int cnRedBars=0; for(int i=AA; i>=BB; i--) {
double Op=iOpen(symbol,5,i), Cs=iClose(symbol,5,i);
if(Op>=Cs) cnRedBars++;
} // to count number of Red bars for a length from shift AA to BB backward When come to signal stage, I want to get the ratio by a division, so that I can use this ratio for other purposes, let's say I want to have 90% of red bars out of total bars to get a signal :-
Inserted Code
cnRedBars / cnBars >= 0.9 // (signal stage)
{Alert(symbol+" Red Bars Ratio : "+DoubleToStr(cnRedBars/cnBars,3));} Now, the output message appeared to be ZERO, why ? Any solution ?
Is it due to problem of both cnBars and cnRedBars are integer values, therefore the MT4 terminal cannot recognise a int / int >= 0.9, ended up with a Zero ? Any solution so that a ratio value can be alerted ? Thanks