Which way? Gold.

There is no doubt a decent chance of a rally here. I just can't make up my mind which commodity area has the best chances : Gold, Silver, Oil. I've reduced my Nat Gas and Copper holdings significantly awaiting how this all shakes out short term.
Mining weak today on ASX but gold is the strongest sector so far today.
 
There is no doubt a decent chance of a rally here. I just can't make up my mind which commodity area has the best chances : Gold, Silver, Oil. I've reduced my Nat Gas and Copper holdings significantly awaiting how this all shakes out short term.

I ran a curve fitting model described here and here on gold (GLD), silver (SLV), and oil (USO).

Each graph has closing prices as of last Friday for the past 123 calendar days (20210119 through 20210521) of close prices (+ signs) with prices interpolated for non-trading days. The overlaid lines on each graph are for 10 genetically-optimized models for that period and the models' predictions for the 21 calendar days after last Friday.

GLD
upload_2021-5-23_21-52-48.png


SLV
upload_2021-5-23_21-52-59.png


USO
upload_2021-5-23_21-53-8.png


Gold looks best for a continued rise according to the models.
 
Damn, Ph1l, if I understand what you are doing its something I dreamed of awhile back. You are plugging the closing prices of X into a program. The program then spits out the equation that came up on average with closest prices that were as close as possible to those actually observed. Then you use that model to extrapolate into the future. That, in my mind, is the logical be-all-end-all as to price forecasting. The devil is in the details I supposed, how far back do you go, do you use every day or once a week pricing, etc. etc. But all in all it seems ideal. Can I ask what program, add-in, etc. you use to do that?

Thanks!!!
 
But all in all it seems ideal. Can I ask what program, add-in, etc. you use to do that?

I wrote it in C++ and opencl (so most of the calculations are done on a GPU) with controlling code in perl and shell (bash). The graphs are from gnuplot.

A model (e.g., for GLD) bwould be something like
Code:
y = 178.67431640625  -  0.552311420440674 * x  +  0.0044319755397737 * x * x
    +  1.70705246925354 * cos(twopi / 38.167761420465 * x  +  2.84865665435791)
    +  1.67844784259796 * cos(twopi / 49.4317214487235 * x  +  2.56916689872742)
    +  1.21163415908813 * cos(twopi / 26.0198103914197 * x  +  4.47486019134521) ;
where y is the predicted price, x is the number of calendar days from the beginning of the input period, and the body of the function has a parabola and three cosine waves with amplitude, period, and phase).

It's nowhere near perfect (e.g., the models don't capture the spike of 24.99 to 26.76 to 24.54 of SLV on trading days 20210129, 20210201, and 20210202 too well). But the code works fairly consistently given the same data (different pseudorandom number sequences) or similar data. For example, here are the same type of graphs (10 overlaid models) for the same 123 calendar days for S&P 500 index ETFs VOO and SPLG (prices adjusted for splits and dividends).

VOO
upload_2021-5-23_22-56-41.png


SPLG
upload_2021-5-23_22-57-2.png


sample model for VOO
Code:
y = 343.538146972656  +  0.316626936197281 * x  +  0.000452404085081071 * x * x
    +  5.90755987167358 * cos(twopi / 73.4853813924861 * x  +  4.88049077987671)
    +  5.03771877288818 * cos(twopi / 27.725765107584 * x  +  0.971799075603485)
    +  3.74927115440369 * cos(twopi / 30.3418598657709 * x  +  5.95282411575317) ;

sample model for SPLG
Code:
y = 43.9298973083496  +  0.0405849181115627 * x  +  5.74740915908478e-05 * x * x
    +  0.756501495838165 * cos(twopi / 73.2716120758861 * x  +  4.86414957046509)
    +  0.680599689483643 * cos(twopi / 27.841080791083 * x  +  1.03640067577362)
    +  0.516805410385132 * cos(twopi / 30.2471932452291 * x  +  5.86949491500854) ;

The graphs for the two S&P 500 index ETFs have similar shapes for the fits and predictions, and the sample models have similar periods and phases in their cosines.
 
I wrote it in C++ and opencl (so most of the calculations are done on a GPU) with controlling code in perl and shell (bash). The graphs are from gnuplot.

A model (e.g., for GLD) bwould be something like
Code:
y = 178.67431640625  -  0.552311420440674 * x  +  0.0044319755397737 * x * x
    +  1.70705246925354 * cos(twopi / 38.167761420465 * x  +  2.84865665435791)
    +  1.67844784259796 * cos(twopi / 49.4317214487235 * x  +  2.56916689872742)
    +  1.21163415908813 * cos(twopi / 26.0198103914197 * x  +  4.47486019134521) ;
where y is the predicted price, x is the number of calendar days from the beginning of the input period, and the body of the function has a parabola and three cosine waves with amplitude, period, and phase).

