金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 2361|回复: 4

信号产生小问题

[复制链接]

33

主题

145

帖子

145

积分

等级: 免费版

注册:
2023-10-12
曾用名:
发表于 2024-1-2 14:13 | 显示全部楼层 |阅读模式
想请老师帮看下为什么在这根k上(也就是光标定位的那根k)不出开多的信号了,按shift+Q调试发现各项条件因子都是正常,但是cond_buy却显示为0,有点疑惑

//申明参数
input:n(1,1,100,1),ss(1,1,100,1),nmin(10,1,100,1),long_co(1,0.001,1.1,0.001),short_co(1,0.001,1.1,0.001);

//技术指标
up_line:ref(hhv(h,n),1)*long_co;
down_line:ref(llv(l,n),1)*short_co;
middle_line:(up_line+down_line)/2;

//交易条件
buytime:=time>opentime(1) and time<closetime(0)-nmin*100;
selltime:=time>=closetime(0)-nmin*100;

//交易主体
cond_buy:=ref(c>up_line and buytime and holding=0,1);
if cond_buy then begin
        buy(1,ss,thisclose);
        end

if c<middle_line and holding>0 then begin
        sell(1,holding,thisclose);
        end


       
cond_buyshort:=ref(c<down_line and buytime and holding=0,1);
if cond_buyshort then begin
        buyshort(1,ss,thisclose);
        end

if c>middle_line and holding<0 then begin
        sellshort(1,holding,thisclose);
        end

       
//收盘平仓
if selltime then begin
        sell(holding>0,0,thisclose);
        sellshort(holding<0,0,thisclose);
        end


       
       
持仓:holding,linethick0;
资产:asset,noaxis,linethick0;
可用现金:cash(0),linethick0;



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号? 微信登录

x
回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2024-1-2 16:30 | 显示全部楼层
你条件里是ref了呀:

ref(c>up_line and buytime and holding=0,1);


你要看前面K里的变量值。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

33

主题

145

帖子

145

积分

等级: 免费版

注册:
2023-10-12
曾用名:
 楼主| 发表于 2024-1-2 16:38 | 显示全部楼层
已经看过了,同样是不出信号的,在轮询模式下使用ref如果当根k满足条件,不是在下根k出信号并下单吗?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号? 微信登录

x
回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2024-1-2 16:41 | 显示全部楼层
你这个持仓为0就不应该 放到条件里去。

你ref获取的是上跟K当前代码行位置holding值。你这里的holding变为0  是因为后面代码执行的缘故。

实际你ref到的结果中 的holding 不为0,因为那个位置还没平空呢。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

33

主题

145

帖子

145

积分

等级: 免费版

注册:
2023-10-12
曾用名:
 楼主| 发表于 2024-1-2 16:46 | 显示全部楼层
技术009 发表于 2024-1-2 16:41
你这个持仓为0就不应该 放到条件里去。

你ref获取的是上跟K当前代码行位置holding值。你这里的holding变 ...

get了,好像是这样,谢谢
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-8-4 00:37 , Processed in 0.123323 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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