大伊人青草狠狠久久-大伊香蕉精品视频在线-大伊香蕉精品一区视频在线-大伊香蕉在线精品不卡视频-大伊香蕉在线精品视频75-大伊香蕉在线精品视频人碰人

您現(xiàn)在的位置:程序化交易>> 期貨公式>> 交易開拓者(TB)>> 開拓者知識>>正文內(nèi)容

AMA策略 [開拓者 TB]

  • 咨詢內(nèi)容: 本帖最后由 duck_arrow 于 2013-10-16 17:15 編輯

    Adaptive Moving Average System by Perry Kaufman


    The adaptive moving average that was discussed in the interview with Perry Kaufman in the 1998 STOCKS & COMMODITIES Bonus Issue (the article originally appeared in March 1995) is an excellent alternative to standard moving average calculations. In this month's Traders' Tips, I will present two Easy Language studies and an Easy Language system that are based on the adaptive moving average.

    The adaptive moving average calculation that is used in the studies and system in TradeStation or SuperCharts is performed primarily by a function referred to as "AMA." Another function referred to as "AMAF" is used to calculate the adaptive moving average filter. As always, the functions should be created prior to the development of the studies/system.







    Type: Function, Name: AMA
    Inputs: Period(Numeric);
    Vars: Noise(0), Signal(0), Diff(0), efRatio(0), Smooth(1), Fastest(.6667), Slowest(.0645), AdaptMA(0);
    Diff = AbsValue(Close - Close[1]);
    IF CurrentBar <= Period Then AdaptMA = Close;
    IF CurrentBar > Period Then Begin
    Signal = AbsValue(Close - Close[Period]);
    Noise = Summation(Diff, Period);
    efRatio = Signal / Noise;
    Smooth = Power(efRatio * (Fastest - Slowest) + Slowest, 2);
    AdaptMA = AdaptMA[1] + Smooth * (Close - AdaptMA[1]);
    End;
    AMA = AdaptMA;




    Type: Function, Name: AMAF
    Inputs: Period(Numeric), Pcnt(Numeric);
    Vars: Noise(0), Signal(0), Diff(0), efRatio(0), Smooth(1), Fastest(.6667), Slowest(.0645), AdaptMA(0), AMAFltr(0);
    Diff = AbsValue(Close - Close[1]);
    IF CurrentBar <= Period Then AdaptMA = Close;
    IF CurrentBar > Period Then Begin
    Signal = AbsValue(Close - Close[Period]);
    Noise = Summation(Diff, Period);
    efRatio = Signal / Noise;
    Smooth = Power(efRatio * (Fastest - Slowest) + Slowest, 2);
    AdaptMA = AdaptMA[1] + Smooth * (Close - AdaptMA[1]);
    AMAFltr = StdDev(AdaptMA-AdaptMA[1], Period) * Pcnt;
    End;
    AMAF = AMAFltr;




    The "MovAvg Adaptive Fltr" system below is based on the rules set forth for entries based on the filtered adaptive moving average calculation.

    Type: System, Name: Adaptive Moving Average Fltr System
    Inputs: Period(10), Pcnt(.15);
    Vars: AMAVal(0), AMAFVal(0), AMALs(0), AMAHs(0);
    AMAVal = AMA(Period);
    AMAFVAl = AMAF(Period, Pcnt);
    IF CurrentBar = 1 Then Begin
    AMALs = AMAVal;
    AMAHs = AMAVal;
    End Else Begin
    IF AMAVal < AMAVal[1] Then
    AMALs = AMAVal;
    IF AMAVal > AMAVal[1] Then
    AMAHs = AMAVal;
    IF AMAVal - AMALs Crosses Above AMAFVal Then
    Buy This Bar on Close;
    IF AMAHs - AMAVal Crosses Above AMAFVal Then
    Sell This Bar on Close;
    End;




    The second indicator, "Mov Avg Adaptive Fltr," takes the filtering concept and applies it to an indicator. Based on the filtered adaptive moving average (AMAF) parameters, this indicator will plot a vertical blue or red line, depending on the condition that is met. The values reflected by the vertical lines reflect the value of the AMA filter calculation. Some suggested format settings are given after the indicator code.





    Type: Indicator, Name: Adaptive Moving Average Fltr System
    Inputs: Period(10), Pcnt(.15);
    Vars: AMAVal(0), AMAFVal(0), AMALs(0), AMAHs(0);
    AMAVal = AMA(Period);
    AMAFVAl = AMAF(Period, Pcnt);
    IF CurrentBar = 1 Then Begin
    AMALs = AMAVal;
    AMAHs = AMAVal;
    End Else Begin
    IF AMAVal < AMAVal[1] Then
    AMALs = AMAVal;
    IF AMAVal > AMAVal[1] Then
    AMAHs = AMAVal;
    IF AMAVal - AMALs Crosses Above AMAFVal Then
    Buy This Bar on Close;
    IF AMAHs - AMAVal Crosses Above AMAFVal Then
    Sell This Bar on Close;
    End;

    AMA趨勢交易系統(tǒng)(含代碼)
    這個系統(tǒng)脫胎于卡夫曼的AMA自適應(yīng)系統(tǒng),我自己做了改進,根據(jù)我自己的習(xí)慣加了BOLL和MA30.

    以下為Perry J.Kaufman的自適應(yīng)移動平均系統(tǒng)
    關(guān)于移動平均
    由一個時間周期的價格平均值構(gòu)成,并以單位時間的價格周期不斷計算,加入新的一個單位時間的價格時去掉第一個單位時間的價格,并計算平均值。一個過去幾天的平均值,減少了人為的由消息引起的過激反應(yīng)的影響。平均較長的數(shù)據(jù)周期,給出了較平滑的趨勢,其結(jié)果經(jīng)常是長期市場方向的一個很好的代表,也反映了市場運行狀況和人們對于利率和政策的預(yù)期。


    趨勢系統(tǒng)


    趨勢計算把價格移動歸納為一個凈方向,并假設(shè)價格將會繼續(xù)沿著這個方向運動。趨勢跟蹤系統(tǒng)則是對趨勢作出反應(yīng),而不是對它們進行預(yù)期。


    噪音


    一個持續(xù)橫盤的期的波動水平,可以很方便的用來測量內(nèi)在噪音。如果一個趨勢是由一個不大于市場內(nèi)在噪音水平移動所引起的,那么這個趨勢就是不可靠的。
    自適應(yīng)


    當市場沿著一個方向快速移動時,快得移動平均值是最好的。


    當市場在橫盤的市場中立拉鋸時,慢的移動平均值是最好的。


    三種價格波動性測量


    a. 簡單地計算價格的凈變化,從開始點到結(jié)束點。這傾向于最保守的測量,因為它平滑了從開始到結(jié)尾之間發(fā)生的任何價格移動。


    b. 高-低范圍更好地描述了在周期內(nèi)可能產(chǎn)生的任意極端值。


    c. 所有變化總和,它是最概括的測量,因為能識別一個價格移動從高到低的次數(shù)。


    自適應(yīng)移動平均值


    步驟1:價格方向


    價格方向被表示為整個時間段中的凈價格變化。比如,使用n天的間隔(或n小時):


    步驟2:波動性


    波動性是市場噪音的總數(shù)量,計算了時間段內(nèi)價格變化的總和


    volatility= @ sum( @ abs(price-price[1]),n)


    步驟3:效率系數(shù)(ER)


    方向移動對噪音之比,成為效率系數(shù)ER


    Efficiency_Ratio = direction/volatility


    步驟4:變換上述系數(shù)為趨勢速度


    為了應(yīng)用于一個指數(shù)式移動平均值,比率將被變換為一個平滑系數(shù)c,依靠使用下面的公式,每天的均線速度可以簡單地用改變平滑系數(shù)來改變,成為自適應(yīng)性的。公式:


    @exp_ma=@exp_ma[1]+c*(price- @ exp_ma[1])


    公式表明,EMA以一個百分比c來接近于今日的收盤價。系數(shù)c與一個標準移動平均值中天數(shù)密切相關(guān),這關(guān)系是2/(n-1),其中n是天數(shù)。


    在橫盤的市場中這個過程選擇了非常慢的趨勢,而在高度趨勢化的周期中加速至非常快的趨勢(但不是100%)。這個平滑系數(shù)是:


    fastest =2/(N+1) =2/(2+1) =0.6667


    slowest =2/(N+1) =2/(30+1) =0.0645


    smooth =ER*(fastest-slowest)+slowest


    c=smooth*smooth


    平方平滑迫使c的數(shù)值趨向于0,這意味著較慢的移動平均值將比快速的移動平均值用得更多。這和在出現(xiàn)不確定狀況時你就更加保守是一樣的道理。


    AMA = AMA[1] + c * (price - AMA[1])

    卡夫曼的原代碼:
    Params
             Numeric        FilterSet(0.1);//過濾器偏移量
             Numeric        lots(1);
             Numeric        terms(10);//自適應(yīng)計算周期
             Numeric        AMAOffSetPercent(0.55);//前后兩日均線差值觸發(fā)值百分比
    Vars
             NumericSeries        AMAValue;
             Numeric        ExtHigh;//前高
             Numeric        ExtLow;//前低
             Numeric        filter;
             Numeric        AMAOffSet;
             Bool        LongEntryCon(false);
             Bool        ShortEntryCon(false);
    Begin
             AMAValue = AdaptiveMovAvg(close,terms,2,30);
             if(close == AMAValue)
                     return;       //如果bar個數(shù)小于計算周期,直接返回
             AMAOffSet=AvgPrice()*AMAOffSetPercent/100;       //取當前均價的0.0055作為均線觸發(fā)值
             filter = StandardDev(AMAValue,20,2)*FilterSet;        //計算過濾器的值
             if(AMAValue>AMAValue[1]and AMAValue[1]<AMAValue[2])
                     ExtLow = AMAValue[1];        //計算前低
             if(AMAValue<AMAValue[1]and AMAValue[1]>AMAValue[2])
                     ExtHigh = AMAValue[1];       //計算前高
          
             if(AMAValue>AMAValue[1])   //如果今天的均線值大于昨天
             {
                     if(ExtLow!=0)    //如果前低不為零
                     {
                                    if((AMAValue - ExtLow)>filter)     //將均線值減去最低值,看是否大于過濾器
                                     LongEntryCon = true;
                     }Else
                     {
                             if((AMAValue-AMAValue[1])>AMAOffSet )   //如果前低為零,即沒有產(chǎn)生前低,則直接比較兩日的均線值是否大于觸發(fā)值
                                             LongEntryCon = true;
                     }
             }
                   
             if(AMAValue<AMAValue[1])
             {
                     if(ExtHigh!=0)
                     {
                             if((AMAValue - ExtHigh)>filter)
                                     ShortEntryCon = true;
                     }Else
                     {
                             f((AMAValue[1]-AMAValue)>AMAOffSet )
                                     ShortEntryCon = true;
                     }
             }
             Commentary("AMA:"+TEXT(AMAValue));
             Commentary("filter:"+TEXT(filter));
             Commentary("ExtLow:"+TEXT(ExtLow));
             Commentary("ExtHigh:"+TEXT(ExtHigh));
             Commentary("LongCon:"+IIFString(LongEntryCon,"true","false"));
             Commentary("ShortCon:"+IIFString(ShortEntryCon,"true","false"));
             Commentary("AMAOffSet:"+text(AMAOffSet));
             if(MarketPosition !=1 and LongEntryCon)
                     buy(lots,NextOpen);
             if(MarketPosition !=-1 and ShortEntryCon)
                     SellShort(lots,NextOpen);
    end

     

  • TB技術(shù)人員: 謝謝分享!
    但這是多久前編寫的啊,居然還有nextopen的?

 

