我想实现这样一个功能,即:
1. 在每天收盘前的最后一分钟之初,即进入15:15分的那一瞬间,平掉一半仓位;
2. 在每天开盘的第一分钟(即开盘的那一瞬间),如果开盘价与昨日收盘价相差不到0.5%,就立即补上前日所减之仓位。
我写了如下的代码,但反复测试都不准确,一个是实际的减仓和补仓量很混乱,与意图不符,另一个是时间上好像不太准确。敬请帮助检查一下,看看问题在哪里?拜托拜托
T1:=time>151400 and time<=151500;
T2:=time>=091500 and time<=091600;
减仓量:=holding/2;
当日开盘价:=valuewhen(date<>ref(date,1),open);
前日收盘价:=ref(close,1);
开盘差:=当日开盘价/前日收盘价;
补仓条件:=开盘差<=1.005 and 开盘差>=0.995;
昨日持仓量:=ref(holding,1);
if T1 then
begin
sell(holding>0,减仓量,marketr);
sellshort(holding<0,减仓量,marketr);
end
if T2 and 补仓条件 then
begin
buy(holding>0,昨日持仓量,thisclose);
buyshort(holding<0,昨日持仓量,thisclose);
end
1. 在每天收盘前的最后一分钟之初,即进入15:15分的那一瞬间,平掉一半仓位;
2. 在每天开盘的第一分钟(即开盘的那一瞬间),如果开盘价与昨日收盘价相差不到0.5%,就立即补上前日所减之仓位。
if time=151500 then sell(1,holding/2,market);
r1:=ref(holding,1);
if todaybar=1 and abs((o-ref(close,1))/ref(close,1))<0.005 then buy(1,r1,market)
if time=151500 then sell(1,holding/2,market); 1. 这里是不是用marketr更好?本周期么,过了151500可就没机会平了?
2. 括号里的1是指什么?
关于前几天你指教的这个问题,我按你的思路实施了,具体这么写的:
if time=151445 then
begin
sell(holding>0,holding/2,marketr);
sellshort(holding<0,holding/2,marketr);
end
我用两个不同的模拟账户测试,另一个是if time=151500 then...但是这两天发现都没有如预期的减仓……请帮看看问题可能出在哪儿?