From: TSTS星人

這裡介紹的是海龜通道突破系統,海龜始祖:理察‧丹尼斯,會用這個方法不是沒道理的,因為簡單的二個參數,便道盡交易的真理,不管你用DMI、MACD、均線交叉,說穿了就是通道突破而已(當你均線交叉了,通常通道也突破了)
模型設定:

1、當突破過去N根K線的高點,做多。

2、當突破過去N根K線的低點,做空。

附上程式碼

inputs:LengthLong(20),Lengthshort(20),stoploss(0.01);
variables:hh(0),ll(0);


hh=highest(high,LengthLong)[1];
ll=lowest(low,Lengthshort)[1];


Buy("Buy") 1 contracts next bar at hh stop;


Sell("Sell") 1 contracts next bar at ll stop;


if marketposition = 1 then begin
exitlong("SlL") 1 contracts next bar at entryprice*(1 -stoploss) stop;
end;

if marketposition = -1 then begin
exitshort("SlS") 1 contracts next bar at entryprice*(1 + stoploss) stop;
end;
arrow
arrow
    全站熱搜

    JinShiang 發表在 痞客邦 留言(0) 人氣()