 NinjaTrader 7 Indicators - True Slope Indicator V1  Categories Show Search Help

 NinjaTrader 7 Indicators Indicators in this section are compatible with NinjaTrader 7

Entries
True Slope Indicator V1 THERE IS A NEW VERSION OF THIS INDICATOR. FIND IT AT:

At various times, I have wanted an indicator that showed the slope of a line between two price points on a chart. I looked here on the forum for one and found a number of people discussing it, generally attempting to measure the slope of a line they'd drawn on the chart, and realizing that, if the chart is resized in any way, the slope is changed, blowing its usability.

I finally looked at the question independent of the chart. Treating the problem as that of measuring the leftmost angle of a right triangle, with the hypotenuse formed by the price at the starting point and the price at the end point and the right angle at the lower right, I finally found a usage for the trigonometry classes I'd had.

If you know the length of two sides of a right triangle, you can calculate the angles using the inversions of the sine, cosine and tangent functions, the arcsin, the arccos and the arctangent.

Taking the difference in price between the starting bar and the ending bar, converted to ticks, as the height of the side opposite the angle and the number of bars as the length of the side parallel to the bottom of the chart, the leftmost angle can be calculated and it will stay the same regardless how the chart is resized. This gives the 'real' angle, or slope, of a line drawn from the price on the starting bar to a price on the ending bar. Fortunately, the C# programming language contains the arctan function, Atan(), so it was possible to build the math without my brain exploding.

I wrote a NinjaTrader indicator that allows you to choose whether to start on Open, Close, High, Median or Low, to choose whether to end on Open, Close, High, Median or Low and the period, or number of bars, you want to measure. I have uploaded the .cs file, zipped. Just import it, as usual. All the math is contained within the indicator.

No line is drawn on the chart (since it calculates for every bar, you'd potentially have a bazillion confusing lines). Instead a new panel is created with the angle at each bar plotted, between +90 and -90, which would be the angle if you measured price change on one bar.

The usability of this indicator is not as immediately obvious as I expected it to be. However, you can see that, where the plot makes a kind of 'plateau' or trough, price is continuing steeply up or down. With a long period, areas that are usually called 'chop' can be seen, as the angle maintains a value closer to zero.

This is not a lagging indicator, regardless how long the period is. Price movement on the current bar is immediately reflected in the angle. Relatively short periods can be used, for example, in automated trading to help guard against sudden unfavorable price spikes, an intra-day nemesis.

I have not tested moving averages of the angle, but those may also be useful, though will add a lag, of course.
(11/25/15) I have found myself using a Linear Regression Channel of the angle indicator and comparing to an LRC of price.)

I may also make an indicator that averages high-to-high, low-to-low, median-to-median and high-to-low angles in an attempt to emulate what the human brain does when we look at a chart. We see all this detailed activity, but the brain sort of fuzzes the image allowing us to immediately see, price going up, price going down, price going nowhere. Seeing the forest, rather than the trees.

If it seems to do the trick, I will post that, as well.
(11/25/15) After further exploration, I realized that the Linear Regression Channel indicator that comes with NinjaTrader does this already, and better than I could.

I hope those of you looking for an angle/slope indicator will find this of some use.

(Double-checked math. It is correct and you can use it with confidence. Understand that the 2 period minimum actually goes BACK 2 bars, so this version minimally measures 3 bars, including bar 0. 11/19/15) 