Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:一个突破模型策略的编写问题

1楼
gongxiangban 发表于:2012/10/18 13:01:22
源码:
DIFF := EMA(CLOSE,S) - EMA(CLOSE,P);
DEA  := EMA(DIFF,M);
MACD := 2*(DIFF-DEA);
MA1  := ema(close,N);
MACD5 := REF(MACD,5);
long:= close>MA1 and MACD>0  and MACD5<0 ;
if long then
begin
 if not (HOLDING > 0) then
    buy(1,1,thisclose);
end;
if MA1> close +20*mindiff THEN
BEGIN 
 BUYSHORT(holding>0,holding,thisclose);
END
---------------------------------------------------------------------------

大概 思路就是 
  当K线穿越移动平均线,macd从下方向上穿越0轴的时候,做多。
 当 K线向下穿越移动平均线+20点时,平仓。




一个很简单的策略模型,可是为什么测试的时候只做了一个单子,且一直没有平仓.
求解答,

个人认为 是 最后几行的平仓策略写错了,请教。
2楼
every 发表于:2012/10/18 13:25:32

是的,有错误

BUYSHORT(holding>0,holding,thisclose);-----改为SELL

 

if long and holding=0 then
begin
    buy(1,1,thisclose);
end;
3楼
gongxiangban 发表于:2012/10/18 15:22:22
那请问,buyshort和 buy有什么区别么
4楼
jinzhe 发表于:2012/10/18 15:23:11
开空和开多
共4 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.01953 s, 3 queries.