https://ninjatrader.com/support/foru...les#post692124
In the example, a static class is created that can act on NijnaScriptBase and NinjaScript methods from the calling strategy.
I created a non-static class to do the same thing, and it seems to be working. Here's a sample of what I'm doing:
namespace NinjaTrader.NinjaScript.Strategies
{
public class XoSignal
{
private NinjaScriptBase nsb;
private NinjaScript ns;
// passed in indicators
private SMA SMA1;
private SMA SMA2;
public XoSignal(NinjaScriptBase nsbPassed, NinjaScript nsPassed, SMA s1, SMA s2)
{
this.nsb = nsbPassed;
this.ns = nsPassed;
this.SMA1 = s1;
this.SMA2 = s2;
}
public bool DidCrossAbove
{
get
{
return nsb.CrossAbove(SMA1, SMA2, 1);
}
}
}
}
private XoSignal Sig;
Sig = new XoSignal(this, this, SMA1, SMA2);
if (Sig.DidCrossAbove) {
// do something
}

Comment