金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 49|回复: 2

关于自己在模型里计算盈亏情况的问题

[复制链接]

97

主题

256

帖子

256

积分

等级: 免费版

注册:
2021-6-20
曾用名:
发表于 2025-6-17 21:33 | 显示全部楼层 |阅读模式
以下是阿火秘籍:十八、 自己在模型里计算盈亏情况的一个简便方法。
从另外一个角度说明了金字塔的测试结果是正确的。
[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手豆粕,那么该如何修改上面的代码?假设开平仓条件不变。





回复

使用道具 举报

97

主题

256

帖子

256

积分

等级: 免费版

注册:
2021-6-20
曾用名:
 楼主| 发表于 2025-6-17 21:33 | 显示全部楼层
//方法示例如下:(这里股指上的简单的均线系统为例)

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;
回复

使用道具 举报

38

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2025-6-18 08:54 | 显示全部楼层
这个不太清楚了,建议不用考虑自己算的,直接用软件自带回测后的数据就行了
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 微信登录

本版积分规则

手机版|小黑屋|上海金之塔信息技术有限公司 ( 沪ICP备13035422号 )

GMT+8, 2025-6-21 12:44 , Processed in 0.143103 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表