龙听期货论坛's Archiver

龙听 发表于 2019-2-28 11:35

Super Scalper 趋势交易策略系统

源码如下:
[code]
/定义参数
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(k,d),High);//KD交叉时对应高点
Gj:=Valuewhen(H>=HHV(High,P3),High);//前一轮行情最高价
Cond4:=Barslast(H>=HHV(High,P3));//前一轮行情高点到现在的周期数
Dj:=Llv(Low,Cond4);//前一轮行情最低价

Cond1:=Sm>Em;
Cond2:=Cross(K,D);//K、D交叉
Cond3:=Barslast(COND2)<=4 AND High>Tp;//KD交叉以后四个周期内,价格突破
BuyCond:Cond1 And K>D And Cond3 ;//开仓条件


//下单语句
If BuyCond And Holding=0 Then
   Begin
   Buy(1,Num,Market);
   Gl:=Gj;//开仓时前一轮行情高价
   Dl:=Dj;//开仓时前一轮最低价
   ls:=Gl-Dl;//区间幅度
   End
   
//幅度止损部分  
If Enterprice>=Gl And Close<=Dl+0.618*ls Then Sell(1,Num,Market);
If Enterprice>=Dl+0.786*ls And Enterprice<=Gl And Close<=Dl+0.5*ls Then Sell(1,Num,Market);
If Enterprice>=Dl+0.5*ls And Enterprice<=Dl+0.786*ls And Close<=Dl+0.236*ls Then Sell(1,Num,Market);
If Enterprice>=Dl+0.236*ls And Enterprice<Dl+0.5*ls And Close<=Dl Then Sell(1,Num,Market);

//幅度止盈部分
If Close>=Dl+1.272*ls Then Sell(1,Intpart(Num/2),Market);
If Close>=Dl+1.618*ls Then Sell(1,0,Market);
[/code]

页: [1]