Hi. Just a quick look...

You defining M15,H1,H4,D1 with the help of BarPeriod. The manual says:

BarPeriod
The duration of one bar in minutes (default = 60). This is the smallest possible time frame in the script. If not explicitely set up, it is determined by the [Period] slider. The run function is called at the end of every bar.


So before the first run you set D1 = (1440/60) = 24 ??
In the run function you the nset BarPeriod to 15 ...

I think this is the first prob you have.