Trying to create a loop to check for a condition then act if meet. The loop does not seem to count down when I use print("i=",i); to error check
// delete 1W1 high if any more recent D1 high is higher
datetime open0W1=iTime(Symbol(),PERIOD_W1,0); // find open bar of the week
int shift=iBarShift(NULL,PERIOD_D1,open0W1); // shift it to the D1 bar
for (int i=shift;i>1;i--) // create loop starting from first D1 bar of the week and count back to bar 1
if (iHigh(NULL,PERIOD_D1,i)>iHigh(NULL,PERIOD_W1,1)) // check if any D1 high is higher than W1 high
ObjectDelete(0,"1HighW1"); // action
Thanks for the reply.
Funny I realized that mistake while out walking, it's great for that.
Before though I used,
Print(" i=", i);
And it was stuck on 2 and not printing 1
I have changed this since, but can't see what difference >= would make. It's working know anyway.
for (int i=shift;i>=1;i--)