안녕하세요. 이동평균선 이 다른 이동평균선에서 만들어지는 지표를 알려주세요.
어... 요점이 보이시나요? 저것들. MA 지표는 다른 MA에 구축되어 있습니까?
설정에서 MA 기간을 늘리는 것이 더 쉽지 않습니까?)))
스무딩을 사용하는 공식을 기반으로 작성한 함수를 사용합니다.
//------------------------------------------------------------------------------------------------- void EMAOnArray(double aySource[],double& ayResult[],int iPeriod,int iCount) { double iMuver=2/(iPeriod*1.0+1); ayResult[iCount-1]=0; for(int Ex=iCount-2; Ex>=0; Ex--) { ayResult[Ex]=ayResult[Ex+1]+iMuver*(aySource[Ex]-ayResult[Ex+1]); } return; } //--------------------------------- LagMAArrayShiftToCalc ----------------------------------- // Average square-law deviation int SMAOnArray(double aySrcAk[],double& ayResult[],int iPeriod,int iCount) { double aySimple[]; ArrayResize(aySimple,iPeriod); ArrayInitialize(aySimple,0.0); double SMAValue=0; int SMAIndex=0; for (int Kx=iCount-1;Kx>=0;Kx--) { SMAValue=SMAValue-aySimple[SMAIndex]; aySimple[SMAIndex]=(aySrcAk[Kx]); SMAValue=SMAValue+aySimple[SMAIndex]; SMAIndex=MathCyclePrext(SMAIndex,1,iPeriod-1,0); ayResult[Kx]=(SMAValue/iPeriod); } return; } //------------------------------------------------------------------------------------------------- void ElasticMAOnArray(double aySource[],double& ayResult[],double iWeight,int iCount) { ayResult[iCount-1]=aySource[iCount-1]; ayResult[iCount-2]=aySource[iCount-2]; for(int Ex=iCount-2; Ex>=0; Ex--) { ayResult[Ex]=(1-iWeight)*(2.*ayResult[Ex+1]-ayResult[Ex+2])+iWeight*aySource[Ex]; } return; } //------------------------------------------ PackToCalcLMAOnArray -------------------------- // MA_Method=3: LWMA - Linear Weighted Moving Average void LWMAOnArray(double aySource[],double& ayResult[],int iPeriod,int iCount) { for (int Ax=iCount-1;Ax>=0;Ax--){ double Sum = 0; double Weight = 0; for (int Px = 0;Px < iPeriod;Px++){ Weight=Weight+ (iPeriod - Px); Sum = Sum+aySource[Ax+Px]*(iPeriod - Px); } if(Weight>0) ayResult[Ax] = Sum/Weight; else ayResult[Ax] = 0; } return; } //--------------------------------- LagMAArrayShiftToCalc ----------------------------------- // MA_Method=4: SineWMA - Sine Weighted Moving Average void SineWMAOnArray(double aySource[],double& ayResult[],int iPeriod,int iCount) { double pi = 3.1415926535; //double del = 0.5*pi/per; for (int Ax=iCount-1;Ax>=0;Ax--){ double Sum = 0; double Weight = 0; for (int Px = 0;Px < iPeriod;Px++){ Weight=Weight+ MathSin(pi*(Px+1)/(iPeriod+1)); Sum = Sum+ aySource[Ax+Px]*MathSin(pi*(Px+1)/(iPeriod+1)); } if(Weight>0) ayResult[Ax] = Sum/Weight; else ayResult[Ax] = 0; } return; } void HMA_LWMAOnArray(double aySource[],double& ayResult[],int iPeriod,int iCount) { LWMAOnArray(aySource,ayTemp1,MathFloor(iPeriod/2),iCount); LWMAOnArray(aySource,ayTemp2,iPeriod,iCount); for (int Ax=iCount-1;Ax>=0;Ax--) ayTemp1[Ax]=2.0*ayTemp1[Ax]-ayTemp2[Ax]; LWMAOnArray(ayTemp1,ayResult,MathFloor(MathSqrt(iPeriod)),iCount); return; }
예, SMAOnArray는 순환 합산 배열을 사용하여 합산 주기를 줄입니다.
//--------------------------------- MathCyclePrext ----------------------------------- // Cycle Countter to Prev or Next int MathCyclePrext ( int Index , int iIncrease , int iMaxIndex , int iMinIndex ) { Index = Index + iIncrease ; while ( Index < iMinIndex ) Index = iMaxIndex - ( iMinIndex - Index ) + 1 ; while ( Index > iMaxIndex ) Index = iMinIndex + ( Index - iMaxIndex ) - 1 ; return ( Index ) ; } //-------------------------------------------------------------------------
계속해서 low-Q 필터를 캐스케이드하고 엉덩이에 들어가세요