 
等级: 超级版主
- 注册:
- 2021-5-18
- 曾用名:
|
// KDJ 参数设置
N := 89;
P1 := 3;
P2 := 3;
// KDJ 计算
RSV := (CLOSE - LLV(LOW, N)) / (HHV(HIGH, N) - LLV(LOW, N)) * 100;
K := SMA(RSV, P1, 1);
D := SMA(K, P2, 1);
J := 3 * K - 2 * D;
// 开仓条件
CONDBUY := J > 50;
CONDSELLSHORT := J < -2 OR J < -10;
// 平仓条件
CONDSELL := (J > 100 AND J < 100) OR (J > 80 AND J < 80);
CONDSELLSHORT := (J < -2 OR J < -10) AND CROSS(J, 0);
// 开仓和平仓
BUY(CONDBUY AND holding < 10, 1, limitr, CLOSE);
SELL(holding > 0, holding, marketr);
SELLSHORT(CONDSELLSHORT AND holding < 10, 1, limitr, CLOSE);
BUY(CONDSELLSHORT, holding, marketr); |
|