Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Another Trail for Amibroker (AFL)
I adjusted code from a recent posting by Gopal titled: “NMA v 3.6 a optimiser” which is written by M.Karthik.
My adjustment code displays the trail using colors and allows the bull and bear parameter to be set separately. Further I use similar code and in my other trail postings. Also I removed the signals. This code simply shows the trend.
Screenshots
Similar Indicators / Formulas
Indicator / Formula
function trail_func(jj,trBull,trBear) { trailArray[ 0 ] = jj[ 0 ]; // initialize for( i = 1; i < BarCount; i++ ) { prev = trailArray[ i - 1 ]; if (jj[ i ] > prev AND jj[ i - 1 ] > prev) { trailArray[ i ] = Max(prev,jj[ i ] - trBull[ i ]); } else if (jj[ i ] < prev AND jj[ i - 1 ] < prev) { trailArray[ i ] = Min(prev,jj[ i ] + trBear[ i ]); } else if (jj[ i ] > prev) { trailArray[ i ] = jj[ i ] - trBull[ i ]; } else { trailArray[ i ] = jj[ i ] + trBear[ i ]; } } return trailArray; } // code by E.M.Pottasch // adjusted from M.Kartnik // following: http://wisestocktrader.com/indicators/1710-nma-v-3-6-a-optimiser k_bull = Param("mult bull",1.25,1,4,0.05); k_bear = Param("mult bear",1.25,1,4,0.05); Per= Param("period",10,5,50,1); HaClose=(O+H+L+C)/4; HaOpen = AMA(Ref(HaClose,-1),0.5); HaHigh = Max(H,Max( HaClose,HaOpen)); HaLow = Min(L,Min(HaClose,HaOpen)); ms=ParamList("ST0P/REV",List="Reg|Smoothed",0); if(ms=="Reg") { nm =(H-L); j=(O+H+L+C)/4; } else { nm=(HaHigh-HaLow); j=(HaOpen+HaHigh+HaLow+HaClose)/4; } rfsctor = WMA(nm,PER); revers_bull=k_bull*rfsctor; revers_bear=k_bear*rfsctor; nw = trail_func(j,revers_bull,revers_bear); GraphXSpace = 5; SetChartOptions(0, chartShowDates); Plot( Close, "\nPrice", colorWhite, styleCandle ); Plot(IIf(NW > j,NW,Null),"\ntrailShort",ParamColor("ColorTrailShort",ColorRGB(255,0,0)),styleStaircase); Plot(IIf(NW < j,NW,Null),"\ntrailLong",ParamColor("ColorTrailLong",ColorRGB(0,255,0)),styleStaircase);
9 comments
Leave Comment
Please login here to leave a comment.
Back
hi can u put the buy and sell arrows in it thx
see link in code for the original code. This code contains signals. It all depends how you want to trade, either pullbacks within the trend or at the point the trend changes.
Hi empottasch,
I have a system that gives entries and exits and I want to use this code just as trail and maybe as a trend filter as well. Can you please tell me how to do that?
Thanks,
Rafael
Hi empottasch,
I have a system that gives entries and exits and I want to use this code just as trail and maybe as a trend filter as well. Can you please tell me how to do that?
Thanks,
Rafael
for your filter question you can use (in case of Long trades) for example:
trendLong = IIf(NW < j,NW,Null);
so if you have your buy signals defined as:
Buy = your buy signal definition;
you add:
Buy = your buy signal definition AND !IsEmpty(trendLong);
to use it as a trail there are many ways to do this. Simple example is e.g. in the Long case:
Buy = your buy signal definition;
Sell = your sell signal definition OR Cross(NW,j);
I used this code also to define trend channels, see: http://www.youtube.com/watch?v=HWPSqwEkN64
hi empottash,
could you plz suggest me an afl formula with indicators .i actually need it with mano calculation
Sir this afl is not working in an hourly charts. Can u pls suggest if we can use this in hourly charts or not.
should work in any timeframe. It works for me with hourly charts with no problem.