以文本方式查看主题
- 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp)
-- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4)
---- 请老师帮忙写下股指代码 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=60365)
|
-- 作者:fshrshilei
-- 发布时间:2013/12/26 16:50:30
-- 请老师帮忙写下股指代码
请老师编写下股指的指标,如果方便的话,请附上注释,方便学习,谢谢老师、
开仓信号:以当天开盘价上涨10个点以后开多,例如当天开盘价2013.6 价格涨到2014.8 以2014.8开多仓。 止损10个点。
以当天开盘价下跌10个点以后开空。同上,止损也是10个点。
平仓:开仓后如果盈利>20个点,止损回到开仓价格。如果不碰止损,收盘平仓。
开仓一天只开一次。多头开仓后,当天不开空头。
空头开仓后,当天不开多头。
|
-- 作者:jinzhe
-- 发布时间:2013/12/26 17:11:32
--
编写中,请稍等
|
-- 作者:fshrshilei
-- 发布时间:2013/12/26 17:12:41
--
谢谢老师。
|
-- 作者:jinzhe
-- 发布时间:2013/12/26 17:28:04
--
oo:=valuewhen(date<>ref(date,1),open);//当天开盘价 tt:=time<=145500;//限定交易时间:在强平前开仓 if h>=oo+10*mindiff and tt then buy(holding=0,1,limitr,high);//超过当天开盘价+10点后,开多
if enterprice-l>=10*mindiff and tt then sell(holding>0,0,market);//多单止损,止损10点
if l<=oo-10*mindiff then buyshort(holding=0,1,limitr,l);//低于当天开盘价-10点后,开空
if h-enterprice>=10*mindiff then sellshort(holding<0,0,market);//空单止损,止损10点
if holding>0 and hhv(h,enterbars+1)-enterprice>20*mindiff and l<=enterprice then sell(holding>0,0,market);//浮盈20点,回落到开仓价后平多
if holding<0 and enterprice-llv(l,enterbars+1)>20*mindiff and h>=enterprice then sellshort(holding<0,0,market);//浮盈20点,回落到开仓价后平多
if time>145500 then begin sellshort(1,0,market); sell(1,0,market); end//收盘前平仓
|
-- 作者:fshrshilei
-- 发布时间:2013/12/26 17:34:26
--
老师,测试后,每根K线上都有开平仓。
|
-- 作者:fshrshilei
-- 发布时间:2013/12/27 8:56:48
--
此主题相关图片如下:qq截图20131227085652.png
 老师 测试过以后就成这样了
|
-- 作者:jinzhe
-- 发布时间:2013/12/27 9:00:52
--
我调试了一下,调试代码:
oo:=valuewhen(date<>ref(date,1),open);//当天开盘价 tt:=time<=145500;//限定交易时间:在强平前开仓
if enterprice-l>=10*mindiff and enterbars>0 and tt then 多止损:sell(holding>0,0,market);//多单止损,止损10点 if h>=oo+10*mindiff and tt then buy(holding=0,1,thisclose);//超过当天开盘价+10点后,开多
if h-enterprice>=10*mindiff and enterbars>0 then 空止损:sellshort(holding<0,0,market);//空单止损,止损10点 if l<=oo-10*mindiff and tt then buyshort(holding=0,1,thisclose);//低于当天开盘价-10点后,开空
if holding>0 and hhv(h,enterbars+1)-enterprice>20*mindiff and l<=enterprice and enterbars>0 then 多回落:sell(holding>0,0,market);//浮盈20点,回落到开仓价后平多
if holding<0 and enterprice-llv(l,enterbars+1)>20*mindiff and h>=enterprice and enterbars>0 then 空回落:sellshort(holding<0,0,market);//浮盈20点,回落到开仓价后平多
if time>145500 then begin sellshort(1,0,market); sell(1,0,market); end//收盘前平仓
发现是你的条件太容易满足,只要一天的行情是一路走高或者走低,那么开平仓条件都容易满足,导致了后面每根k线都有信号
|
-- 作者:fshrshilei
-- 发布时间:2013/12/27 9:20:15
--
老师,是当天只开一次仓,是以满足开多,或者开空的条件,谁先满足 就开多或空仓, 然后有止损,止损后当天不开第二次仓
|
-- 作者:jinzhe
-- 发布时间:2013/12/27 9:26:21
--
oo:=valuewhen(date<>ref(date,1),open);//当天开盘价 tt:=time<=145500;//限定交易时间:在强平前开仓
if enterprice-l>=10*mindiff and enterbars>0 and tt then 多止损:sell(holding>0,0,market);//多单止损,止损10点 if h>=oo+10*mindiff and tt and totaldaytrade<1 then buy(holding=0,1,thisclose);//超过当天开盘价+10点后,开多
if h-enterprice>=10*mindiff and enterbars>0 then 空止损:sellshort(holding<0,0,market);//空单止损,止损10点 if l<=oo-10*mindiff and tt and totaldaytrade<1 then buyshort(holding=0,1,thisclose);//低于当天开盘价-10点后,开空
if holding>0 and hhv(h,enterbars+1)-enterprice>20*mindiff and l<=enterprice and enterbars>0 then 多回落:sell(holding>0,0,market);//浮盈20点,回落到开仓价后平多
if holding<0 and enterprice-llv(l,enterbars+1)>20*mindiff and h>=enterprice and enterbars>0 then 空回落:sellshort(holding<0,0,market);//浮盈20点,回落到开仓价后平多
if time>145500 then begin sellshort(1,0,market); sell(1,0,market); end//收盘前平仓
|
-- 作者:fshrshilei
-- 发布时间:2013/12/27 10:19:23
--
此主题相关图片如下:qq截图20131227101919.png
 老师,在股指上测试 看不到平仓信号的图标
|