It's nowhere near perfect (e.g., the models don't capture the spike of 24.99 to 26.76 to 24.54 of SLV on trading days 20210129, 20210201, and 20210202 too well). But the code works fairly consistently given the same data (different pseudorandom number sequences) or similar data. For example, here are the same type of graphs (10 overlaid models) for the same 123 calendar days for S&P 500 index ETFs VOO and SPLG (prices adjusted for splits and dividends).

VOO
View attachment 259483

SPLG
View attachment 259484

sample model for VOO
Code:
y = 343.538146972656  +  0.316626936197281 * x  +  0.000452404085081071 * x * x
    +  5.90755987167358 * cos(twopi / 73.4853813924861 * x  +  4.88049077987671)
    +  5.03771877288818 * cos(twopi / 27.725765107584 * x  +  0.971799075603485)
    +  3.74927115440369 * cos(twopi / 30.3418598657709 * x  +  5.95282411575317) ;

sample model for SPLG
Code:
y = 43.9298973083496  +  0.0405849181115627 * x  +  5.74740915908478e-05 * x * x
    +  0.756501495838165 * cos(twopi / 73.2716120758861 * x  +  4.86414957046509)
    +  0.680599689483643 * cos(twopi / 27.841080791083 * x  +  1.03640067577362)
    +  0.516805410385132 * cos(twopi / 30.2471932452291 * x  +  5.86949491500854) ;

The graphs for the two S&P 500 index ETFs have similar shapes for the fits and predictions, and the sample models have similar periods and phases in their cosines.
Fantastic! A bit beyond me, rocket science.
Do you have a name for it, like perhaps,.... Iron Dome? :)
20210524_185706.jpg

 
Fantastic! A bit beyond me, rocket science.
Do you have a name for it, like perhaps,.... Iron Dome?

I was thinking of a play on words like "Time of the Sines" (already used by a band from your neighborhood:)) or something to confuse other machine learning enthusiasts like "Least Squares Time Machine (LSTM)," but I just call it GaCurveFitter.
 
Double Bottom 100% minimum target looks to be hit.
Let's see if support holds up there...
https://www.elitetrader.com/et/thre...t-right-here-baby.335635/page-18#post-5309309
delete dbgc.png

I wrote it in C++ and opencl (so most of the calculations are done on a GPU) with controlling code in perl and shell (bash). The graphs are from gnuplot.

A model (e.g., for GLD) bwould be something like
Code:
y = 178.67431640625  -  0.552311420440674 * x  +  0.0044319755397737 * x * x
    +  1.70705246925354 * cos(twopi / 38.167761420465 * x  +  2.84865665435791)
    +  1.67844784259796 * cos(twopi / 49.4317214487235 * x  +  2.56916689872742)
    +  1.21163415908813 * cos(twopi / 26.0198103914197 * x  +  4.47486019134521) ;
where y is the predicted price, x is the number of calendar days from the beginning of the input period, and the body of the function has a parabola and three cosine waves with amplitude, period, and phase).

It's nowhere near perfect (e.g., the models don't capture the spike of 24.99 to 26.76 to 24.54 of SLV on trading days 20210129, 20210201, and 20210202 too well). But the code works fairly consistently given the same data (different pseudorandom number sequences) or similar data. For example, here are the same type of graphs (10 overlaid models) for the same 123 calendar days for S&P 500 index ETFs VOO and SPLG (prices adjusted for splits and dividends).

VOO
View attachment 259483

SPLG
View attachment 259484

sample model for VOO
Code:
y = 343.538146972656  +  0.316626936197281 * x  +  0.000452404085081071 * x * x
    +  5.90755987167358 * cos(twopi / 73.4853813924861 * x  +  4.88049077987671)
    +  5.03771877288818 * cos(twopi / 27.725765107584 * x  +  0.971799075603485)
    +  3.74927115440369 * cos(twopi / 30.3418598657709 * x  +  5.95282411575317) ;

sample model for SPLG
Code:
y = 43.9298973083496  +  0.0405849181115627 * x  +  5.74740915908478e-05 * x * x
    +  0.756501495838165 * cos(twopi / 73.2716120758861 * x  +  4.86414957046509)
    +  0.680599689483643 * cos(twopi / 27.841080791083 * x  +  1.03640067577362)
    +  0.516805410385132 * cos(twopi / 30.2471932452291 * x  +  5.86949491500854) ;

The graphs for the two S&P 500 index ETFs have similar shapes for the fits and predictions, and the sample models have similar periods and phases in their cosines.

Hook 'er up on GC-202106-NYMEX Daily and Cut the New Data off on Dates:
2021 0416 for Run One,
and 2021 0515? for Run Two...
Let's see how she go...?
 
Last edited:
View attachment 259643


