以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  布林线策略结合macd编写问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=64944)

--  作者:beckham6666
--  发布时间:2014/5/13 11:24:23
--  布林线策略结合macd编写问题
老师,请教一下:
1、当价格上涨,diff走低,且价格在布林线上轨,做空。当价格在3根k线以上跌至中轨,平仓。当价格在3根k线以内跌至中轨,持有到跌破布林线下轨,平仓。
2、当价格下跌,diff走高,且价格在布林线下轨,做多。当价格在3根k线以上涨至中轨,平仓。当价格在3根k线以内涨至中轨,持有到涨至布林线上轨,平仓。

新手上路,请多多指教  谢谢

--  作者:jinzhe
--  发布时间:2014/5/13 13:24:56
--  

当价格在3根k线以上跌至中轨

解释一下这个是一种什么样的状态


--  作者:beckham6666
--  发布时间:2014/5/13 13:53:10
--  
就是比较缓慢的跌倒中轨位置,不是急跌。我定义了3根k线的时间。
--  作者:jinzhe
--  发布时间:2014/5/13 14:19:37
--  
开仓后3根k线之内跌倒中规的位置吗?
--  作者:beckham6666
--  发布时间:2014/5/13 15:16:54
--  
是开仓后,3根K线以外跌至中轨,平仓    3根k线以内跌至中轨,继续持有,跌至下轨后,平仓。
--  作者:jinzhe
--  发布时间:2014/5/13 15:45:17
--  

m:=26;
n:=2;
s1:=12;
p1:=26;
m1:=9;
MID :  MA(CLOSE,M);
UPPER: MID + N*STD(CLOSE,M);
LOWER: MID - N*STD(CLOSE,M);//这个是系统自带的boll指标

DIFF : EMA(CLOSE,S1) - EMA(CLOSE,P1);
DEA  : EMA(DIFF,M1);
MACD1 : 2*(DIFF-DEA);//这个是系统自带的macd指标

shoushu:=1;//下单手数

if h>ref(h,1) and diff<ref(diff,1) and l<upper and h>upper then buyshort(holding=0,shoushu,market);
if enterbars>3 and l<mid and h>mid then sellshort(1,shoushu,market);
if enterbars>3 and l<lower and h>lower and ref(count(l<mid and h>mid,3),1) then sellshort(1,shoushu,market);

if h>ref(h,1) and diff>ref(diff,1) and l<lower and h>lower then buy(holding=0,shoushu,market);
if enterbars>3 and l<mid and h>mid then sell(1,shoushu,market);
if enterbars>3 and l<lower and h>lower and ref(count(l<mid and h>mid,3),1) then sell(1,shoushu,market);


--  作者:beckham6666
--  发布时间:2014/5/14 15:58:35
--  
老师,我有点不太明白 ref(count(l<mid and h>mid,3),1) 这个语句的含义 
--  作者:jinzhe
--  发布时间:2014/5/14 16:04:22
--  

少些了一点

count(l<mid and h>mid,3)>=1