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.
- Find all Swing highs and swing lows, in the last 300 bars.
- A swing high is a bar that is higher than the 3 previous bars and the 3 following bars.
- 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.
- These "mean" value lines form the Support/Resistance structure.
- 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.
- If price comes within 4 pips to such a line from bellow, with decelerating momentum, SELL.
- 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.