I recently developed a support/resistance indicator that calculates daily support/resistance on a 5 minute bar chart and I am trying to develop a countertrend strategy that will buy when price hits support and sells when price his resistance.
The values are stored in the custom indicator as SLine and RLine as follows;
[Browsable(false)]
[XmlIgnore()]
public Series<double> RLine
{ get {return Values[1];} }
[Browsable(false)]
[XmlIgnore()]
public Series<double> SLine
{ get {return Values[0];} }
My goal is to store these values as private doubles within the strategy as follows;
namespace NinjaTrader.NinjaScript.Strategies
{
public class SRstrategy : Strategy
{
private double Sl, Rl;
private double contracts = 1;
private SRstrategy _SRIndicator;
....
else if (State == State.Configure)
{
_SRIndicator = SRstrategy(_ExtraneousInput1,_ExtraneousInput2, _ExtraneousInput3, _ExtraneousInput4);
base.AddChartIndicator(_SRIndicator);
.............
protected override void OnBarUpdate()
{
_SRIndicator.Update();
Sl = _SRIndicator.SLine[0]; // OR
Rl = _SRIndicator.RLine[0]; // OR
if(Time[0].TimeOfDay >= _StartTime && Time[0].TimeOfDay <= _FinishTime)
{
if(this.IsFlat && Low[0] <= Sl)
{
base.EnterLong(contracts);
}
else if(this.IsFlat && High[0] >= Rl)
{
base.EnterShort(contracts);
}
}
if(Time[0].TimeOfDay == _FinishTime)
{
if(this.IsLong)
{
base.ExitLong();
}
else if(this.IsShort)
{
base.ExitShort();
}
}
}
.......
Does anyone have insight as to why this might not be working?
Thanks in advance.
Comment