以文本方式查看主题
- 金字塔客服中心 - 专业程序化交易软件提供商 (http://222.73.7.161/bbs/index.asp)
-- 公式模型编写问题提交 (http://222.73.7.161/bbs/list.asp?boardid=4)
---- 老师您好,能帮我转换一个公式吗?万分感激 (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=175977)
|
-- 作者:TRADE580
-- 发布时间:2020/5/11 15:07:17
-- 老师您好,能帮我转换一个公式吗?万分感激
|
DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA :
EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
JC:=CROSS(DIFF,DEA);
SC:=CROSSDOWN(DIFF,DEA);
N1:=BARSLAST(JC)+1;
N2:=BARSLAST(SC)+1;
HH:=BACKSET(REFX(SC,1)||ISLASTBAR&&MACD>0,HHVBARS(H,N1)+1);
LL:=BACKSET(REFX(JC,1)||ISLASTBAR&&MACD<0,LLVBARS(L,N2)+1);
DRAWICON(JC&&DEA>0&&COUNT(SC,BARSLASTCOUNT(DEA>0))=2,0,\'ICO130\'),VALIGN0;
DRAWICON(SC&&DEA<0&&COUNT(JC,BARSLASTCOUNT(DEA<0))=2,0,\'ICO131\'),VALIGN2;
上面是文华公式的源代码,帮我转换成金字塔的,主要是金字塔没有BARSLASTCOUNT的代码,只有BARSLAST或BARSCOUNT的代码,不知道怎样转换,老师要是不忙的话,能帮我修改一下,万分感激 |
|
-- 作者:FireScript
-- 发布时间:2020/5/11 15:28:30
--
DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA : EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
JC:=CROSS(DIFF,DEA);
SC:=CROSS(DEA,DIFF);
N1:=BARSLAST(JC)+1;
N2:=BARSLAST(SC)+1;
HH:=BACKSET(REFX(SC,1) or ISLASTBAR and MACD>0,HHVBARS(H,N1)+1);
LL:=BACKSET(REFX(JC,1) or ISLASTBAR and MACD<0,LLVBARS(L,N2)+1);
DRAWICON(JC and DEA>0 and COUNT(SC,BARSLAST(DEA<=0))=2,0,\'ICO130\'),VALIGN0; DRAWICON(SC and DEA<0 and COUNT(JC,BARSLAST(DEA>=0))=2,0,\'ICO131\'),VALIGN2;
|
-- 作者:TRADE580
-- 发布时间:2020/5/11 15:47:22
--
非常感谢,very much
|
-- 作者:TRADE580
-- 发布时间:2020/5/11 15:55:33
--
还有一个小问题,用DIFF和DEA金叉死叉在主图上绘制波段,当DEA大于0时,在波段的低点绘制支撑线;当DEA小于0时,在波段的高点绘制压力线
注:支撑压力线用虚线呈现,不要用实线
如图所示,在金字塔上这种公式怎么写 此主题相关图片如下:qq浏览器截图20200511155419.png
|
-- 作者:FireScript
-- 发布时间:2020/5/11 16:15:04
--
金叉死叉位置绘制以收盘价为数值的线?
|
-- 作者:TRADE580
-- 发布时间:2020/5/11 16:18:00
--
最高最低价来划支撑压力线
|
-- 作者:FireScript
-- 发布时间:2020/5/11 16:38:34
--
从金叉位置的最低价上画到 死叉 或者是dea<=0
从死叉位置的最高价画到 金叉或者dea>0
是这样的思路?
|
-- 作者:TRADE580
-- 发布时间:2020/5/11 16:58:57
--
不要画这么长,用MACD的diff和dea的金叉死叉来绘制波段,如图所示,当DEA大于0时,在每一个上升波段的最低点画一根支撑线;反之当当DEA小于0时,在每一个下降波段的最高点画一根压力线。波段的最高最低点以最高最低价来绘制,而不是收盘价。支撑压力线横向绘制3个单位的长度就够了
|
-- 作者:TRADE580
-- 发布时间:2020/5/11 17:05:06
--
DIFF :=EMA(CLOSE,12) - EMA(CLOSE,26),COLORRED; DEA := EMA(DIFF,9); MACD:=2*(DIFF-DEA),COLORSTICK;
JC:=CROSS(DIFF,DEA); SC:=CROSSDOWN(DIFF,DEA); N1:=BARSLAST(JC)+1; N2:=BARSLAST(SC)+1; HH:=BACKSET(REFX(SC,1)||ISLASTBAR&&MACD>0,HHVBARS(H,N1)+1); LL:=BACKSET(REFX(JC,1)||ISLASTBAR&&MACD<0,LLVBARS(L,N2)+1); DRAWLINE1(CROSS(LL,0.001),L,CROSS(HH,0.001),H,0),COLORLIGHTRED,LINETHICK1; DRAWLINE1(CROSS(HH,0.001),H,CROSS(LL,0.001),L,0),RGB(0,64,0),LINETHICK1;
DRAWSL(CROSS(HH,0.001)&&DEA<0,H,0,5,0,COLORGREEN),DOT; DRAWSL(CROSS(LL,0.001)&&DEA>0,L,0,5,0,COLORRED),DOT;
这个是文华财经的源码,您可以参照修改一下,用到金字塔上
|
-- 作者:FireScript
-- 发布时间:2020/5/11 17:17:25
--
有现成的直接改造下就行,省的我写了。
//DIFF : EMA(CLOSE,12) - EMA(CLOSE,26); //DEA : EMA(DIFF,9); //MACD:=2*(DIFF-DEA); // //JC:CROSS(DIFF,DEA); //SC:CROSS(DEA,DIFF); //N1:=BARSLAST(JC)+1; //N2:=BARSLAST(SC)+1; // //DRAWLINE(JC and dea<=0,L,sc or dea>0,ref(L,N1),COLORRED); //DRAWLINE(sc and dea>0,h,jc or dea<=0,ref(h,N2),COLORRED);
DIFF :=EMA(CLOSE,12) - EMA(CLOSE,26),COLORRED; DEA := EMA(DIFF,9); MACD:=2*(DIFF-DEA),COLORSTICK;
JC:=CROSS(DIFF,DEA); SC:=CROSS(DEA,DIFF); N1:=BARSLAST(JC)+1; N2:=BARSLAST(SC)+1; HH:=BACKSET(REFX(SC,1) or ISLASTBAR and MACD>0,HHVBARS(H,N1)+1); LL:=BACKSET(REFX(JC,1) or ISLASTBAR and MACD<0,LLVBARS(L,N2)+1); DRAWLINE(CROSS(LL,0.001),L,CROSS(HH,0.001),H,0,COLORRED),,LINETHICK1; DRAWLINE(CROSS(HH,0.001),H,CROSS(LL,0.001),L,0),LINETHICK1;
DRAWSL(CROSS(HH,0.001) and DEA<0,H,0,5,0,COLORGREEN,1,vtDOT); DRAWSL(CROSS(LL,0.001) and DEA>0,L,0,5,0,COLORRED,1,vtDOT);
此主题相关图片如下:temp.png
|