等级: 标准版
- 注册:
- 2022-6-27
- 曾用名:
|
楼主 |
发表于 2023-2-8 09:50
|
显示全部楼层
//定义参数
Input:N(27,1,200,1);//均线和标准差参数
Num:=1;//开仓手数
//中间变量
Ma10:Ma(c,N);//10日均线
Std1:=Std(c,N);//一个标准差
Upper:=Ma10+Std1;//通道上轨
Bottom:=Ma10-Std1;//通道下轨
//开空单
BuyCond:=h<ref(h,1) and l>ref(l,1) and l>=Bottom and ma10>close;//上涨趋势中价格触及下轨开多仓
SellCond:=h>ref(l,1) and l<ref(l,1) and h<=Upper;//下跌趋势中价格触及上轨开空仓
//开多单
BuyCond:=h>ref(h,1) and l>ref(l,1) and l>=Bottom and ma10<close;//上涨趋势中价格触及下轨开多仓
SellCond:=h<ref(l,1) and l<ref(l,1) and h<=Upper;//下跌趋势中价格触及上轨开空仓
//下空单语句
if BuyCond then begin
Sellshort(holding<0,0,limitr,c);//市价平空(market)挂单价(limitr,c)
Buy(holding=0,Num,limitr,c);//市价开多(market)挂单价(limitr,c)
end
if SellCond then begin
Sell(holding>0,0,limitr,c);//市价平多(market)挂单价(limitr,c)
BuyShort(holding=0,Num,limitr,c);//市价开空(market)挂单价(limitr,c)
end
//下多单语句
if BuyCond then begin
Sellshort(holding<0,0,limitr,c);//市价平空(market)挂单价(limitr,c)
Buy(holding=0,Num,limitr,c);//市价开多(market)挂单价(limitr,c)
end
if SellCond then begin
Sell(holding>0,0,limitr,c);//市价平多(market)挂单价(limitr,c)
BuyShort(holding=0,Num,limitr,c);//市价开空(market)挂单价(limitr,c)
end
//止盈止损
Win_Buy:=h-enterprice>=4;//多头盈利4点
Win_Sell:=enterprice-l>=4;//空头盈利4点
Lose_Buy:=enterprice-l>=5;//多头亏损5点
Lose_Sell:=h-enterprice>=5;//空头亏损5点
//市价止盈止损
if Win_Buy and holding>0 then 多止盈:Sell(enterbars>0,0,market);
if Win_Sell and holding<0 then 空止盈:Sellshort(enterbars>0,0,market);
if Lose_Buy and holding>0 then 多止损:Sell(enterbars>0,0,market);
if Lose_Sell and holding<0 then 空止损:Sellshort(enterbars>0,0,market);
我想均线上,开多仓,均线下,开空仓,修改后怎么实现不了 |
|