TradingView
rstraat
Jan 22, 2017 1:32 PM

SMA slope 

GOLD (US$/OZ)TVC

描述

Slope function for SMA in degrees. This slope function you can use or modify for your own strategies. Feel free to change source to calculate the slope of another indicator. In this case you can see that the indicator is above the zero line indicating a positive momentum.
评论
Jaba76
Hi! Your indicator looks interesting, but I just can't quite understand it. So could you please help me a bit with it:
- Why exactly you are using "iBarsBack = 10"? Shouldn't it be more feasible to always compare to the previous SMA value, to see current angle?
- I also don't quite understand the result for this indicator. I mean, even though I can see that there is really deep slope up, maybe 45 degrees or such, the indicator still shows values such as 0.05? Wouldn't 0.05 degrees be pretty much a horizontal line??
icubedm
@jasurakk, This is simplest geometrical meaning of differential.
This is a basic triangle task. The algorithm takes 2 points (price at the current bar, and price at the bar-iBarsBack)

Here you have a 90deg triangle with 2 known sides: price1-price2 and bar-(bar-iBarsBack) = iBarsBack

Then, using atan function, you can find an angle from the horizontal axis (iBarsBack side) and hypotenuse

The local slope of the sma is very small, but if you take close price, for example, and put period of 2 bars, you will have jumping angle from ~90 to ~-90 degrees
davincitom
what is bars back mean in here
thanks
davincitom
@davincitom, ok, I think I got. it is mean 10, 50SMA?
rstraat
@davincitom, yep thats right!
CarlEverest
Dear sir, is it possible to get an alert, if the SMA slope is above 0 AND if the the price is below the SMA?

bullonwall
Would it be possible to get the slope of the Volume MA instead of Price MA using your script? thanks!
rstraat
@bullonwall, just change the line sma2sample=sma(close,iSMA) into sma2sample=vwma(close,iSMA)
andaldana
Thank you!
pmcllc
cool..
更多