Gaussain MA
Gaussian Moving Average (MA) is a smoothing indicator used to reduce noise in price data. Traders can employ Amibroker AFL to create Gaussian MA indicators that calculate the average of prices based on a Gaussian distribution. Integration with Amibroker data feed ensures real-time application of this indicator for smoother price analysis and trend identification.
/_SECTION_BEGIN("GSMA"); SetBarsRequired(500,0); PI = 3.1415926; period=Param("period",15,1,40,1); //A=C-Ref(C,-T1); //a[0]=C[0]; function IIR2( input, f0, f1, f2 ) { result[ 0 ] = input[ 0 ]; result[ 1 ] = input[ 1 ]; for( i = 10; i < BarCount; i++ ) { result[ i ] = f0 * input[ i ] + f1 * result[ i - 1 ] + f2 * result[ i - 2 ]; } return result; } function GSMA( input, Period ) { N = 0; an = 2 * PI / Period; c0 = b0 = 1; c1 = b1 = b2 = a1 = a2 = gamma1 = 0; beta1 = 2.415 * ( 1- cos( an ) ); alpha = -beta1 + sqrt( beta1 ^ 2 + 2 * beta1 ); alpha1 = ( cos( an ) + sin( an ) - 1 )/cos( an ); { fo = alpha ^ 2; f1 = 2 * ( 1- alpha ); f2 = -( 1 - alpha )*( 1 - alpha ); } return IIR2( input, fo,f1,f2); } period=Param("period",15,1,40,1); Plot( gsma(C,period), "Gaussian MA", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); PlotOHLC( O,H,L,C, "" + Name(), IIf(C>Ref(C,-1),colorGreen,colorRed), styleBar | styleNoLabel|styleThick ); _SECTION_END();