Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Zero lag EMA for Amibroker (AFL)
This AFL file is for Zero lag EMA,designed to reduce the impact of delay in technical indicators.
Indicator / Formula
_SECTION_BEGIN("Zero-Lag EMA Indicator for AmiBroker "); SetBarsRequired(100000,0); GraphXSpace = 15; SetChartOptions(0,chartShowArrows|chartShowDates); SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0))); GfxSetBkMode(0); GfxSetOverlayMode(1); SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey))); Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0); Length = Param("Length", 69, 20, 100,1 ); GainLimit = Param("Gain limit", 22, 1, 100); SetPositionSize(2,spsShares); alpha = 2 / ( Length + 1 ); iEMA = AMA( Close, alpha ); EC = Close[ 0 ]; for( bar = 0; bar < BarCount; bar++ ) { EC1 = EC; LeastError = 1e9; BestEC = 0; for( gain = -0.1 * GainLimit; gain < 0.1 * GainLimit; gain += 0.1 ) { EC = alpha * ( iEMA[ bar ] + gain * ( Close[ bar ] - EC1 ) ) + ( 1 - alpha ) * EC1; Error = abs( Close[ bar ] - EC ); if( Error < LeastError ) { LeastError = Error; BestEC = EC; } } iEC[ bar ] = BestEC; iLeastError[ bar ] = LeastError; } Plot( iEMA, "EMA", colorRed ); Plot( iEC, "EC" + _PARAM_VALUES(), colorYellow, styleThick ); Plot( C, "Close", ParamColor("Color", colorGreen ), ParamStyle("Style") | GetPriceStyle() ); // strategy rules Buy = Cross( iEC, iEMA ); Sell = Cross( iEMA, iEC ); Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); Short=Sell; Cover=Buy; BuyPrice=ValueWhen(Buy,C); SellPrice=ValueWhen(Sell,C); ShortPrice=ValueWhen(Short,C); CoverPrice=ValueWhen(Cover,C); Title = EncodeColor(colorWhite)+ "ZL EMA code from www.marketcalls.in" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) + " - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+ "Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+ EncodeColor(colorLime)+ WriteIf (Buy , " GO LONG / Reverse sig at "+C+" ","")+ WriteIf (Sell , " EXIT LONG / Reverse sig at "+C+" ","")+"\n"+EncodeColor(colorYellow)+ WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+ WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"",""); PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40); PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50); PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40); PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50); PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
6 comments
Leave Comment
Please login here to leave a comment.
Back
ERROR
errors continue to remain, I was able to partially fix it by deleting these lines of code, but code still remains partial
// if( Error < LeastError ) { // LeastError = Error;//Error = abs( Close[ bar ] – EC );
Code is good but very slow to calcolate functions so backtesting is very slow
AGAIN ERROR
Hi! It is corrected AFL code by APOLLOBIN not include Error.
errorrs. I think continuous errors of tabulation; i only succeed to make work this afl only deleting the 3 lines posted: //Error = abs( Close[ bar ] – EC );
// if( Error < LeastError ) { // LeastError = Error;