Category Other  Published on 01/11/2023

NightMares On Chart 404

Description

What if I told you the chart could talk to you……    

Build with Net Leg 4….    

Example is for AUD:USD    

I like these settings….    

 

 

First turn off these lines….    

 

First Turn off these lines

And it should look like this….    

Now try these settings….    

 

 

And it should look like this….    

This is the MACD as colored Bars 

 

 

And change X Arrows for X Bars ….    

 

 

And it should look like this….    

 


using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo

{
      [Cloud( "CCU1" , "CCD1" , Opacity = 1, FirstColor = "CCU1", SecondColor = "CCD1" )]
      [Cloud( "CCU2" , "CCD2" , Opacity = 1, FirstColor = "CCU2", SecondColor = "CCD2" )]
      [Cloud ("Macd", "Signal", Opacity = 1, FirstColor = "Macd", SecondColor = "Signal")]
      [Indicator(IsOverlay = true, AutoRescale = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
      public class NOC404 : Indicator
      {
      
      [Parameter("Color Bars ?" , DefaultValue = ColorBars.Yes , Group = "Color BARS" )]
      public ColorBars CHB { get; set; }
      [Parameter("MACD Bars ?" , DefaultValue = MACDBars.No , Group = "Color BARS" )]
      public MACDBars MCDB { get; set; }
      
      [Parameter("MACD Cloud" , DefaultValue = MACDCloud.Yes, Group = "MACD Cloud" )] public MACDCloud MACC { get; set; }
      [Parameter("MACD Scale" , DefaultValue = 3, Group = "MACD Cloud" )] public int MD1 { get; set; } private MacdCrossOver MACDC;
      [Output("Macd"  ,LineColor = "66FFFF00")] public IndicatorDataSeries Macd {get;set;}
      [Output("Signal",LineColor = "77AA00FF")] public IndicatorDataSeries Signal {get;set;}
      
      [Parameter ("MA Cloud" , DefaultValue = MACloud.Yes, Group = "MA Cloud" ) ] public MACloud Cloud {get;set;}
      [Parameter ("MA Lines" , DefaultValue = MALines.Yes, Group = "MA Cloud" ) ] public MALines Lines {get;set;}
      [Parameter("M.1 Bars", DefaultValue = 8, Group = "MA Cloud")] public int MA1 { get; set; }
      [Parameter("M.2 Bars", DefaultValue = 32, Group = "MA Cloud")] public int MA2 { get; set; }
      [Parameter("M.3 Bars", DefaultValue = 96, Group = "MA Cloud")] public int MA3 { get; set; }
      
      [Parameter ("X Bars" , DefaultValue = XB.No, Group = "X Arrow" ) ] public XB XB1 {get;set;}
      [Parameter ("X Arrow" , DefaultValue = XA.No, Group = "X Arrow" ) ] public XA XA1 {get;set;}
      [Parameter ("Up Arrow Type" , DefaultValue=ChartIconType.Star ,Group = "X Arrow" ) ] public ChartIconType ITU {get; set;}
      [Parameter ("Down Arrow Type" , DefaultValue=ChartIconType.Star ,Group = "X Arrow" ) ] public ChartIconType ITD {get; set;}
      
      [Output ("MA1" ,LineColor = "AA00FF00")] public IndicatorDataSeries MA1C {get;set;}
      [Output ("MA2" ,LineColor = "AAFF8000")] public IndicatorDataSeries MA2C {get;set;}
      [Output ("MA3" ,LineColor = "CCFF0000")] public IndicatorDataSeries MA3C {get;set;}
      
      [Output ("CCU1" ,LineColor = "2200FF00")] public IndicatorDataSeries CCU1 {get;set;}
      [Output ("CCD1" ,LineColor = "22FF0000")] public IndicatorDataSeries CCD1 {get;set;}
      [Output ("CCU2" ,LineColor = "2200FF00")] public IndicatorDataSeries CCU2 {get;set;}
      [Output ("CCD2" ,LineColor = "22FF0000")] public IndicatorDataSeries CCD2 {get;set;}
      
      
      [Parameter ("ATR Bands" , DefaultValue = ATRBands.Yes, Group = "ATR Bands" ) ] public ATRBands Bands {get;set;}
      [Parameter("ATR Center", Group = "ATR Bands", DefaultValue = 50)] public int CATRP { get; set; }
      [Parameter("ATR Periods", Group = "ATR Bands", DefaultValue = 50)] public int ATRP { get; set; }
      [Parameter("Band Width", Group = "ATR Bands", DefaultValue = 4)] public int BW { 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("Center ATR" , LineColor = "FF7030A0" , PlotType = PlotType.DiscontinuousLine, Thickness = 1 )]
      public IndicatorDataSeries CATRC { get; set; }
      MovingAverage MA;
      MovingAverage M1;
      MovingAverage M2;
      MovingAverage M3;
      MovingAverage MATR;
      AverageTrueRange ATR;
      public enum ColorBars {Yes,No}
      public enum MACDBars {Yes,No}
      public enum ATRBands {Yes,No}
      public enum MACloud {Yes,No}
      public enum MALines {Yes,No}
      public enum MACDCloud {Yes,No}
      public enum XB {Yes,No}
      public enum XA {Yes,No}
 protected override void Initialize()
      {
      M1 = Indicators.WellesWilderSmoothing(Bars.ClosePrices,MA1 );
      M2 = Indicators.WellesWilderSmoothing(M1.Result,MA2 );
      M3 = Indicators.WellesWilderSmoothing(M2.Result,MA3 );
      MACDC = Indicators.MacdCrossOver(26,12,9);
      MA = Indicators.WellesWilderSmoothing(Bars.ClosePrices,14);
      MATR = Indicators.WellesWilderSmoothing(Bars.ClosePrices,CATRP );
      ATR = Indicators.AverageTrueRange (ATRP,MovingAverageType.WilderSmoothing);
      }
 public override void Calculate(int index)
      
      {
      var BC = Bars.ClosePrices.Last(0);
      var BO = Bars.OpenPrices.Last(0);
      
      var X = MA.Result.Last(0);
      var Y = Bars.HighPrices.Last(0)-Bars.LowPrices.Last(0);
      var M = MACDC.MACD[index] * ((X*MD1)/X)+X;
      var S = MACDC.Signal[index] * ((X*MD1)/X)+X;
      
      var Aspace = ATR.Result.Last(0);
      var AU1 = MATR.Result[index] + (Aspace*BW);
      var AD1 = MATR.Result[index] - (Aspace*BW);
      var AU2 = MATR.Result[index] + (Aspace*(BW*2));
      var AD2 = MATR.Result[index] - (Aspace*(BW*2));
      var ACL = MATR.Result[index];
      
      var MR1 = M1.Result.Last(0);
      var MR2 = M2.Result.Last(0);
      var MR3 = M3.Result.Last(0);
      
        // MA Lines
   if (Lines == MALines.Yes)
      {
      MA1C[index] = MR1;
      MA2C[index] = MR2;
      MA3C[index] = MR3;
      }
        // MACD Cloud
   if (MACC == MACDCloud.Yes)
      {      
      Macd[index] = M;
      Signal[index] = S;
      }
        // ATR Bands
   if (Bands == ATRBands.Yes)
      {
      UpATR1[index] = AU1;
      DnATR1[index] = AD1;
      UpATR2[index] = AU2;
      DnATR2[index] = AD2;
      CATRC[index]  = ACL;
      }
        // Moving Average Cloud
   if (Cloud == MACloud.Yes)
      {
      CCU1[index] = MR1;
      CCD1[index] = MR3;
      CCU2[index] = MR1;
      CCD2[index] = MR2;
      }
        // Color Bars
   if (CHB == ColorBars.Yes)
      {
      if ( BC > AU1)
         Chart.SetBarColor(index, "EE00FF00" );
      if ( BC < AD1)
         Chart.SetBarColor(index, "CCFF0000" );
      if ( BC > MR1 && BC < AU1)
         Chart.SetBarColor(index, "A600CCFF" );
      if ( BC < MR1 && BC > AD1)
         Chart.SetBarColor(index, "FFEE6633" );
      }
        // MACD Bars
   if (MCDB == MACDBars.Yes)
      {
      if ( M > S)
         Chart.SetBarColor(index, "66FFFF00" );
      if ( M < S)
         Chart.SetBarColor(index, "77AA00FF" );
      }
        // X Bars
   if ( XB1== XB.Yes )
      {
      if (BC < AU1 && BO > AU1)
         Chart.SetBarColor(index, "CCFF0000" );
      if (BC > AD1 && BO < AD1)
         Chart.SetBarColor(index, "EE00FF00" );
      }
        // X Arrows
   if ( XA1== XA.Yes )
      {
      if (BC < AU1 && BO > AU1)
         Chart.DrawIcon("Down" + index, ITD, index, Bars.HighPrices[index] + Y, "FFFF0000");
      if (BC > AD1 && BO < AD1)
         Chart.DrawIcon("Up" + index, ITU, index, Bars.LowPrices[index] - Y, "FF00FF00");
      }
    }
  }
}

VE
VEI5S6C4OUNT0

Joined on 06.12.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: NOC404.algo
  • Rating: 5
  • Installs: 722
  • Modified: 01/11/2023 14:40
Comments
Log in to add a comment.
VE
VEI5S6C4OUNT0 · 1 year ago

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC,AccessRights = AccessRights.None)]
    public class ATRBand : Robot
    {
        public DataSeries Source { get; set; }
        
        [Parameter("Start Hour", DefaultValue = 1 , Step = 1)]
        public double StartTime { get; set; }
        [Parameter("Stop Hour", DefaultValue = 16 , Step = 1)]
        public double StopTime { get; set; }

        [Parameter("MA", Group = "MA ATR", DefaultValue = 50)]
        public int P1 { get; set; }
        [Parameter("MA", Group = "MA ATR", DefaultValue = 50)]
        public int P2 { get; set; }
        [Parameter("Band Width", Group = "MA ATR", DefaultValue = 4)]
        public int BW { get; set; }
        
        
        [Parameter("Per Account", Group = "What", Step = 1)]
        public double Q { get; set; }
        [Parameter("Stop Loss ", Group = "What",DefaultValue = 10 ,Step = 1)]
        public int SL { get; set; }
        [Parameter("Take Profit", Group = "What",DefaultValue = 10 ,Step = 1)]
        public int TP { get; set; }
        [Parameter("MaxPos", Group = "What",DefaultValue = 2, MinValue = 1)]
        public int MaxPos { get; set; }
        
        MovingAverage MATR;
        AverageTrueRange ATR;
        
        private const string Lab = "ATRBand";
        
        protected override void OnStart()
        {
        MATR = Indicators.WellesWilderSmoothing(Bars.ClosePrices,P1 );
        ATR  = Indicators.AverageTrueRange (P2,MovingAverageType.WilderSmoothing);
        }

        protected override void OnBar()
        {
        var TIMENOW = Server.Time.TimeOfDay.TotalHours;
        
        var Aspace = ATR.Result.Last(0);
        var UT1    = MATR.Result.Last (0) + (Aspace*BW);
        var DT1    = MATR.Result.Last (0) - (Aspace*BW);
        var BC    = Bars.ClosePrices.Last(0);
        var BO    = Bars.OpenPrices.Last(0);
        
        var Units  = Symbol.NormalizeVolumeInUnits(Q * Account.Balance, RoundingMode.Down);
        
         if ((TIMENOW > StartTime && TIMENOW < StopTime) && (Positions.Count < MaxPos))
            {
               if (BC > DT1 && BO < DT1)
                 {                  
                   ExecuteMarketOrder(TradeType.Buy, SymbolName, Units, Lab,SL,TP);
                 }
               if (BC < UT1 && BO > UT1)
                   ExecuteMarketOrder(TradeType.Sell, SymbolName, Units, Lab,SL,TP);                  
            }
        }
    }
}

