When adding indicators in PRT, the standard stochastic is a good starting point. Is the prorealcode for this standard indicator as included in PRT available?
Would like to expand on it, but need code to get started.
Markus
This is the standard formula:
//--------------------------------------------------------------------------------------
// Formula:
//
// https://en.wikipedia.org/wiki/Stochastic_oscillator
// https://www.investopedia.com/terms/s/stochasticoscillator.asp
//
DEFPARAM CalculateOnLastBars = 2000
// settings for Stochastic 10,5,3)
// Periods = 10
// Kline = 5
// Dline = 3
// AvgType = 1 //Ema
K = average[Kline,AvgType](((close - lowest[Periods](low)) / (highest[Periods](high) - lowest[Periods](low))) * 100)
D = average[Dline,AvgType](K)
RETURN K AS "%K",D AS "%D"
Perfect, thanks a lot!
It seems with Stochstic there is also a “slow” one, will this only relate to the “K” number of days to average?
Thank you for the super fast assistance!
Markus
Yes, slow and fast are determined by settings only.
is there also a chance to get the code for the standard PRT RSI indicator with a few variables to play with period and average Type?
Markus
Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
Your request will be addressed asap.
Thank you 🙂
There you go:
// RSI indicator
//
// Formula:
//
// (https://www.prorealcode.com/topic/indicatore-rsi/#post-51250)
// (https://www.investopedia.com/terms/r/rsi.asp)
//
p = 14 //periods
Ob = 70 //OverBought
Os = 100 - Ob //OverSold
//
Bullish = MAX(0, CLOSE - CLOSE[1])
Bearish = MAX(0, CLOSE[1] - CLOSE)
//
mmBullish = WILDERAVERAGE[p](Bullish)
mmBearish = WILDERAVERAGE[p](Bearish)
//
RS = mmBullish / mmBearish
myRSI = 100 - (100 / (1 + RS))
//
RETURN MyRSI AS "Rsi",Os AS "Os",Ob AS "Ob"
thank you! very helpful indeed.