金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
12
返回列表 发新帖
楼主: 张恒

求助指标怎么改写。

[复制链接]

47

主题

163

帖子

163

积分

等级: 免费版

注册:
2024-1-11
曾用名:
 楼主| 发表于 2024-2-22 11:16 | 显示全部楼层
技术009 发表于 2024-2-22 10:47
你这个or是干嘛的。。 你后面那些if 语句都是独立判断的。不需要加or,你加了都编译不了的吧。

variable:maxprofit:=0.01;
k:=1;//首次开仓手数;
jk:=1;//加仓手数;
tt:=3;//开仓每个信号之间的间距;

tp:=100;//止盈
lp:=20;//止损;

ma5:=ema((high+low+open+2*close)/5,5);
ma10:=ema((2*high+low+open+2*close)/6,10);
ma55:=ema(ema(c,34),34);
n_jc_ma5_ma10:=sumbars(cross(ma5,ma10),1);//金叉加仓;
n_sc_ma5_ma10:=sumbars(cross(ma10,ma5),1);//死叉减仓;

//中枢线
中枢:ema(ema(c,10),10),colorgreen,linethick2;
aa:=中枢>ref(中枢,1);//多头趋势;
中枢线:if(aa-0.03,中枢,drawnull),colorred,linethick2;

//趋势线
趋势:ema((2*high+low+open+2*close)/6,34),colormagenta,linethick2;
a:=趋势>ref(趋势,1);//多头趋势;
趋势线:if(a-0.03,趋势,drawnull),colorred,linethick2;

//大趋势
多空线:ema(ema(c,34),34),colorwhite,linethick2;
a2:=多空线>ref(多空线,1);//多头趋势;
大趋势:if(a2-0.03,多空线,drawnull),colorred,linethick2;

b:=cross(ma5,趋势);
s:=cross(趋势,ma5);

//引用macd
diff:=ema(close,9)-ema(close,34);
dea:=ema(diff,9);
macd:=(diff-dea)*2,colorstick;

//引用kd;
rsv:=(close-llv(low,21))/(hhv(high,21)-llv(low,21))*100;
k:=sma(rsv,5,1),colorred;
d:=sma(k,5,1),colorgreen;

//多空
xx:=b and diff>dea and k>d and a;
xxx:=s and dea>diff and d>k and not(a);
drawtext(xx,l*0.9998,'多'),colorred,fontszup3;
drawtext(xxx,h+3,'空'),coloryellow,fontszup3;

barsbk:ref(c,typebar(1,1));
barssp:=ref(c,typebar(1,2));

if holding=0 then maxprofit:=0.01;

tcd:time>=091000 and time<145000;
//开仓
kd:=xx;
sellshort(kd and holding<0  ,holding,market);
buy(kd and holding=0 and tcd,k,market);
jd:=min(barsbk,barssp)>=tt and c>=ma55 and n_jc_ma5_ma10=1;//加仓
加多:buy(holding>0 and jd and tcd,tt,market);

pd1:=min(barsbk,barssp)>=tt and c>=ma55 and n_sc_ma5_ma10=1;//减仓
减仓:sell(pd1,tt,market);


pd2:=cross(ema(ema(c,34),34),c);//下穿55日均线时候,平所有仓位;
下穿ema平多:sell(pd2,holding,market);
dzy:=c>avgenterprice+tp*mindiff;//止盈100跳;
多止盈:sell(dzy,holding,market);

dzs:=c<avgenterprice-lp*mindiff;//止损20跳;
多止损:sell(dzs,holding,market);

barssk:ref(c,typebar(1,3));
barssp:=ref(c,typebar(1,4));
kk1:=xxx;
sell(kk1,holding,market);
if holding=0 then maxprofit:=0.01;

buyshort(kk1 and holding=0 and tcd,k,market);
kk2:=min(barssk,barssp)>=tt and c<ma55 and n_sc_ma5_ma10=1;
buyshort(kk2 and holding=0 and tcd,jk,market);

pk1:=min(barssk,barssp)>=tt and c<ma55 and n_jc_ma5_ma10=1;
sellshort(pk1,jk,market);
pk2:=cross(c,ma55);
sellshort(pk2,holding,market);

pk3:=c<avgenterprice-lp*mindiff;

空止盈:sellshort(pk3,holding,market);

