Need Help (Trend Quality)

#1
Deal all Amibroker experts

I have 2 afl: Q-indicator (Trend Quality) and B-indicator (balance) , I use both in Ami ver 6.0 / 6.1 and it running well.

But since Amibroker upgrade to version 6.2, it's produce a chart irregular (strange chart ).

Is there that needs to be changed line of code in both the afl order to run properly ?

Please help
Thanks in advance


Q-indicator (Trend Quality) :
_SECTION_BEGIN("TREND");
// Piecewise EMA is an EMA that restarts calculations each time
// the 'sincebar' argument is true
function PiecewiseEMA( array, range, sincebar )
{
factor = IIf( sincebar, 1, 2/(range+1) );
return AMA2( array, factor, 1-factor );
}
// parameters
m=4;
n=250;
// generate reversal signals based on EMA crossover rule
Lpf1 = EMA( C, 7 );
Lpf2 = EMA( C, 15 );
CrossPoint = Cross( Lpf1, Lpf2 ) OR Cross( Lpf2, Lpf1 );
Periods = BarsSince( CrossPoint );
// variable bar sum
DC = Close - Ref( Close, -1 );
CPC = Sum( DC, Periods );
// smooth CPC by piecewise 4 bar EMA
Trend = PiecewiseEMA( CPC, 4, CrossPoint );
// noise
DT = CPC - Trend;
Noise = 2 * sqrt( MA( DT^2, n ) );
// alternative 'linear' noise calculation
// Noise = 2 * MA( abs( DT ), n ) );
QIndicator = Trend/Noise;
Plot(sign(Lpf1-Lpf2), "Rev", colorRed );
Plot( Qindicator, "Qindicator", colorGreen, styleHistogram);
PlotGrid( -1 );
PlotGrid( 1 );
PlotGrid( 2 );
PlotGrid( -2 );
PlotGrid( 5 );
PlotGrid( 5);
_SECTION_END();


B-indicator (Balance Indicator) :
// Piecewise EMA is an EMA function that restarts calculations each time
// the 'sincebar' argument is true
function PiecewiseEMA( array, range, sincebar )
{
factor = IIf( sincebar, 1, 2/(range+1) );
return AMA2( array, factor, 1-factor );
//ama2( ARRAY, SMOOTHINGFACTOR, FEEDBACKFACTOR )
}
// parameters
smoothing=Param("smooth",4,0,100,1);
//m=4;
n=250;
// generate reversal signals based on EMA crossover rule
Lpf1 = EMA( C, 7 );
Lpf2 = EMA( C, 15 );
CrossPoint = Cross( Lpf1, Lpf2 ) OR Cross( Lpf2, Lpf1 );
Periods = BarsSince( CrossPoint );
// variable bar sum
DC = Close - Ref( Close, -1 );
CPC = Sum( DC, Periods );
// smooth CPC by piecewise 4 bar EMA
Trend = PiecewiseEMA( CPC, smoothing , CrossPoint );
// noise
DT = CPC - Trend;
Noise = 2 * sqrt( MA( DT^2, n ) );
// alternative 'linear' noise calculation
// Noise = 2 * MA( abs( DT ), n ) );
BIndicator = (abs(Trend)/(abs (Noise)+abs(Trend))) * 100;
Plot( Bindicator, "Bindicator", colorBrightGreen, 1);
PlotGrid( 0 );
PlotGrid( 20 );
PlotGrid( 40 );
PlotGrid( 60 );
PlotGrid( 80);
PlotGrid(100);
GraphXSpace = 3;
 

Similar threads