people with nt,
regards.
i have a strategy with a structure similar to the one below:
// Set 1 if ( (SMA1[0] < SMA1[1]) && (Stochastics1.D[0] < 20 ) ) { EnterShort( ); } // Set 2 if ( (SMA1[0] > SMA1[0])) { ExitShort( ); } // Set 3 if ( (SMA1[0] > SMA1[1]) && (Stochastics1.D[0] > 80 ) ) { EnterLong( ); } // Set 4 if ( (SMA1[0] < SMA1[0]) ) { ExitLong( ); }
if all the conditions in set 1 are true, the strategy should open a short position and hold it until the condition in set 2 is true. and it is the same story just inverted for sets 3 and 4. on occasion it could happen that both an exit condition and the opposite entry condition become true at the same time. in those cases, the strategy should completely reverse position. as far as i can tell, nt and strategies with structures like these work well.
however, i want to create indicators that will replicate exactly the same behavior and i haven't been able to. my preferred methodology is to have an indicator that plots an sma and have this sma change colors according to the conditions of the data.
i have tried to modify smas that i already have that already change colors according to conditions like SMA1[0] < SMA1[1] or SMA1[0] > SMA1[1] but it has been a mess. some won't plot and others won't compile when i try to incorporate a structure like the one above.
i want an indicator that will plot a yellow sma, if all the conditions in set 1 are true, the color should change to red. it could also be helpful to create a downtrend condition and declare it to be true. when the condition in set 2 becomes true, then the downtrend condition should become false and the color should change back to yellow. and it is the same story for sets 3 and 4, with a condition called uptrend and green color.
i have been working on this indicator below but it is useless. i think i must be missing additional logic to get the indicator to replicate exactly the strategy above (¿maybe i need to nest each pair of conditions inside one another?. ¿what changes must be made to this code to get it to work just like the strategy i included above?
AddPlot(Brushes.Yellow, " indicator "); } else if (State == State.Configure) { SMA1 = new Series<double>(this); Stochastics1 = new Series<double>(this); } } protected override void OnBarUpdate() { Values[0][0] = SMA(period1)[0]; SMAc1[0] = SMA(period1)[0]; Stochasticsc[0] = Stochastics(period2)[0]; if (CurrentBar < 1) return; // Set 1 if ( (SMA1[0] < SMA1[1]) && (Stochastics1.D[0] < 20) ) { PlotBrushes[0][0] = Brushes.red; } // Set 2 if ( (SMA1[0] > SMA1[0])) { PlotBrushes[0][0] = Brushes.yellow; } // Set 3 if ( (SMA1[0] > SMA1[1]) && (Stochastics1.D[0] > 80 ) ) { PlotBrushes[0][0] = Brushes.green; } // Set 4 if ( (SMA1[0] < SMA1[0]) ) { PlotBrushes[0][0] = Brushes.yellow; }
if i could also receive email notifications every time one of these changes has taken place and visual alerts like pop-up windows that would be fantastic. i'm still learning the capabilities that nt has to offer.
very well, thanks, regards.
Comment