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 ....
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
ITrend for Amibroker (AFL)
Copy & Paste Friendly
Back
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 | //---------------------------------------------------------- SetBarsRequired (20000,20000); function ITrend(array, alpha) { // Choose One Of the initialization : // No pre-filter : it = array; // Pre-initialize its first value and after it converge to "array" value during main recursion (so act like no pre-Filter after some times) //it = (array[2] - 2*array[1] + array[0])/4; //This initialization takes a long time to converge. // Pre-filter with classic triangular MA it = (array + Ref (array, -1) * 2 + Ref (array, -2))/4; factor = (alpha - alpha^2/4) + 5*alpha^2 - (alpha - .75*alpha^2) + 2*(1 - alpha) - (1 - alpha)^2; for (i = 4; i < BarCount ; i++) { it[i] = (alpha - alpha^2/4)*array[i] + 5*alpha^2*array[i-1] - (alpha - .75*alpha^2)*array[i-2] + 2*(1 - alpha)*it[i-1] - (1 - alpha)^2*it[i-2]; it[i] = it[i]/factor; } return it; } P = ParamField ( "Price field" ,-1); alpha = Param ( "Alpha" , 0.3, 0, 1, 0.01 ); data = ITrend(P, alpha); Plot ( data, "ITrend" , ParamColor ( "Color ITrend" , colorCycle ), ParamStyle ( "Style" ) ); //---------------------------------------------------------- |