The Labels only give the value of the close on the last Candle plotted! That is the starting point! It doesn't give out the value of the projection 50 bars out
mod note:
Think of seasonal data like a weather forecast for the market.
Looking at the past five years gives a rough road map of how prices tend to move during certain times.
Keep in mind that past performance is not an indicator of future returns, given each year has unique drivers and economic circumstances.
However, the market has shown itself to be cyclical where certain parts of the year usually heats up or cools off.
Hanging this indictor in the expansion area for a few bars provides a heads-up as to what has occurred in past years; so traders can analysize if those circumstances exist in the current period.
That way, trades can be timed better, risk can be managed smarter, and entries/exits can line up with those seasonal patterns.
Just remember—it’s only one tool in the kit. Market surprises can still flip the script, so pairing it with other analysis is key.
Here is the thinkscript to show the future price projection based on seasonality price movement in the last five years.
This is not ChatGPT created version. I took few days to figure out this logic.
Feel free to modify or improve as per the need.
Rich (BB code):
#--------------------------------------------------------#
# Project the future price for next fifty bars based on
# seasonality price action in the last five years.
#--------------------------------------------------------#
declare upper;
input price = close;
input shift_daily = 252;
input shift_weekly = 52;
input shift_monthly = 12;
input shift_default = 252;
def shift = if GetAggregationPeriod() == AggregationPeriod.DAY then shift_daily
else if GetAggregationPeriod() == AggregationPeriod.WEEK then shift_weekly
else if GetAggregationPeriod() == AggregationPeriod.MONTH then shift_monthly
else shift_default;
# Bar number starts from 1 for left most bar shown on chart and ends at the
# right most bar positon (can be on extended area) on the displayed chart.
def bn = barnumber();
# Last/latest bar number which is for the current price.
def lastbn = HighestAll(If(IsNaN(price), 0, bn));
# Bar number for the bar position on the righ most section of the chart.
# If chart expansion to the right is enabled, then it is for the future bar
# appearing at that position.
def endbn = highestall(bn);
# expansion area, bars after last bar to right edge of chart
def expan_bars = (endbn - lastbn );
def expan_area = if (bn >= lastbn and bn <= endbn) then 1 else 0;
# Latest price of the underlying
def lastcls = if bn < lastbn then Double.NaN else if bn == lastbn then price else lastcls[1];
# Space available to print extended/future bars
def expan_bar_num = bn - lastbn;
def expan_bar_num_int = if expan_bar_num >= 0 then expan_bar_num else Double.NaN;
# Get the percentage increment in the last five years.
# Project the future price based on the average of past performance.
def shift_1 = shift * 1;
def shift_2 = shift * 2;
def shift_3 = shift * 3;
def shift_4 = shift * 4;
def shift_5 = shift * 5;
# Unable to get past price based on expan_bar_num_int (e.g. close[expan_bar_num_int]
# as expan_bar_num is of series data type and the thinkscript interpreter expects
# the offset to be a constant value.
# Here is a crude way to get around that problem.
# Get the percentage change and add it to the current price to project.
def change_shift_1 = if !IsNaN(expan_bar_num_int) then
if (expan_bar_num_int == 0) then price[shift_1]/price[shift_1 - 0] - 1.0 else if (expan_bar_num_int == 1) then price[shift_1]/price[shift_1 - 1] - 1.0
else if (expan_bar_num_int == 2) then price[shift_1]/price[shift_1 - 2] - 1.0 else if (expan_bar_num_int == 3) then price[shift_1]/price[shift_1 - 3] - 1.0
else if (expan_bar_num_int == 4) then price[shift_1]/price[shift_1 - 4] - 1.0 else if (expan_bar_num_int == 5) then price[shift_1]/price[shift_1 - 5] - 1.0
else if (expan_bar_num_int == 6) then price[shift_1]/price[shift_1 - 6] - 1.0 else if (expan_bar_num_int == 7) then price[shift_1]/price[shift_1 - 7] - 1.0
else if (expan_bar_num_int == 8) then price[shift_1]/price[shift_1 - 8] - 1.0 else if (expan_bar_num_int == 9) then price[shift_1]/price[shift_1 - 9] - 1.0
else if (expan_bar_num_int == 10) then price[shift_1]/price[shift_1 - 10] - 1.0 else if (expan_bar_num_int == 11) then price[shift_1]/price[shift_1 - 11] - 1.0
else if (expan_bar_num_int == 12) then price[shift_1]/price[shift_1 - 12] - 1.0 else if (expan_bar_num_int == 13) then price[shift_1]/price[shift_1 - 13] - 1.0
else if (expan_bar_num_int == 14) then price[shift_1]/price[shift_1 - 14] - 1.0 else if (expan_bar_num_int == 15) then price[shift_1]/price[shift_1 - 15] - 1.0
else if (expan_bar_num_int == 16) then price[shift_1]/price[shift_1 - 16] - 1.0 else if (expan_bar_num_int == 17) then price[shift_1]/price[shift_1 - 17] - 1.0
else if (expan_bar_num_int == 18) then price[shift_1]/price[shift_1 - 18] - 1.0 else if (expan_bar_num_int == 19) then price[shift_1]/price[shift_1 - 19] - 1.0
else if (expan_bar_num_int == 20) then price[shift_1]/price[shift_1 - 20] - 1.0 else if (expan_bar_num_int == 21) then price[shift_1]/price[shift_1 - 21] - 1.0
else if (expan_bar_num_int == 22) then price[shift_1]/price[shift_1 - 22] - 1.0 else if (expan_bar_num_int == 23) then price[shift_1]/price[shift_1 - 23] - 1.0
else if (expan_bar_num_int == 24) then price[shift_1]/price[shift_1 - 24] - 1.0 else if (expan_bar_num_int == 25) then price[shift_1]/price[shift_1 - 25] - 1.0
else if (expan_bar_num_int == 26) then price[shift_1]/price[shift_1 - 26] - 1.0 else if (expan_bar_num_int == 27) then price[shift_1]/price[shift_1 - 27] - 1.0
else if (expan_bar_num_int == 28) then price[shift_1]/price[shift_1 - 28] - 1.0 else if (expan_bar_num_int == 29) then price[shift_1]/price[shift_1 - 29] - 1.0
else if (expan_bar_num_int == 30) then price[shift_1]/price[shift_1 - 30] - 1.0 else if (expan_bar_num_int == 31) then price[shift_1]/price[shift_1 - 31] - 1.0
else if (expan_bar_num_int == 32) then price[shift_1]/price[shift_1 - 32] - 1.0 else if (expan_bar_num_int == 33) then price[shift_1]/price[shift_1 - 33] - 1.0
else if (expan_bar_num_int == 34) then price[shift_1]/price[shift_1 - 34] - 1.0 else if (expan_bar_num_int == 35) then price[shift_1]/price[shift_1 - 35] - 1.0
else if (expan_bar_num_int == 36) then price[shift_1]/price[shift_1 - 36] - 1.0 else if (expan_bar_num_int == 37) then price[shift_1]/price[shift_1 - 37] - 1.0
else if (expan_bar_num_int == 38) then price[shift_1]/price[shift_1 - 38] - 1.0 else if (expan_bar_num_int == 39) then price[shift_1]/price[shift_1 - 39] - 1.0
else if (expan_bar_num_int == 40) then price[shift_1]/price[shift_1 - 40] - 1.0 else if (expan_bar_num_int == 41) then price[shift_1]/price[shift_1 - 41] - 1.0
else if (expan_bar_num_int == 42) then price[shift_1]/price[shift_1 - 42] - 1.0 else if (expan_bar_num_int == 43) then price[shift_1]/price[shift_1 - 43] - 1.0
else if (expan_bar_num_int == 44) then price[shift_1]/price[shift_1 - 44] - 1.0 else if (expan_bar_num_int == 45) then price[shift_1]/price[shift_1 - 45] - 1.0
else if (expan_bar_num_int == 46) then price[shift_1]/price[shift_1 - 46] - 1.0 else if (expan_bar_num_int == 47) then price[shift_1]/price[shift_1 - 47] - 1.0
else if (expan_bar_num_int == 48) then price[shift_1]/price[shift_1 - 48] - 1.0 else if (expan_bar_num_int == 49) then price[shift_1]/price[shift_1 - 49] - 1.0
else if (expan_bar_num_int == 50) then price[shift_1]/price[shift_1 - 50] - 1.0 else if (expan_bar_num_int == 51) then price[shift_1]/price[shift_1 - 51] - 1.0
else Double.NaN
else Double.NaN;
def change_shift_2 = if !IsNaN(expan_bar_num_int) then
if (expan_bar_num_int == 0) then price[shift_2]/price[shift_2 - 0] - 1.0 else if (expan_bar_num_int == 1) then price[shift_2]/price[shift_2 - 1] - 1.0
else if (expan_bar_num_int == 2) then price[shift_2]/price[shift_2 - 2] - 1.0 else if (expan_bar_num_int == 3) then price[shift_2]/price[shift_2 - 3] - 1.0
else if (expan_bar_num_int == 4) then price[shift_2]/price[shift_2 - 4] - 1.0 else if (expan_bar_num_int == 5) then price[shift_2]/price[shift_2 - 5] - 1.0
else if (expan_bar_num_int == 6) then price[shift_2]/price[shift_2 - 6] - 1.0 else if (expan_bar_num_int == 7) then price[shift_2]/price[shift_2 - 7] - 1.0
else if (expan_bar_num_int == 8) then price[shift_2]/price[shift_2 - 8] - 1.0 else if (expan_bar_num_int == 9) then price[shift_2]/price[shift_2 - 9] - 1.0
else if (expan_bar_num_int == 10) then price[shift_2]/price[shift_2 - 10] - 1.0 else if (expan_bar_num_int == 11) then price[shift_2]/price[shift_2 - 11] - 1.0
else if (expan_bar_num_int == 12) then price[shift_2]/price[shift_2 - 12] - 1.0 else if (expan_bar_num_int == 13) then price[shift_2]/price[shift_2 - 13] - 1.0
else if (expan_bar_num_int == 14) then price[shift_2]/price[shift_2 - 14] - 1.0 else if (expan_bar_num_int == 15) then price[shift_2]/price[shift_2 - 15] - 1.0
else if (expan_bar_num_int == 16) then price[shift_2]/price[shift_2 - 16] - 1.0 else if (expan_bar_num_int == 17) then price[shift_2]/price[shift_2 - 17] - 1.0
else if (expan_bar_num_int == 18) then price[shift_2]/price[shift_2 - 18] - 1.0 else if (expan_bar_num_int == 19) then price[shift_2]/price[shift_2 - 19] - 1.0
else if (expan_bar_num_int == 20) then price[shift_2]/price[shift_2 - 20] - 1.0 else if (expan_bar_num_int == 21) then price[shift_2]/price[shift_2 - 21] - 1.0
else if (expan_bar_num_int == 22) then price[shift_2]/price[shift_2 - 22] - 1.0 else if (expan_bar_num_int == 23) then price[shift_2]/price[shift_2 - 23] - 1.0
else if (expan_bar_num_int == 24) then price[shift_2]/price[shift_2 - 24] - 1.0 else if (expan_bar_num_int == 25) then price[shift_2]/price[shift_2 - 25] - 1.0
else if (expan_bar_num_int == 26) then price[shift_2]/price[shift_2 - 26] - 1.0 else if (expan_bar_num_int == 27) then price[shift_2]/price[shift_2 - 27] - 1.0
else if (expan_bar_num_int == 28) then price[shift_2]/price[shift_2 - 28] - 1.0 else if (expan_bar_num_int == 29) then price[shift_2]/price[shift_2 - 29] - 1.0
else if (expan_bar_num_int == 30) then price[shift_2]/price[shift_2 - 30] - 1.0 else if (expan_bar_num_int == 31) then price[shift_2]/price[shift_2 - 31] - 1.0
else if (expan_bar_num_int == 32) then price[shift_2]/price[shift_2 - 32] - 1.0 else if (expan_bar_num_int == 33) then price[shift_2]/price[shift_2 - 33] - 1.0
else if (expan_bar_num_int == 34) then price[shift_2]/price[shift_2 - 34] - 1.0 else if (expan_bar_num_int == 35) then price[shift_2]/price[shift_2 - 35] - 1.0
else if (expan_bar_num_int == 36) then price[shift_2]/price[shift_2 - 36] - 1.0 else if (expan_bar_num_int == 37) then price[shift_2]/price[shift_2 - 37] - 1.0
else if (expan_bar_num_int == 38) then price[shift_2]/price[shift_2 - 38] - 1.0 else if (expan_bar_num_int == 39) then price[shift_2]/price[shift_2 - 39] - 1.0
else if (expan_bar_num_int == 40) then price[shift_2]/price[shift_2 - 40] - 1.0 else if (expan_bar_num_int == 41) then price[shift_2]/price[shift_2 - 41] - 1.0
else if (expan_bar_num_int == 42) then price[shift_2]/price[shift_2 - 42] - 1.0 else if (expan_bar_num_int == 43) then price[shift_2]/price[shift_2 - 43] - 1.0
else if (expan_bar_num_int == 44) then price[shift_2]/price[shift_2 - 44] - 1.0 else if (expan_bar_num_int == 45) then price[shift_2]/price[shift_2 - 45] - 1.0
else if (expan_bar_num_int == 46) then price[shift_2]/price[shift_2 - 46] - 1.0 else if (expan_bar_num_int == 47) then price[shift_2]/price[shift_2 - 47] - 1.0
else if (expan_bar_num_int == 48) then price[shift_2]/price[shift_2 - 48] - 1.0 else if (expan_bar_num_int == 49) then price[shift_2]/price[shift_2 - 49] - 1.0
else if (expan_bar_num_int == 50) then price[shift_2]/price[shift_2 - 50] - 1.0 else if (expan_bar_num_int == 51) then price[shift_2]/price[shift_2 - 51] - 1.0
else Double.NaN
else Double.NaN;
def change_shift_3 = if !IsNaN(expan_bar_num_int) then
if (expan_bar_num_int == 0) then price[shift_3]/price[shift_3 - 0] - 1.0 else if (expan_bar_num_int == 1) then price[shift_3]/price[shift_3 - 1] - 1.0
else if (expan_bar_num_int == 2) then price[shift_3]/price[shift_3 - 2] - 1.0 else if (expan_bar_num_int == 3) then price[shift_3]/price[shift_3 - 3] - 1.0
else if (expan_bar_num_int == 4) then price[shift_3]/price[shift_3 - 4] - 1.0 else if (expan_bar_num_int == 5) then price[shift_3]/price[shift_3 - 5] - 1.0
else if (expan_bar_num_int == 6) then price[shift_3]/price[shift_3 - 6] - 1.0 else if (expan_bar_num_int == 7) then price[shift_3]/price[shift_3 - 7] - 1.0
else if (expan_bar_num_int == 8) then price[shift_3]/price[shift_3 - 8] - 1.0 else if (expan_bar_num_int == 9) then price[shift_3]/price[shift_3 - 9] - 1.0
else if (expan_bar_num_int == 10) then price[shift_3]/price[shift_3 - 10] - 1.0 else if (expan_bar_num_int == 11) then price[shift_3]/price[shift_3 - 11] - 1.0
else if (expan_bar_num_int == 12) then price[shift_3]/price[shift_3 - 12] - 1.0 else if (expan_bar_num_int == 13) then price[shift_3]/price[shift_3 - 13] - 1.0
else if (expan_bar_num_int == 14) then price[shift_3]/price[shift_3 - 14] - 1.0 else if (expan_bar_num_int == 15) then price[shift_3]/price[shift_3 - 15] - 1.0
else if (expan_bar_num_int == 16) then price[shift_3]/price[shift_3 - 16] - 1.0 else if (expan_bar_num_int == 17) then price[shift_3]/price[shift_3 - 17] - 1.0
else if (expan_bar_num_int == 18) then price[shift_3]/price[shift_3 - 18] - 1.0 else if (expan_bar_num_int == 19) then price[shift_3]/price[shift_3 - 19] - 1.0
else if (expan_bar_num_int == 20) then price[shift_3]/price[shift_3 - 20] - 1.0 else if (expan_bar_num_int == 21) then price[shift_3]/price[shift_3 - 21] - 1.0
else if (expan_bar_num_int == 22) then price[shift_3]/price[shift_3 - 22] - 1.0 else if (expan_bar_num_int == 23) then price[shift_3]/price[shift_3 - 23] - 1.0
else if (expan_bar_num_int == 24) then price[shift_3]/price[shift_3 - 24] - 1.0 else if (expan_bar_num_int == 25) then price[shift_3]/price[shift_3 - 25] - 1.0
else if (expan_bar_num_int == 26) then price[shift_3]/price[shift_3 - 26] - 1.0 else if (expan_bar_num_int == 27) then price[shift_3]/price[shift_3 - 27] - 1.0
else if (expan_bar_num_int == 28) then price[shift_3]/price[shift_3 - 28] - 1.0 else if (expan_bar_num_int == 29) then price[shift_3]/price[shift_3 - 29] - 1.0
else if (expan_bar_num_int == 30) then price[shift_3]/price[shift_3 - 30] - 1.0 else if (expan_bar_num_int == 31) then price[shift_3]/price[shift_3 - 31] - 1.0
else if (expan_bar_num_int == 32) then price[shift_3]/price[shift_3 - 32] - 1.0 else if (expan_bar_num_int == 33) then price[shift_3]/price[shift_3 - 33] - 1.0
else if (expan_bar_num_int == 34) then price[shift_3]/price[shift_3 - 34] - 1.0 else if (expan_bar_num_int == 35) then price[shift_3]/price[shift_3 - 35] - 1.0
else if (expan_bar_num_int == 36) then price[shift_3]/price[shift_3 - 36] - 1.0 else if (expan_bar_num_int == 37) then price[shift_3]/price[shift_3 - 37] - 1.0
else if (expan_bar_num_int == 38) then price[shift_3]/price[shift_3 - 38] - 1.0 else if (expan_bar_num_int == 39) then price[shift_3]/price[shift_3 - 39] - 1.0
else if (expan_bar_num_int == 40) then price[shift_3]/price[shift_3 - 40] - 1.0 else if (expan_bar_num_int == 41) then price[shift_3]/price[shift_3 - 41] - 1.0
else if (expan_bar_num_int == 42) then price[shift_3]/price[shift_3 - 42] - 1.0 else if (expan_bar_num_int == 43) then price[shift_3]/price[shift_3 - 43] - 1.0
else if (expan_bar_num_int == 44) then price[shift_3]/price[shift_3 - 44] - 1.0 else if (expan_bar_num_int == 45) then price[shift_3]/price[shift_3 - 45] - 1.0
else if (expan_bar_num_int == 46) then price[shift_3]/price[shift_3 - 46] - 1.0 else if (expan_bar_num_int == 47) then price[shift_3]/price[shift_3 - 47] - 1.0
else if (expan_bar_num_int == 48) then price[shift_3]/price[shift_3 - 48] - 1.0 else if (expan_bar_num_int == 49) then price[shift_3]/price[shift_3 - 49] - 1.0
else if (expan_bar_num_int == 50) then price[shift_3]/price[shift_3 - 50] - 1.0 else if (expan_bar_num_int == 51) then price[shift_3]/price[shift_3 - 51] - 1.0
else Double.NaN
else Double.NaN;
def change_shift_4 = if !IsNaN(expan_bar_num_int) then
if (expan_bar_num_int == 0) then price[shift_4]/price[shift_4 - 0] - 1.0 else if (expan_bar_num_int == 1) then price[shift_4]/price[shift_4 - 1] - 1.0
else if (expan_bar_num_int == 2) then price[shift_4]/price[shift_4 - 2] - 1.0 else if (expan_bar_num_int == 3) then price[shift_4]/price[shift_4 - 3] - 1.0
else if (expan_bar_num_int == 4) then price[shift_4]/price[shift_4 - 4] - 1.0 else if (expan_bar_num_int == 5) then price[shift_4]/price[shift_4 - 5] - 1.0
else if (expan_bar_num_int == 6) then price[shift_4]/price[shift_4 - 6] - 1.0 else if (expan_bar_num_int == 7) then price[shift_4]/price[shift_4 - 7] - 1.0
else if (expan_bar_num_int == 8) then price[shift_4]/price[shift_4 - 8] - 1.0 else if (expan_bar_num_int == 9) then price[shift_4]/price[shift_4 - 9] - 1.0
else if (expan_bar_num_int == 10) then price[shift_4]/price[shift_4 - 10] - 1.0 else if (expan_bar_num_int == 11) then price[shift_4]/price[shift_4 - 11] - 1.0
else if (expan_bar_num_int == 12) then price[shift_4]/price[shift_4 - 12] - 1.0 else if (expan_bar_num_int == 13) then price[shift_4]/price[shift_4 - 13] - 1.0
else if (expan_bar_num_int == 14) then price[shift_4]/price[shift_4 - 14] - 1.0 else if (expan_bar_num_int == 15) then price[shift_4]/price[shift_4 - 15] - 1.0
else if (expan_bar_num_int == 16) then price[shift_4]/price[shift_4 - 16] - 1.0 else if (expan_bar_num_int == 17) then price[shift_4]/price[shift_4 - 17] - 1.0
else if (expan_bar_num_int == 18) then price[shift_4]/price[shift_4 - 18] - 1.0 else if (expan_bar_num_int == 19) then price[shift_4]/price[shift_4 - 19] - 1.0
else if (expan_bar_num_int == 20) then price[shift_4]/price[shift_4 - 20] - 1.0 else if (expan_bar_num_int == 21) then price[shift_4]/price[shift_4 - 21] - 1.0
else if (expan_bar_num_int == 22) then price[shift_4]/price[shift_4 - 22] - 1.0 else if (expan_bar_num_int == 23) then price[shift_4]/price[shift_4 - 23] - 1.0
else if (expan_bar_num_int == 24) then price[shift_4]/price[shift_4 - 24] - 1.0 else if (expan_bar_num_int == 25) then price[shift_4]/price[shift_4 - 25] - 1.0
else if (expan_bar_num_int == 26) then price[shift_4]/price[shift_4 - 26] - 1.0 else if (expan_bar_num_int == 27) then price[shift_4]/price[shift_4 - 27] - 1.0
else if (expan_bar_num_int == 28) then price[shift_4]/price[shift_4 - 28] - 1.0 else if (expan_bar_num_int == 29) then price[shift_4]/price[shift_4 - 29] - 1.0
else if (expan_bar_num_int == 30) then price[shift_4]/price[shift_4 - 30] - 1.0 else if (expan_bar_num_int == 31) then price[shift_4]/price[shift_4 - 31] - 1.0
else if (expan_bar_num_int == 32) then price[shift_4]/price[shift_4 - 32] - 1.0 else if (expan_bar_num_int == 33) then price[shift_4]/price[shift_4 - 33] - 1.0
else if (expan_bar_num_int == 34) then price[shift_4]/price[shift_4 - 34] - 1.0 else if (expan_bar_num_int == 35) then price[shift_4]/price[shift_4 - 35] - 1.0
else if (expan_bar_num_int == 36) then price[shift_4]/price[shift_4 - 36] - 1.0 else if (expan_bar_num_int == 37) then price[shift_4]/price[shift_4 - 37] - 1.0
else if (expan_bar_num_int == 38) then price[shift_4]/price[shift_4 - 38] - 1.0 else if (expan_bar_num_int == 39) then price[shift_4]/price[shift_4 - 39] - 1.0
else if (expan_bar_num_int == 40) then price[shift_4]/price[shift_4 - 40] - 1.0 else if (expan_bar_num_int == 41) then price[shift_4]/price[shift_4 - 41] - 1.0
else if (expan_bar_num_int == 42) then price[shift_4]/price[shift_4 - 42] - 1.0 else if (expan_bar_num_int == 43) then price[shift_4]/price[shift_4 - 43] - 1.0
else if (expan_bar_num_int == 44) then price[shift_4]/price[shift_4 - 44] - 1.0 else if (expan_bar_num_int == 45) then price[shift_4]/price[shift_4 - 45] - 1.0
else if (expan_bar_num_int == 46) then price[shift_4]/price[shift_4 - 46] - 1.0 else if (expan_bar_num_int == 47) then price[shift_4]/price[shift_4 - 47] - 1.0
else if (expan_bar_num_int == 48) then price[shift_4]/price[shift_4 - 48] - 1.0 else if (expan_bar_num_int == 49) then price[shift_4]/price[shift_4 - 49] - 1.0
else if (expan_bar_num_int == 50) then price[shift_4]/price[shift_4 - 50] - 1.0 else if (expan_bar_num_int == 51) then price[shift_4]/price[shift_4 - 51] - 1.0
else Double.NaN
else Double.NaN;
def change_shift_5 = if !IsNaN(expan_bar_num_int) then
if (expan_bar_num_int == 0) then price[shift_5]/price[shift_5 - 0] - 1.0 else if (expan_bar_num_int == 1) then price[shift_5]/price[shift_5 - 1] - 1.0
else if (expan_bar_num_int == 2) then price[shift_5]/price[shift_5 - 2] - 1.0 else if (expan_bar_num_int == 3) then price[shift_5]/price[shift_5 - 3] - 1.0
else if (expan_bar_num_int == 4) then price[shift_5]/price[shift_5 - 4] - 1.0 else if (expan_bar_num_int == 5) then price[shift_5]/price[shift_5 - 5] - 1.0
else if (expan_bar_num_int == 6) then price[shift_5]/price[shift_5 - 6] - 1.0 else if (expan_bar_num_int == 7) then price[shift_5]/price[shift_5 - 7] - 1.0
else if (expan_bar_num_int == 8) then price[shift_5]/price[shift_5 - 8] - 1.0 else if (expan_bar_num_int == 9) then price[shift_5]/price[shift_5 - 9] - 1.0
else if (expan_bar_num_int == 10) then price[shift_5]/price[shift_5 - 10] - 1.0 else if (expan_bar_num_int == 11) then price[shift_5]/price[shift_5 - 11] - 1.0
else if (expan_bar_num_int == 12) then price[shift_5]/price[shift_5 - 12] - 1.0 else if (expan_bar_num_int == 13) then price[shift_5]/price[shift_5 - 13] - 1.0
else if (expan_bar_num_int == 14) then price[shift_5]/price[shift_5 - 14] - 1.0 else if (expan_bar_num_int == 15) then price[shift_5]/price[shift_5 - 15] - 1.0
else if (expan_bar_num_int == 16) then price[shift_5]/price[shift_5 - 16] - 1.0 else if (expan_bar_num_int == 17) then price[shift_5]/price[shift_5 - 17] - 1.0
else if (expan_bar_num_int == 18) then price[shift_5]/price[shift_5 - 18] - 1.0 else if (expan_bar_num_int == 19) then price[shift_5]/price[shift_5 - 19] - 1.0
else if (expan_bar_num_int == 20) then price[shift_5]/price[shift_5 - 20] - 1.0 else if (expan_bar_num_int == 21) then price[shift_5]/price[shift_5 - 21] - 1.0
else if (expan_bar_num_int == 22) then price[shift_5]/price[shift_5 - 22] - 1.0 else if (expan_bar_num_int == 23) then price[shift_5]/price[shift_5 - 23] - 1.0
else if (expan_bar_num_int == 24) then price[shift_5]/price[shift_5 - 24] - 1.0 else if (expan_bar_num_int == 25) then price[shift_5]/price[shift_5 - 25] - 1.0
else if (expan_bar_num_int == 26) then price[shift_5]/price[shift_5 - 26] - 1.0 else if (expan_bar_num_int == 27) then price[shift_5]/price[shift_5 - 27] - 1.0
else if (expan_bar_num_int == 28) then price[shift_5]/price[shift_5 - 28] - 1.0 else if (expan_bar_num_int == 29) then price[shift_5]/price[shift_5 - 29] - 1.0
else if (expan_bar_num_int == 30) then price[shift_5]/price[shift_5 - 30] - 1.0 else if (expan_bar_num_int == 31) then price[shift_5]/price[shift_5 - 31] - 1.0
else if (expan_bar_num_int == 32) then price[shift_5]/price[shift_5 - 32] - 1.0 else if (expan_bar_num_int == 33) then price[shift_5]/price[shift_5 - 33] - 1.0
else if (expan_bar_num_int == 34) then price[shift_5]/price[shift_5 - 34] - 1.0 else if (expan_bar_num_int == 35) then price[shift_5]/price[shift_5 - 35] - 1.0
else if (expan_bar_num_int == 36) then price[shift_5]/price[shift_5 - 36] - 1.0 else if (expan_bar_num_int == 37) then price[shift_5]/price[shift_5 - 37] - 1.0
else if (expan_bar_num_int == 38) then price[shift_5]/price[shift_5 - 38] - 1.0 else if (expan_bar_num_int == 39) then price[shift_5]/price[shift_5 - 39] - 1.0
else if (expan_bar_num_int == 40) then price[shift_5]/price[shift_5 - 40] - 1.0 else if (expan_bar_num_int == 41) then price[shift_5]/price[shift_5 - 41] - 1.0
else if (expan_bar_num_int == 42) then price[shift_5]/price[shift_5 - 42] - 1.0 else if (expan_bar_num_int == 43) then price[shift_5]/price[shift_5 - 43] - 1.0
else if (expan_bar_num_int == 44) then price[shift_5]/price[shift_5 - 44] - 1.0 else if (expan_bar_num_int == 45) then price[shift_5]/price[shift_5 - 45] - 1.0
else if (expan_bar_num_int == 46) then price[shift_5]/price[shift_5 - 46] - 1.0 else if (expan_bar_num_int == 47) then price[shift_5]/price[shift_5 - 47] - 1.0
else if (expan_bar_num_int == 48) then price[shift_5]/price[shift_5 - 48] - 1.0 else if (expan_bar_num_int == 49) then price[shift_5]/price[shift_5 - 49] - 1.0
else if (expan_bar_num_int == 50) then price[shift_5]/price[shift_5 - 50] - 1.0 else if (expan_bar_num_int == 51) then price[shift_5]/price[shift_5 - 51] - 1.0
else Double.NaN
else Double.NaN;
#def change_avg = (change_shift_1 + change_shift_2 + change_shift_3 + change_shift_4 + change_shift_5)/5;
def change_avg = if !IsNaN(change_shift_1) and !IsNaN(change_shift_2) and !IsNaN(change_shift_3) and !IsNaN(change_shift_4) and !IsNaN(change_shift_5)
then (change_shift_1 + change_shift_2 + change_shift_3 + change_shift_4 + change_shift_5)/5
else if !IsNaN(change_shift_1) and !IsNaN(change_shift_2) and !IsNaN(change_shift_3) and !IsNaN(change_shift_4)
then (change_shift_1 + change_shift_2 + change_shift_3 + change_shift_4)/4
else if !IsNaN(change_shift_1) and !IsNaN(change_shift_2) and !IsNaN(change_shift_3)
then (change_shift_1 + change_shift_2 + change_shift_3)/3
else if !IsNaN(change_shift_1) and !IsNaN(change_shift_2)
then (change_shift_1 + change_shift_2)/2
else if !IsNaN(change_shift_1)
then (change_shift_1)/1
else Double.NaN
;
plot price_projection_1 = (1.0 + change_shift_1)*lastcls;
price_projection_1.SetDefaultColor(Color.PINK);
price_projection_1.HideBubble();
price_projection_1.HideTitle();
price_projection_1.Hide();
plot price_projection_2 = (1.0 + change_shift_2)*lastcls;
price_projection_2.SetDefaultColor(Color.GRAY);
price_projection_2.HideBubble();
price_projection_2.HideTitle();
price_projection_2.Hide();
plot price_projection_3 = (1.0 + change_shift_3)*lastcls;
price_projection_3.SetDefaultColor(Color.YELLOW);
price_projection_3.HideBubble();
price_projection_3.HideTitle();
price_projection_3.Hide();
plot price_projection_4 = (1.0 + change_shift_4)*lastcls;
price_projection_4.SetDefaultColor(Color.RED);
price_projection_4.HideBubble();
price_projection_4.HideTitle();
price_projection_4.Hide();
plot price_projection_5 = (1.0 + change_shift_5)*lastcls;
price_projection_5.SetDefaultColor(Color.GREEN);
price_projection_5.HideBubble();
price_projection_5.HideTitle();
price_projection_5.Hide();
plot price_projection_avg = (1.0 + change_avg)*lastcls;
price_projection_avg.SetDefaultColor(Color.CYAN);
price_projection_avg.SetLineWeight(3);
price_projection_avg.HideBubble();
price_projection_avg.HideTitle();
By default, average of the past five years price movement is shown:
is there any way to look back to see how it performs? forward projection is a great idea I am trying to figure out how this script performed over last say 5 years? or may be even 2 years that would help tremendously.
The Forward Seasonality Projection is a Weather Forecast
Think of seasonal data like a meteorological weather forecast for the market. Looking at the past 5 years provides a rough roadmap of the market's "seasons"—it tells us that, historically, it tends to get cold in January and hot in July.
For the market, history tells us there is usually a February pullback and an August/September correction.
The 2026 Problem with "Backtesting" a Forward Seasonality Projection
The theory that history can project the path of the current 2026 AI CAPEX mania cycle is flawed.
The Reality: The AI CAPEX Mania & Trillion-Dollar Shifts
We are sitting in an unprecedented market expansion. The Q1 earnings cycles and massive AI CAPEX spending have fundamentally altered the structural plumbing of the market.
10-year projections indicate these shifts are only just starting to manifest.
This isn't just about Nvidia or picks and shovels AI stocks anymore—the entire market's productivity and margin baseline is changing as legacy companies implement automated AI efficiency.
The market just ripped a historic 14% gain in Q2, running roughshod over sticky inflation, runaway CPI, hot PPI numbers, and bombs-falling geopolitical strife.
The traditional historical baselines broke down because when corporate margins are clearing 70% and there are trillion-dollar mega-IPOs like SpaceX, Anthropic, and SK Hynix, historical price targets become irrelevant.
What Does Matter: The Slope, Not the Price
Does this mean the script is useless? No. The slope of seasonality—the general timing of the market's breathing patterns—will still show up. The market will still take breathers, and it will still have periods of accumulation.
The real question you have to ask yourself as a trader in this environment isn't "did the price hit the exact target the script predicted?" Instead, ask:
Will the massive YTD gains result in deeper, sharper contractions because things are overextended?
Or will the current momentum completely steamroller the normal seasonal corrections, just like it did to the bad inflation data and the geopolitical frictions?
Bottom Line
Use the seasonality script to anticipate when the market might change directions or experience a volume shift. But do not try to backtest it to see if it accurately predicted a specific price level. We cannot mathematically predict the absolute ceiling of this market expansion using a rearview mirror.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
How do I get started?
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.