Hook 'er up on GC-202106-NYMEX Daily and Cut the New Data off on Dates:
2021 0416 for Run One,
and 2021 0515? for Run Two...
Let's see how she go...?

Using data from yahoo finance for Gold Jun 21
https://finance.yahoo.com/quote/GC=F/history?p=GC=F

For 123 calendar days ending 20210416 (starting point 20201215), 10 fitting functions generated were:
Code:
y = 1891.65246582031  -  2.29241752624512 * x  +  0.00931525230407715 * x * x
    +  42.7822418212891 * cos(twopi / 115.654159496883 * x  +  4.35306692123413)
    +  16.919397354126 * cos(twopi / 24.5898112829417 * x  +  1.45940971374512)
    +  16.8471221923828 * cos(twopi / 44.3543272678755 * x  +  4.38106203079224) ;
y = 1908.59790039062  -  2.56609535217285 * x  +  0.00945630297064781 * x * x
    +  35.8195724487305 * cos(twopi / 103.452217649011 * x  +  3.93166017532349)
    +  17.1379241943359 * cos(twopi / 24.7247505178715 * x  +  1.55146980285645)
    +  16.0772495269775 * cos(twopi / 43.755675297652 * x  +  4.21933555603027) ;
y = 1906.78918457031  -  2.53952932357788 * x  +  0.00945632252842188 * x * x
    +  36.3711318969727 * cos(twopi / 104.866253928001 * x  +  3.979252576828)
    +  17.1010513305664 * cos(twopi / 24.7055847094145 * x  +  1.54115855693817)
    +  16.1919708251953 * cos(twopi / 43.9064811307829 * x  +  4.25069379806519) ;
y = 1911.43579101562  -  2.6111752986908 * x  +  0.00945622846484184 * x * x
    +  34.7836227416992 * cos(twopi / 101.083952145404 * x  +  3.83083748817444)
    +  17.1185970306396 * cos(twopi / 24.7386763082527 * x  +  1.56551933288574)
    +  16.0714340209961 * cos(twopi / 43.6188209715383 * x  +  4.18557071685791) ;
y = 1910.6064453125  -  2.59805178642273 * x  +  0.00945628248155117 * x * x
    +  35.1552810668945 * cos(twopi / 101.863798860001 * x  +  3.86549377441406)
    +  17.1319961547852 * cos(twopi / 24.7129461946726 * x  +  1.54816460609436)
    +  16.1127624511719 * cos(twopi / 43.6530457483224 * x  +  4.19464874267578) ;
y = 1899.90087890625  -  2.43233847618103 * x  +  0.00945338979363441 * x * x
    +  39.4018173217773 * cos(twopi / 109.756838357579 * x  +  4.15686273574829)
    +  16.9519939422607 * cos(twopi / 24.6562124530077 * x  +  1.50224697589874)
    +  16.5276794433594 * cos(twopi / 44.1947179062348 * x  +  4.33504772186279) ;
y = 1906.86730957031  -  2.54043912887573 * x  +  0.00945636443793774 * x * x
    +  36.5937385559082 * cos(twopi / 104.727228628642 * x  +  3.97624349594116)
    +  17.0573921203613 * cos(twopi / 24.7172486992862 * x  +  1.54474449157715)
    +  16.2824172973633 * cos(twopi / 43.8682840927564 * x  +  4.24856758117676) ;
y = 1896.373046875  -  2.37708878517151 * x  +  0.00945633742958307 * x * x
    +  40.8680686950684 * cos(twopi / 112.527877150575 * x  +  4.2486743927002)
    +  16.9697189331055 * cos(twopi / 24.6308175234862 * x  +  1.48041188716888)
    +  16.61962890625 * cos(twopi / 44.2891972464519 * x  +  4.35945415496826) ;
y = 1910.37438964844  -  2.59436821937561 * x  +  0.00945636443793774 * x * x
    +  35.071403503418 * cos(twopi / 101.959337467326 * x  +  3.86820292472839)
    +  17.0923919677734 * cos(twopi / 24.7246635309817 * x  +  1.55332887172699)
    +  16.1620483398438 * cos(twopi / 43.6290299508623 * x  +  4.1805591583252) ;
y = 1896.12829589844  -  2.37457180023193 * x  +  0.00945632252842188 * x * x
    +  40.962589263916 * cos(twopi / 112.665893066898 * x  +  4.25157690048218)
    +  16.9778289794922 * cos(twopi / 24.6352613135766 * x  +  1.48288822174072)
    +  16.6502418518066 * cos(twopi / 44.325805833612 * x  +  4.36462497711182) ;

The graph of the close prices and fitted curves extrapolated for 31 calendar days were:
upload_2021-5-26_21-42-48.png


The next two predicted inflection points would be about 20210421 and 20210507.

