程序如下:
input: n1(2,1,60),n2(13,1,100),n3(2,2,10),drawdown(3,1,10);
LC := REF(CLOSE,1);
RSI1:=SMA(MAX(CLOSE-LC,0),n1,1)/SMA(ABS(CLOSE-LC),n1,1)*100;
RSI2:=SMA(MAX(CLOSE-LC,0),n2,1)/SMA(ABS(CLOSE-LC),n2,1)*100;
r1:=ema(rsi1,n3);
r2:=ema(rsi2,n3);
r3:(r1-r2),COLORGRAY,LINETHICK0;
ts:=iif(r3>0,1,-1),noaxis;
if holding<>0 then zs:=AVGENTERPRICE-drawdown/100*asset/10/Holding; //空头是负数,所以能合并
买入价:AVGENTERPRICE,linethick0;
止损:zs,linethick0;
{平多}
sell(holding>0,0,STOP,zs); //止损价
sell(holding>0 and r3<0,0,thisclose);
{平空}
sellshort(holding<0,0,STOP,zs); //止损价
sellshort(holding<0 and r3>0,0,thisclose);
{开多}
buy(vol>5000 and holding=0 and r3>0,intpart(asset*0.4/close),thisclose);
{开空}
buyshort(vol>5000 and holding=0 and r3<0,intpart(asset*0.4/close),thisclose);
资产:asset,noaxis,colorgreen;
持仓:holding,noaxis,linethick0;
提示:ts,noaxis,linethick0;
请教
1:我能同时2个Sell指令么?如上,一个是定义止损,一个是正常交易用。
2:在RB02 60min看11/20 15:00 怎么会被平空?最高价是4115,而程序显示止损价是4140,更本没有触及啊
谢谢
STOP表示次周期达到设定价格即操作买入或卖出,否则放弃。
本周起的用STOPr
{平多}
sell(holding>0,0,STOPr,zs); //止损价
sell(holding>0 and r3<0,0,thisclose);
{平空}
sellshort(holding<0,0,STOPr,zs); //止损价
sellshort(holding<0 and r3>0,0,thisclose);
哦。原来如此,没见有通知的?
另外,
1:同时写2个Sell,Buy的语法没问题是么?
2:TBuy,Tsell 改成 STPr,对么?
谢谢
在函数表述中有。
写2个Sell,Buy的语法没问题。
谢谢
Buy,Sell 对应Stopr,TBuy,TSell 对应Stop ??还是STOPr 是单独的止损指令?
谢谢,帮助的举例都是Buy,Sell 的。
注意:TBuy,TSell 对应Stp
有时就是一字之差