简单的说明:源码
//中间变量
input:NS(5,0,60,1);
Price:=AVGENTERPRICE;//持仓价位
//交易条件
开多平空条件:=CROSS(MA(c,16),MA(c,5));
开空平多条件:=CROSS(MA(c,5),MA(c,16));
//交易系统
SELLSHORT(开多平空条件 and HOLDING<0,1,market);
SELLSHORT(HOLDING<0,1,Stopr,Price+NS); //止损
BUY(开多平空条件 and HOLDING=0,30%,market);
SELL(开空平多条件 and HOLDING>0,1,market);
SELL(HOLDING>0,1,Stopr,Price-NS);//止损
BUYSHORT(开空平多条件 and HOLDING=0,30%,market);
//其他
资产:asset,noaxis,colorgreen,LINETHICK0;
持从:HOLDING,LINETHICK0;
总次数: TOTALTRADE,LINETHICK0;
盈刟:NUMWINTRADE,LINETHICK0;
问题:1、没有信号就是三角符号?没有开仓新号吧! 2、SELLSHORT(HOLDING<0,1,Stopr,Price+NS); //止损;这里价格PRICE+NS指的是哪个价格,直接使用开仓价格:enterprice+ns可以吗?3、如果空单是开仓价+ns止损,止盈就是 开仓价-ns;麻烦给写一下吧;多单正好与之相反;4、我上午已经购买3年使用,今后要经常麻烦你们了;主要是把程序搞得好点;
5、图中使用的源码
( stopprice):=ma(c,20);
做多:=。。。。。
多空:。。。。。
//开多
IF ( stopprice)<做多THEN
BEGIN
SELLSHORT( HOLDING<0,HOLDING,market); //平空操作
BUY( HOLDING=0,1,market);//开多操作
maxprofit:=0;
END
//平仓
SELL((stopprice)>做空hand HOLDING>0,HOLDING,market);//平多
BUYSHORT((stopprice)>做空 and HOLDING=0,1,market); //开空操作
//多头为例回撤K3平仓
if enterbars>=3 then begin
if c>o and holding>0 then sell(1,holding,market);
if c<o then buy(holding>0,1,market);
end
//空头为例
if enterbars>=3 then begin
if c>o and holding<0 then sell(1,holding,market);
if c<o then buy(holding<0,1,market);
end
给试试,要求就是第3根K线的处理:比如下跌趋势,开仓成立;第3根K线,c>o,平仓止盈;之后,继续按原反方向开仓,直到方向翻转为止;
//开多
IF ( stopprice)<l THEN
BEGIN
SELLSHORT( HOLDING<0,HOLDING,market); //平空操作
BUY( HOLDING=0,1,market);//开多操作
maxprofit:=0;
END
//平仓
SELL((stopprice)>h and HOLDING>0,HOLDING,market);//平多
BUYSHORT((stopprice)>hand HOLDING=0,1,market); //开空操作
//多头为例回撤K3平仓
if enterbars>=3 then begin
if c>o and holding>0 then sell(1,holding,market);
if c<o then buy(holding>0,1,market);
end
//空头为例
if enterbars>=3 then begin
if c>o and holding<0 then sell(1,holding,market);
if c<o then buy(holding<0,1,market);
end
1.白色三角箭头,表示这里有信号但是因为你指定的价格不能成交,所以变成不算作是信号
2.你指定的价格,PRICE是你自己定义的,是什么价格自己应该清除。想要用什么价格根据自己的需求来没有固定的规矩
3.所谓止损不是指你要下止损单。这个是两个意思,直接限价下单
sellshort(holding<0,0,limitr,enterprice-ns);
sell(holding>0,0,limitr,enterprice+ns);
4.ok
5.
if enterbars>=3 then begin
if c>o and holding>0 then sell(1,holding,market);
if c<o and type(1)= 2 then buy(holding>=0,1,market);
end
//空头为例
if enterbars>=3 then begin
if c>o and holding<0 then sellshort(1,holding,market);
if c<o and type(1)=4 then buyshort(holding<=0,1,market);
end
谢谢,再试试
2.你指定的价格,PRICE是你自己定义的,是什么价格自己应该清除。想要用什么价格根据自己的需求来没有固定的规矩,
谢谢
请教:我使用enterprice可以吧,看看下面我写的对不对,请把止盈的句子给加上写法,我以后模仿使用;谢谢
//交易系统
SELLSHORT(开多平空条件 and HOLDING<0,1,market);//平空
SELLSHORT(HOLDING<0,1,Stopr,enterPrice-NS); //多单止损
BUY(开多平空条件 and HOLDING=0,30%,market);//开多
SELL(开空平多条件 and HOLDING>0,1,market);//平多
SELL(HOLDING>0,1,Stopr,enterPrice+NS);//空单止损
BUYSHORT(开空平多条件 and HOLDING=0,30%,market);//开空
你这样写的太乱,写成这样比较好
if 平多开空条件 then begin
SELLSHORT( HOLDING<0,1,market);//平空
BUY(HOLDING=0,30%,market);//开多
end
if 平空开多条件 then begin
SELL( HOLDING>0,1,market);//平多
BUYSHORT(HOLDING=0,30%,market);//开空
end
if 空单止损条件 then SELLSHORT(HOLDING<0,1,limitr,enterPrice-NS); //空单止损
if 多单止损条件 then SELL(HOLDING>0,1,limitr,enterPrice+NS);//多单止损
你的止损条件是什么?