data-miner 11 posts msg #144174 - Ignore data-miner |
7/23/2018 4:06:48 PM
I was curious about ALMA and I discovered found your post here. I have tried to duplicate this from the formula you had listed.
There is so much code here, that you may get a performance limit error if you try to add anything. I have a base subscription so when I tried to plot the average on the price chart I got an error. So I stripped out all of the comments and posted them separately. Sometimes it works, sometimes it does not. One option may be to scale it down and do a window of 5 instead of 9
I don't believe looping is possible in stockfetcher. So I am having to add each line
I would be curious if this has any correlation to the original site's code.
COMMENTS BELOW:
set{Window, 9 }
set{Sigma, 6}
set{Offset,0.85}
set{varm1, Window - 1}
set{m, Offset * varm1}
set{s, Window / Sigma}
/* for k = 0 to Window - 1 do */
/* FOR K = 0 TO 8 so there are 9 loops including 0 */
set{k0,0}
set{k1,1}
set{k2,2}
set{k3,3}
set{k4,4}
set{k5,5}
set{k6,6}
set{k7,7}
set{k8,8}
set{WtdSum, 0.0000}
/* I don't believe looping is possible in stockfetcher.*/
/* if it is someody please let me know */
/* BEGINNING OF WHAT WOULD BE THE LOOP*/
/* Here is the section for the equation Wtd = Exp(-((k-m)*(k-m))/(2*s*s)) */
set{varss1, s * s}
set{varss2, 2 * varss1}
set{varkm0, k0 - m}
set{varkm1, k1 - m}
set{varkm2, k2 - m}
set{varkm3, k3 - m}
set{varkm4, k4 - m}
set{varkm5, k5 - m}
set{varkm6, k6 - m}
set{varkm7, k7 - m}
set{varkm8, k8 - m}
set{varkmA, varkm0 * varkm0}
set{varkmB, varkm1 * varkm1}
set{varkmC, varkm2 * varkm2}
set{varkmD, varkm3 * varkm3}
set{varkmE, varkm4 * varkm4}
set{varkmF, varkm5 * varkm5}
set{varkmG, varkm6 * varkm6}
set{varkmH, varkm7 * varkm7}
set{varkmI, varkm8 * varkm8}
set{varExpA1, varkmA / varss2}
set{varExpB1, varkmB / varss2}
set{varExpC1, varkmC / varss2}
set{varExpD1, varkmD / varss2}
set{varExpE1, varkmE / varss2}
set{varExpF1, varkmF / varss2}
set{varExpG1, varkmG / varss2}
set{varExpH1, varkmH / varss2}
set{varExpI1, varkmI / varss2}
set{varExpA, -1 * varExpA1}
set{varExpB, -1 * varExpB1}
set{varExpC, -1 * varExpC1}
set{varExpD, -1 * varExpD1}
set{varExpE, -1 * varExpE1}
set{varExpF, -1 * varExpF1}
set{varExpG, -1 * varExpG1}
set{varExpH, -1 * varExpH1}
set{varExpI, -1 * varExpI1}
set{WtdA, Exp(varExpA) }
set{WtdB, Exp(varExpB) }
set{WtdC, Exp(varExpC) }
set{WtdD, Exp(varExpD) }
set{WtdE, Exp(varExpE) }
set{WtdF, Exp(varExpF) }
set{WtdG, Exp(varExpG) }
set{WtdH, Exp(varExpH) }
set{WtdI, Exp(varExpI) }
/*Here is the section for WtdSum = WtdSum + Wtd * Price[Window - 1 - k] */
/*Window - 1 - k */
/*9-1-0 = 8 price 8 days ago*/
/*...*/
/*9-1-2 = 2 price 2 days ago*/
/*9-1-2 = 1 price one day ago*/
/*9-1-2 = 0 current price*/
set{WtdSum0, WtdA * Price 8 days ago}
set{WtdSum1, WtdB * Price 7 days ago}
set{WtdSum2, WtdC * Price 6 days ago}
set{WtdSum3, WtdD * Price 5 days ago}
set{WtdSum4, WtdE * Price 4 days ago}
set{WtdSum5, WtdF * Price 3 days ago}
set{WtdSum6, WtdG * Price 2 days ago}
set{WtdSum7, WtdH * Price 1 day ago}
set{WtdSum8, WtdI * Price}
/* Here is where the totals are accumulated */
/* it does not appear that you can var = var +1 in stockfetcher*/
Set{WtdSumA, WtdSum0}
Set{WtdSumB, WtdSum1 + WtdSumA}
Set{WtdSumC, WtdSum2 + WtdSumB}
Set{WtdSumD, WtdSum3 + WtdSumC}
Set{WtdSumE, WtdSum4 + WtdSumD}
Set{WtdSumF, WtdSum5 + WtdSumE}
Set{WtdSumG, WtdSum6 + WtdSumF}
Set{WtdSumH, WtdSum7 + WtdSumG}
Set{WtdSumI, WtdSum8 + WtdSumH}
set{CumWt0, WtdA}
set{CumWt1, CumWt0 + WtdB}
set{CumWt2, CumWt1 + WtdC}
set{CumWt3, CumWt2 + WtdD}
set{CumWt4, CumWt3 + WtdE}
set{CumWt5, CumWt4 + WtdF}
set{CumWt6, CumWt5 + WtdG}
set{CumWt7, CumWt6 + WtdH}
set{CumWt8, CumWt7 + WtdI}
/*END OF WHAT WOULD BE THE LOOP*/
/*This is the main average that is sought*/
set{ALAverage, WtdSumI / CumWt8}
show stocks where price is between 10 and 100
draw ALAverage on plot Price
|