Description
Could someone please explane why we are not getting preview pictures like before , I've tryed different formats (png,jpg….) and nothing works ?
A simple better version that filters the smaller movements and larger movements over an ATR Band.
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo
{
[Cloud("CU0", "CD2", Opacity = 1 )]
[Cloud("CU1", "CD2", Opacity = 1 )]
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NIGHTMARE2 : Indicator
{
public DataSeries Source { get; set; }
[Parameter("P 1", DefaultValue = 8 , Group = "Moving Average" )]
public int P1 { get; set; }
[Parameter("P 2", DefaultValue = 32 , Group = "Moving Average" )]
public int P2 { get; set; }
[Parameter("P 3", DefaultValue = 96 , Group = "Moving Average" )]
public int P3 { get; set; }
[Parameter("M A", DefaultValue = MovingAverageType.WilderSmoothing, Group = "Moving Average" )]
public MovingAverageType MAType { get; set; }
[Output("Up1" , LineColor = "4400FF00" , PlotType = PlotType.DiscontinuousLine , Thickness = 1 )]
public IndicatorDataSeries Up1 { get; set; }
[Output("Dn1" , LineColor = "44FF0000" , PlotType = PlotType.DiscontinuousLine , Thickness = 1 )]
public IndicatorDataSeries Dn1 { get; set; }
[Output("Up2" , LineColor = "44DDFF00" , PlotType = PlotType.DiscontinuousLine , Thickness = 1 )]
public IndicatorDataSeries Up2 { get; set; }
[Output("Dn2" , LineColor = "44FF00DD" , PlotType = PlotType.DiscontinuousLine , Thickness = 1 )]
public IndicatorDataSeries Dn2 { get; set; }
[Output("Up3" , LineColor = "5500FFBB" , PlotType = PlotType.DiscontinuousLine , Thickness = 1 )]
public IndicatorDataSeries Up3 { get; set; }
[Output("Dn3" , LineColor = "88EE6633" , PlotType = PlotType.DiscontinuousLine , Thickness = 1 )]
public IndicatorDataSeries Dn3 { get; set; }
[Parameter ("Cloud On Off" , DefaultValue = EnumCloud.No, Group = "Cloud" ) ]
public EnumCloud Cloud {get;set;}
[Output ("CU0" , LineColor = "1100FF00")]
public IndicatorDataSeries CU0 {get;set;}
[Output ("CU1" , LineColor = "1100FF00")]
public IndicatorDataSeries CU1 {get;set;}
[Output ("CD1" , LineColor = "11FF0000")]
public IndicatorDataSeries CD1 {get;set;}
[Output ("CD2" , LineColor = "11FF0000")]
public IndicatorDataSeries CD2 {get;set;}
MovingAverage M1;
MovingAverage M2;
MovingAverage M3;
MovingAverage MATR;
AverageTrueRange ATR;
[Parameter("ATR P" , DefaultValue = 26 , Group = "ATR" )]
public int ATRP { get; set; }
[Parameter("ATR Band 1" , DefaultValue = 2 , Group = "ATR" )]
public int ATR1 { get; set; }
[Parameter("ATR Band 2" , DefaultValue = 4 , Group = "ATR" )]
public int ATR2 { get; set; }
[Parameter("ATR Type" , DefaultValue = MovingAverageType.WilderSmoothing, Group = "ATR" )]
public MovingAverageType ATRType { get; set; }
[Parameter("Use Color Bars L1 ?" , DefaultValue = EnumColorBarsL1.Yes , Group = "BARS" )]
public EnumColorBarsL1 ColorBarsL1 { get; set; }
[Parameter("Up Bars L1" , DefaultValue = "A600CCFF" , Group = "BARS" )]
public Color UpB1 { get; set; }
[Parameter("Dn Bars L2" , DefaultValue = "FFEE6633" , Group = "BARS" )]
public Color DnB2 { get; set; }
[Parameter("Up Bars L3" , DefaultValue = "EE00FF00" , Group = "BARS" )]
public Color UpB3 { get; set; }
[Parameter("Dn Bars L3" , DefaultValue = "CCFF0000" , Group = "BARS" )]
public Color DnB3 { get; set; }
[Output("Up ATR 1 cc" , LineColor = "0000FFBB" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
public IndicatorDataSeries UpATR1 { get; set; }
[Output("Dn ATR 1 ff" , LineColor = "00EE6633" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
public IndicatorDataSeries DnATR1 { get; set; }
[Output("Up ATR 2 ee" , LineColor = "0000FF00" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
public IndicatorDataSeries UpATR2 { get; set; }
[Output("Dn ATR 2 cc" , LineColor = "00FF0000" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
public IndicatorDataSeries DnATR2 { get; set; }
[Output("UpA1 66" , LineColor = "00FFFF00" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
public IndicatorDataSeries UpA1 { get; set; }
[Output("DnA1 66" , LineColor = "00AA00FF" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
public IndicatorDataSeries DnA1 { get; set; }
public enum EnumColorBarsL1
{
Yes,No
}
public enum EnumCloud
{
Yes,No
}
protected override void Initialize()
{
M1 = Indicators.MovingAverage ( Source , P1 , MAType );
M2 = Indicators.MovingAverage ( Source , P2 , MAType );
M3 = Indicators.MovingAverage ( Source , P3 , MAType );
MATR = Indicators.MovingAverage ( Source , ATRP , ATRType );
ATR = Indicators.AverageTrueRange ( ATRP, ATRType );
}
public override void Calculate(int index)
{
var Aspace = ATR.Result.Last(0);
UpATR1[index] = MATR.Result[index] - (Aspace*ATR1);
DnATR1[index] = MATR.Result[index] + (Aspace*ATR1);
UpATR2[index] = MATR.Result[index] - (Aspace*ATR2);
DnATR2[index] = MATR.Result[index] + (Aspace*ATR2);
//Cloud
if (Cloud == EnumCloud.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
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];
}
//MA
if (M1.Result.Last(0) >= M1.Result.Last(1))
{
Up1[index] = M1.Result[index];
}
if (M1.Result.Last(0) <= M1.Result.Last(1))
{
Dn1[index] = M1.Result[index];
}
if (M2.Result.Last(0) >= M2.Result.Last(1))
{
Up2[index] = M2.Result[index];
}
if (M2.Result.Last(0) <= M2.Result.Last(1))
{
Dn2[index] = M2.Result[index];
}
if (M3.Result.Last(0) >= M3.Result.Last(1))
{
Up3[index] = M3.Result[index];
}
if (M3.Result.Last(0) <= M3.Result.Last(1))
{
Dn3[index] = M3.Result[index];
}
// Color Bars
if (ColorBarsL1 == EnumColorBarsL1.Yes)
{
if ( Bars.ClosePrices.Last(0) > DnATR1.Last(0))
Chart.SetBarColor(index, UpB3 );
if ( Bars.ClosePrices.Last(0) < UpATR1.Last(0))
Chart.SetBarColor(index, DnB3 );
if ( Bars.ClosePrices.Last(0) > M1.Result.Last(0) && Bars.ClosePrices.Last(0) < DnATR1.Last(0))
Chart.SetBarColor(index, UpB1 );
if ( Bars.ClosePrices.Last(0) < M1.Result.Last(0) && Bars.ClosePrices.Last(0) > UpATR1.Last(0))
Chart.SetBarColor(index, DnB2 );
}
}
}
}
VEI5S6C4OUNT0
Joined on 06.12.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: NIGHTMARE2.algo
- Rating: 0
- Installs: 523
- Modified: 26/09/2023 00:59