crasher

5x Period Cycle Seasonality

1730 views
231
1730 5
Shows the average from the last 5 periods for close price cycle. For example to see the annual seasonality of a stock for the last 5 years use on daily chart with the default setting of 252, the number of trading days in a year, approximately.
Remove from Favorite Scripts Add to Favorite Scripts
study("5 Period Cycle Seasonality")

Period = input(title="Period Cycle", type=integer , defval=252)

LastYear = close[Period]
TwoYearsAgo = close [2 * Period]
ThreeYearsAgo = close [3 * Period]
FourYearsAgo = close [4 *Period]
FiveYearsAgo = close [5 * Period]

Offset = Period
LastYearE = close[Period - Offset]
TwoYearsAgoE = close [2 * Period - Offset]
ThreeYearsAgoE = close [3 * Period - Offset]
FourYearsAgoE = close [4 *Period - Offset]
FiveYearsAgoE = close [5 * Period - Offset]

plot((LastYearE + TwoYearsAgoE + ThreeYearsAgoE + FourYearsAgoE + FiveYearsAgoE) / 5, color = #00ff00, linewidth = 5, offset =  Offset)

plot((LastYear + TwoYearsAgo + ThreeYearsAgo + FourYearsAgo + FiveYearsAgo) / 5, color = #ff0000, linewidth = 5)

Related Ideas

Hi, You are really Great .
Reply
I know what seasonality is, but I don't really get this indicator. What does it do exactly?
+2 Reply
Great idea!

I've experimented with it some bit and find the following also interesting... It plots the average %-change instead of the average nominal change.

==

study("5 Period Cycle Seasonality")

Period = input(title="Period Cycle", type=integer , defval=252)

LastYear = (close-close)/close
TwoYearsAgo = (close -close)/close
ThreeYearsAgo = (close -close)/close
FourYearsAgo = (close -close)/close
FiveYearsAgo = (close -close)/close

Offset = Period
LastYearE = (close-close )/close
TwoYearsAgoE = (close -close )/close
ThreeYearsAgoE = (close -close )/close
FourYearsAgoE = (close -close )/close
FiveYearsAgoE = (close -close )/close

plot((LastYearE + TwoYearsAgoE + ThreeYearsAgoE + FourYearsAgoE + FiveYearsAgoE) / 5, color = #00ff00, linewidth = 2, offset = Offset)
plot((LastYear + TwoYearsAgo + ThreeYearsAgo + FourYearsAgo + FiveYearsAgo) / 5, color = #ff0000, linewidth = 2)
hline(0)

==
Reply
accidentje accidentje
Seems TV can't handle code in the 'comment' field. I refer to
Reply
Excellent, thanks for sharing!
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar Shows How It Works Chart Features Pricing House Rules Moderators Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Help Center Refer a friend Feature Request Blog & News FAQ Wiki Twitter
Profile Profile Settings Account and Billing Refer a friend My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out