Buy when current candle above WMA and last 5 candles below WMA

So I am trying to figure how to check if the trend reversal is happening and WMA will act as support level. The formula I am trying to write is

BUY: if (current candle is green and current candle is opening above WMA and previous 3 candles have closed below WMA)

AND

SELL: if (current candle is red and current candle opened below WMA and previous 3 candles have closed above WMA)

Questions:

  1. Noob at algo trading so not sure if this formula works or not, it is something i came up with.
  2. Is there a shortcut to know what happened with last N candles instead of writing Close(-1), Close(-2) offset syntax
  3. Is there a better way to express this? In terms of technical indicator that already encapsulate this information?

The formula I wrote:

PS: couldn’t write for all 3 candles because limited by 5 conditions.

@Streak can you.

You need to backtest and see if the Entry point areas you want or not. If no, check the chart to see the pattern that might help to identify such areas.

Depends on the query. Period min/max can be used in some queries.

The query logic points towards a crossover of candles and WMA. So in short one can write Close crosses above WMA

Use the Advanced create page. no limits there.