This indicator is made to identify trends.
Schaff cycle periods (pdsCy = 10)
short periods (pdsSh = 10)
long periods (pdsLg = 21)
// Schaff Trend Cycle
MCD = WilderAverage[pdsSh] - WilderAverage[pdsLg]
ST =( MCD-LOWEST[pdsCy] (MCD) )/(HIGHEST[pdsCy] (MCD)-LOWEST[pdsCy] (MCD) )*100
STC=WilderAverage [round(pdsCy / 2)] (ST)
// automatic trigger levels
pk = STC[1] >STC AND STC[1] > STC[2]
IF pk THEN
spkval = spkval +STC[1]
spk = spk + 1
ENDIF
pkAvg =spkval / ( spk +.000001)
if pkAvg = 0 THEN
pkAvg = 100
ENDIF
str =STC[1]
IF str THEN
sstr = sstr + 1
strval = strval + STC[1]
ENDIF
trAvg=strval / (sstr +.000001)
// plot on own window (or not)
RETURN pkAvg, trAvg, STC