金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 1094|回复: 3

请帮我的交易条件里加个时间条件,谢谢!

[复制链接]

26

主题

93

帖子

93

积分

等级: 免费版

注册:
2022-11-17
曾用名:
发表于 2024-7-28 20:21 | 显示全部楼层 |阅读模式
ti_cond1:=time>011500 and time<024500;
ti_cond2:=time>131500 and time<184500;
只在以上两个时间段进行交易,请帮我把这时间条件加到下面的代码中。我自己试过了好几种方法都编译错误,请老师帮忙直接帮我添加进去修改好,谢谢。

MA1:MA(CLOSE,20);
DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA);

//做多       
Long:=cross(MACD,0) AND ma1>ref(ma1,1);
if Long  then
begin
sellshort(holding<0,holding,thisclose);
buy(holding=0,SS,thisclose);
end
//多头平仓         
LongX:=cross(0,macd) AND  Holding>0;
if LongX then
begin
sell(SS,0,Limitr,c);
END

//做空
Short:=cross(0,macd) AND ma1<ref(ma1,1);;
if Short  then
begin
SELL(holding>0, holding,thisclose);
BUYSHORT(holding=0,ss,thisclose) ;
end
       
//空头平仓

ShortX:=cross(MACD,0) AND  Holding<0;  
if ShortX then
begin
SELLSHORT(SS,0,Limitr,c);
END         


回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-7-29 08:52 | 显示全部楼层
Long:=cross(MACD,0) AND ma1>ref(ma1,1);
if Long and (ti_cond1 orti_cond2)  then
begin
sellshort(holding<0,holding,thisclose);
buy(holding=0,SS,thisclose);
end
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-7-29 08:53 | 显示全部楼层
and (ti_cond1 orti_cond2)

就是条件里加上这个就行了
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

26

主题

93

帖子

93

积分

等级: 免费版

注册:
2022-11-17
曾用名:
 楼主| 发表于 2024-7-29 10:31 | 显示全部楼层
哦,原来是这样啊,价格括号就行了。我试过把ti_cond1 or ti_cond2 重新定义为变量加进去不行,两个时间段分别做一条开仓条件,也不行。谢谢!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-23 20:31 , Processed in 0.086830 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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