Would this be easy to program with array-only code?

Hi

Here is the Price Action logic for a simple trading. I would like to know if it would be easy to program this with efficient array-only code.

I could code this, but with extensive use of loops and matrixes.

  1. Find all Swing highs and swing lows, in the last 300 bars.
  2. A swing high is a bar that is higher than the 3 previous bars and the 3 following bars.
  3. Group all swing high/lows that are less than 5 pips away, ie do not allow lines with less than 5 pips distance. Take the mean value of each group.
  4. These "mean" value lines form the Support/Resistance structure.
  5. From those lines, remove (invalidate) the ones that were breached/crossed with very litle force, but do allow lines that were cleanly crossed with great strength and long candles.
  6. If price comes within 4 pips to such a line from bellow, with decelerating momentum, SELL.
  7. If price comes within 4 pips to such a line from above, with decelerating momentum, BUY.

By "decelerating momentum" I mean what is easy to spot visually on a chart, price is rising fast and then slowly flatens, as it approaches the resistance.

If it is possible, then any help/pointers would be appreciated.

The post really belongs to other thread started by the same poster. Please do not create duplicate threads if the matter discussed is continuation of the other post.

20 posts were merged into an existing topic: How do I backtest a script that only sets signals on the last bar?