The following script return -1 (instead of 2) if the graph period is different from 10 minutes
It's possible that a handle of type double could cause that problem because it gets stored as NNN.999999999 and gets truncated down to NNN. It should be type int.
Thanks for your remark
I changed the handle declaration to Int instead of Double.
But it makes no difference (still returns -1) when I change to a time frame different from 10 minutes (at least until a new candle shows up)
You need to wait for indicator calculating.