  
等级: 专业版 
- 注册: 
 - 2021-5-20
 
- 曾用名: 
 
 
 
 | 
 
请问一下:我在训练把TB的公式全部能翻译成金字塔的能力,但是在翻译的时候不知道哪里出了问题(TB是RSI公式,我也知道金字塔系统里有公式,但是我就是想学一下): 
我是这么写的,看一下: 
VARIABLE:NetChgAvg:=0; 
VARIABLE:TotChgAvg:=0; 
SF:=0; 
REFCLOSE:=REF(CLOSE,1); 
IF BARPOS<14-1 THEN BEGIN 
        NetChgAvg:=(CLOSE-REFCLOSE)/14; 
        TotChgAvg:=MA(ABS(CLOSE-REFCLOSE),14); 
///////这里就提醒IF 中不允许使用MA函数,这样我不知道怎么翻译了,帮我看看怎么解决,或者直接把下面的TB公式翻译出来也可以(备注:LC := REF(CLOSE,1);RSI1:SMA(MAX(CLOSE-LC,0),12,1)/SMA(ABS(CLOSE-LC),12,1)*100;,这个公式不要,我要的就是把TB翻译出来) 
 
 
 
 
 
Params  
        Numeric Length(14) ; //周期 
        Numeric OverSold(30) ; //超卖 
        Numeric OverBought(70) ; //超买 
Vars 
        Series<Numeric> NetChgAvg( 0 ); 
        Series<Numeric> TotChgAvg( 0 ); 
        Numeric SF( 0 ); 
        Numeric Change( 0 );         
        Numeric ChgRatio( 0 ) ; 
        Numeric RSIValue; 
Events 
        OnBar(ArrayRef<Integer> indexs) 
        {         
                Range[0:DataSourceSize() - 1] 
                { 
                        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("超买",OverBought); 
                        PlotNumeric("超卖",OverSold); 
                } 
        } 
 
 |   
 
 
 
 |