The output is a dictionary of objects of my custom class, keyed by bar number.
If I set up my strategy to work like this:
public class PermaCodeSwingState : Indicator
{
PermaCodeSwing swingIndy;
protected override void Initialize()
{
Overlay = true;
CalculateOnBarClose = true;
Add(PermaCodeSwing(2, 2, 20, 0.00001));
swingIndy = PermaCodeSwing(2, 2, 20, 0.00001);
}
protected override void OnBarUpdate()
{
swingIndy.Update();
if (CurrentBars[0] < BarsRequired)
{
return;
}
}
private Dictionary<int, SwingPoint> swingHighs
= new Dictionary<int, SwingPoint>(), swingLows = new Dictionary<int, SwingPoint>();
public class SwingPoint
{
public int before, after;
public IBar bar;
public int barNum;
public IBar creationBar;
public int creationBarNum;
public DateTime creationTime;
public SwingPoint(int newBefore, int newAfter, int swingBarNum, IBar swingBar,
int cb, IBar currentIBar)
{
this.before = newBefore;
this.after = newAfter;
this.bar = swingBar;
this.barNum = swingBarNum;
this.creationBar = currentIBar;
this.creationBarNum = cb;
}
}
protected override void OnBarUpdate()
{
if (isSwingHigh)
{
SwingPoint swingPoint = new SwingPoint(before, after,
CurrentBar - swingBar, Bars.Get(CurrentBar - swingBar),
CurrentBar, Bars.Get(CurrentBar));
swingHighs.Add(CurrentBar - swingBar, swingPoint);
}
}
public Dictionary<int, SwingPoint> SwingHighs
{
get { return swingHighs; }
}
Additionally I'm worried at this point that writing the swing points algorithm into a seperate indicator will also incur unnecessary overhead compared to writing it as a simple function in an NinjaTrader.Indicator partial class. Please advise.
Thanks.

Comment