// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Bill_Howell // "$d_web"'CompLangs/PineScript/Howell - SP500 trend 1926-2022.txt' // view this file in a text editor, with [constant width font, tab = 3 spaces], no line-wrap //@version=5 indicator("SP500 semi-log trend 1926-2022", overlay=true) // ************************** // relStdDevTrn - relative standard deviation in transformed coorodinates // "$d_web"'economics, markets/SP500/PuetzUWS intnl stocks/semi-log SP500 1926-2022 TV,yahoo,article regression fit.txt' // 09Aug2022 last run // // paramSLRgressL : // +--------------------------------+-------+---------+-------+---------+---------+--------+ // |symName |xTrnPhr|xUnTrnPhr|yTrnPhr|yUnTrnPhr|slope |constant| // +--------------------------------+-------+---------+-------+---------+---------+--------+ // |SP500 1926-2022 TV,yahoo,article|pass |?noexpr |log |?noexpr |0.0298315|-56.7736| // +--------------------------------+-------+---------+-------+---------+---------+--------+ // // key statistics (in transformed co-ordinates [xTrnPhr, yTrnPhr]) : // +------------+------------+ // |relStdDevObs|relStdDevTrn| // +------------+------------+ // | 0.333903| 0.0937853| // +------------+------------+ // relStdDev_plus1 = 1 + 0.0937853 // ************************** // time conversions // from "$d_web"'CompLangs/PineScript/PuetzUWS IntlStkIdxs multi-fractals.txt' var float t_year_to_millisecs = 365.25*24*60*60*1000 yrFrac = time / t_year_to_millisecs + 1970 // ************************** // trendlines SP500_base_trender = math.pow(10, -56.7736 + (0.029831 * yrFrac)) SP500_plus_1stdDev = SP500_base_trender * relStdDev_plus1 SP500_less_1stdDev = SP500_base_trender / relStdDev_plus1 // plots // Note that this plot may "scrunch" the actual SP500 plot if is on the same axis // if not on the same axis, there will be an annoying offset plot(SP500_base_trender, color=color.black, linewidth=2, title="SP500_base_trender") plot(SP500_plus_1stdDev, color=color.gray , linewidth=1, title="SP500_plus_1stdDev") plot(SP500_less_1stdDev, color=color.gray , linewidth=1, title="SP500_less_1stdDev") // enddoc