原因就是图表,程序计算是6月1日开始交易,真实是7月1日开始交易,从而导致了金额的不同。
图表交易的本质,就是虚拟资金和持仓,核心就是忽略图表虚拟的资金变化,下单的时候,取账户里的实际金额,进行交易。
Intpart(Tasset/(Close*Multiplier*MarginRatio));
有位朋友建议用这个公式解决,可以吗?
//可以,以下例为例说明如何使用
//一分钟周期,逐周期
ma5:ma(close,5);
ma15:ma(close,15);
MarginRatio:=0.18;//MarginRatio是保证金比率
num:=Intpart(Tasset*0.3/(Close*Multiplier*MarginRatio));//开仓手数为总资金的30%
if num=0 then exit;
if CROSS(ma5,ma15) and time>091500 and time<145000 then
begin
sellshort(holding<0,0,thisclose);
buy(holding=0,num,limit,c+2*mindiff);
end
if CROSS(ma15,ma5) and time>091500 and time<145000 then
begin
sell(holding>0,0,thisclose);
buyshort(holding=0,num,limit,c-2*mindiff);
end
//收盘前5分钟平仓
if time > 145500 then
begin
sell(holding > 0, 0, thisclose);
sellshort(holding < 0, 0, thisclose);
end
谢谢,请问在后台程式化交易中
Intpart(Tasset/(Close*Multiplier*MarginRatio));语句中的Multiplier是直接写成5,还是可以写成zqcf00?,或者有其他的表达方式?
不好意思哦,原来的是有点问题.
是由于TASSET是个常数(只在最后一个周期有效)导致的
以下在最后一个周期和非最后一个周期,做了更改.
runmode:0;
ma5:=ma(close,n1);
ma15:=ma(close,n2);
MarginRatio:=0.18;
num:Intpart(Tasset*0.3/(Close*Multiplier*MarginRatio)),linethick0;//开仓手数---MarginRatio是保证金比率
if num=0 then exit;
if CROSS(ma5,ma15) and time>091500 and time<145000 then
begin
if islastbar then
begin
sellshort(holding<0,num,thisclose);
buy(holding=0,num,limit,c+2*mindiff);
end
else
begin
sellshort(holding<0,0,thisclose);
buy(holding=0,1,limit,c+2*mindiff);
end
end
if CROSS(ma15,ma5) and time>091500 and time<145000 then
begin
if islastbar then
begin
sell(holding>0,num,thisclose);
buyshort(holding=0,num,limit,c-2*mindiff);
end
else
begin
sell(holding>0,0,thisclose);
buyshort(holding=0,1,limit,c-2*mindiff);
end
end
谢谢姜总赐教!
if islastbar then
begin
sell(holding>0,num,thisclose);----------------这里的holding修改为tholding,在图表,轮询模式下,会导致信号消失,请问姜总,解决之道。
buyshort(holding=0,num,limit,c-2*mindiff);--同上
end
else
begin
sell(holding>0,0,thisclose);--同上
buyshort(holding=0,1,limit,c-2*mindiff);--同上
end