on every new bar I can determine two possible positions of close prices of this bar. Lower close is at (High-Range Value), higher close is at (Low+Range Value). I use the ranage 6 for this example. In the same chart I have RSI inidcator displayed. I would like to do 2 RSI predictions on both positions - lower and higher close.
I supposed a can use dataseries with Close values and for the latest Close value I can use
High-Range value for higher and Low+Range Value for lower and then calculate RSI on these dataseries. But It does not work properly
The prediciton done this way is not accurate. Calculated value of RSI is little bit different then final value of real RSI according to price close value.
Would anybody be so king and help me.
Thank you very much.
Alex
Just simply code:
Period = period for RSI (14 default)
in Initialize:
closeUP = new DataSeries(this);
closeDN = new DataSeries(this);
protected override void OnBarUpdate()
{
closeUP.Set( Close[0] );
closeDN.Set( Close[0] );
// calculate just for last bar
if (CurrentBar<=(Bars.Count-2)) return;
// not necessary, just for sure - copy values
for(int i=0; i<=Period; i++) {
closeUP.Set(i,Close[i]);
closeDN.Set(i,Close[i]);
}
closeShort = Bars.Instrument.MasterInstrument.Round2TickSize( High[0] - ((Bars.Period.Value) * Bars.Instrument.MasterInstrument.TickSize) );
// for short
closeDN.Set(0,closeShort);
// this value does not equal to real RSI value on real bar close value
rsiValueShort = RSI(closeDN, Period, 3)[0];
}
Comment