"// This source code is subject to the terms of the Mozilla Public License 2.0 at…
- User
"// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © arijeetsat
//@version=2 //Deviation Scaled Moving Average by John Ehlers study("Speculation Ratio Territory ",shorttitle = "SRT") Period =input(124) PI = 3.1415926 a1 = exp( -1.414 * PI / ( 0.5 * Period ) ) b1 = 2 * a1 * cos( 1.414 * PI / ( 0.5 * Period ) ) c2 = b1 c3 = -a1 * a1 c1 = 1 - c2 - c3
Zeros = close - close[2] // SuperSmoother Filter Filt = c1*(Zeros + Zeros[1]) / 2 + c2nz(Filt[1]) + c3nz(Filt[2]) // Compute Standard Deviation RM = sum( Filt * Filt, Period ) RMS = sqrt( RM / Period ) // Rescale Filt in terms of Standard Deviations ScaledFilt = Filt / RMS alpha1 = abs( ScaledFilt ) * 5 / Period DSMA = alpha1 * close + (1 - alpha1) * nz(DSMA[1]) //plot( DSMA, color=blue )
// 2 moving average
Period2 =input(124) a12 = exp( -1.414 * PI / ( 0.5 * Period2 ) ) b12 = 2 * a12 * cos( 1.414 * PI / ( 0.5 * Period2 ) ) c22 = b12 c32 = -a12 * a12 c12 = 1 - c22 - c32
//Zeros = close - close[2] // SuperSmoother Filter Filt2 = c12*(Zeros + Zeros[1]) / 2 + c22nz(Filt2[1]) + c32nz(Filt2[2]) // Compute Standard Deviation RM2 = sum( Filt2 * Filt2, Period2 ) RMS2 = sqrt( RM2 / Period2 ) // Rescale Filt in terms of Standard Deviations ScaledFilt2 = Filt2 / RMS2 alpha12 = abs( ScaledFilt2 ) * 5 / Period2 DSMA2 = alpha12 * close + (1 - alpha12) * nz(DSMA2[1]) //plot( DSMA2, color=red )
SRT = close / DSMA line1 = 0.55 line2 = 0.85 line3 = 1.25 line4 = 1.55 p1 = plot(line1, color = green) p2 = plot(line2, color = orange) p3 = plot(line3, color = red) p4 = plot(line4, color = gray) fill(p1, p2, color = #0af54d ) fill(p2, p3, color = blue) fill(p3, p4 ,color = red)
plot( SRT, color=black) "
study this script
- Assistant
- User
how srt is calculated
- Assistant
- User
ittta complex?
- Assistant
Yes, the calculation of the Speculation Ratio Territory (SRT) in this script is indeed complex. It involves several advanced concepts, including adaptive moving averages, smoothing filters, and volatility scaling. Let's break down why it seems complex:
-
Advanced Filtering Techniques:
- The script uses a "SuperSmoother Filter," which is more sophisticated than basic moving averages like the Simple Moving Average (SMA) or Exponential Moving Average (EMA). This type of filtering reduces the noise more effectively and can adapt to market conditions more dynamically.
-
- User
i wan to convert it into google app scripr any chance?
- Assistant