 
等级: 超级版主
- 注册:
- 2021-5-18
- 曾用名:
|
https://www.weistock.com/univercity_video.html
教程,这里看下
// 计算 EMA20
EMA20 := EMA(CLOSE, 20);
// 判断阳线和阴线条件
IS_UPPER_K := C > O;
IS_LOWER_K := C < O;
// 计算前 K最高点和最低点
PREV_HIGH := high=hhv(high,10);
PREV_LOW := low=llv(low,10);
// 开仓条件
LONG_CONDITION := IS_UPPER_K AND C > EMA20 and PREV_HIGH;
SHORT_CONDITION := IS_LOWER_K AND C < EMA20 AND PREV_LOW;
cond_vol:ma(vol,5)>ma(vol,20);
// 开仓逻辑
IF LONG_CONDITION THEN BEGIN
SELLSHORT(1,HOLDING, MARKET); // 空头平仓
BUY(cond_vol,1, MARKET); // 开多 N手
END
IF SHORT_CONDITION THEN BEGIN
SELL(1,HOLDING, MARKET); // 多头平仓
SELLSHORT(cond_vol,1, MARKET); // 开空 N手
END
// 平仓逻辑
IF HOLDING > 0 AND low<ref(low,1)-5*mindiff THEN BEGIN
SELL(1,HOLDING, MARKET); // 多头平仓
END
IF HOLDING < 0 AND high>ref(low,1)+5*mindiff THEN BEGIN
SELLSHORT(1,HOLDING, MARKET); // 空头平仓
END |
|