VE
VEI5S6C4OUNT0 · 1 year ago

I'm not sure what you are asking here

This Arrow/Bar is a Bars Close Price Crossing across an ATR Band  (50 Wells Wilder plus or minus ATR Result)?

You can just add the system ATR to your robot

And use these values to in your “if” statement ?

drkhashix's avatar
drkhashix · 1 year ago

For manual trading, it doesn't look bad by combining it with the smart money block order strategy, for example, when it gets saturated at the block order points and the candles change color at that point,and rsi say yes

can you see this image https://ibb.co/zXWrkR2

 but it's a pity that there is no smart money indicator in CTrader, 

drkhashix's avatar
drkhashix · 1 year ago

what is the signal code for this part of cod 

if (noc404Signal.LastValue == Up Arrow)
            {
                return 0;
            }

else if (noc404Signal.LastValue == Down Arrow)

drkhashix's avatar
drkhashix · 1 year ago
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.API.Requests;

namespace cAlgo.Robots
{
    [Robot("DRKHASHIX", AccessRights = AccessRights.None)]
    public class DRKHASHIX : Robot
    {
        [Parameter("Lot Size", Group = "Volume", DefaultValue = 0.01, MinValue = 0.00001, MaxValue = 100, Step = 0.00001)]
        public double LotSize { get; set; }

        [Parameter("Stop Loss (pips)", Group = "Risk Management", DefaultValue = 20, MinValue = 1)]
        public int StopLossInPips { get; set; }

        [Parameter("Take Profit (pips)", Group = "Risk Management", DefaultValue = 40, MinValue = 1)]
        public int TakeProfitInPips { get; set; }

        private bool isPositionOpen = false;
        private IndicatorDataSeries noc404Signal;

        protected override void OnStart()
        {

            noc404Signal = CreateDataSeries();


        }

        protected override void OnBar()
        {
            int signal = GetNOC404Signal();

            if (!isPositionOpen && signal != -1)
            {
                TradeType tradeType = (signal == 0) ? TradeType.Buy : TradeType.Sell;

                double volume = Symbol.NormalizeVolumeInUnits(Symbol.QuantityToVolumeInUnits(LotSize));

                var position = ExecuteMarketOrder(tradeType, Symbol, volume, "SupportResistanceBot", StopLossInPips, TakeProfitInPips);

                if (position != null)
                {
                    isPositionOpen = true;
                }
            }
        }

        protected override void OnPositionClosed(Position position)
        {
            isPositionOpen = false;
        }

        private int GetNOC404Signal()
        {
            int lastBarIndex = MarketSeries.Close.Count - 2;
            int prevBarIndex = lastBarIndex - 1;

            if (noc404Signal.LastValue == Up Arrow)
            {
                return 0;
            }

            else if (noc404Signal.LastValue == Down Arrow)
            {
                return 1;
            }

            return -1;
        }
    }
}
VE
VEI5S6C4OUNT0 · 1 year ago

I have tested crossover bots before and they have ups and downs and they don't work as expected with back testing , but I can look into it.

So you are thinking of something like if 3 up arrows then enter buy and set SL and TP at ATR levels? (Should give an average 1:1.4 RR) Look at my other indicator > “3 line Strike P2” < for reference.

Also the ATR Bands here are not as bolinger or rsi but a reference for SL and TP 

eg; you could use the inner bands for SL and outer for TP when using Quick Trade Buttons to set them faster.

But I suggest watching it for a while to see how it looks so you can see what to look for during market sessions or what ever appeals to you could work with UpDownTick ?.

drkhashix's avatar
drkhashix · 1 year ago

can you buld robot buy this looks when 3 signal down the robot open one pos whit stoplos and tp

TommyDee's avatar
TommyDee · 1 year ago

Thank you!