I have plotted the '20 day moving average' of the 'On Balance Volume' on my chart and am trying to write a go-long or go-short strategy for backtesting when the moving average (of the obv) line crosses over the 'On Balance Volume'.

In other words

IF the (20 day Moving average of OBV) is greater than the OBV then go LONG and

IF the (20 Day Moving average of OBV) is less than the OBV then go SHORT.

How do I write this code? Any help will be much appreciated. Thanks.

In other words

IF the (20 day Moving average of OBV) is greater than the OBV then go LONG and

IF the (20 Day Moving average of OBV) is less than the OBV then go SHORT.

How do I write this code? Any help will be much appreciated. Thanks.

## Comment