股资源-股票学习站-学炒股-股票课程-炒股教程-分析选股指标-入门基础知识

 找回密码
 注册昵称

QQ登录

只需一步,快速开始

搜索
上一主题 下一主题

[飞狐] 反映指标状态的趋势K线(源码)


    [-----复制链接-----]
楼主
 通达信源码安装路径:1,工具栏点击公式选项。2,弹出公式窗口点击新建。3,把源码复制到指标编辑器保存。4,回到K线图界面安装建立好的公式 || 2023-10-25 14:42:03

以下是反映指标状态的趋势K线(源码)

行情分为操作与观望,这里以周MACD从金叉到死叉区间为可操作区间为例,做一个K线反映这种趋势.这段源码包含了周线MACD 及不定周期K线的写法,匆忙之中肯定有瑕疵,也望各位指正 

input:long(26,20,100),short(12,5,40),m(9,2,60);
m60:ma(c,60);
wtj1:=datediff(ref(date,1),date)<>weekday-ref(weekday,1)orbarpos=1;
wtj:=refx(wtj1,1)orweekday=5;
fc:=close;
start:=barpos-barssince(wtj);
diff:=0*close;
dea:=0*close;
tmp:=setlbound(diff,start[datacount]);
tmp:=setlbound(dea,start[datacount]);
d1:=fc[start[datacount]];d2:=d1;wdea:=0;
fori=start[datacount]+1todatacountdobegin
ifwtjthenbegin
d1:=(2*fc+(short-1)*d1)/(short+1);
d2:=(2*fc+(long-1)*d2)/(long+1);
wdiff:=d1-d2;
wdea:=(2*wdiff+(m-1)*wdea)/(m+1);
diff:=wdiff;
dea:=wdea;
endelsebegin
diff:=(2*fc+(short-1)*d1)/(short+1)-
(2*fc+(long-1)*d2)/(long+1);
dea:=(2*diff+(m-1)*wdea)/(m+1);
end;
end;
macd:=2*(diff-dea),colorstick;

jc:=cross(DIFF,DEA);scc:=cross(DEA,DIFF);
DT:=DIFF>DEA;
Sed:=refx(scc,1)orbarpos=datacount;
Sp:=BARSLAST(jc)+1;wse:=barslast(scc);ts:=Sp-wse-1;
SO:ref(O,BARSLAST(jc))LINETHICKcolorred;
SH:HHV(H,Sp)LINETHICKcolorred;
SH:=SETVAL(Sed,SH,-BARSLAST(jc),SH);
SL:LLV(L,Sp)LINETHICKcolorred;
SL:=SETVAL(Sed,SL,-BARSLAST(jc),SL);
SC:SETVAL(Sed,C,-BARSLAST(jc),C)LINETHICKcolorred;
SV:=SETVAL(Sed,0,-FLOOR(BARSLAST(jc)/2),1);
SV:=SETVAL(Sed,SV,-FLOOR(BARSLAST(jc)/2)+1,0);

Spk:=barslast(jc);
SPKM:=SPKandSVanddt;
SPKL:=jcANDNOT(Sed)anddt;
SPKR:=SPKandSedanddt;
PARTLINE(SpkandDT,SO)coloryellow;
PARTLINE(Spk>0andDT,SC)coloryellow;
STICKLINE(SPKM,SH,MAX(SC,SO),0,0)coloryellow;
STICKLINE(SPKM,SL,MIN(SC,SO),0,0)coloryellow;
STICKLINE(SPKL,SC,SO,0,0)coloryellow;
STICKLINE(SPKRandDT,SC,SO,0,0)coloryellow; 






回复

举报

QQ|

GMT+8, 2024-11-16 03:32

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