What about using the tick() function? Something like:
int thisBar, ticks;
funtion tick() {
if (Bar == thisBar) {
ticks += 1;
else {
thisBar = Bar; //increment thisBar to start counting a new bar
ticks = 0; //start counting ticks from zero again
}
}
I haven't run this, but it should work.
Re: open number of contracts - not sure how you get this unless you are the broker.