以文本方式查看主题

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

--  作者:莫远祥
--  发布时间:2019/10/26 11:15:03
--  老师给我编写一下谢谢
当MACD指标参数修改为,SHORT修改为241时,LONG修改为413时,M修改为23的时候,当MACD上穿0柱上方并且红柱值收线等于或者大于正1时买入开仓,当MACD 下穿0柱下方并且绿柱值等于或者小于负1收线的时候卖出平仓,同时卖出开仓,
当MACD 下穿0柱下方并且绿柱值等于或者小于负1收线的时候卖出开仓,当MACD 上穿0柱上方并且红柱值等于或者大于正1的时候,买入平仓,同时买入开仓。备注:可以使用在任何周期

--  作者:FireScript
--  发布时间:2019/10/28 9:16:38
--  
input:p(26,20,100,8),s(12,5,40,4),m(9,2,60,6);//参数设置


DIFF : =EMA(CLOSE,S) - EMA(CLOSE,P);
DEA  := EMA(DIFF,M);
MACD1 := 2*(DIFF-DEA), COLORSTICK;
macdjc:=cross(diff,dea);//macd金叉
macdsc:=cross(dea,diff);


if macdsc and macd1<=-1 then
begin
sell(holding>0,holding,MARKET);
buyshort(holding=0,1,market);
end

if macdjc  and macd1>=1 then
begin
sellshort(holding<0,holding,market);
buy(holding=0,1,MARKET);
end


三个参数的值可以自行调整下默认值,或者加载在K线上后手动修改。