This will be an EA in the sense that it will signal (visual and audible) when a market is close to an SLMA and then has crossed it. This project module will not include automated trading but it is planned for the future. SLMA is the swing length moving average. This is a moving average of period recent cycle high to cycle low or low to high.
Dot or other visible mark on chart above/below current bar indicating current SLMA value. Continuously drawn MA is not necessary or desired. It would be good though for each chart screen drawn that the marker show where there was bar convergence.
SLMA - swing length moving average; a moving average of period length from prior extreme high to extreme low
First thing, code needs to identify a significant high or low paired with a subsequent low or high. For example, from a high to a subsequent low that are considered paired, the high must have at least as many bars before it that have a high lower than that high's high as there are bars with lower highs down to subsequent bar with the lowest low. Also, for this exercise, let's say no fewer than 5 bars from low to high/high to low bar, inclusive. These constraints can be adjusted in future versions of this EA using user inputs but for now can just be adjusted in the code annually as needed.
Stipulation - source code provided, fully commented in simple terms