Skip to main content

AO optimize for Amibroker (AFL)

reizeal almost 12 years ago Amibroker (AFL)

  • Rating:
    4 / 5 (Votes 3)
  • Tags:
    oscillator, trading system, amibroker

AO indicators from Bill Williams with optimization
submitted by reizeal

Screenshots

Indicator / Formula

Copy & Paste Friendly
/*
Signal:
1. Saucer
When the AO bars above the zero line, buy when the bars change from red to green. need 3 bars for confirmation. 
place buy stop one tick above the high from the signal bar 
2. AO Cross
when the AO bars cross the zero line.
3. Twin Peaks
the first peak must be higher than the second peak. buy when the bars change to green. 
*/


_SECTION_BEGIN( "AO" );
AOFast	= MA( ( H + L ) / 2, 5 );
AOSlow	= MA( ( H + L ) / 2, 34 );
AO 		= AOFast - AOSlow;
UB 		= AO > Ref( AO, -1 );
DB		= AO < Ref( AO, -1 );
ClrBar	= IIf( UB, ParamColor( "AO Up", colorGreen ), IIf( DB, ParamColor( "AO Down", colorRed ), colorGrey40 ) );
Plot( AO, "AO", ClrBar, styleHistogram );

SoucerUp	= Ref( AO, -2 ) > Ref( AO, -1 ) AND Ref( AO, -1 ) < AO;
SoucerDn	= Ref( AO, -2 ) < Ref( AO, -1 ) AND Ref( AO, -1 ) > AO;
SoucerBuy	= SoucerUp AND ( AO > 0 AND Ref( AO, -1 ) > 0 AND Ref( AO, -2 ) > 0 );
SoucerSell	= SoucerDn AND ( AO < 0 AND Ref( AO, -1 ) < 0 AND Ref( AO, -2 ) < 0 );

CrossBuy	= AO > 0 AND Ref( AO, -1 ) < 0;
CrossSell	= AO < 0 AND Ref( AO, -1 ) > 0;

LatestLPeak	= IIf( AO < 0, Ref( LowestSince( CrossSell, AO, 1 ), -1 ), 0 );
TwinPeaksBuy	= AO < 0 AND Ref( DB, -1 ) AND UB AND Ref( AO, -1 ) > LatestLPeak;
LatestLPeak	= IIf( TwinPeaksBuy, Ref( AO, -1 ), LatestLPeak );
LatestHPeak	= IIf( AO > 0, Ref( HighestSince( CrossBuy, AO, 1 ), -1 ), 0 );
TwinPeaksSell	= AO > 0 AND Ref( UB, -1 ) AND DB AND Ref( AO, -1 ) < LatestHPeak;
LatestHPeak	= IIf( TwinPeaksSell, Ref( AO, -1 ), LatestHPeak );

SuperAOBuy		= Ref( DB, -3 ) AND Ref( UB, -2 ) AND Ref( UB, -1 ) AND UB;
SuperAOSell	= Ref( UB, -3 ) AND Ref( DB, -2 ) AND Ref( DB, -1 ) AND DB;

Buy			= SoucerBuy OR CrossBuy;
Sell		= SoucerSell OR CrossSell;

PlotShapes( IIf( SoucerBuy, shapeDigit1, 0 ), colorBlue, 0, 0, -12 );
PlotShapes( IIf( SoucerSell, shapeDigit1, 0 ), colorOrange, 0, 0, 12 );
PlotShapes( IIf( CrossBuy, shapeDigit2, 0 ), colorBlue, 0, 0, -12 );
PlotShapes( IIf( CrossSell, shapeDigit2, 0 ), colorOrange, 0, 0, 12 );
PlotShapes( IIf( TwinPeaksBuy, shapeDigit3, 0 ), colorBlue, 0, 0, 12 );
PlotShapes( IIf( TwinPeaksSell, shapeDigit3, 0 ), colorOrange, 0, 0, -12 );
PlotShapes( IIf( SuperAOBuy, shapeDigit4, 0 ), colorBlue, 0, 0, 12 );
PlotShapes( IIf( SuperAOSell, shapeDigit4, 0 ), colorOrange, 0, 0, -12 );
PlotShapes( IIf( AO > Ref( HHV( AO, 140 ), -1 ), shapeSmallCircle, 0 ), ParamColor( "HHV AO", colorGold ), 0, 0, 0 );
Plot( Ref( HHV( AO, 140 ), -1 ), "HHV AO-140", colorGold, stylehidden );
_SECTION_END();

0 comments

Leave Comment

Please login here to leave a comment.