RSI的第一個(gè)值是怎么來(lái)的 [開(kāi)拓者 TB]
- 咨詢(xún)內(nèi)容:
剛開(kāi)始學(xué)TB,請(qǐng)教一下RSI的計(jì)算。
If(CurrentBar <= Length - 1)的時(shí)候Close[Length] 的值都是空的,那么NetChgAvg = ( Close - Close[Length] ) / Length 應(yīng)該也是空值,那么第一個(gè)NetChgAvg的值是怎么計(jì)算來(lái)的,謝謝。- //------------------------------------------------------------------------
- // 簡(jiǎn)稱(chēng): RSI
- // 名稱(chēng): 相對(duì)強(qiáng)弱指數(shù)
- // 類(lèi)別: 公式應(yīng)用
- // 類(lèi)型: 內(nèi)建應(yīng)用
- //------------------------------------------------------------------------
- Params
- Numeric Length(14) ;
- Numeric OverSold(30) ;
- Numeric OverBought(70) ;
- Vars
- NumericSeries NetChgAvg( 0 );
- NumericSeries TotChgAvg( 0 );
- Numeric SF( 0 );
- Numeric Change( 0 );
- Numeric ChgRatio( 0 ) ;
- Numeric RSIValue;
- Begin
- If(CurrentBar <= Length - 1)
- {
- NetChgAvg = ( Close - Close[Length] ) / Length ;
- TotChgAvg = Average( Abs( Close - Close[1] ), Length ) ;
- }Else
- {
- SF = 1/Length;
- Change = Close - Close[1] ;
- NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
- TotChgAvg = TotChgAvg[1] + SF * ( Abs( Change ) - TotChgAvg[1] ) ;
- }
-
- If( TotChgAvg <> 0 )
- {
- ChgRatio = NetChgAvg / TotChgAvg;
- }else
- {
- ChgRatio = 0 ;
- }
- RSIValue = 50 * ( ChgRatio + 1 );
- PlotNumeric("RSI",RSIValue);
- PlotNumeric("超買(mǎi)",OverBought);
- PlotNumeric("超賣(mài)",OverSold);
- End
- //------------------------------------------------------------------------
- // 編譯版本 GS2010.12.08
- // 版權(quán)所有 TradeBlazer Software 2003-2010
- // 更改聲明 TradeBlazer Software保留對(duì)TradeBlazer平
- // 臺(tái)每一版本的TradeBlazer公式修改和重寫(xiě)的權(quán)利
- //------------------------------------------------------------------------
- //------------------------------------------------------------------------
- TB技術(shù)人員:
自己搞明白了,原來(lái)Bar數(shù)據(jù)、序列變量在回溯越界時(shí)用該數(shù)據(jù)源的第1個(gè)值代替,而不是返回空值。
- TB客服:
if(hitoday>=ssetup and marketposition>-1 and GetGlobalVar(1)<1)
{
If(Low<=(senter+(hitoday-ssetup)/div))
{
SellShort(1,senter+(hitoday-ssetup)/div);
SetGlobalVar(1,Time);
Return;
}
}
if(ltoday<=bsetup and marketposition<1 and GetGlobalVar(1)<1)
{
If(High>=(benter-(bsetup-ltoday)/div))
{
Buy(1,benter-(bsetup-ltoday)/div);
SetGlobalVar(1,Time);
Return;
}
}
這一段可能會(huì)出現(xiàn)同一根BAR既滿(mǎn)足high值高于ssetup,又滿(mǎn)足Low<=(senter+(hitoday[1]-ssetup)/div)的情況,但實(shí)際無(wú)法判斷先后。
改成
if(hitoday[1]>=ssetup and marketposition>-1 and GetGlobalVar(1)<1 &&date==date[1])
{
If(Low<=(senter+(hitoday[1]-ssetup)/div))
{
SellShort(1,senter+(hitoday[1]-ssetup)/div);
SetGlobalVar(1,Time);
Return;
}
}
if(ltoday[1]<=bsetup and marketposition<1 and GetGlobalVar(1)<1 &&date==date[1])
{
If(High>=(benter-(bsetup-ltoday[1])/div))
{
Buy(1,benter-(bsetup-ltoday[1])/div);
SetGlobalVar(1,Time);
Return;
}
}
這樣子會(huì)不會(huì)好一點(diǎn)?還有后面的if(marketposition==0)那一段貌似也得加上跳空判斷~ 本人在實(shí)盤(pán)觀察過(guò)的確有實(shí)盤(pán)閃爍過(guò)。還要自己仔細(xì)看一看啦!
- 網(wǎng)友回復(fù):
if(hitoday>=ssetup and marketposition>-1 and GetGlobalVar(1)<1)
{
If(Low<=(senter+(hitoday-ssetup)/div))
{
SellShort(1,senter+(hitoday-ssetup)/div);
SetGlobalVar(1,Time);
Return;
}
}
if(ltoday<=bsetup and marketposition<1 and GetGlobalVar(1)<1)
{
If(High>=(benter-(bsetup-ltoday)/div))
{
Buy(1,benter-(bsetup-ltoday)/div);
SetGlobalVar(1,Time);
Return;
}
}
這一段可能會(huì)出現(xiàn)同一根BAR既滿(mǎn)足high值高于ssetup,又滿(mǎn)足Low<=(senter+(hitoday[1]-ssetup)/div)的情況,但實(shí)際無(wú)法判斷先后。
改成
if(hitoday[1]>=ssetup and marketposition>-1 and GetGlobalVar(1)<1 &&date==date[1])
{
If(Low<=(senter+(hitoday[1]-ssetup)/div))
{
SellShort(1,senter+(hitoday[1]-ssetup)/div);
SetGlobalVar(1,Time);
Return;
}
}
if(ltoday[1]<=bsetup and marketposition<1 and GetGlobalVar(1)<1 &&date==date[1])
{
If(High>=(benter-(bsetup-ltoday[1])/div))
{
Buy(1,benter-(bsetup-ltoday[1])/div);
SetGlobalVar(1,Time);
Return;
}
}
這樣子會(huì)不會(huì)好一點(diǎn)?還有后面的if(marketposition==0)那一段貌似也得加上跳空判斷~ 本人在實(shí)盤(pán)觀察過(guò)的確有實(shí)盤(pán)閃爍過(guò)。還要自己仔細(xì)看一看啦!
有思路,想編寫(xiě)各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 1145508240 進(jìn)行 有償 編寫(xiě)!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒(méi)有相關(guān)內(nèi)容