hh:=ref(hitoday,1); cc:=ref(close,1); ll:=ref(ltoday,1);
if date>ref(date,1) then begin startnow:=startnow+1;
ssetup:=hh+f1*(cc-ll);
senter:=((1+f2)/2)*(hh+cc)-f2*ll; benter:=((1+f2)/2)*(ll+cc)-f2*hh; bsetup:=ll-f1*(hh-cc);
bbreak:=ssetup+f3*(ssetup-bsetup); sbreak:=bsetup-f3*(ssetup-bsetup);
hitoday:=high; ltoday:=low;
rfilter:=hh-cc>=rangemin; end
if high>hitoday then hitoday:=high; if low if time>=notbef and time if ltoday<=bsetup and holding<=0 then begin if high>=benter-(bsetup-ltoday)/div then begin sellshort(1,holding,limitr,benter-(bsetup-ltoday)/div); buy(1,1,limitr,benter-(bsetup-ltoday)/div); end end if holding<0 then begin if high-enterprice>=i_reverse then sellshort(1,enterprice+i_reverse); end if holding>0 then begin if enterprice-low>=i_reverse then sell(1,enterprice-i_reverse); end //来源 www.88gs.com if holding=0 then begin if high>=bbreak then buy(1,bbreak); end if holding=0 then begin if low<=sbreak then sellshort(1,sbreak); end end if time>=notaft then begin if holding<0 then sellshort(1,holding,limitr,open); if holding>0 then sell(1,holding,limitr,open); end 盈亏:asset-500000,noaxis,coloryellow,linethick2; 复制上述代码粘贴到公式管理器即可 TB顺势指标交易策略源码 简称: CCIapply // 名称: 顺势指标 // 类别: 公式应用 // 类型: 用户应用 // 来源: WW.CXH99.COM //------------------------------------------------------------------------ Params Numeric Para1(10); Numeric Para2(5); Numeric Length(14); Numeric AvgLength(9); Vars Bool Condition1; Bool Condition2; Bool PreBreakoutFailure; NumericSeries TmpValue; Numeric Mean( 0 ); Numeric AvgDev( 0 ); Numeric Counter( 0 ) ; NumericSeries CCIValue(0); NumericSeries CCIAvg; Numeric ExitLowestPrice; Numeric myEntryPrice; // 开仓价格 Numeric myExitPrice; // 平仓价格 NumericSeries preEntryPrice(0); // 前一次开仓的价格 Begin TmpValue = High + Low + Close; Mean = AverageFC( TmpValue, Length ) ; AvgDev = 0 ; for Counter = 0 to Length - 1 { AvgDev = AvgDev + Abs( TmpValue[Counter] - Mean ) ; } AvgDev = AvgDev / Length ; if( AvgDev == 0) CCIValue = 0; Else CCIValue = ( TmpValue - Mean ) / ( 0.015 * AvgDev ) ; //求CCI值 CCIAvg = AverageFC(CCIValue, AvgLength ); If(BarStatus == 0) { preEntryPrice = InvalidNumeric; PreBreakoutFailure = false; } Condition1 =CCIValue>=CCIAvg&&CCIValue[1] If(Condition1) { if (MarketPosition==-1) { myExitPrice=c; Commentary(\ BuyToCover(1,c); } if (MarketPosition==0) { myEntryPrice=Data0.close; Commentary(\ Buy(1,close); } } If(Condition1) { If(MarketPosition==1) { myExitPrice=c; Commentary(\ Sell(1,c); } If (MarketPosition==0) { myEntryPrice=Data0.close; Commentary(\ SellShort(1,close); } } End //------------------------------------------------------------------------ // 编译版本 GS2010.12.08 CXH99.COM // 来源: www.88gs.com // 版权所有 guitar1234 // 更改声明 TradeBlazer Software保留对TradeBlazer平台 // 每一版本的TrabeBlazer公式修改和重写的权利 多空价差平仓源码 咨询内容: Params Numeric M(1); Numeric BarRef(30);//回溯bar的根数 Numeric MARef(30);//均线回溯天数 Vars NumericSeries Spread(0); Bool CondInB(False); Bool CondInS(False); Bool CondExB(False); Bool CondExS(False); Begin If(Data0.Close!=InvalidNumeric&&Data1.Close!=InvalidNumeric) { Spread=Data0.Close-Data1.Close; // 定义价差 //参数定义 ////////////////////////////////////// CondInB= Spread>Highest(Spread[1],BarRef); //做多价差 CondInS= Spread CondExB= CrossUnder(Spread ,Average(Spread[1],MARef)); //做多价差平仓 CondExS= CrossOver(Spread ,Average(Spread[1],MARef) ); //做空价差平仓 /////////////////////////////////////////////////////画图 1分钟k线显示当日结算价的线(即是分时图里的黄线) 咨询内容: Vars NumericSeries AmountCum; // 当日以来成交总额的合计值 NumericSeries VolCum; // 当日以来成交量的合计值 Begin if(day!=Day[1]) { Amountcum=close*Vol; volcum=vol; }else { AmountCum = amountcum[1]+close*vol; VolCum = volcum[1]+vol; PlotNumeric(\ } 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库国外五大股票交易系统,及其源码(8)在线全文阅读。
相关推荐: