I could be wrong on this but try replacing:
Code:
TimeFrame = 1440;
frameSync(24);

with just:
Code:
TimeFrame = frameSync(1440);



I think as your code as is, is syncing the D1 to change frame every 24 days. This is because you have already set TimeFrame to D1.

Also, this is more flexible when setting timeframes as it is always relative to BarPeriod:
Code:
TimeFrame = x/BarPeriod

where x is whatever timeframe you want to use in minutes.

Cheers