[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] In April of 2004 there was a "Q indicator" and "B indicator" published



PureBytes Links

Trading Reference Links

*******************************************************************************************************

mleonsprint <mleonsprint@xxxxxxxxx> wrote:


Does anyone have the code for the "B indicator"? I saw the code for
the "Q indicator" but I didn't see the "B indicator", was hoping maybe
someone has coded it up?

Thanks for your help
Mark

*****************************************************************
Hi ,

/*AMIBROKER: TREND-QUALITY-BALANCE INDICATOR 
In "Trend-Quality Indicator" in this issue, David Sepiashvili presents an innovative trend-detection tool -- the trend-quality indicator -- that attempts to estimate the trend in relation to noise. 
Calculations presented in the article can be easily reproduced using AmiBroker Formula Language. The only tricky part is a piecewise exponential moving average that restarts the calculations on every moving average crossover, but we managed to implement it in two lines of code, thanks to AmiBroker's powerful Ama2 function, which allows easy implementation of all kinds of single-order infinite impulse response filters. 
Listing 1 shows ready-to-use indicator code to plot the Q-indicator. In AmiBroker, select Indicator Builder from the Analysis
 menu, click the "Add" button, enter the formula, and then press "Apply." Figure 3 shows a sample chart. 
reproduces the chart presented in Sepiashvili's article.
LISTING 1
*/
// 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", colorDarkGreen, 1);
PlotGrid( 0 );
PlotGrid( 20 );
PlotGrid( 40 );
PlotGrid( 60 );
PlotGrid( 80);
PlotGrid(100);
//--Tomasz Janeczko, AmiBroker.com 
GraphXSpace = 3;
****************************************
The above is trend Noise balance:
*****************************************
 The below is trend Quality:
*AMIBROKER: TREND-QUALITY INDICATOR 
In "Trend-Quality Indicator" in this issue, David Sepiashvili presents an innovative trend-detection tool -- the trend-quality indicator -- that attempts to estimate the trend in relation to noise. 
Calculations
 presented in the article can be easily reproduced using AmiBroker Formula Language. The only tricky part is a piecewise exponential moving average that restarts the calculations on every moving average crossover, but we managed to implement it in two lines of code, thanks to AmiBroker's powerful Ama2 function, which allows easy implementation of all kinds of single-order infinite impulse response filters. 
Listing 1 shows ready-to-use indicator code to plot the Q-indicator. In AmiBroker, select Indicator Builder from the Analysis menu, click the "Add" button, enter the formula, and then press "Apply." Figure 3 shows a sample chart. 
reproduces the chart presented in Sepiashvili's article.
 
*AMIBROKER: TREND-QUALITY INDICATOR 
In "Trend-Quality Indicator" in this issue, David Sepiashvili presents an innovative trend-detection tool -- the trend-quality indicator -- that attempts to estimate the trend in relation to noise. 
Calculations presented in the article can be easily reproduced using AmiBroker Formula Language. The only tricky part is a piecewise exponential moving average that restarts the calculations on every moving average crossover, but we managed to implement it in two lines of code, thanks to AmiBroker's powerful Ama2 function, which allows easy implementation of all kinds of single-order infinite impulse response filters. 
Listing 1 shows ready-to-use indicator code to plot the Q-indicator. In AmiBroker, select Indicator Builder
 from the Analysis menu, click the "Add" button, enter the formula, and then press "Apply." Figure 3 shows a sample chart. 
reproduces the chart presented in Sepiashvili's article.
LISTING 1
*/
// 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 ) );
QIndicator = Trend/Noise;
sign = IIf(Lpf1>Lpf2,1,-1);
Plot(sign/*(Lpf1-Lpf2)*/, "Rev", colorRed );
Plot( Qindicator, "Qindicator", colorBrightGreen, styleHistogram);
PlotGrid( -1 );
PlotGrid( 1 );
PlotGrid( 2 );
PlotGrid( -2 );
PlotGrid( 5 );
PlotGrid(-5);
//--Tomasz Janeczko, AmiBroker.com 
GraphXSpace = 5;
 
Have fun ,


Warm regards,
Natasha !
 
Visit The Doll Palace [Where Cartoon Dolls Live]


Do you Yahoo!?
Yahoo! Search presents - Jib Jab's 'Second Term'

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Yahoo! Groups Sponsor
ADVERTISEMENT


Yahoo! Groups Links

GIF image