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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | _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;