if ATR is greater than ATR average taken from last 5 candles, then market considered as trending, and so Open(0)>Close(1)=buy Open(0)<Close(1)=sell.
if ATR is less than ATR average, then market considered as consolidating, and so Open(0)>Close(1)=sell Open(0)<Close(1)=buy.
If trending, then buy high & sell low, if consolidation then buy low sell high.
Exit is by trail and Take Profit.
PM me for edit or MT4 version info.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.