Here are two moving averages, one based on positive candles and the other based on negative candles. If the current bar is positive, the negative MA will use its last known negative bar for the calculation. The default setting uses Heikin Ashi to smooth the candles with the trend, you can turn this off if you want in inputs.