if holding=0 then maxprofit:=0.01;


if  holding<>0 and maxprofit=0.01 then maxprofit:=openprofit;//如果maxprofit是初始值,直接赋值为最新的浮动盈亏
if openprofit>maxprofit and maxprofit<>0.01 then maxprofit:=openprofit;//更新最大盈利

//最大盈利大于0 当前小于最大盈利80%
if maxprofit>0 and openprofit<=maxprofit*0.8  and  holding<>0 then
begin
回撤平多:sell(holding>0,0,market);
回撤平空:sellshort(holding<0,0,market);
maxprofit:=0.01;     
end

if time>144500 and time<=150000 then//如果时间在14点45分以后,那么
begin
收盘平多:sell(holding>0,0,market);//如果持有多单,以市价卖出所有持仓量
收盘平空:sellshort(holding<0,0,market);//如果持有空单,以市价空头卖出所有持仓量         
maxprofit:=0.01;                                                                           
End

//夜盘21点10分-凌晨2点20分;
tcd:time>=211000 and time<022000;
//开仓
kd:=xx;
sellshort(kd and holding<0  ,holding,market);
buy(kd and holding=0 and tcd,k,market);
jd:=min(barsbk,barssp)>=tt and c>=ma55 and n_jc_ma5_ma10=1;//加仓
加多:buy(holding>0 and jd and tcd,tt,market);

pd1:=min(barsbk,barssp)>=tt and c>=ma55 and n_sc_ma5_ma10=1;//减仓
减仓:sell(pd1,tt,market);


pd2:=cross(ema(ema(c,34),34),c);//下穿55日均线时候,平所有仓位;
下穿ema平多:sell(pd2,holding,market);
dzy:=c>avgenterprice+tp*mindiff;//止盈100跳;
多止盈:sell(dzy,holding,market);

dzs:=c<avgenterprice-lp*mindiff;//止损20跳;
多止损:sell(dzs,holding,market);

barssk:ref(c,typebar(1,3));
barssp:=ref(c,typebar(1,4));
kk1:=xxx;
sell(kk1,holding,market);
if holding=0 then maxprofit:=0.01;


buyshort(kk1 and holding=0 and tcd,k,market);
kk2:=min(barssk,barssp)>=tt and c<ma55 and n_sc_ma5_ma10=1;
buyshort(kk2 and holding=0 and tcd,jk,market);

pk1:=min(barssk,barssp)>=tt and c<ma55 and n_jc_ma5_ma10=1;
sellshort(pk1,jk,market);

pk2:=cross(c,ma55);
sellshort(pk2,holding,market);

pk3:=c<avgenterprice-lp*mindiff;

空止盈:sellshort(pk3,holding,market);

if holding=0 then maxprofit:=0.01;


if  holding<>0 and maxprofit=0.01 then maxprofit:=openprofit;//如果maxprofit是初始值,直接赋值为最新的浮动盈亏
if openprofit>maxprofit and maxprofit<>0.01 then maxprofit:=openprofit;//更新最大盈利

//最大盈利大于0 当前小于最大盈利80%
if maxprofit>0 and openprofit<=maxprofit*0.8  and  holding<>0 then
begin
回撤平多:sell(holding>0,0,market);
回撤平空:sellshort(holding<0,0,market);
maxprofit:=0.01;     
end

if time>225000 and time<=230000 then//如果时间在22点50分以后,那么
begin
收盘平多:sell(holding>0,0,market);//如果持有多单,以市价卖出所有持仓量
收盘平空:sellshort(holding<0,0,market);//如果持有空单,以市价空头卖出所有持仓量         
maxprofit:=0.01;                                                                           
End

