| 1 | protected override void OnStateChange() |
| 2 | { |
| 3 | if(State == State.SetDefaults) |
| 4 | { |
| 5 | Name = "Example Indicator"; |
| 6 | // Add two plots |
| 7 | AddPlot(Brushes.Blue, "Upper"); |
| 8 | AddPlot(Brushes.Orange, "Lower"); |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | protected override void OnBarUpdate() |
| 13 | { |
| 14 | // Sets values to our two plots |
| 15 | Upper[0] = SMA(High, 20)[0]; |
| 16 | Lower[0] = SMA(Low, 20)[0]; |
| 17 | |
| 18 | // Color the Upper plot based on plot value conditions |
| 19 | if (IsRising(Upper)) |
| 20 | PlotBrushes[0][0] = Brushes.Blue; |
| 21 | else if (IsFalling(Upper)) |
| 22 | PlotBrushes[0][0] = Brushes.Red; |
| 23 | else |
| 24 | PlotBrushes[0][0] = Brushes.Yellow; |
| 25 | |
| 26 | // Color the Lower plot based on plot value conditions |
| 27 | if (IsRising(Lower)) |
| 28 | PlotBrushes[1][0] = Brushes.Blue; |
| 29 | else if (IsFalling(Lower)) |
| 30 | PlotBrushes[1][0] = Brushes.Red; |
| 31 | else |
| 32 | PlotBrushes[1][0] = Brushes.Yellow; |
| 33 | } |
| 34 | |
| 35 | public Series<double> Upper |
| 36 | { |
| 37 | get { return Values[0]; } |
| 38 | } |
| 39 | |
| 40 | public Series<double> Lower |
| 41 | { |
| 42 | get { return Values[1]; } |
| 43 | } |