金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 1901|回复: 2

请老师帮着看看,这是哪里写的错了

[复制链接]

61

主题

295

帖子

305

积分

Rank: 4

等级: 专业版

注册:
2022-1-11
曾用名:
发表于 2023-6-16 09:50 | 显示全部楼层 |阅读模式
1.请教以下代码平仓这样写为什么有错,因为用这样的平仓,回测时只有一次交易。如果要修改应该怎么修改?
2.请帮我检查一下其它语句有没有错误?

zq:=36;sb:=5;
TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR:=MA(TR1,zq*2);

var0:hhv(ref(high,1),zq*2);
var1:llv(ref(low,1),zq*2);
var2:=(var0+var1)/2;
var3:var2+(var0-var1)*0.25;
var4:var2-(var0-var1)*0.25;
var5:ema(var2,zq);
var6:=atr;

if holding=0 and var5>ref(var5,1) and cross(var3,c) and var0-var1>sb*ref(var6,1)  then
BEGIN
        buy(holding=0,1,market);
END
if holding=0 and var5<ref(var5,1) and cross(c,var4) and var0-var1>sb*ref(var6,1)  then
BEGIN
        buyshort(holding=0,1,market);
END


if holding=0 and ref(c,1)-c>(var0-var1)*0.25 and cross(var2,c) THEN
BEGIN
        buyshort(holding=0,1,market);
END
if holding=0 and c-ref(c,1)>(var0-var1)*0.25 and cross(c,var2) THEN
BEGIN
        buy(holding=0,1,market);
end


if holding>1 and c<=var5 then
begin
        sell(1,0,market);
END
if holding<-1 and c>=var5 then
BEGIN
        sellshort(1,0,market);
END

回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2023-6-16 11:21 | 显示全部楼层
你平仓这里持仓判断有问题。如下这样修改下即可:

if holding>=1 and c<=var5 then
begin
sell(1,0,market);
END
if holding<=-1 and c>=var5 then
BEGIN
sellshort(1,0,market);
END
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

61

主题

295

帖子

305

积分

Rank: 4

等级: 专业版

注册:
2022-1-11
曾用名:
 楼主| 发表于 2023-6-16 11:30 | 显示全部楼层
可以了,出信号了。真是太感谢,我自己找了几天也没找出原因!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-15 02:22 , Processed in 0.141760 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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