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.
By default, average of the past five years price movement is shown:
With "Show plot" enabled under settings, all previous five years price movements are shown on the chart.
Shared at: http://tos.mx/zXpuFtr
Thinkofswim has the chart settings to show seasonality, but it doesn't show how much the price may move from the current price.
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:
With "Show plot" enabled under settings, all previous five years price movements are shown on the chart.
Shared at: http://tos.mx/zXpuFtr
Thinkofswim has the chart settings to show seasonality, but it doesn't show how much the price may move from the current price.
Last edited: