I did a new custom class called "PatternFilter" into "NinjaTrader.Custom.Classes", but when I try to call "PatternFilter" class from my strategy class, called "Test2", then it doesen't work.
In the code below, I explane how I did it.
After had created my Test2 strategy, I create a custom PatternFilter, then use PatternFilter from Test2.
The problem is that when I try to launch the strategy analyzer, it doesn't work.
1) Is maybe that I must applicate my custom class in other method in place of "State.DataLoaded" and "onBarsUpdate"?
2) Should I use the constructor differently?
Exemple:
namespace NinjaTrader.NinjaScript.Strategies
{
public class Test2 : Strategy (that's my strategy)
{
//constructor
public Test2()
{
customPatternFilter = new CustomPatternFilter(this);
}
if (State == State.SetDefaults){
...
}
if (State == State.DataLoaded)
{
...
}
customPatternFilter = new CustomPatternFilter(this);
}
protected override void OnBarUpdate()
{
//exemple, here I call my custom method.
customPatternFilter.DrawPatternCandles(this);
customPatternFilter.CheckPatternFilter();
}
ecc..
}
My custom method:
using NinjaTrader.NinjaScript.DrawingTools;
using NinjaTrader.NinjaScript.Indicators;
using NinjaTrader.NinjaScript.Strategies;
using System.Windows.Media;
namespace NinjaTrader.Custom.Classes (that's my custom method)
{
public class PatternFilter
{
private CandlestickPattern candlestickPattern;
private Test2 strategy;
//constructor
public PatternFilter(Test2 strategy)
{
this.candlestickPattern = new CandlestickPattern();
this.strategy = strategy;
}
public bool CheckPatternFilter()
{
if (strategy == null)
{
return false;
}
if (candlestickPattern.CandlestickPattern(ChartPatter n.BearishEngulfing, 0)[0] == 1)
{
return true;
}
ecc...
else
return false;
}
//other methods
}

Comment