以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (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=168068)

--  作者:lx123
--  发布时间:2019/1/30 15:45:55
--  公式编写

老师好,

 

KD金叉,KD值小于50,收盘价≥MA40日均线,开多1手,收盘价触摸MA20日均线下方,多单止盈,收盘价小于MA40,多单止损;

 

KD死叉,KD值大于70,收盘价≤MA40之下,开空1手,收盘价触摸MA20日均线上方,空单止盈,收盘价大于MA40,空单止损,这一段公式怎么写。谢谢!


--  作者:FireScript
--  发布时间:2019/1/30 15:54:49
--  
 “收盘价触摸MA20日均线下方”这个如何理解?详细说明下。
--  作者:lx123
--  发布时间:2019/1/30 16:02:16
--  
刚好到达MA20
--  作者:lx123
--  发布时间:2019/1/30 16:06:01
--  
也就是MA20不能碰,碰了就算数
--  作者:FireScript
--  发布时间:2019/1/30 16:07:15
--  
所以就是最新价收盘价等于ma20? 是这样?

--  作者:lx123
--  发布时间:2019/1/30 16:11:23
--  
嗯,是的
--  作者:FireScript
--  发布时间:2019/1/30 16:11:53
--  
input:n(9,1,100,10),p1(3,2,40,4),p2(3,2,40,4);//参数设置

ma40:ma(c,40);
RSV:=(CLOSE-LLV(LOW,N))/(HHV(HIGH,N)-LLV(LOW,N))*100;
K:SMA(RSV,P1,1);
D:SMA(K,P2,1);
J:3*K-2*D;

kdjjc:cross(k,d);//kdj金叉
kdjsc:cross(d,k);

if kdjjc and k<50 and d<50 and c>ma40  then
begin
buy(holding=0,1,MARKET);
end

if holding>0 and c<=ma40 then sell(holding>0,holding,market);

if kdjsc and  k>70 and d>70 and c<ma40  then
begin
buyshort(holding=0,1,MARKET);
end

if holding<0 and c>=ma40 then sellshort(holding<0,holding,market);


参考上面这个代码。

[此贴子已经被作者于2019/1/30 16:12:11编辑过]