Working with time frames is described here: http://manual.zorro-project.com/barperiod.htm. If you want to call a function not at any bar, but only at the end of a time frame, use the frame() function.