Category Trend  Published on 02/07/2020

Adaptive Price Channel (APC)

Description

The APC are based on the average difference between the Lowest Low and Highest High over a selected multiplier of number of intervals, therefore they tend to be associated with potential areas of support or resistance. Unlike classic Price Channel, the APC do not tend to narrow during periods of sideways trading and price consolidation, typically before a breakout.

The APC can be used to identify trend reversals or overbought/oversold levels that denote pullbacks within a bigger trend. A surge above the upper channel line shows extraordinary strength that can signal the start of an uptrend. Conversely, a plunge below the lower channel line shows serious weakness that can signal the start of a downtrend.

Download

 

 


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

namespace cAlgo.Indicators
{
    [Indicator(TimeZone = TimeZones.UTC, IsOverlay = true)]
    public class DivergenceStart : Indicator
    {
        // Please download this indicator from 
        //
        // https://gum.co/divergencepro

        private string title = "Adaptive Price Channel";
        private string url = "https://gum.co/adaptivepricechannel";


        protected override void Initialize()
        {
            string buttonText = "Download " + title;
            Color backgroundColor = Application.ColorTheme == ColorTheme.Dark ? GetColorWithOpacity(Color.FromHex("#292929"), 0.85m) : GetColorWithOpacity(Color.FromHex("#FFFFFF"), 0.85m);

            var background = new Rectangle 
            {
                Height = Chart.Height,
                Width = Chart.Width,
                FillColor = backgroundColor
            };

            var button = new Button 
            {
                Text = buttonText,
                Padding = "16",
                Style = ButtonStyle(Color.FromHex("#009345"), Color.FromHex("#10A651"))
            };
            button.Click += e => System.Diagnostics.Process.Start(url);
            var container = new StackPanel 
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };
            container.AddChild(button);

            Chart.AddControl(background);
            Chart.AddControl(container);

            Print(title);
            Print(url);
        }

        public override void Calculate(int index)
        {

        }

        private Style ButtonStyle(Color color, Color hoverColor)
        {
            var style = new Style(DefaultStyles.ButtonStyle);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.DarkTheme);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.LightTheme);
            style.Set(ControlProperty.BackgroundColor, hoverColor, ControlState.DarkTheme | ControlState.Hover);
            style.Set(ControlProperty.BackgroundColor, hoverColor, ControlState.LightTheme | ControlState.Hover);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.DarkTheme);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.LightTheme);
            return style;
        }

        private Color GetColorWithOpacity(Color baseColor, decimal opacity)
        {
            var alpha = (int)Math.Round(byte.MaxValue * opacity, MidpointRounding.AwayFromZero);
            return Color.FromArgb(alpha, baseColor);
        }
    }
}


diiptrade's avatar
diiptrade

Joined on 17.11.2016

  • Distribution: Paid
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Adaptive Price Channel Start.algo
  • Rating: 0
  • Installs: 958
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.