The SuperTrend indicator is used. This indicator is necessary for definition of a trend.
If now a uptrend and a candle red - to open a long position (and to close short)
If now a downtrend and a candle green - to open a short position (and to close long)