有思路,想編寫各種指標公式,程序化交易模型,選股公式,預(yù)警公式的朋友

可聯(lián)系技術(shù)人員 QQ: 1145508240  有需要幫忙請點擊這里留言!!!進行 有償 編寫!不貴!點擊查看價格!


【字體: 】【打印文章】【查看評論

相關(guān)文章

    沒有相關(guān)內(nèi)容
主站蜘蛛池模板: 4虎最新网站 | 精品无人乱码一区二区三区 | 国产精品亚洲成在人线 | 日日摸夜夜添夜夜添人人爽 | 国产精品亚洲精品久久成人 | 成人美女免费网站视频 | 在线日韩中文字幕 | 亚洲免费视频一区二区三区 | 亚洲成人视 | 在线日本中文字幕 | 亚洲日本视频在线 | 欧美久久久久久 | 欧美亚洲日本国产 | 精品国产999 | 久久99国产精品视频 | 久久精品国产亚洲综合色 | aa毛片免费全部播放完整 | 欧美理论片大全在线观看 | www.亚洲 | 成人影视在线观看 | 99热在线看 | 99热这里只有精品8 99热这里只有精品88 | 欧美线人一区二区三区 | 免费国产视频 | 五月在线视频 | 久久精品亚洲综合一品 | 国产精品一区在线免费观看 | 久久久99精品免费观看 | 香蕉视频免费在线观看 | 天天做夜夜做久久做狠狠 | 免费a级在线观看完整片 | 亚洲视频在线观看免费视频 | 成人xxxx| 奇米第四色视频 | 免费看一级特黄a大片 | 99九九精品国产高清自在线 | 最新69成人精品毛片 | 久青草视频免费观看青 | 高清免费毛片 | 操人视频网站 | 欧美亚洲综合在线 |