Colour based system for Amibroker (AFL)
konidena about 15 years ago Amibroker (AFL)
From S&C Magazine of July 2011
Indicator / Formula
Copy & Paste Friendly
_SECTION_BEGIN("colour based system");
// color chart code
Range = 10;
P2 = C;
V2 = V;
P1 = Ref( C, -Range );
V1 = Ref( V, -Range );
Color = IIf( P2 > P1 AND V2 > V1, colorGreen,
IIf( P2 > P1 AND V2 < V1, colorBlue,
IIf( P2 < P1 AND V2 < V1, colorOrange,
/*else*/ colorRed ) ) );
Plot( Volume, "Volume", Color, styleHistogram | styleThick );
// color exploration code
Filter = BarIndex() > Range;
AddColumn( P2, "P2" );
AddColumn( V2, "Vol2", 1.0 );
AddColumn( Ref( DateTime(), -Range ), "Date P1", formatDateTime );
AddColumn( P1, "P1" );
AddColumn( V1, "Vol1", 1.0 );
AddColumn( 100 * (P2-P1)/P1, "Price delta%" );
AddColumn( 100 * (V2-V1)/V1, "Vol delta%" );
AddTextColumn( "", "V2 Color", 0, colorDefault, Color );
// system code
SetTradeDelays( 1, 1, 1, 1 ); // realistic delays
SetOption("ActivateStopsImmediately", True );
BuyPrice = Open;
SellPrice = Open;
Buy = Color == colorGreen OR Color == colorBlue;
Sell = False; // only use stops for exit
ApplyStop( stopTypeTrailing, stopModePercent, 1 );
_SECTION_END();0 comments
Leave Comment
Please login here to leave a comment.