if time>005000 and time<=010000 then//如果时间在12点50分以后,那么
begin
收盘平多:sell(holding>0,0,market);//如果持有多单,以市价卖出所有持仓量
收盘平空:sellshort(holding<0,0,market);//如果持有空单,以市价空头卖出所有持仓量         
maxprofit:=0.01;                                                                           
end
if time>022000 and time<=023000 then//如果时间在凌晨2点20分以后,那么
begin
收盘平多:sell(holding>0,0,market);//如果持有多单,以市价卖出所有持仓量
收盘平空:sellshort(holding<0,0,market);//如果持有空单,以市价空头卖出所有持仓量         
maxprofit:=0.01;                                                                           
end
这么写是不是很臃肿啊,大神。
回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2024-2-22 11:24 | 显示全部楼层
合并下:
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2024-2-22 11:24 | 显示全部楼层
tcon:(time>144500 and time<=150000 ) or (time>225000 and time<=230000) or (time>005000 and time<=010000) or (time>022000 and time<=023000);
if tcon then//如果时间在14点45分以后,那么
begin
收盘平多:sell(holding>0,0,market);//如果持有多单,以市价卖出所有持仓量
收盘平空:sellshort(holding<0,0,market);//如果持有空单,以市价空头卖出所有持仓量         
maxprofit:=0.01;                                                                           
end
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

47

主题

163

帖子

163

积分

等级: 免费版

注册:
2024-1-11
曾用名:
 楼主| 发表于 2024-2-22 12:12 | 显示全部楼层
技术009 发表于 2024-2-22 11:24
tcon:(time>144500 and time225000 and time005000 and time022000 and time0,0,market);//如果持有多单, ...

tcon:(time>091000 and time<=145000 ) or (time>211000 and time<=022000);
时间上,也个开市时间也可以这样合并吧?
回复

使用道具 举报

47

主题

163

帖子

163

积分

等级: 免费版

注册:
2024-1-11
曾用名:
 楼主| 发表于 2024-2-22 15:51 | 显示全部楼层
pk3:=c<avgenterprice-lp*mindiff;

空止盈:sellshort(pk3,holding,market);
这个是空止损20吧?
回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2024-2-22 15:53 | 显示全部楼层
空头价格降低 不是盈利吗?
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

47

主题

163

帖子

163

积分

等级: 免费版

注册:
2024-1-11
曾用名:
 楼主| 发表于 2024-3-2 23:12 | 显示全部楼层
技术009 发表于 2024-2-22 15:53
空头价格降低 不是盈利吗?

//其他
次数:TOTALTRADE,LINETHICK0;
胜率:PERCENTWIN,LINETHICK0;
连亏:MAXSEQLOSS,LINETHICK0;
连赢:MAXSEQWIN,LINETHICK0;
当前持仓:HOLDING,COLORGRAY,LINETHICK0;
当前资产:ASSET,NOAXIS,COLORGRAY;

ma5:=ema((high+low+open+2*close)/5,5);
ma10:=ema((2*high+low+open+2*close)/6,10);
ma55:=ema(ema(c,34),34);

variable:maxprofit:=0.15;

k:=5;//首次开仓手数;
jk:=5;//加仓手数;
tt:=3;//开仓每个信号之间的间距;

tp:=100;//止盈
lp:=20;//止损;
n_jc_ma5_ma10:=sumbars(cross(ma5,ma10),1);//金叉加仓;
n_sc_ma5_ma10:=sumbars(cross(ma10,ma5),1);//死叉减仓;

//中枢线
中枢:ema(ema(c,10),10),colorgreen,linethick2;
aa:=中枢>ref(中枢,1);//多头趋势;
中枢线:if(aa-0.03,中枢,drawnull),colorred,linethick2;

//趋势线
趋势:ema((2*high+low+open+2*close)/6,34),colormagenta,linethick2;
a:=趋势>ref(趋势,1);//多头趋势;
趋势线:if(a-0.03,趋势,drawnull),colorred,linethick2;

//大趋势
多空线:ema(ema(c,34),34),colorwhite,linethick2;
a2:=多空线>ref(多空线,1);//多头趋势;
大趋势:if(a2-0.03,多空线,drawnull),colorred,linethick2;

b:=cross(ma5,趋势);
s:=cross(趋势,ma5);

//引用macd
diff:=ema(close,9)-ema(close,34);
dea:=ema(diff,9);
macd:=(diff-dea)*2,colorstick;

//引用kd;
rsv:=(close-llv(low,21))/(hhv(high,21)-llv(low,21))*100;
k:=sma(rsv,5,1),colorred;
d:=sma(k,5,1),colorgreen;

//多空
xx:=b and diff>dea and k>d and a;
xxx:=s and dea>diff and d>k and not(a);
drawtext(xx,l*0.9998,'多'),colorred,fontszup3;
drawtext(xxx,h+3,'空'),coloryellow,fontszup3;

