Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Golden and Dead Cross for Amibroker (AFL)

Rating:
5 / 5 (Votes 3)
Tags:
amibroker, exploration, moving average

AFL explores EMA golden and dead cross.
Parameters of EMA can be modified to determine golden or dead cross.

Similar Indicators / Formulas

Advanced MA system
Submitted by kazul over 14 years ago
Wilders moving average
Submitted by meenaprem almost 14 years ago
Guppy Ultimate
Submitted by cnbondre about 14 years ago
EMA Cross
Submitted by nehal_s143 over 14 years ago
Yasu With BB
Submitted by tukinem_bbc over 14 years ago
OPENING RANGE BREAK-OUT
Submitted by cnbondre over 14 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Chart Display");
GraphXSpace = 10;
SetBarsRequired( 1,1); 
Param_systemTitle = ParamStr("System Title?","Golden and Dead Cross");
if(ParamToggle("Show System Title?","No|Yes",1))
{
	GfxSelectFont("Arial",10,600); 
	GfxSetTextColor(colorBlue);
	GfxSetBkMode(1);
	GfxTextOut(Param_systemTitle,15,25);
}
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(colorLightGrey);
SetBarFillColor( IIf( C>O, colorWhite, colorBlack ) ); 
Plot( C, "Close", ParamColor("Candle Color", colorBlack), styleCandle|styleNoTitle); 
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
//plot tool tip
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();
_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorGrey50), ParamStyle( "Style", styleHistogram | styleOwnScale, maskHistogram), 2 );
_SECTION_END();


_SECTION_BEGIN("Trading System");

///Defining Trend with Moving Average///



x=Param("Short EMA",20,1,200,1);
y=Param("Long EMA", 50,1,200,1);
EMA1= EMA(C,x);
EMA2=EMA(C,y);


goldencross= Cross(EMA1, EMA2); //moving average bullish 
deadcross= Cross(EMA2, EMA1); //moving average bearish 

_SECTION_END();


//////Defining Buy or Sell Conditions/////////
//BuyCondition 	= 	ValueWhen(PL,C)<=ValueWhen(PL,L,2) AND C>ValueWhen(PL,L,2) AND BarsSince(PL)<BarsSince(PH) AND BarsSince(PL)<=Param_buyDelay AND ValueWhen(PL,C)>=LLV(C,Param_lookbackBuy) AND IIf(MH_Buy,MH>ValueWhen(PL,MH,2),True) AND IIf(SD_Buy,SD<20,True) AND IIf(BB_Buy,BB_BuyValue,True) AND IIf(SMA_Buy,SMA_BuyValue,True) AND IIf(EMA_Buy,EMA_BuyValue,True) AND IIf(Price_Buy,C<=Price_UpperBuyValue AND C>=Price_LowerBuyValue,True) AND IIf(Volume_Buy,V>=Volume_BuyValue,True) AND IIf(RS_Buy,RS_BuyValue,True);
BuyCondition 	= goldencross  ;
//SellCondition = 	ValueWhen(PH,C)>=ValueWhen(PH,H,2) AND C<=ValueWhen(PH,H,2) AND BarsSince(PH)<BarsSince(PL) AND BarsSince(PH)<=Param_sellDelay AND ValueWhen(PH,C)<=HHV(C,Param_lookbackSell) AND 	IIf(MH_Sell,MH<ValueWhen(PH,MH,2),True) AND IIf(SD_Sell,SD>80,True) AND IIf(BB_Sell,BB_SellValue,True) AND IIf(SMA_Sell,SMA_SellValue,True) AND IIf(EMA_Buy,EMA_SellValue,True) AND IIf(Price_Sell,C<=Price_UpperSellValue AND C>=Price_LowerSellValue,True) AND 	IIf(Volume_Sell,V>=Volume_SellValue,True) AND IIf(RS_Sell,RS_SellValue,True);
SellCondition = deadcross ;


Buy = BuyCondition;
Short = SellCondition;

_SECTION_END();

_SECTION_BEGIN("Exploration");
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone),colorBlue,0,L,-25);
PlotShapes(IIf(Short,shapeSmallDownTriangle,shapeNone),colorOrange,0,H,-25);

SetOption("NoDefaultColumns",True);
bkColour = IIf(BuyCondition ,colorGreen,colorRed);
//bkColour = IIf(BuyCondition OR Cover,colorGreen,colorRed);
txtColour = colorWhite;
AddTextColumn(Name() ,"  Ticker  ",1.2,txtColour,bkColour,75);
AddTextColumn(FullName() ,"  Full Name  ",1.2,txtColour,bkColour,100);
AddColumn(DateTime(),"  Date / Time  ",formatDateTime,txtColour,bkColour,125);
AddColumn(C,"  Close  ",1.2,txtColour,bkColour,75);
AddColumn(ROC( C,1)," % Change ",1.2,txtColour,bkColour,50);
AddColumn(V,"  Volume  ",1.0,txtColour,bkColour,100);

Filter = Buy OR Short;
	AddColumn( IIf( BuyCondition, 66, 83 ), "Buy/Sell?", formatChar,txtColour,bkColour,40); 

Var = WriteIf(goldencross,"GoldenCross",WriteIf(deadcross,"DeadCross",""));
AddTextColumn( Var , "Remark", 1.2 , colorBlack, IIf( goldencross, colorLime,IIf(deadcross,colorOrange,colorWhite)),60);

_SECTION_END();

1 comments

1. Ricardo

Hi,

You can insert the formula the option to optimize and backtest?

Huges

Leave Comment

Please login here to leave a comment.

Back