If you still have difficulty, post your script.

The example you gave will always open a Long position whenever there is none open.


Thanks so much,

OptimusPrime