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]<CCIAvg[1];
Condition2 = CCIValue<=CCIAvg&&CCIValue[1]>CCIAvg[1];
If(Condition1)
{
if (MarketPosition==-1)
{
myExitPrice=c;
Commentary("myExitPrice="+Text(myExitPrice));
BuyToCover(1,c);
}
if (MarketPosition==0)
{
myEntryPrice=Data0.close;
Commentary("myEntryPrice="+Text(myEntryPrice));
Buy(1,close);
}
}
If(Condition1)
{
If(MarketPosition==1)
{
myExitPrice=c;
Commentary("myExitPrice="+Text(myExitPrice));
Sell(1,c);
}
If (MarketPosition==0)
{
myEntryPrice=Data0.close;
Commentary("myEntryPricePrice="+Text(myEntryPrice));
SellShort(1,close);
}
}
End
//------------------------------------------------------------------------
// 編譯版本 GS2010.12.08 CXH99.COM
// 來源: www.tumamayizhan.com
// 版權所有 guitar1234
// 更改聲明 TradeBlazer Software保留對TradeBlazer平臺
// 每一版本的TrabeBlazer公式修改和重寫的權利
//------------------------------------------------------------------------
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 262069696 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容