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 ....
CenterOfGravity 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | // CenterOfGravity.afl // // Trading system based on John Ehlers’ // Center of Gravity Oscillator. // Quantitative Trading System - Dr. Howard B.Bandy // Cybernetic Analysis for Stocks and Futures, // Wiley, 2004. // SetTradeDelays (0,0,0,0); BuyPrice = C ; SellPrice = C ; SetBarsRequired (200, 0); function CGOscillator(Price, Length) { Result = 0; for (i=length; i< BarCount ; i++) { Num = 0; Denom = 0; for (j=0; j<Length; j++) { Num = Num + (1 + j) * Price[i-j]; Denom = Denom + Price[i-j]; } if (Denom != 0) Result[i] = 100.0 * ((-Num / Denom) + (Length + 1)/2); } return Result; } Price = ( H + L ) / 2; CGOLength = Param ( "CGOLength" , 13, 1, 250, 10); CGO = CGOscillator(Price, CGOLength); SmLength = Param ( "SmLength" , 2, 1, 20, 2); CGOSmoothed = DEMA (CGO,SmLength); Buy = Cross (CGO,CGOSmoothed); HoldDays = Param ( "HoldDays" ,6,1,10,1); Sell = Cross (CGOSmoothed, CGO) OR ( BarsSince ( Buy ) >= HoldDays); Sell = ExRem ( Sell , Buy ); e = Equity (); shape = Buy * shapeUpArrow + Sell * shapeDownArrow ; Plot ( Close , "Price" , colorBlack , styleCandle ); PlotShapes ( shape, IIf ( Buy , colorGreen , colorRed ), 0, IIf ( Buy , Low , High ) ); GraphXSpace = 5; Plot (e, "Equity" , colorRed , styleLine | styleOwnScale ); Plot (CGO, "CG Oscillator" , colorRed , styleLine | styleLeftAxisScale ); Plot (CGOSmoothed, "CGO Smoothed" , colorBlue , styleLine | styleLeftAxisScale ); //Figure 10.1 Center of Gravity |