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 ....
Alan Hull's ActVest Tradestation formula for Amibroker (AFL)
Copy & Paste Friendly
Back
Find the linear regression value in Weekly // *** RANGE *** // Alan Hull's ActVest Tradestation formula converted to AmiBroker // Note this is the old version; His latest (unpublished) version has a slightly higher CC and some other slight variations. SetChartOptions(0,chartShowArrows|chartShowDates); //_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) )); TimeFrameSet(inWeekly); //Use weekly data // Central Cord - Find the Highest linear regression value in 13 to 52 week range i = 52; CC = 0; while (i > 12) { LR = LinearReg(C, i); CC = Max(CC, LR); i = i-1; } //Boundary displacement // 23.6%, 38.2%, 50.0%, 61.8%, 100%, 161.8%, 261.8% and 423.6% // dodatek //MoveUP = 2.618 * CC * ATR(52)/MA(C,52); // ory //MoveDown = 2.618 * CC * ATR(52)/MA(C,52); // ory //MoveUP = 1.618 * CC * ATR(52)/EMA(C,52); //MoveDown = 1.618 * CC * ATR(52)/EMA(C,52); MoveUP = 1.618 * CC * ATR(52)/WMA(C,52); MoveDown = 1.618 * CC * ATR(52)/WMA(C,52); // Upper deviation UD = CC + MoveUp; // Lower deviation LD = CC - MoveDown; for (i = 1; i < BarCount; i++ ) { if (LD[i] < LD[i-1]) // if falling LD[i] = LD[i-1]; // then hold value if (LD[i] >= CC[i]) // if collides with descending central cord LD[i] = CC[i]; // then follow central cord } // Now plot it all Plot(C, "", colorBlack, styleCandle); Plot(UD,"\nUpper deviation",colorGreen,1); Plot(CC,"Central Cord",colorBlue,1); Plot(LD,"Lower deviation",colorRed,1); TimeFrameRestore();