卡夫曼均線代碼
作者:開拓者 TB 來源:cxh99.com 發(fā)布時間:2014年12月03日
- 咨詢內(nèi)容:
系統(tǒng)自帶函數(shù)是錯誤的,正確的如下所示:
參考《精明交易者》P139- //------------------------------------------------------------------------
- // 簡稱: Kama
- // 名稱: 卡夫曼自適應(yīng)均線
- // 類別: 用戶函數(shù)
- // 類型: 用戶函數(shù)
- // 輸出: 數(shù)值型
- //------------------------------------------------------------------------
- Params
- NumericSeries price;
- Numeric fast(2);
- Numeric slow(30);
- Numeric period(20);
- Vars
- Numeric fastest;
- Numeric slowest;
- Numeric dir;
- Numeric volSum(0);
- NumericSeries barMove;
- Numeric i;
- Numeric er;
- Numeric cc;
- Numeric sc;
- NumericSeries ret;
-
- Begin
- fastest = 2 / (fast + 1);
- slowest = 2 / (slow + 1);
- dir = abs(price - price[period]);
- barMove = Abs(price - price[1]);
-
- If(CurrentBar >= period){
- for i = 0 To period - 1
- {
- volSum = volSum + barMove[i];
- }
-
- If(volSum == 0){
- er = 0;
- } else {
- er = dir / volSum;
- }
- cc = er * (fastest - slowest) + slowest;
- sc = cc ^ 2;
-
- If(CurrentBar == period){
- ret = price[1] + sc * (price - price[1]);
- } else {
- ret = ret[1] + sc * (price - ret[1]);
- }
- }
-
- return ret;
- End
- TB技術(shù)人員:
卡夫曼的確是技術(shù)分析大師
這個均線是我測試過的自適應(yīng)均線里,性能最好的
- TB客服:
本帖最后由 camedia 于 2014-9-23 22:20 編輯
NumericSeries price;
錯誤號:C0108,參數(shù)聲明的數(shù)據(jù)類型錯誤。
- 網(wǎng)友回復:
謝謝分享。。。。。