金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 1932|回复: 1

麻烦帮我改一下这段for循环的代码

[复制链接]

182

主题

419

帖子

419

积分

等级: 免费版

注册:
2022-1-15
曾用名:
发表于 2024-2-22 14:34 | 显示全部楼层 |阅读模式
目的是统计最近10笔多头交易中的亏损笔数

VARIABLE:dkcp=0,dpcp=0;
maS:=ma(c,5);
ma20:=ma(c,20);

if cross(maS,ma20) and holding=0 then
begin
        buy(1,1,marketr);
        dkcp:=c;
END

if cross(ma20,maS) and holding>0 then
begin
        sell(1,1,marketr);
        dpcp:=c;
END


hold:=holding;
dcount:=0;
dsumLoss:=0;//统计最近10笔多头交易中的亏损笔数
for i=barpos downto 2 do
begin
        if hold[i]=0 and hold[i-1]>0 and dcount<10 then
        begin
                dcount:=dcount+1;
                if dpcp[i]<dkcp[i] then
                        dsumLoss:=dsumLoss+1;
        end
        else if dcount>=10 then
                break;               
END

x1:dcount,NODRAW;
x2:dsumLoss,NODRAW;//错误: 输出值始终为0

回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2024-2-22 14:52 | 显示全部楼层
r1:dkcp;
r2:dpcp;

hold:=holding;
dcount:=0;
dsumloss:=0;//统计最近10笔多头交易中的亏损笔数
for i=barpos downto 2 do
begin
        if hold=0 and hold[i-1]>0 and dcount<10 then
        begin
                dcount:=dcount+1;
                if r2<r1 then
                        dsumloss:=dsumloss+1;
        end
        else if dcount>=10 then
                break;               
end

x1:dcount,nodraw;
x2:dsumloss,nodraw;//错误: 输出值始终为0


我们通常建议客户能不使用循环 就不使用循环。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-8-2 21:42 , Processed in 0.103036 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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