I do not see where your script skips bars or skips trading outside market hours. You can find examples of skipping bars in the manual. The simplest way is just checking the time, f.i. if(between(ltod(0),930,1530)) enterLong();.