等级: 免费版
- 注册:
- 2021-6-20
- 曾用名:
|
以下是阿火秘籍:十八、 自己在模型里计算盈亏情况的一个简便方法。
从另外一个角度说明了金字塔的测试结果是正确的。
[PEL] [color=rgb(51, 102, 153) !important][color=rgb(51, 102, 153) !important]复制代码
[color=rgb(255, 255, 255) !important][color=#ffffff !important] ?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| //方法示例如下:(这里股指上的简单的均线系统为例)
variable:sumwealth=0;
ma10:=ma(c,5);
ma25:=ma(c,25);
sxf:=0.01/100;//手续费0.01%
if holding>0 and ma10<ma25 then begin
sell(1,1,thisclose);
sumwealth:=sumwealth+1*c*300*(1-sxf);//卖出时减去交易额
end
if holding<0 and ma10>ma25 then begin
sellshort(1,1,thisclose);
sumwealth:=sumwealth-1*c*300*(1+sxf);//买入时加上交易额
end
if holding=0 and ma10>ma25 then begin
buy(1,1,thisclose);
sumwealth:=sumwealth-1*c*300*(1+sxf);
end
if holding=0 and ma10<ma25 then begin
buyshort(1,1,thisclose);
sumwealth:=sumwealth+1*c*300*(1-sxf);
end
zichan:sumwealth+holding*c*300-abs(holding)*c*300*sxf,noaxis;
| 我的问题是,如果我想借鉴一下阿火秘籍这段代码,用来自己计算自建套利合约的盈亏情况。比如豆油和豆粕比例1:4,买入1手豆油,卖出4手豆粕,那么该如何修改上面的代码?假设开平仓条件不变。
|
|