Hello community,
I have a strange behavior of a bool variable, which value remains „true“ despite initialization with “false” for each bar run.
Even “dead certain” comparisons like “if (1 == 2) Cond2 = true;” will be set to “true” in the 14. call of following function.
Also strange: all bool flags show always the same value at the same time in the plot, although this is impossible.
Has somebody an idea why this happens? The instruction “watch("!Cond2",Cond2);” shows that the value changes, but not why.
Thanks so much for every hint!
bool check_long_signal(void)
{
// Variables
int i;
bool TmpLongSignal[5] = {false};
bool LongSignal = false;
bool QLSMALongsignal = false;
// check conditions
bool Cond1 = false;
bool Cond2 = false;
bool Cond3 = false;
bool Cond4 = false;
bool Cond5 = false;
bool Cond6 = false;
watch("!Cond2",Cond2);
counter_checklong = counter_checklong +1;
printf("\n counter_checklong: %d\n", counter_checklong);
printf("\n\nCond1 bis Cond6 DIREKT NACH INITIALISIERUNG in check_long_signal: \n");
printf("\n LongSignal: "); if (LongSignal == true) printf ("true"); else printf ("false");
printf("\n Cond1: QLSMA 2: ");
if (Cond1 == true)
{
printf ("true");
// plot("Cond1", Cond1, NEW, GREEN);
}
else
{
printf ("false");
// plot("Cond1", Cond1, LINE, RED);
}
printf("\n Cond2: Keltner: "); if (Cond2 == true) printf ("true"); else printf ("false"); printf("\n Cond3: RMI : "); if (Cond3 == true) printf ("true"); else printf ("false");
printf("\n Cond4: SAR : "); if (Cond4 == true) printf ("true"); else printf ("false");
printf("\n Cond5: Stochhastik : "); if (Cond5 == true) printf ("true"); else printf ("false");
printf("\n cond6: MACD : "); if (Cond6 == true) printf ("true"); else printf ("false");
printf("\n\n\n");
// conditions
if (QLSMALongsignal) Cond1 = true;
// if (valley(Keltner_lowerBand1)) Cond2 = true;
if (1 == 2) Cond2 = true;
// if (valley(myRmi)) Cond3 = true;
if (3 == 4) Cond3 = true;
if (valley(MySAR_02)) Cond4 = true;
if (valley(MyStochFastK)) Cond5 = true;
if (valley(MACDLine)) Cond6 = true;
if ((Cond1 == true) || (Cond2 == true) || (Cond3 == true) || (Cond4 == true) || (Cond5 == true) || (Cond6 == true))
{
LongSignal = true;
printf("\n\n\n Bin in check_long_signal NACH VERGLEICH\n");
printf("\n LongSignal in check_long_signal: "); if (LongSignal == true) printf ("true"); else printf ("false");
printf("\n Cond1: QLSMA 2: "); if (Cond1 == true) printf ("true"); else printf ("false");
printf("\n Cond2: Keltner : "); if (Cond2 == true) printf ("true"); else printf ("false");
printf("\n Cond3: RMI : "); if (Cond3 == true) printf ("true"); else printf ("false");
printf("\n Cond4: SAR : "); if (Cond4 == true) printf ("true"); else printf ("false");
printf("\n Cond5: Stochhastik : "); if (Cond5 == true) printf ("true"); else printf ("false");
printf("\n cond6: MACD : "); if (Cond6 == true) printf ("true"); else printf ("false");
printf("\n\n\n");
plot("Cond1", Cond1, NEW, RED);
plot("Cond2", Cond2, NEW, RED);
plot("Cond3", Cond3, NEW, RED);
plot("Cond4", Cond4, NEW, RED);
plot("Cond5", Cond5, NEW, RED);
plot("Cond6", Cond6, NEW, RED);
plot("LongSignal", LongSignal, NEW, BLUE);
plot("check_long_signal",Closes,NEW,CYAN);
}
else
{
LongSignal = false;
}
LongSignal = false;
printf("\n\n LongSignal vor Übergabe: \n\n"); if (LongSignal == true) printf ("true"); else printf ("false");
return (LongSignal);
}
Here us the log:
Log:
Cond1 bis Cond6 DIREKT NACH INITIALISIERUNG in check_long_signal:
LongSignal: false
Cond1: QLSMA 2: false
Cond2: Keltner : false
Cond3: RMI : false
Cond4: SAR : false
Cond5: Stochhastik : false
cond6: MACD : false
Bin in check_long_signal NACH VERGLEICH
LongSignal in check_long_signal: true
Cond1: QLSMA 2: false
Cond2: Keltner : false
Cond3: RMI : false
Cond4: SAR : false
Cond5: Stochhastik : false
cond6: MACD : true
This is how it should work.
But with the 14. call of check long signal, this happens:
[GER30::L] Skipped (outside bars 1503..2008)
Main: Long Trade entered
[1115: Thu 16-03-17 16:05] 9853.50/9861.20\9842.00/9846.20 -1.00
Bin in new trades allowed
New_Trade_ok: true
counter_checklong: 14
Cond1 bis Cond6 DIREKT NACH INITIALISIERUNG in check_long_signal:
LongSignal: true
Cond1: QLSMA 2: true
[color:#FFFF66] Cond2: Keltner: true
Cond3: RMI : true Cond4: SAR : true
Cond5: Stochhastik : true
cond6: MACD : true[/color]
Bin in check_long_signal NACH VERGLEICH
LongSignal in check_long_signal: true
Cond1: QLSMA 2: true
Cond2: Keltner: true
Cond3: RMI : true
Cond4: SAR : true
Cond5: Stochhastik : true
cond6: MACD : true
LongSignal vor Übergabe:
true