W1 bars start on Sundays. For D1 there's no Sunday so you get the bar of the previous week's Friday. So the loop should start with shift-1 and that's it, rest looks ok.
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--)
And added,
shift=shift-1;
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi
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