barsbk:ref(c,typebar(1,1));
barssp:=ref(c,typebar(1,2));

if holding=0 then maxprofit:=0.01;

tcon:(time>091000 and time<=145000 ) or (time>211000 and time<=022000);
//开仓
kd:=xx;
sellshort(kd and holding<0,holding,market);
buy(kd and holding=0 and tcon,k,market);
jd:=min(barsbk,barssp)>=tt and c>=ma55 and n_jc_ma5_ma10=1;//加仓
加多:buy(holding>0 and jd and tcon,tt,market);

pd1:=min(barsbk,barssp)>=tt and c>=ma55 and n_sc_ma5_ma10=1;//减仓
减仓:sell(pd1,tt,market);

pd2:=cross(ema(ema(c,34),34),c);//下穿55日均线时候,平所有仓位;
下穿ema平多:sell(pd2,holding,market);

dzy:=c>avgenterprice+tp*mindiff;//止盈100跳;
多止盈:sell(dzy,holding,market);

dzs:=c<avgenterprice-lp*mindiff;//止损20跳;
多止损:sell(dzs,holding,market);

barssk:ref(c,typebar(1,3));
barssp:=ref(c,typebar(1,4));
kk1:=xxx;
sell(kk1,holding,market);
if holding=0 then maxprofit:=1;

buyshort(kk1 and holding=0 and tcon,k,market);
kk2:=min(barssk,barssp)>=tt and c<ma55 and n_sc_ma5_ma10=1;
buyshort(kk2 and holding=0 and tcon,jk,market);

pk1:=min(barssk,barssp)>=tt and c<ma55 and n_jc_ma5_ma10=1;
sellshort(pk1,jk,market);
pk2:=cross(c,ma55);
止盈:sellshort(pk2,holding,market);
pk3:=c<avgenterprice-tp*mindiff;
空止盈:sellshort(pk3,holding,market);


if holding=0 then maxprofit:=10;
if holding<>0 and maxprofit=10 then maxprofit:=openprofit;//如果maxprofit是初始值,直接赋值为最新的浮动盈亏
if openprofit>maxprofit and maxprofit<>0.01 then maxprofit:=openprofit;//更新最大盈利

//最大盈利大于0 当前小于最大盈利80%
if maxprofit>0 and openprofit<=maxprofit*0.3  and  holding<>0 then
begin
回撤平多:sell(holding>0,0,market);
回撤平空:sellshort(holding<0,0,market);
maxprofit:=10;     
end

tcon1:(time>144500 and time<=150000 ) or (time>225000 and time<=230000) or (time>005000 and time<=010000) or (time>022000 and time<=023000);
if tcon1 then//如果时间在14点45分以后,那么begin
begin
收盘平多:sell(holding>0,0,market);//如果持有多单,以市价卖出所有持仓量
收盘平空:sellshort(holding<0,0,market);//如果持有空单,以市价空头卖出所有持仓量         
maxprofit:=0.01;                                                                           
End


大神
为什么加了tcon:(time>091000 and time<=145000 ) or (time>211000 and time<=022000);
显示不了数据呢?
回复

使用道具 举报

37

主题

1万

帖子

6万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
wenarm
发表于 2024-3-4 09:13 | 显示全部楼层
(time>211000 and time<=022000);这个行不成立,时间不可能即大于21点又小于2点20.

时间的控制在北京时区下应该分段处理,即24点之前分段判断。建议用金字塔时区,时间逻辑上更好判断。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

47

主题

163

帖子

163

积分

等级: 免费版

注册:
2024-1-11
曾用名:
 楼主| 发表于 2024-3-16 14:54 | 显示全部楼层
技术009 发表于 2024-2-22 15:53
空头价格降低 不是盈利吗?


pk3:=c<avgenterprice-lp*mindiff;
这个lp是设定20;为什么不用tp=60去设定止盈呢?因为设定的就是tp是止盈,lp是止损。按照设定规则,应该是pk3:=c<avgenterprice-tp*mindiff;
对吗?大神。
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-3-18 09:20 | 显示全部楼层
c<avgenterprice-tp*mindiff;

这个就是当前价格小于成本价-tp*变动价位

也就是亏损60个跳就止损

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-8-1 07:32 , Processed in 0.092492 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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