| |
我改成这样,但是好像哪里不对呀?麻烦帮我看看
//中间变量
Variable:ls=0,Gl=0,Dl=0;
Num:=2;
Em:Ema(Close,34);//收盘价34期EMA
Sm:Sma(Close,8,1);//收盘价8期SMA
Rsv:=(Close-Llv(Low,N))/(Hhv(High,N)-Llv(Low,N))*100;
K:=Sma(RSV,P1,1),NOAXIS;
D:=Sma(K,P2,1),noaxis;
Tp:=Valuewhen(Cross(D,K),LOW);//KD交叉时对应低点
Gj:=Valuewhen(L<=LLV(LOW,P3),LOW);//前一轮行情最低价
Cond4:=Barslast(L<=LLV(LOW,P3));//前一轮行情低点到现在的周期数
Dj:=HHV(high,Cond4);//前一轮行情最高价
Cond1:=Sm<Em;
Cond2:=Cross(D,K);//K、D交叉
Cond3:=Barslast(COND2)<=4 AND LOW<Tp;//KD交叉以后四个周期内,价格突破
BuyCond:=Cond1 And K<D And Cond3 ;//开仓条件
//下单语句
If BuyCond And Holding=0 Then
Begin
BUYSHORT(1,Num,Market);
Gl:=Gj;//开仓时前一轮行情低价
Dl:=Dj;//开仓时前一轮最高价
ls:=Dl-GL;//区间幅度
End
//幅度止损部分
If Enterprice>=Dl And Close<=Dl-0.382*ls Then SELLSHORT(1,Num,Market);
If Enterprice<=Gl-1.786*ls And Enterprice>=Dl And Close>=Gl-1.5*ls Then SELLSHORT(1,Num,Market);
If Enterprice<=Gl-1.5*ls And Enterprice>=Gl-1.786*ls And Close>=Gl-1.236*ls Then SellSHORT(1,Num,Market);
If Enterprice<=Gl-1.236*ls And Enterprice>Gl-1.5*ls And Close>=Gl Then SellSHORT(1,Num,Market);
//幅度止盈部分
If Close<=Gl-0.272*ls Then SellSHORT(1,Intpart(Num/2),Market);
If Close<=Gl-0.618*ls Then SellSHORT(1,0,Market);
Input:N(81,1,100,10),P1(14,2,40,4),P2(14,2,40,4),P3(36,10,100,2);
//中间变量
Variable:ls=0,Gl=0,Dl=0;
Num:=2;
Em:Ema(Close,34);//收盘价34期EMA
Sm:Sma(Close,8,1);//收盘价8期SMA
Rsv:=(Close-Llv(Low,N))/(Hhv(High,N)-Llv(Low,N))*100;
K:=Sma(RSV,P1,1),NOAXIS;
D:=Sma(K,P2,1),noaxis;
Tp:=Valuewhen(Cross(D,K),LOW);//KD交叉时对应低点
Gj:=Valuewhen(L<=LLV(LOW,P3),LOW);//前一轮行情最低价
Cond4:=Barslast(L<=LLV(LOW,P3));//前一轮行情低点到现在的周期数
Dj:=HHV(high,Cond4);//前一轮行情最高价
Cond1:=Sm<Em;
Cond2:=Cross(D,K);//K、D交叉
Cond3:=Barslast(COND2)<=4 AND LOW<Tp;//KD交叉以后四个周期内,价格突破
BuyCond:=Cond1 And K<D And Cond3 ;//开仓条件
//下单语句
If BuyCond And Holding=0 Then
Begin
BUYSHORT(1,Num,Market);
Gl:=Gj;//开仓时前一轮行情低价
Dl:=Dj;//开仓时前一轮最高价
ls:=Dl-GL;//区间幅度
End
//幅度止损部分
If Enterprice>=Dl And Close<=Dl-0.382*ls Then SELLSHORT(1,Num,Market);
If Enterprice<=Gl-1.786*ls And Enterprice>=Dl And Close>=Gl-1.5*ls Then SELLSHORT(1,Num,Market);
If Enterprice<=Gl-1.5*ls And Enterprice>=Gl-1.786*ls And Close>=Gl-1.236*ls Then SellSHORT(1,Num,Market);
If Enterprice<=Gl-1.236*ls And Enterprice>Gl-1.5*ls And Close>=Gl Then SellSHORT(1,Num,Market);
//幅度止盈部分
If Close<=Gl-0.272*ls Then SellSHORT(1,Intpart(Num/2),Market);
If Close<=Gl-0.618*ls Then SellSHORT(1,0,Market);
有变量的,一楼的变量!我编译公式成功的,但是把图表放小后,信号就消失不见了
历史信号受K线数量的影响,尤其你其中还使用对数据比较敏感的函数sma.
所以会在成信号的变化