Thank you Tomasz, fxshrat, Guiseppe for your prior able and generous help, and Happy New Year. Fxshrat's help on the OSAKA sort and extraction of values was a major help in execution time in particular, and thank you to Guiseppe on matrix insights. As always, this is the best software for analysis, Tomasz.
I am a newbie to amateur, running 6.30.0 Amibroker (WILL UPGRADE SOON), windows 8.1, version 6.1.0.20 DTN (latest according to them), have a 2.4 GHz pentium, 16 MB Ram, using wi-fi 85gb and above download speed fiber optic, and plot 20 cent range bars typically on symbol TQQQ (triple leverage QQQ ETF). My decimal setting in "Miscellaneous" preferences is 4 for titles & tools
My full code is shown below. It is, in essence, several composite Ehlers' stochastic fisher calculations. There are four of them, three covering different periods, and one that is simply an average of two of the others. I have applied the AFL check, and no coding errors appear, nor do any "divide by zero" warnings appear. I have also applied the "Code Check and Profile", and it indicates "no future quotes" are used. Everything "appears" fine. However, at various times, one of the plots (the Blue Histogram noted in the plot section at the end of the code) will flash "off" and then "reappear", usually within an instant. If you hold the cursor over that bar, the Blue histogram value will remain in the data window even when the plot disappears (very rarely, but sometimes, the value will show zero). The other plot overlays noted at the bottom of my code remain intact. I would have provided a screenshot, but can't "grab" one quickly enough when this happens. I have tried the steps noted earlier to sort this out. Within my amateur ability, I have also looked for any other items that might lead to unstable numbers, but don't see anything. I have also searched on web and Amibroker for any graphical and/or numerical limits on plotting multiple "indicators" over each other (the indicators are all calculated within the same named indicator, and then plotted together). I also tried the Prec function in Amibroker, hoping it might limit any decimal errors.
I don't know how to proceed at this point.
Any help would be greatly appreciated!! Thank you......Mike
function SuperSmoother2(Price,Period)
{
a1 = 0;
b1 = 0;
coef1 = 0;
coef2 = 0;
coef3 = 0;
Result = 0;
Filt = Nz( Price ); // not in regular SuperSmoother code; had to use Nz to eliminate infinite or undefined values that caused function to return an "Empty" data set
for (i=1; i< 11; i++)
{
Result[i] = Filt[i] ;
}
for (i > 10; i < BarCount; i++)
{
a1 = exp(-1.414*3.14159 /Period);
b1 = 2*a1*cos(1.414*(3.14159/2) /Period);
coef2 = b1;
coef3 = -a1*a1;
coef1 = 1 - coef2 - coef3;
Result[i] = coef1*Filt[i] + coef2*Result[i-1] + coef3*Result[i-2];
}
return Result;
}
function Cycle(Input, Alphas)
{
Smooth = 0;
Result = 0;
/*
// Do we go to firstValid + 6 or firstValid + 4 ????
for (i = 2; i < 6; i++)
{
Result[i] = (Input[i] - 2 * Input[i-1] + Input[i-2]) / 4.0 ;
}
for (i = 4; i < 6; i++)
{
// Seed Values...
Smooth[i] = (Input[i]
+ 2 * Input[i-1]
+ 2 * Input[i-2]
+ Input[i-3])
/ 6.0 ;
}
*/
for (i = 6; i < BarCount; i++)
{
alpha = Alphas[i];
if (alpha < 0)
alpha = 0;
if (alpha > 1)
alpha = 1;
Smooth[i] = (Input[i]
+ 2 * Input[i-1]
+ 2 * Input[i-2]
+ Input[i-3])
/ 6.0 ;
Result[i] = (1 - .5*alpha) * (1 - .5*alpha) * (Smooth[i] - 2*Smooth[i-1] + Smooth[i-2]) + 2*(1 - alpha)
* Result[i-1] - (1 - alpha) * ( 1 - alpha) * Result[i-2];
}
return Result;
}
function StochFisher(Input, Periods, Alphas)
{
R = 0;
R1 = 0;
R2 = 0;
TempHHV = HHV(Input, Periods);
TempLLV = LLV(Input, Periods);
for (i = 1; i < BarCount; i++)
{
alpha = Alphas[i];
if (alpha < 0)
alpha = 0;
if (alpha > 1)
alpha = 1;
if ((TempHHV[i] - TempLLV[i]) != 0)
{
R =(Input[i] - TempLLV[i]) /
(TempHHV[i] - TempLLV[i]);
}
else
R = 0.0;
//extra smoothing of stochastic, via Mike's workaround code
//R[0] = .5 * 2 * (R[0] - .5) + .5 * R[1];
R1 = R - 0.5;
R2[i] = 2 * R1;
R2[i] = .5 * R2[i] + .5 * R2[i-1];
// The number of 9's used here determines the range bound of the final indicator
// using only 2 9's gives a bound around abs(2.64), using 5 9's gives bound around abs(6.01).
if (R2[i] < -0.9999)
R2[i] = -0.9999;
if (R2[i] > 0.9999)
R2[i] = 0.9999;
if ((1-R2[i]) != 0)
Result[i] = .5 * log( (1+R2[i]) / (1-R2[i]) ) ;
else
Result[i] = Result[i-1];
Result[i] = Result[i] * alpha + Result[i-1] * (1-alpha) ;
}
return Result;
}
Price = 2*(H+L)/2 - Ref((H+L)/2, -1) + 0.001;
Price1 = Cycle(2*(H+L)/2 - Ref((H+L)/2, -1) + 0.001, .005); //200
Price2 = Cycle(2*(H+L)/2 - Ref((H+L)/2, -1) + 0.001, .02); //50
Price3 = Cycle(2*(H+L)/2 - Ref((H+L)/2, -1) + 0.001, .01); //100
n=5;
k=4;
SF = Prec((StochFisher(Price, n , 0.50) +
StochFisher(Price, n + k , 0.50) +
StochFisher(Price, n + 2k , 0.50) +
StochFisher(Price, n + 3k , 0.50) +
StochFisher(Price, n + 4k , 0.50) +
StochFisher(Price, n + 5k , 0.50) +
StochFisher(Price, n + 6k , 0.50) +
StochFisher(Price, n + 7k , 0.50) +
StochFisher(Price, n + 8k , 0.50) +
StochFisher(Price, n + 9k , 0.50) +
StochFisher(Price, n + 10k , 0.50) +
StochFisher(Price, n + 11k , 0.50) +
StochFisher(Price, n + 12k , 0.50) +
StochFisher(Price, n + 13k , 0.50) +
StochFisher(Price, n + 14k , 0.50) +
StochFisher(Price, n + 15k , 0.50) +
StochFisher(Price, n + 16k , 0.50) +
StochFisher(Price, n + 17k , 0.50) +
StochFisher(Price, n + 18k , 0.50) +
StochFisher(Price, n + 19k , 0.50) +
StochFisher(Price, n + 20k , 0.50) +
StochFisher(Price, n + 21k , 0.50) +
StochFisher(Price, n + 22k , 0.50) +
StochFisher(Price, n + 23k , 0.50) +
StochFisher(Price, n + 24k , 0.50) +
StochFisher(Price, n + 25k , 0.50) +
StochFisher(Price, n + 26k , 0.50) +
StochFisher(Price, n + 27k , 0.50) +
StochFisher(Price, n + 28k , 0.50) +
StochFisher(Price, n + 29k , 0.50) +
StochFisher(Price, n + 30k , 0.50) +
StochFisher(Price, n + 31k , 0.50) +
StochFisher(Price, n + 32k , 0.50) +
StochFisher(Price, n + 33k , 0.50) +
StochFisher(Price, n + 34k , 0.50) +
StochFisher(Price, n + 35k , 0.50) +
StochFisher(Price, n + 36k , 0.50) +
StochFisher(Price, n + 37k , 0.50) +
StochFisher(Price, n + 38k , 0.50) +
StochFisher(Price, n + 39k , 0.50) +
StochFisher(Price, n + 40k , 0.50) +
StochFisher(Price, n + 41k , 0.50) +
StochFisher(Price, n + 42k , 0.50) +
StochFisher(Price, n + 43k , 0.50) +
StochFisher(Price, n + 44k , 0.50) +
StochFisher(Price, n + 45k , 0.50) +
StochFisher(Price, n + 46k , 0.50) +
StochFisher(Price, n + 47k , 0.50) +
StochFisher(Price, n + 48k , 0.50) +
StochFisher(Price, n + 49k , 0.50))/50, 4);
SFA = Prec((StochFisher(Price1, n , 0.50) +
StochFisher(Price1, n + k , 0.50) +
StochFisher(Price1, n + 2k , 0.50) +
StochFisher(Price1, n + 3k , 0.50) +
StochFisher(Price1, n + 4k , 0.50) +
StochFisher(Price1, n + 5k , 0.50) +
StochFisher(Price1, n + 6k , 0.50) +
StochFisher(Price1, n + 7k , 0.50) +
StochFisher(Price1, n + 8k , 0.50) +
StochFisher(Price1, n + 9k , 0.50) +
StochFisher(Price1, n + 10k , 0.50) +
StochFisher(Price1, n + 11k , 0.50) +
StochFisher(Price1, n + 12k , 0.50) +
StochFisher(Price1, n + 13k , 0.50) +
StochFisher(Price1, n + 14k , 0.50) +
StochFisher(Price1, n + 15k , 0.50) +
StochFisher(Price1, n + 16k , 0.50) +
StochFisher(Price1, n + 17k , 0.50) +
StochFisher(Price1, n + 18k , 0.50) +
StochFisher(Price1, n + 19k , 0.50) +
StochFisher(Price1, n + 20k , 0.50) +
StochFisher(Price1, n + 21k , 0.50) +
StochFisher(Price1, n + 22k , 0.50) +
StochFisher(Price1, n + 23k , 0.50) +
StochFisher(Price1, n + 24k , 0.50) +
StochFisher(Price1, n + 25k , 0.50) +
StochFisher(Price1, n + 26k , 0.50) +
StochFisher(Price1, n + 27k , 0.50) +
StochFisher(Price1, n + 28k , 0.50) +
StochFisher(Price1, n + 29k , 0.50) +
StochFisher(Price1, n + 30k , 0.50) +
StochFisher(Price1, n + 31k , 0.50) +
StochFisher(Price1, n + 32k , 0.50) +
StochFisher(Price1, n + 33k , 0.50) +
StochFisher(Price1, n + 34k , 0.50) +
StochFisher(Price1, n + 35k , 0.50) +
StochFisher(Price1, n + 36k , 0.50) +
StochFisher(Price1, n + 37k , 0.50) +
StochFisher(Price1, n + 38k , 0.50) +
StochFisher(Price1, n + 39k , 0.50) +
StochFisher(Price1, n + 40k , 0.50) +
StochFisher(Price1, n + 41k , 0.50) +
StochFisher(Price1, n + 42k , 0.50) +
StochFisher(Price1, n + 43k , 0.50) +
StochFisher(Price1, n + 44k , 0.50) +
StochFisher(Price1, n + 45k , 0.50) +
StochFisher(Price1, n + 46k , 0.50) +
StochFisher(Price1, n + 47k , 0.50) +
StochFisher(Price1, n + 48k , 0.50) +
StochFisher(Price1, n + 49k , 0.50))/50, 4);
n=4;
k=4;
SFX = Prec((StochFisher(Price2, n , 0.50) +
StochFisher(Price2, n + k , 0.50) +
StochFisher(Price2, n + 2k , 0.50) +
StochFisher(Price2, n + 3k , 0.50) +
StochFisher(Price2, n + 4k , 0.50) +
StochFisher(Price2, n + 5k , 0.50) +
StochFisher(Price2, n + 6k , 0.50) +
StochFisher(Price2, n + 7k , 0.50) +
StochFisher(Price2, n + 8k , 0.50) +
StochFisher(Price2, n + 9k , 0.50) +
StochFisher(Price2, n + 10k , 0.50) +
StochFisher(Price2, n + 11k , 0.50) +
StochFisher(Price2, n + 12*k , 0.50))/13,4);
SFY = Prec((StochFisher(Price3, n , 0.50) +
StochFisher(Price3, n + k , 0.50) +
StochFisher(Price3, n + 2k , 0.50) +
StochFisher(Price3, n + 3k , 0.50) +
StochFisher(Price3, n + 4k , 0.50) +
StochFisher(Price3, n + 5k , 0.50) +
StochFisher(Price3, n + 6k , 0.50) +
StochFisher(Price3, n + 7k , 0.50) +
StochFisher(Price3, n + 8k , 0.50) +
StochFisher(Price3, n + 9k , 0.50) +
StochFisher(Price3, n + 10k , 0.50) +
StochFisher(Price3, n + 11k , 0.50) +
StochFisher(Price3, n + 12k , 0.50) +
StochFisher(Price3, n + 13k , 0.50) +
StochFisher(Price3, n + 14k , 0.50) +
StochFisher(Price3, n + 15k , 0.50) +
StochFisher(Price3, n + 16k , 0.50) +
StochFisher(Price3, n + 17k , 0.50) +
StochFisher(Price3, n + 18k , 0.50) +
StochFisher(Price3, n + 19k , 0.50) +
StochFisher(Price3, n + 20k , 0.50) +
StochFisher(Price3, n + 21k , 0.50) +
StochFisher(Price3, n + 22k , 0.50) +
StochFisher(Price3, n + 23k , 0.50) +
StochFisher(Price3, n + 24*k , 0.50))/25,4);
SF1 = SuperSmoother2(SF, 5);
SF2 = SuperSmoother2(SFA, 5);
SF3 = SuperSmoother2(SFX, 5);
//SF4 = SuperSmoother2(SFY, 8);
Plot(SF1 ,"Fshavg", colorBlue, styleHistogram, styleThick, Null, Null, Null, 3);
Plot(SF2 ,"FshavgRf", colorRed, styleLine, styleThick, Null, Null, Null, 2);
Plot((0.33SF1 + 0.67SF2) ,"FshCmb2", colorWhite, styleHistogram, styleThick, Null, Null, Null, 2);
Plot(SF3 ,"FshavgQ", colorBlack, styleLine, styleThick, Null, Null, Null, 6);
//Plot(SF4 ,"FshavgTH", colorBlack, styleLine, styleThick, Null, Null, Null, 3);
Plot(1 ,"", colorWhite,styleThick);
Plot(-1 ,"", colorWhite,styleThick);
Plot(2 ,"", colorYellow,styleThick);
Plot(-2 ,"", colorYellow,styleThick);
Plot(3 ,"", colorRed,styleThick);
Plot(-3 ,"", colorRed,styleThick);