I think I managed to figure out a work around. Basically I don't apply an outlier filter in the loop until (i + 1) > Period.
--- In [email protected], reinsley <[EMAIL PROTECTED]> wrote: > > Hello, > > I don't understand AFL code, but your indicator looks like this one > without loop. > > //priceOscillator > > priceOscillator = EMA( C, 39 ) - EMA( C, 189 ) ; > Plot( 0, "", colorBlack, 4 ); > up = IIf( LastValue( priceOscillator ) <= Ref( LastValue( > priceOscillator ), -1 ), 1, 0 ); > down = IIf( priceOscillator >= Ref( priceOscillator , -1 ), 0, 1 ); > _TRACE( "up = " + up + " down = " + down ); > Title = "PriceOscillator - " + Name() + "[PrOsc 39 , 189= " + WriteVal( > priceOscillator, 4.2 ) + ""; > Plot(priceOscillator,"",IIf(priceOscillator >=0, colorGreen, colorRed),4); > > > Best regards > > searnp a écrit : > > > > Problem: > > When I implement the code below in Amibroker, /sometimes/ the output > > slightly changes value and/or flatlines to one value on the chart when > > I am scrolling across the chart (in less than maximum zoom out, while > > looking carefully as I scroll). Yet when I zoom out completely to look > > across all the data on the chart, the line and values look fine. Note, > > I only have this problem with an Open, High, Low, or Close array (the > > volume array does not seem to be affected by this problem). > > > > What am I doing wrong? What is going on? Is it just a visual thing?/ > > > > /Thanks./ > > / > > _CODE_: > > > > // Parameters > > Period = 15; > > Input = Close; > > SF = 2 / (Period + 1); > > > > // Initialization of first and second values prior to start of loop > > NInput[0] = Input[0]; MMA[0] = Input[0]; STD[0] = Null; > > NInput[1] = Input[1]; MMA[1] = (Input[1] + Input[0]) / 2; > > STD[1] = (((Input[1] - MMA[1]) ^ 2 + (Input[0] - MMA[1]) ^ 2) / 2) ^ > > (1/2); > > > > for( i = 2; i < BarCount; i++ ) > > { > > > > // Normalize input to mitigate outliers > > NInput[i] = IIf(Input[i] >= MMA[i-1], Min(Input[i], MMA[i-1] + 3 * > > STD[i-1]), Max(Input[i], MMA[i-1] - 3 * STD[i-1])); > > > > // Moving average from normalized input > > MMA[i] = SF * NInput[i] + (1 - SF) * MMA[i-1]; > > > > // Moving standard deviation from normalized input > > STD[i] = (SF * (NInput[i] - MMA[i]) ^ 2 + (1 - SF) * (STD[i-1]) ^ > > 2) ^ (1/2); > > > > } > > > > Plot( MMA, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), > > ParamStyle("Style") ); > > >
