金字塔布林通道+MA+diff落影模型源码-金字塔公式
更多金钻指标股票技术讨论QQ群:966329692 技术讨论QQ群:220302856 技术讨论QQ群:39652085 如群满可换一个

金字塔公式 金字塔模型策略源码:
 

input:P(26,20,100,8);
 input:S(12,5,40,4);

input:B1(26,5,300,30);
 input:B2(2,0.1,10,1);

input:N2(10,1,120,12);
 input:N3(20,1,200,20);
 input:N4(60,1,200,20);

ma2:=ma(c,n2);
 ma3:=ma(c,n3);
 ma4:=ma(c,n4);

MID := MA(CLOSE,B1);
 UPPER:= MID + B2*STD(CLOSE,B1);
 LOWER:= MID - B2*STD(CLOSE,B1),colorred;

diff := EMA(CLOSE,S) - EMA(CLOSE,P);

variable:vmin = 090000;//用于隔夜高开或低开时间差

if (abs(o-ref(c,1))>=20*MINDIFF AND time>090000 and time<090400) then vmin := 091500;

//开多仓条件:
BOPEON1:=c>upper and diff>0 and c>o and c>ma4 AND HOLDING=0 AND time>vmin AND time<144800;

//平多仓条件:
BLIQCON:=holding>0 and cross(ma3,ma2);

//开空仓条件:
SOPCON1:=c<lower and diff<0 and c<o and c<ma4 AND HOLDING=0 AND time>vmin AND time<144800;

//平空仓条件:
SLIQCON:=holding<0 and cross(ma2,ma3);


buy(BOPEON1,1,market);
 sell(BLIQCON,holding,market);
 buyshort(SOPCON1,1,market);
 sellshort(SLIQCON,holding,market);

//收盘前平仓
sell(time>145400 and holding>0,holding,market);
 sellshort(time>145400 and holding<0,holding,market);

可用现金:CASH(0),LINETHICK0;
持仓:HOLDING,LINETHICK0;
资产:ASSET,LINETHICK0;

==============================================================

源码解析:

MA2赋值:收盘价的N2日简单移动平均
MA3赋值:收盘价的N3日简单移动平均
MA4赋值:收盘价的N4日简单移动平均
 赋值: 收盘价的B1日简单移动平均
UPPER赋值: MID + B2*收盘价的B1日估算标准差
LOWER赋值: MID - B2*收盘价的B1日估算标准差,画红色
 赋值: 收盘价的S日指数移动平均 - 收盘价的P日指数移动平均
 输出VARIABLE:VMIN = 090000
赋值: 091500
 EON1赋值:收盘价>UPPER AND DIFF>0 AND 收阳线AND 收盘价>MA4 AND HOLDING=0 AND 时间>VMIN AND 时间<144800
 QCON赋值:HOLDING>0 AND MA3上穿MA2
 CON1赋值:收盘价<LOWER AND DIFF<0 AND 收阴线AND 收盘价<MA4 AND HOLDING=0 AND 时间>VMIN AND 时间<144800
 QCON赋值:HOLDING<0 AND MA2上穿MA3
 BUY(BOPEON1,1,MARKET)
 SELL(BLIQCON,HOLDING,MARKET)
 BUYSHORT(SOPCON1,1,MARKET)
 SELLSHORT(SLIQCON,HOLDING,MARKET)
 //收盘前平仓SELL(时间>145400 AND HOLDING>0,HOLDING,MARKET)
 SELLSHORT(时间>145400 AND HOLDING<0,HOLDING,MARKET)
输出可用现金:CASH(0),线宽为0
输出持仓:HOLDING,线宽为0
输出资产:ASSET,线宽为0
 

 


选股票看什么指标最好 >股票指标网