波动突破交易策略源码-金字塔公式
更多金钻指标股票技术讨论QQ群:966329692 技术讨论QQ群:220302856 技术讨论QQ群:39652085 如群满可换一个

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

runmode:0;
 input:volatility(20,5,100,5);
  variable:myasset=30000;
 entertime:=time>=092500 and time<=145500;   //这一句为什么编译有错误???
 exittime:=time>=150000;
 
 dist:=barslast(date<>ref(date,1));
 oo:=ref(open,dist);
 
  highest:=oo+volatility*mindiff;
  lowest:=oo-volatility*mindiff;

 buycond:=entertime and high>=highest;
  buyprice:=max(open,highest);
 
  buyshortcond:=entertime and low<=lowest;
  buyshortprice:=min(open,lowest);
 
  if holding=0 and buycond then begin
      buy(1,1,limitr,buyprice);
  end
 
 if holding=0 and buyshortcond then begin
      buyshort(1,1,limitr,buyshortprice);
  end
 
 if holding>0 and exittime then begin
     sell(1,holding,limitr,close);
 end

 if holding<0 and exittime then begin
      sellshort(1,holding,limitr,close);
  end
 
  if exittime then
      myasset:=asset;
     
  资产:myasset,noaxis,colormagenta;
  次数:totaltrade,linethick0;
  收益:(myasset-30000)/30000,linethick0;
  胜率:percentwin,linethick0;
  出击:totaltrade/(count(date<>ref(date,1),0)+1),linethick0;
  连亏:maxseqloss,linethick0;
  连赢:maxseqwin,linethick0;

源码解析:

输出RUNMODE:0
输出 INPUT:VOLATILITY(20,5,100,5)
输出  VARIABLE:MYASSET=30000
 ENTERTIME赋值:时间>=092500 AND 时间<=145500
 EXITTIME赋值:时间>=150000
 DIST赋值:上次日期<>昨日日期距今天数
OO赋值:DIST日前的开盘价
HIGHEST赋值:OO+VOLATILITY*MINDIFF
 LOWEST赋值:OO-VOLATILITY*MINDIFF
 BUYCOND赋值:ENTERTIME AND 最高价>=HIGHEST
 BUYPRICE赋值:开盘价和HIGHEST的较大值
BUYSHORTCOND赋值:ENTERTIME AND 最低价<=LOWEST
 BUYSHORTPRICE赋值:开盘价和LOWEST的较小值
   逻辑判断 HOLDING=0 AND BUYCOND THEN BEGIN      BUY(1,1,LIMITR,BUYPRICE)
   END  逻辑判断 HOLDING=0 AND BUYSHORTCOND THEN BEGIN      BUYSHORT(1,1,LIMITR,BUYSHORTPRICE)
   END  逻辑判断 HOLDING>0 AND EXITTIME THEN BEGIN     SELL(1,HOLDING,LIMITR,收盘价)
  END  逻辑判断 HOLDING<0 AND EXITTIME THEN BEGIN      SELLSHORT(1,HOLDING,LIMITR,收盘价)
MYASSET赋值:ASSET
输出        资产:MYASSET,NOAXIS,画洋红色
 输出  次数:TOTALTRADE,线宽为0
输出  收益:(MYASSET-30000)/30000,线宽为0
输出  胜率:PERCENTWIN,线宽为0
输出  出击:TOTALTRADE/(统计0日中满足日期<>昨日日期的天数+1),线宽为0
输出  连亏:MAXSEQLOSS,线宽为0
输出  连赢:MAXSEQWIN,线宽为0

 


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