金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 7797|回复: 3

手动写sar指标遇见的奇怪问题

[复制链接]

25

主题

64

帖子

64

积分

等级: 免费版

注册:
2022-7-5
曾用名:
发表于 2022-8-4 16:40 | 显示全部楼层 |阅读模式
我在金魔方里面写了个 然后弄好了 验算都没啥问题.
改了下放这反而不行了




[PEL] 复制代码
INPUT:
af(0.02, 0.02, 0.2,0.01);


afinit:=0.02;
bc:=barpos;
inith:=ref(h,bc-1);
initl:=ref(l,bc-1);
initc:=ref(c,bc-1);
inito:=ref(o,bc-1);


variable:dir:=0,nh:=0,ep:=0;

if initc>inito then initdir:=1;
if initc<inito then initdir=-1;

if initdir=1&&barpos=1 then Begin
ep:=inith;
sar1:=l;
end
else if initdir=-1&&barpos=1 then Begin
ep:=initl;
sar1:=h;
end
//初始ep

lep:=ref(ep,1);

if barpos>1 Then Begin
	//if barpos=2&&initdir=1 then dir:=1;
	//if barpos=2&&initdir=-1 then dir:=-1;
//dir:=initdir;

	if initdir=1&&dir=0 then Begin
	if h>ep then begin 
	ep:=h;
	nh:=nh+1;
	end
	end
	

	//if dir=1 then afnow:=afinit*(nh+1);
	//if afnow>0.2 then afnow:=0.2;
	if initdir=1 then Begin
	afnow:=afinit*(nh+1);
	if afnow>0.2 then afnow:=0.2;
	sar1:=sar1[barpos-1]+afnow[barpos-1]*(ep[barpos-1]-sar1[barpos-1]);
	end
	//上面是初始的多sar 
	
	//下面是空初始sar
	if initdir=-1&&dir=0 then Begin
	if l<ep then begin 
	ep:=l;
	nh:=nh+1;
	end
	end
	

	//if dir=-1 then afnow:=afinit*(nh+1);
	//if afnow>0.2 then afnow:=0.2;
	if initdir=-1 then Begin
	afnow:=afinit*(nh+1);
	if afnow>0.2 then afnow:=0.2;
	sar1:=sar1[barpos-1]-afnow[barpos-1]*(sar1[barpos-1]-ep[barpos-1]);
	end
//上面的2个方向初始计算 只是为了从第一个柱子画出来第一条线.
//dir什么的设定还都没写

if (h[barpos-1]<=sar1&&h>sar1) then dir:=1; 
if (l[barpos-1]>=sar1&&l<sar1) then dir:=-1; 
ddd:=dir;
//金魔方cross 前面>= 现在< 不算交叉
//基于第一个线 设定方向
//后续sar的计算 ep更新 看起来都依赖方向 所以必须写这下面 不可以写上面

	if dir=1&&dir[barpos-1]<>1 then Begin
	ep:=h;
	sar1:=ep[barpos-1];
	nh:=1;
	afnow:=0.02;
	end
	
	if dir=1&&dir[barpos-1]=1 then Begin
	if h>ep then begin 
	ep:=h;
	nh:=nh+1;
	end
	
	afnow:=afinit*(nh);
	if afnow>0.2 then afnow:=0.2;
	sar1:=sar1[barpos-1]+afnow[barpos-1]*(ep[barpos-1]-sar1[barpos-1]);
	end
	

	if dir=-1&&dir[barpos-1]<>-1 then Begin
	ep:=l;
	sar1:=ep[barpos-1];
	nh:=1;
	afnow:=0.02;
	end	
	
	if dir=-1&&dir[barpos-1]=-1 then Begin
	if l<ep then begin 
	ep:=l;
	nh:=nh+1;
	end
	
	afnow:=afinit*(nh);
	if afnow>0.2 then afnow:=0.2;
	sar1:=sar1[barpos-1]-afnow[barpos-1]*(sar1[barpos-1]-ep[barpos-1]);
	end

//if cross(h,sar1) then dir:=1; 
//if cross(sar1,l) then dir:=-1;
//单柱的有正又反 前面空 没处理
if (h[barpos-1]<=sar1&&h>sar1)||(c[barpos-1]<=sar1&&c>sar1) then dir:=1; 
if (l[barpos-1]>=sar1&&l<sar1)||(c[barpos-1]>=sar1&&c<sar1) then dir:=-1; 
//if cross(h,sar1)||(ref(h<=sar1,1)&&h>sar1)||(ref(c<=sar1,1)&&c>sar1) then dir:=1; 
//if cross(sar1,l)||(ref(l>=sar1,1)&&l<sar1)||(ref(c>=sar1,1)&&c<sar1) then dir:=-1; 