May 15 was last Saturday, so it wouldn't have been possible to have anything real end that day. So I used May 14 instead.
For 123 calendar days ending 20210514 (starting point 20210112), 10 fitting functions generated were:
Code:
y = 1898.06323242188  -  4.71660995483398 * x  +  0.0331664308905602 * x * x
    +  25.1880168914795 * cos(twopi / 67.6508115253057 * x  +  3.31783294677734)
    +  17.1019897460938 * cos(twopi / 47.5546822143787 * x  +  3.18071889877319)
    +  15.8818511962891 * cos(twopi / 27.5227649213683 * x  +  3.66259407997131) ;
y = 1903.29638671875  -  4.92417097091675 * x  +  0.0347889587283134 * x * x
    +  26.837085723877 * cos(twopi / 64.3726983450353 * x  +  2.9828794002533)
    +  19.6935157775879 * cos(twopi / 48.3282079400492 * x  +  3.39958119392395)
    +  15.8888416290283 * cos(twopi / 27.4897330616493 * x  +  3.6426157951355) ;
y = 1905.3076171875  -  4.99167919158936 * x  +  0.0352950803935528 * x * x
    +  30.6605339050293 * cos(twopi / 62.3402006289076 * x  +  2.7248740196228)
    +  23.8041534423828 * cos(twopi / 49.4728826461845 * x  +  3.6591157913208)
    +  15.8895301818848 * cos(twopi / 27.5900963386342 * x  +  3.70210242271423) ;
y = 1904.64636230469  -  4.9676251411438 * x  +  0.0351265072822571 * x * x
    +  28.1028728485107 * cos(twopi / 63.2773184135123 * x  +  2.85453677177429)
    +  21.4426307678223 * cos(twopi / 48.7542678185313 * x  +  3.51133012771606)
    +  15.9308938980103 * cos(twopi / 27.503060783747 * x  +  3.65065288543701) ;
y = 1902.9111328125  -  4.89834690093994 * x  +  0.034557119011879 * x * x
    +  26.6950664520264 * cos(twopi / 64.5793393352562 * x  +  3.01244854927063)
    +  19.5435638427734 * cos(twopi / 48.085330744763 * x  +  3.36315608024597)
    +  16.003116607666 * cos(twopi / 27.4928016139202 * x  +  3.64931535720825) ;
y = 1902.60974121094  -  4.88496685028076 * x  +  0.0344494879245758 * x * x
    +  26.030948638916 * cos(twopi / 65.0213581747575 * x  +  3.06422352790833)
    +  18.6598796844482 * cos(twopi / 47.7989168792231 * x  +  3.29749536514282)
    +  15.9772357940674 * cos(twopi / 27.4531550431897 * x  +  3.61939263343811) ;
y = 1904.09289550781  -  4.94840526580811 * x  +  0.0349581092596054 * x * x
    +  27.251537322998 * cos(twopi / 63.8897155910453 * x  +  2.93368077278137)
    +  20.2985324859619 * cos(twopi / 48.3563908460508 * x  +  3.42422819137573)
    +  15.9643077850342 * cos(twopi / 27.4861688805672 * x  +  3.64252996444702) ;
y = 1905.18029785156  -  5.00100517272949 * x  +  0.0353938899934292 * x * x
    +  27.3891983032227 * cos(twopi / 63.7906192098912 * x  +  2.90799927711487)
    +  20.1940422058105 * cos(twopi / 48.535291178567 * x  +  3.43874287605286)
    +  15.8564863204956 * cos(twopi / 27.514282722582 * x  +  3.64667844772339) ;
y = 1903.6591796875  -  4.91341066360474 * x  +  0.0346580259501934 * x * x
    +  26.9016819000244 * cos(twopi / 63.4620577653807 * x  +  2.88441586494446)
    +  20.414737701416 * cos(twopi / 48.3833408032323 * x  +  3.43518590927124)
    +  16.0291976928711 * cos(twopi / 27.4632630058429 * x  +  3.63818144798279) ;
y = 1901.51916503906  -  4.84075117111206 * x  +  0.0340838171541691 * x * x
    +  25.9263610839844 * cos(twopi / 65.6579405766497 * x  +  3.11967349052429)
    +  18.5207290649414 * cos(twopi / 47.8676349838773 * x  +  3.29146528244019)
    +  15.9820861816406 * cos(twopi / 27.4714810959806 * x  +  3.63981080055237) ;

The graph of the close prices and fitted curves extrapolated for 31 calendar days were:
upload_2021-5-26_21-45-6.png


The next predicted inflection point would be about 20210528.
 
...at what avg price?

The mean price for the 10 models on 20210514 (end of input data) was 1,835.57391357422.
The mean price for the 10 models on 20210528 was 1,825.53142089844 (10.0424926757798 lower than the mean for 20210514).
 
Back
Top