This indicator is a simple setup of Three Bar Reversal. Logic of the code is as below.
Rules :
Long Setup
Bar 1 closes down
Low of Bar 2 is below the low of Bar 1 (and Bar 3)
Bar 3 closes above the high of both Bar 1 and Bar 2
Buy at the close of Bar 3
Short Setup
Bar 1 closes up
High of Bar 2 is above the high of Bar 1 (and Bar 3)
Bar 3 closes below the low of both Bar 1 and Bar 2
Sell at the close of Bar 3