sarolp:=h>=sar1&&l<=sar1;
sara1:=(dir[barpos-1]=-1&&dir[barpos-2]<>-1)&&sarolp[barpos-1]=1&&c[barpos-1]>sar1[barpos-1];
sara2:=(dir[barpos-1]=1&&dir[barpos-2]<>1)&&sarolp[barpos-1]=1&&c[barpos-1]<sar1[barpos-1];
	if sara2 then dir:=-1;
	if sara1 then dir:=1;

	if dir=-1&&dir[barpos-1]=1 then Begin
	ep:=l;
	sar1:=ep[barpos-1];
	nh:=1;
	afnow:=0.02;
	end

	if dir=1&&dir[barpos-1]=-1 then Begin
	ep:=h;
	sar1:=ep[barpos-1];
	nh:=1;
	afnow:=0.02;
	end

	if sara1 then Begin
	ep:=h;
	sar1:=ep[barpos-1];
	nh:=1;
	afnow:=0.02;
	end
	
	if sara2 then Begin
	ep:=l;
	sar1:=ep[barpos-1];
	nh:=1;
	afnow:=0.02;
	end	

//if cross(h,sar1)||(ref(h<=sar1,1)&&h>sar1)||(ref(c<=sar1,1)&&c>sar1) then dir:=1; 
//if cross(sar1,l)||(ref(l>=sar1,1)&&l<sar1)||(ref(c>=sar1,1)&&c<sar1) then dir:=-1; 

End



if barpos=1 then hh:=h;
else if h>hh then hh:=h;

if barpos=1 then ll:=l;
else if l<ll then ll:=l;

as:ep;
as1:nh,nodraw;
as2:sar1;
as3:afnow,nodraw;
as4:=ddd,nodraw;
as5:dir,nodraw,colorgray;

//if(dir=0,sar1,nodraw),NoDrawInvalid,colorgray,Pointdot,linethick4;
//if(dir>0,sar1,nodraw),NoDrawInvalid,colorred,Pointdot,linethick4;
//if(dir<0,sar1,nodraw),NoDrawInvalid,colorgreen,Pointdot,linethick4;





补充内容 (2022-8-4 16:42):
附件里面有原版指标

补充内容 (2022-8-5 11:44):
现在是特定情况下 数组读取前面值是0 有bug!!!
有时候0都不是 直接不存在一样

本帖子中包含更多资源

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

x
回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2022-8-5 08:52 | 显示全部楼层
你这个就没法处理了。我们没办法验证金魔方上的东西的。

没办法对比出差异,尽管语法似乎都一致。就比如通达信和我们语法上基本也一致,实际他们对无效值处理和我们就有隐藏的差异, 你从语法上看不出来的。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

25

主题

64

帖子

64

积分

等级: 免费版

注册:
2022-7-5
曾用名:
 楼主| 发表于 2022-8-5 10:55 | 显示全部楼层
技术009 发表于 2022-8-5 08:52
你这个就没法处理了。我们没办法验证金魔方上的东西的。

没办法对比出差异,尽管语法似乎都一致。就比如 ...

为什么我的initdir在cs09上是0呢
有些品种有数据有些没有

补充内容 (2022-8-5 11:00):
哦是我少写了个冒号.....
回复

使用道具 举报

25

主题

64

帖子

64

积分

等级: 免费版

注册:
2022-7-5
曾用名:
 楼主| 发表于 2022-8-5 11:25 | 显示全部楼层
技术009 发表于 2022-8-5 08:52
你这个就没法处理了。我们没办法验证金魔方上的东西的。

没办法对比出差异,尽管语法似乎都一致。就比如 ...



我想问下为什么黄线用数组模式barpos-1读取不出前面的值 如果黄线是平的 前一个值读的是0.




补充内容 (2022-8-5 11:25):
绿线变的很小是因为黄线前一个值变成0造成的.

补充内容 (2022-8-5 13:19):
他为什么会变成0呢 明明应该读出数据才对

本帖子中包含更多资源

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

x
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-17 23:38 , Processed in 0.140972 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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