input:x(5,1,100);
m:=26;
n:=2;
MID : MA(CLOSE,M);
UPPER: MID + N*STD(CLOSE,M);
LOWER: MID - N*STD(CLOSE,M);
{布林交易,我想做成突破上軌平空做多。突破下軌平多做空。回到中軌不管!!
要走完一根k線,還保持條件。第二根k線一開始下單!!
條件二是如果突破上下軌x個單位值在當根k線就下單。布林帶上中下軌,還有x,都可以調整參數的!!
}
if ref(cross(h,upper),1) then BEGIN
sellshort(1,0,limitr,open);
buy(holding=0,1,limitr,open);
end
if h>upper+x*mindiff or l<lower-x*mindiff then begin
sell(1,0,thisclose);
buyshort(holding=0,1,thisclose);
end
需要在圖表使用1秒輪詢的方式,具體參見下圖
input:x(5,1,100);
input:m(26,1,100);
input:n(2,1,100);
MID : MA(CLOSE,M);
UPPER: MID + N*STD(CLOSE,M);
LOWER: MID - N*STD(CLOSE,M);
{布林交易,我想做成突破上軌平空做多。突破下軌平多做空。回到中軌不管!!
要走完一根k線,還保持條件。第二根k線一開始下單!!
條件二是如果突破上下軌x個單位值在當根k線就下單。布林帶上中下軌,還有x,都可以調整參數的!!
}
if ref(cross(h,upper),1) then BEGIN
sellshort(1,0,limitr,open);
buy(holding=0,1,limitr,open);
end
if ref(cross(lower,l),1) then begin
sell(1,0,limitr,open);
buyshort(holding=0,1,limitr,open);
end
if h>upper+x*mindiff then begin
sellshort(1,0,thisclose);
buy(holding=0,1,thisclose);
end
if l<lower-x*mindiff then begin
sell(1,0,thisclose);
buyshort(holding=0,1,thisclose);
end
布林帶那個你改上面N和M的賦值就行了