um... do you see the point in this? i.e. is the MA indicator built on a different MA?
wouldn't it be easier to increase the period in the MA settings?)))
MA from MA - you get a smoother curve...
the graph below shows three curves
yellow is the initial period of the MA
blue is MA from MA
and the pink one is MA with the period twice as long as the initial one
this indicator shows the difference of MA: MA[x]-MA[x+n] (ROC)
you can see that the double MA has a smoother curve
um... do you see the point in this? i.e. is the MA indicator built on a different MA?
wouldn't it be easier to increase the period in the MA settings?)))
my thoughts...my thoughts)
//------------------------------------------------------------------------------------------------- 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; }
>> Thank you!
yes also SMAOnArray uses a cyclic summing array to reduce summing cycles
//--------------------------------- 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); } //-------------------------------------------------------------------------
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use