I need an indicator that draws two lines (or dots) on the chart, one above and one under the last price and moving average crossing.
- usual Moving average parameters(Period, Method, Apply to)
- numbers of candles we analize backwards (PARAM1)
- numbers of maximum distances to average (PARAM2)
- color for 2 lines
The distance of the lines from the last closed calndle will be calculated as follows:
1.) go back PARAM1 candles and calculate all maximal price distances for long and short (closing price above and under the moving average)
from the moving average. A distance is defined as the maximal candle closing distance between the price and moving average between two price
and moving average crosses. Please take a look at the attached prictures. The blue triangles show the price and moving average crossings.
The white lines are the maximal distances between those crossings.
2.) Calcualte the average of the highest distances given by PARAM2
3.) draw a line above and one under the last price and moving average crossing for each following candle until the price and moving average
4.) calculate and draw again, if the price crosses the moving average
Step 1.) we go back 1000(PARAM1) candles and analize the maximul distances and we get this distances:
- 10 pips
- 20 pips
- 30 pips
- 40 pips
- 50 pips
2.) if PARAM2 = 3, we take the 3 highest distance and build the simple average : (30 + 40 + 50) / 3 = 40
3.) Draw the two lines ( can be also dots like Parabolic SAR)