I am programming a simple strategy which part of it checks if RSI is above 50 (uptrend) and opens a long position.
So I am doing the following:
if (State==State.DataLoaded)
{
_RSIAvgSeries = new Series<double>(this);
}
private void AddIndicators()
{
_RSI = RSI(Close,Convert.ToInt32(RSIperiod), RSISmoothPeriod);
AddChartIndicator(_RSI);
_RSIAvgSeries = RSI(Close, Convert.ToInt32(RSIperiod), RSISmoothPeriod).Avg;
}
private void SetEntrySignalState()
{
_enterLong = IsUpTrend();
_enterShort = IsDownTrend();
}
private bool IsUpTrend()
{
return _RSIAvgSeries[0]> 50;
}
private bool IsDownTrend()
{
return _RSIAvgSeries[0] < 50;
}
protected override void OnBarUpdate()
{
SetEntrySignalState();
if (_enterLong)
{
_longEntry = EnterLong(_posSize, LongEntry);
}
else if (_enterShort)
{
_shortEntry = EnterShort(_posSize, ShortEntry);
}
}
I ran the strategy and I am not getting any long or short orders when the RSI is above 50. Furthermore I am trying to Print(_RSIAvgSeries[0]) to check the value of the RSI but the strategy does not give any results on the output window.
Could you please help on this because I think I am confused with the logic.
Thank you.
Comment