- 精华
- 0
- 在线时间
- 463 小时
- UID
- 219647
- 积分
- 56
- 帖子
- 33
- 阅读权限
- 30
- 注册时间
- 2015-9-14
- 最后登录
- 2023-6-12
- 精华
- 0
- UID
- 219647
- 积分
- 56
- 帖子
- 33
- 主题
- 14
- 阅读权限
- 30
- 注册时间
- 2015-9-14
- 最后登录
- 2023-6-12
|
本帖最后由 lcxamm 于 2018-11-7 00:22 编辑
Params
Numeric notaft(14.55);//平仓时间
Numeric upperband(4280);//压力位置
Numeric lowerband(4272);//支撑位置
Vars
Numeric Minpoint;//最小跳点数
bool con; // bool中间变量
bool con1; // bool中间变量
Begin
if(BarStatus==0)
SetGlobalVar(0,0); //初始化全局变量
if(GetGlobalVar(0)==0 and A_BuyPosition>0)
SetGlobalVar(0,1);//判断多头持仓并标记
if(GetGlobalVar(0)==0 and A_SellPosition>0)
SetGlobalVar(0,-1);//判断空头持仓并标记
MinPoint = MinMove*PriceScale;//最小变动
PlotNumeric("upperband=",upperband);
PlotNumeric("lowerband=",lowerband);
con = High >= upperband;//多单条件
con1= low <= lowerband;//空单条件
//开仓
if (a_buyposition==0&&barstatus==2&&GetGlobalVar(0)==0&&con)//无多单,最新bar,全局变量初始值,多单条件满足
{A_SendOrder(Enum_Buy,Enum_Entry,1,Q_AskPrice,upperband-6*MinPoint,Q_UpperLimit);;SetGlobalVar(0,1);}//买入开仓1手,对价,压力-6跳止损,涨停止盈
if (a_sellposition==0&&barstatus==2&&GetGlobalVar(0)==0&&con1 )//无空单,最新bar,全局变量初始值,空单条件满足
{A_SendOrder(Enum_Sell,Enum_Entry,1,Q_BidPrice,lowerband+6*MinPoint,Q_LowerLimit);;SetGlobalVar(0,-1);} //卖出开仓1手,对价,支撑+6跳止损,跌停止盈
//收盘平仓
if(barstatus==2&&Time*100>=notaft&&Time<0.1600 )//最新bar,时间超过平仓时间
{
{if(A_BuyPosition>0&&GetGlobalVar(0)==1)//持有多单
{
A_SendOrder(Enum_Sell, Enum_Exit, A_BuyPosition(), Q_BidPrice);//对价平所有仓
SetGlobalVar(0,0);}//初始化
else If(A_SellPosition>0&&GetGlobalVar(0)==-1)//持有空单
{A_SendOrder(Enum_Buy, Enum_Exit, A_SellPosition(), Q_AskPrice);//对价平所有仓
SetGlobalVar(0,0);//初始化
}
}
}
End |
|