AMIBROKER AFL is simple MY TREND FOLLOW STRATEGY AFL
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
trendup = IIf(MACD(12,26) > 0 AND MACD(12,26) > Signal(12,26,9), colorGreen, colorWhite);
trendcolor = IIf(MACD(12,26) < 0 AND MACD(12,26) < Signal(12,26,9), colorRed, trendup);
Plot( C, "Close", trendcolor, styleCandle | styleThick );
sp = Param( "RSI Period", 7, 1, 100 );
r = RSI( sp );
RSIup = r > 70;
RSIdown = r < 30;
shape = RSIup * shapeNone + RSIdown * shapeNone;
PlotShapes(shape, IIf( RSIup, colorBrightGreen, colorRed ), 0, IIf( RSIup, Low, High ) );
if( ParamToggle("Tooltip shows", "All Values | Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}
_SECTION_END();
DayH = TimeFrameGetPrice("H", inDaily, -1)*(1+0.0005); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1)*(1-0.0005); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
YHL = ParamToggle("Yesterday HI LO","Hide|Show",1);
if(YHL==1) {
}
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorBrightGreen) );
Hor=Param("Horizontal Position",940,1,1200,1);
Ver=Param("Vertical Position",12,1,830,1);
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True );
GfxSetBkMode( colorBlack );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+45 );
_SECTION_END();
DayH = TimeFrameGetPrice("H", inHourly, -1); DayHI = LastValue (DayH,1);// hourly high
DayL = TimeFrameGetPrice("L", inHourly, -1); DayLI = LastValue (DayL,1); // hourly low
DayC = TimeFrameGetPrice("C", inHourly, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inHourly); // current day open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
YHL = ParamToggle("Yesterday HI LO","Hide|Show",1);
if(YHL==1) {
}
_SECTION_BEGIN("MOHAN CROSSOVER");
P = ParamField("Price field",-1);
Periods1 = Param("Periods1", 5, 2, 300, 1, 10 );
Periods2 = Param("Periods2", 20, 2, 300, 1, 10 );
Plot( MA( P, Periods1 ), StrFormat(_SECTION_NAME()+"(%g)", Periods1), ParamColor( "Color1", colorRed ), ParamStyle("Style") );
Plot( MA( P, Periods2 ), StrFormat(_SECTION_NAME()+"(%g)", Periods2), ParamColor( "Color2", colorBlue ), ParamStyle("Style") );
Buy = Cross( MA( P, Periods1 ), MA( P, Periods2 ) );
Sell = Cross(MA( P,Periods2 ), MA( P, Periods1 ) );
Display= ParamToggle("Display","Off|On",0);
PlotOHLC( Null,MA( P, Periods1 ),MA( P, Periods2 ),Null, "", IIf(MA( P, Periods1 )>MA( P, Periods2 ) ,colorDarkGreen,colorDarkRed), styleCloud);
Color = IIf( MA(p,periods1) > MA(p,periods2) , colorLime, IIf( MA(p,periods2) > MA(p,periods1), colorRed, colorGrey50 ));
Plot( 1, "", Color, styleArea | styleOwnScale | styleNoLabel, -0.1, 30 );
_SECTION_BEGIN("EMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
_SECTION_BEGIN("MOHAN MACD");
r = Param( "TSI period 'R':", 7, 1, 100, 1 );
s = Param( "TSI period 'S':", 27, 1, 100, 1 );
u = Param( "TSI period 'U':", 1, 1, 100, 1 );
sig = Param( "Signal period:", 7, 1, 100, 1 );
Mtm = C - Ref ( C, -1 );
AbsMtm = abs ( Mtm );
Num_T = EMA ( EMA( EMA ( Mtm, r ), s ), u );
Den_T = EMA ( EMA( EMA ( AbsMtm, r ), s ), u);
TSI = 100 * Nz ( Num_T / Den_T );
TSIL = 100 * Nz ( Num_T / Den_T );
//Green TSIL Line=Rising; Red TSIL Line=Falling
col = IIf( TSIL > Ref( TSIL, -1 ), colorGreen, colorRed );
//Plot( TSIL, "TSI("+r+","+s+","+u+")", col, styleLine | styleThick);
//Green EMA TSI,sig Line=Rising; Red EMA TSI,sig Line=Falling
col = IIf( EMA(TSI,sig) > Ref( EMA(TSI,sig), -1 ), colorGreen, colorRed );
//Plot( EMA(TSI,sig), "", col, styleThick);
Histcol= IIf(TSI>0,colorLime,colorRed) ;
//Plot( TSI, "", histcol, ParamStyle("Histogram style", styleThick |styleHistogram | styleNoLabel, maskHistogram ) );
//Plot(0,"",ParamColor( "ColorZero", colorBrown ),styleLine);
//Title = "MOHAN MACD";
_SECTION_END();
_SECTION_BEGIN("MACDval");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
dynamic_color = IIf( MACD() > 0, colorGreen, colorRed);
MACD_trend = IIf( MACD() >= 0, 0.5, -0.5);
//Plot( 2, "ribbon",IIf( MACD_trend>=0, colorLime, colorRed ), styleOwnScale|styleArea|styleNoLabel, 0, 100 );
No comments:
Post a Comment
Thanks