AMIBROKER, TRADING DIVERGENCES. Here is a sample AmiBroker chart demonstrating the RSI(14) overlay (lower pane) and five-day SVAPO
LISTING 1: Zero-lag moving average
function ZeroLagMA( data, periods )
{
EMA1 = EMA( data, periods );
EMA2 = EMA( EMA1, periods );
Diff = EMA1 - EMA2;
return EMA1 + Diff;
}
Periods = Param("Periods", 20, 2, 100 );
Plot( ZeroLagMA( Close, Periods ), "ZeroLagMA-"+Periods, colorRed );
LISTING 2: SVAPO price-only
// input parameters
Period = Param("SVAPO period", 8, 2, 20, 1 );
CutOff = Param("Min. % price change", 1, 0, 10, 0.1 );
devH = Param("Std. Dev High", 1.5, 0.1, 5, 0.1 );
devL = Param("Std. Dev Low", 1.3, 0.1, 5, 0.1 );
StDevPer = Param("Std. Dev. Period", 100, 1, 200, 1 );
// heikin-ashi smoothing
Av4 = (O+H+L+C)/4;
HaOpen = AMA( Ref( Av4, -1 ), 0.5 );
HaCl = ( Av4 + HaOpen + Max( Av4, Max( H, HaOpen ) ) + Min( Av4, Min( L, HaOpen ) ) ) / 4;
HaC = TEMA( HaCl, period/1.6 );
// medium term MA of volume to limit extremes
Vave = Ref( MA( C, period * 5 ), -1 );
// basic trend
Vtr = TEMA( LinRegSlope( C, period ), period );
HaCLimitUp = Ref( HaC, -1 ) * (1 + Cutoff/1000);
HaCLimitDn = Ref( HaC, -1 ) * (1 - Cutoff/1000);
// SVAPO result of price only
SVAPOSum = Sum( IIf( ( HaC > HaCLimitUp ) AND Hold( Vtr >= Ref( Vtr,-1 ), 2 ), C,
IIf( ( HaC < HaCLimitDn ) AND Hold( Vtr > Ref( Vtr, -1 ), 2 ), -C, 0 ) ), period );
SVAPO = TEMA( SVAPOSum / (Vave+1), period );
PlotGrid( 0 );
Plot( SVAPO, "SVAPO", colorBlue, styleThick );
Plot( devH * StDev( SVAPO, StDevPer ), "Up", colorGreen );
Plot( -devL * StDev( SVAPO, StDevPer ), "Dn", colorRed );
LISTING 3: Trailing stop reversal
stop = Param("Trailing Stop", 7, 0, 20 );
trail = Null;
for( i = 1; i < BarCount; i++ )
{
prev = trail[ i - 1 ];
Cur = 0;
if( prev == C[ i ] )
Cur = prev;
else
if( C[ i - 1 ] < prev AND C[ i ] < prev )
Cur = Min( prev, C[ i ] * ( 1 + stop/100 ) );
else
if( C[ i - 1 ] > prev AND C[ i ] > prev )
Cur = Max( prev, C[ i ] * ( 1 - stop/100 ) );
else
if( C[ i ] > prev )
Cur = C[ i ] * ( 1 - stop/100 );
else
Cur = C[ i ] * ( 1 + stop/100 );
trail[ i ] = Cur;
}
Plot( C, "Price", colorBlack );
Plot( trail, "Trailstop", colorRed );
1 comment:
Good post and Smart Blog
Thanks for your good information and i hope to subscribe and visit my blog STD Symptoms and more Syphilis Pictures thanks again admin
Post a Comment