以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请帮忙改成金字塔公式  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=7234)

--  作者:淡定688
--  发布时间:2011/7/16 16:55:36
--  请帮忙改成金字塔公式

{海龟法则1交易系统}

{定义变量,即ATR Ratchet 跟踪停损价格}
variable: xstop=0;

{计算ATR}
tr:=max(high-low,max(abs(high-ref(close,1)),abs(low-ref(close,1))));
atr:=sma(tr,20,1);

{计算Turtle rule-1 跟踪停损价格}

if high>=hhv(high,20) then
        xstop:=llv(low,10); {20日新高,建立多头停损价格起点——最近10日低点}
else if low>xstop then
        xstop:=xstop+0.05*atr; {多头延续,每天跟踪停损价格上移ATR的5%}
else if low<=llv(low,20) then
        xstop:=hhv(high,10);{20日新低,建立空头停损价格起点——最近10日高点}
else if high<xstop then
        xstop:=xstop - 0.05*atr;{空头延续,每天跟踪停损价格下移ATR的5%}

StopPrice: xstop;{显示停损价格}

 


--  作者:王锋
--  发布时间:2011/7/16 17:11:57
--  

{海龟法则1交易系统}

{定义变量,即ATR Ratchet 跟踪停损价格}
variable: xstop=0;

{计算ATR}
tr1:=max(high-low,max(abs(high-ref(close,1)),abs(low-ref(close,1))));
atr:=sma(tr1,20,1);

{计算Turtle rule-1 跟踪停损价格}
tmp1:=llv(low,10);
tmp2:=llv(low,20);
tmp3:=hhv(high,10);

if high>=hhv(high,20) then
        xstop:=tmp1; {20日新高,建立多头停损价格起点——最近10日低点}
else if low>xstop then
        xstop:=xstop+0.05*atr; {多头延续,每天跟踪停损价格上移ATR的5%}
else if low<=tmp2 then
        xstop:=tmp3;{20日新低,建立空头停损价格起点——最近10日高点}
else if high<xstop then
        xstop:=xstop - 0.05*atr;{空头延续,每天跟踪停损价格下移ATR的5%}

StopPrice: xstop;{显示停损价格}

 


--  作者:淡定688
--  发布时间:2011/7/16 18:52:55
--  
非常感谢!