等级: 免费版
- 注册:
- 2024-1-6
- 曾用名:
|
图表固定止损及止盈代码是否正确?我试着写了一下。不确定空头的写法是否正确。
{多开仓下单 示例文件是这么写的
多开仓:BUY(BS卖开执行A组,2,MARKET);
//SELL(COND2,HOLDING,MARKET);
}
我是不是最好不使用全局变量?
买开仓价A:=(ref(h,1)+3*open)/4;
卖开仓价A:=(ref(l,1)+3*open)/4;
//*************** 多头 ********************
//****持仓管理*****
VARIABLE:B_01:=0,B_OPN_01:=0,B_TKP_01:=0,B_STP_01:=0,B_STP_BRK_01:=0,
B_02:=0,B_OPN_02:=0,B_TKP_02:=0,B_STP_02:=0,B_STP_BRK_02:=0;
//****多单平仓*****
//固定止损部分************************
//多止盈
IF C-AVGENTERPRICE>=4*MINDIFF THEN BEGIN
SELL(1,HOLDING,MARKET);
END
//多止损
IF AVGENTERPRICE-C>=4*MINDIFF THEN BEGIN
SELL(1,HOLDING,MARKET);
END
//多开仓
IF BS买开执行A组 AND B_01=0 THEN
BEGIN
多开仓A:BUY(1,1,LIMITR,买开仓价A);
END
//*************** 空头 ********************
//****持仓管理*****
VARIABLE:S_01:=0,S_OPN_01:=0,S_TKP_01:=0,S_STP_01:=0,S_STP_BRK_01:=0,S_IDX_01:=0,S_COUNT_01:=0,
S_02:=0,S_OPN_02:=0,S_TKP_02:=0,S_STP_02:=0,S_STP_BRK_02:=0,S_IDX_02:=0,S_COUNT_02:=0;
//****空单平仓*****
//固定止损部分************************
//空止盈
IF C-AVGENTERPRICE>=4*MINDIFF THEN BEGIN
SELL(1,HOLDING,MARKET);
END
//空止损
IF AVGENTERPRICE-C>=4*MINDIFF THEN BEGIN
SELL(1,HOLDING,MARKET);
END
//空开仓
IF BS卖开执行A组 AND S_01=0 THEN
BEGIN
KA:BUYSHORT(BS卖开执行A组,1,LIMITR,卖开仓价A);
END
|
|