1、开仓条件
最新一个已完成K线的收盘价,高于布林线上轨,进多单。
最新一个已完成K线的收盘价,低于布林线下轨,进空单。
价格比较只要高于或低于即可,无其他突破判断。
2、平仓条件 无
3、止损条件
多单止损位设在布林线下轨,随布林线移动,只上不下。
空单止损位设在布林线上轨,随布林线移动,只下不上。
4、止盈条件 无
5、其他要求
布林线参数可自由设定。
input:M(95,5,100,10),K(9,0.4,10,1),SS(1,1,10000,1);
//中间变量
MID: MA(CLOSE,M);//布林中轨
UPPER: MID + K*STD(CLOSE,M);//布林上轨
LOWER: MID - K*STD(CLOSE,M);//布林下轨
手数:=ss;
//交易条件
if ref(close,1)>UPPER then //开多
begin
buy(holding>=0,ss,MARKET);
end
if ref(close,1)<LOWER then //开空
begin
buyshort(holding<=0,ss,MARKET);
end
//止损
if holding>0 and close<=LOWER then sell(1,holding,MARKET);
if holding<0 and close>=UPPER then sellshort(1,holding,MARKET);
范例,仅供参考。