Category Trend  Published on 16/10/2023

Nightmares On Chart Ver 2

Description

Here I've added the option to change the MACD Colors

And now has a POSSIBLE Trend change indicator Letting you know if there is a crossover.

 

Low setting >

 

High setting >

How to better understand using this , Open 3 charts 1hour, 15min, 1m.

 

 

 

 

using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo
{
      [Cloud("CU0", "CD2", Opacity = 1, FirstColor = "1100FF00", SecondColor = "11FF0000" )]
      [Cloud("CU1", "CD2", Opacity = 1, FirstColor = "1100FF00", SecondColor = "11FF0000" )]
      [Cloud ("Macd", "Signal", Opacity = 1, FirstColor = "Macd", SecondColor = "Signal")]
      [Indicator(IsOverlay = true, AutoRescale = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
 public class NIGHTMARESOCV2 : Indicator
      {
      [Output("Macd"  ,LineColor = "66FFFF00")] public IndicatorDataSeries Macd {get;set;}
      [Output("Signal",LineColor = "77AA00FF")] public IndicatorDataSeries Signal {get;set;}
      [Parameter("MACD Cloud" , DefaultValue = MACDCloud.Yes, Group = "MACD Cloud" )] public MACDCloud MACC { get; set; }
      private MacdCrossOver MACDC;
      [Parameter ("MA Cloud" , DefaultValue = MACloud.Yes, Group = "MA Cloud" ) ]
      public MACloud Cloud {get;set;}
      [Output ("CU0" ,LineColor = "0000FF00")] public IndicatorDataSeries CU0 {get;set;}
      [Output ("CU1" ,LineColor = "0000FF00")] public IndicatorDataSeries CU1 {get;set;}
      [Output ("CD1" ,LineColor = "00FF0000")] public IndicatorDataSeries CD1 {get;set;}
      [Output ("CD2" ,LineColor = "00FF0000")] public IndicatorDataSeries CD2 {get;set;}
      [Parameter("Color Bars High or Low Volume ?" , DefaultValue = ColorBars.LowVolume , Group = "Color BARS" )]
      public ColorBars CHB { get; set; }
      [Output("Up ATR 1 cc" , LineColor = "6600FFBB" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
      public IndicatorDataSeries UpATR1 { get; set; }
      [Output("Dn ATR 1 ff" , LineColor = "77EE6633" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
      public IndicatorDataSeries DnATR1 { get; set; }
      [Output("Up ATR 2 ee" , LineColor = "6600FF00" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
      public IndicatorDataSeries UpATR2 { get; set; }
      [Output("Dn ATR 2 cc" , LineColor = "77FF0000" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
      public IndicatorDataSeries DnATR2 { get; set; }
      [Output("UpA1 66" , LineColor = "66FFFF00" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
      public IndicatorDataSeries UpA1 { get; set; }
      [Output("DnA1 66" , LineColor = "77AA00FF" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
      public IndicatorDataSeries DnA1 { get; set; }
      MovingAverage MA;
      MovingAverage M1;
      MovingAverage M2;
      MovingAverage M3;
      MovingAverage MATR;
      AverageTrueRange ATR;
      public enum ColorBars {LowVolume,HighVolume}
      public enum MACloud {Yes,No}
      public enum MACDCloud {Yes,No}
 protected override void Initialize()
      {
      M1 = Indicators.WellesWilderSmoothing(Bars.ClosePrices,8 );
      M2 = Indicators.WellesWilderSmoothing(Bars.ClosePrices,32 );
      M3 = Indicators.WellesWilderSmoothing(Bars.ClosePrices,96 );
      MACDC = Indicators.MacdCrossOver(26,12,9);
      MA = Indicators.WellesWilderSmoothing(Bars.ClosePrices,14);
      MATR = Indicators.WellesWilderSmoothing(Bars.ClosePrices,50 );
      ATR = Indicators.AverageTrueRange (50,MovingAverageType.WilderSmoothing);
      }
 public override void Calculate(int index)
      {
      var X = MA.Result.Last(0);
      var Y = Bars.HighPrices.Last(0)-Bars.LowPrices.Last(0);
   if (MACC == MACDCloud.Yes)
      {      
      Macd[index] = MACDC.MACD[index] * ((X*10)/X)+X;
      Signal[index] = MACDC.Signal[index] * ((X*10)/X)+X;
      }
      var Aspace = ATR.Result.Last(0);
      UpATR1[index] = MATR.Result[index] - (Aspace*3);
      DnATR1[index] = MATR.Result[index] + (Aspace*3);
      UpATR2[index] = MATR.Result[index] - (Aspace*7);
      DnATR2[index] = MATR.Result[index] + (Aspace*7);
        // Moving Average Cloud
   if (Cloud == MACloud.Yes)
      {
      CU0[index] = M1.Result.Last(0);
      CU1[index] = M2.Result.Last(0);
      CD1[index] = M2.Result.Last(0);
      CD2[index] = M3.Result.Last(0);
      }
        // ATR Bands
   if (MATR.Result.Last(0) >= MATR.Result.Last(1))
      { UpA1[index] = MATR.Result[index]; }
   if (MATR.Result.Last(0) <= MATR.Result.Last(1))
      { DnA1[index] = MATR.Result[index]; }
        // Color Bars
   if (CHB == ColorBars.LowVolume)
      {
      if ( Bars.ClosePrices.Last(0) > DnATR1.Last(0))
         Chart.SetBarColor(index, "EE00FF00" );
      if ( Bars.ClosePrices.Last(0) < UpATR1.Last(0))
         Chart.SetBarColor(index, "CCFF0000" );
      if ( Bars.ClosePrices.Last(0) > M1.Result.Last(0) && Bars.ClosePrices.Last(0) < DnATR1.Last(0))
         Chart.SetBarColor(index, "A600CCFF" );
      if ( Bars.ClosePrices.Last(0) < M1.Result.Last(0) && Bars.ClosePrices.Last(0) > UpATR1.Last(0))
         Chart.SetBarColor(index, "FFEE6633" );
      if (Bars.ClosePrices.Last(0) < DnATR1.Last(0) && Bars.ClosePrices.Last(1) > DnATR1.Last(1))
         Chart.DrawIcon("Down" + index, ChartIconType.DownArrow, index, Bars.HighPrices[index] + Y, "FFFF0000");
      if (Bars.ClosePrices.Last(0) > UpATR1.Last(0) && Bars.ClosePrices.Last(1) < UpATR1.Last(1))
         Chart.DrawIcon("Up" + index, ChartIconType.UpArrow, index, Bars.LowPrices[index] - Y, "FF00FF00");
      }
   if (CHB == ColorBars.HighVolume)
      {
      if ( Bars.ClosePrices.Last(0) > DnATR2.Last(0))
         Chart.SetBarColor(index, "EE00FF00" );
      if ( Bars.ClosePrices.Last(0) < UpATR2.Last(0))
         Chart.SetBarColor(index, "CCFF0000" );
      if ( Bars.ClosePrices.Last(0) > M3.Result.Last(0) && Bars.ClosePrices.Last(0) < DnATR2.Last(0))
         Chart.SetBarColor(index, "A600CCFF" );
      if ( Bars.ClosePrices.Last(0) < M3.Result.Last(0) && Bars.ClosePrices.Last(0) > UpATR2.Last(0))
         Chart.SetBarColor(index, "FFEE6633" );
      if (Bars.ClosePrices.Last(0) < DnATR2.Last(0) && Bars.ClosePrices.Last(1) > DnATR2.Last(1))
         Chart.DrawIcon("Down" + index, ChartIconType.DownArrow, index, Bars.HighPrices[index] + Y, "FFFF0000");
      if (Bars.ClosePrices.Last(0) > UpATR2.Last(0) && Bars.ClosePrices.Last(1) < UpATR2.Last(1))
         Chart.DrawIcon("Up" + index, ChartIconType.UpArrow, index, Bars.LowPrices[index] - Y, "FF00FF00");
      
      }
    }
  }
}


The author decided to hide the source code.
VE
VEI5S6C4OUNT0

Joined on 06.12.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: NIGHTMARESONCHARTV2.algo
  • Rating: 5
  • Installs: 459
Comments
Log in to add a comment.
No comments found.