金字塔公式 金字塔模型策略源码:runmode:0;
input:p(5,1,60,1);
lc:=ref(close,1);
rsi:=sma(max(close-lc,0),p,1)/
sma(abs(close-lc),p,1)*100;
entertime:=time>=143000 and time<=145500;
exittime:=time>=150000;
if holding=0 then begin
if entertime and rsi<=10 then
buy(1,1,limitr,close);
end
if holding=0 then begin
if entertime and rsi>=90 then
buyshort(1,1,limitr,close);
end
if holding>0 then begin
if entertime and rsi>=90 then begin
sell(1,holding,limitr,close),orderqueue;
buyshort(1,1,limitr,close),orderqueue;
end
if exittime then
sell(1,holding,limitr,close);
end
if holding<0 then begin
if entertime and rsi<=10 then begin
sellshort(1,holding,limitr,close),orderqueue;
buy(1,1,limitr,close),orderqueue;
end
if exittime then
sellshort(1,holding,limitr,close);
end
盈亏:asset,noaxis,colormagenta;
收益:(asset-50000)/50000,linethick0;
次数:totaltrade,linethick0;
胜率:percentwin,linethick0;
连亏:maxseqloss,linethick0;
连赢:maxseqwin,linethick0;
复制上述代码粘贴到到公式管理器
源码解析:
输出RUNMODE:0
输出INPUT:P(5,1,60,1)
LC赋值:昨收
RSI赋值:收盘价-LC和0的较大值的P日[1日权重]移动平均/收盘价-LC的绝对值的P日[1日权重]移动平均*100
ENTERTIME赋值:时间>=143000 AND 时间<=145500
EXITTIME赋值:时间>=150000
逻辑判断 HOLDING=0 THEN BEGIN 逻辑判断 ENTERTIME AND RSI<=10 THEN BUY(1,1,LIMITR,收盘价)
ENDIF HOLDING=0 THEN BEGIN 逻辑判断 ENTERTIME AND RSI>=90 THEN BUYSHORT(1,1,LIMITR,收盘价)
ENDIF HOLDING>0 THEN BEGIN 逻辑判断 ENTERTIME AND RSI>=90 THEN BEGIN SELL(1,HOLDING,LIMITR,收盘价),ORDERQUEUE
BUYSHORT(1,1,LIMITR,收盘价),ORDERQUEUE
END 逻辑判断 EXITTIME THEN SELL(1,HOLDING,LIMITR,收盘价)
ENDIF HOLDING<0 THEN BEGIN 逻辑判断 ENTERTIME AND RSI<=10 THEN BEGIN SELLSHORT(1,HOLDING,LIMITR,收盘价),ORDERQUEUE
BUY(1,1,LIMITR,收盘价),ORDERQUEUE
END 逻辑判断 EXITTIME THEN SELLSHORT(1,HOLDING,LIMITR,收盘价)
输出END盈亏:ASSET,NOAXIS,画洋红色
输出 收益:(ASSET-50000)/50000,线宽为0
输出次数:TOTALTRADE,线宽为0
输出胜率:PERCENTWIN,线宽为0
输出连亏:MAXSEQLOSS,线宽为0
输出连赢:MAXSEQWIN,线宽为0