Params
Numeric Length(55) ;
Numeric OverSold(30) ;
Numeric OverBought(70) ;
Vars
Numeric A;
Numeric B;
NumericSeries NetChgAvg( 0 );
NumericSeries TotChgAvg( 0 );
Numeric SF( 0 );
Numeric Change( 0 );
Numeric ChgRatio( 0 ) ;
NumericSeries RSIValue;
NumericSeries RSIMA;
//------------------------------------------
NumericSeries NetChgAvg1( 0 );
NumericSeries TotChgAvg1( 0 );
Numeric SF1( 0 );
Numeric Change1( 0 );
Numeric ChgRatio1( 0 ) ;
NumericSeries RSIValue1;
NumericSeries RSIMA1;
Begin
//----------------------DATA0--------------------------------------------------
If(CurrentBar <= Length - 1)
{
NetChgAvg = ( DATA0.Close - DATA0.Close[Length] ) / Length ;
TotChgAvg = Average( Abs( DATA0.Close - DATA0.Close[1] ), Length ) ;
}Else
{
SF = 1/Length;
Change = DATA0.Close - DATA0.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 );
RSIMA = Average(RSIValue,13);
//----------------------------DATA1---------------------------------------------
If(CurrentBar <= Length - 1)
{
NetChgAvg1 = ( DATA1.Close - DATA1.Close[Length] ) / Length ;
TotChgAvg1 = Average( Abs( DATA1.Close - DATA1.Close[1] ), Length ) ;
}Else
{
SF1 = 1/Length;
Change1 = DATA1.Close - DATA1.Close[1] ;
NetChgAvg1 = NetChgAvg1[1] + SF1 * ( Change1 - NetChgAvg1[1] ) ;
TotChgAvg1 = TotChgAvg1[1] + SF1 * ( Abs( Change1 ) - TotChgAvg1[1] ) ;
}
If( TotChgAvg1 <> 0 )
{
ChgRatio1 = NetChgAvg1 / TotChgAvg1;
}else
{
ChgRatio1 = 0 ;
}
RSIValue1 = 50 * ( ChgRatio1 + 1 );
RSIMA1 = Average(RSIValue1,13);
A = data0.RSIMA;
B =data1.RSIMA1;
PlotNumeric(" A",A);
PlotNumeric(" B",B);
PlotNumeric("超买",OverBought);
PlotNumeric("超卖",OverSold);
End