Look at this:

Bar variable: http://manual.zorro-trader.com/barperiod.htm
NumOpenLong: http://zorro-project.com/manual/en/winloss.htm

The rest is your homework.