has anyone figured out a way how to implement D3Spotter into a strategy? I'm using it along with some other indicators, like RecatanglePriceBreakout, simple moving averages, and those are quite simple. But for D3 I keep getting errors, and being new to this whole programming ordeal it's frying my brain a bit.
For example, for SMAs:
public class MyOWn : Strategy
{
private SMA smaFast;
private SMA smaSlow;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Fast = 8;
Slow = 13;
}
else if (State == State.Configure)
{
smaFast = SMA(Fast);
smaSlow = SMA(Slow);
smaFast.Plots[0].Brush = Brushes.Orange;
smaSlow.Plots[0].Brush = Brushes.Green;
AddChartIndicator(smaFast);
AddChartIndicator(smaSlow);
}
}
Add the region properties at the bottom and it's operational. Similarly PriceBreakoutRecatangularBase indicator has a strategy created for it, but looking at it, it's also quite easy to follow - 2 variables that have indicators created for it, and #regions that are copied over to the strategy file. For D3 indicator, there are a TON of variables (copied in below), so must I define every variable, if I JUST want to use it's divergence spotter for RSI only?
Essentially, I would have to include all these below in the strategy, and define them all as well?
Is there a way to create only a few private variables for what I need for RSI, and copy over the #regions that are relevant, rather than again the entire load? Then, of course I want to draw it on the chart, just like SMAs, but it won't let me just do RSI function.
If i try:
AddChartIndicator(D3SpotIndicatorMethod.RSI(14));
I get "non-invocable member.... cannot be used like a method.
Hopefully someone has tackled this, and could shed some light on how to approach this.
Thank you for your thoughts.
public class D3SpotterV3 : Indicator
{
private D3SpotIndicatorMethod method = D3SpotIndicatorMethod.RSI;
private D3SpotPriceType pType = D3SpotPriceType.High_Low;
private bool useDefaultPlot = true; // Default setting for UseDefaultPlot
private bool showAlerts = false;
// Results
private double foundValue;
private double foundAvg;
private double foundDiff;
private double foundStochD;
private double foundStochK;
private int rsi_Period = 14;
private int mom_Period = 14;
private int rsi_Smooth = 3;
private int rvi_Period = 14;
private int cci_Period = 14;
private int mfi_Period = 14;
private int roc_Period = 14;
private int stochrsi_Period = 14;
private int smi_EMAPeriod1 = 25;
private int smi_EMAPeriod2 = 1;
private int smi_Range = 13;
private int smi_SMIEMAPeriod = 25;
// MACD variables
private int macd_Fast = 12;
private int macd_Slow = 26;
private int macd_Smooth = 9;
// Stochastics and Fast Stochastics
private int stoch_PeriodD = 7;
private int stoch_PeriodK = 14;
private int stoch_Smooth = 3;
private int stochfast_PeriodD= 3;
private int stochfast_PeriodK= 14;
private bool initDone = false;
private ISeries<double> Indicator;
private int [] HighBarsAgo;
private int [] LowBarsAgo;
private int ThisHigh;
private int ThisLow;
private int QHLength = 0;
private int QLLength = 0;
private int QueueLength = 3;
private int scanWidth = 30;
private int A = 1;
private int BarsAgo;
private double priceDiffLimit = 0.0;
private double indicatorDiffLimit = 0.0;
private DashStyleHelper divergenceDashStyle = DashStyleHelper.Dot;
private int divergenceLineWidth = 3;
private int markerDistanceFactor = 1;
private Brush divergenceColor = Brushes.DarkMagenta;
private Brush lowerDotColor = Brushes.Cyan;
private Brush upperDotColor = Brushes.Yellow;
private string myAlert1 = @"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert1.wav";
private string myAlert2 = @"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert2.wav";
private int do_Period = 14;
private int do_Smooth1 = 5;
private int do_Smooth2 = 3;
private int do_Smooth3 = 9;
Comment