以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  老师帮写下程序  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=142364)

--  作者:huanglei2011
--  发布时间:2016/11/8 15:29:48
--  老师帮写下程序
1.定义三条均线;
5日均线
10日均线
20日均线

2.求5日均线、10日均线、20日均线三者的最大值与最小值

3.当价格大于3条均线的最大值,平空做多;
  当价格小于3条均线的最大值,平多做空;

4.当根K线跌幅超过2%,(当根K线收盘价与上一K线收盘价的比值)平多;
  当根K线涨幅超过2%,(当根K线收盘价与上一K线收盘价的比值)平空;

--  作者:jinzhe
--  发布时间:2016/11/8 15:57:58
--  

ma1:=ma(c,5);
ma2:=ma(c,10);
ma3:=ma(c,20);
h3:=max(ma1,max(ma2,ma3));
l3:=min(ma1,min(ma2,ma3));
if close<h3 then begin
 sellshort(1,0,thisclose);
 buy(holding=0,1,thisclose);
end

if close>h3 then begin
 sell(1,0,thisclose);
 buyshort(holding=0,1,thisclose);
end

if (c-ref(c,1))/ref(c,1)<=-0.02 then sell(1,0,thisclose);
if (c-ref(c,1))/ref(c,1)>=0.02 then sellshort(1,0,thisclose);