I am struggling to fix a problem in my code.
The idea is to save a close value of a bar after a condition is met. I have this:
{ bool firstCondition = false; double barClosed1 = 0; // this is the close value of the bar when the first condition is met. double barClosed1 = 0; // this is the close value of the bar in the second piece of my code. if(Close[0] < EMA(Close, 5)) { firstCondition = true; barClosed1 = Close[0]; } }
I have this code:
if(firstCondition && Close[0] > barClosed1) { barClosed2 = Close[0]; print(barClosed2); firstCondition = false barClosed1 = 0; barClosed2 = 0; }
The first condition is set to false at the end of the second code to be used again.
Also barClosed1 and barClosed2 are set to zero.
Could someone please points out where I am mistaking?
Best regards,
Comment