hareketli ortalamadan hareketli ortalama
uh... buradaki noktayı anlıyor musun? onlar. MA göstergesi başka bir MA üzerine mi kurulu?
Ayarlardan MA süresini artırmak daha kolay değil mi?)))
MACD'yi deneyin.
MA'dan MA - daha yumuşak bir eğri elde edilir..
Aşağıdaki grafik üç eğriyi göstermektedir
sarı MA'nın ilk dönemidir
mavi MA'dan MA'dır
ve pembe, başlangıç döneminden 2 kat daha uzun bir süreye sahip MA'dır.
bu gösterge MA arasındaki farkı gösterir: MA[x]-MA[x+n] (ROC)
çift MA'nın daha yumuşak bir eğriye sahip olduğu görülebilir
//------------------------------------------------------------------------------------------------- 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; }
evet, SMAOnArray, toplama döngülerini azaltmak için döngüsel bir toplama dizisi kullanır
//--------------------------------- 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 ) ; } //-------------------------------------------------------------------------
