Price Channels free

by srm_bcn in category Trend at 03/05/2022
Description

 

Hello,

This is the old Linear Regression Channel indicator published by Researcher on 12/19/2013. Thank you very much for your work.

The indicator plots a mean, two standard deviations, two double standard deviations and finally, a line of maximums and another of minimums. It would be prudent to add a triple or even quadruple deviation or even more because in certain circumstances the volatility can increase dramatically and the risk as a consequence.

In the video, backtesting on TFm1, the indicator loaded twice with 240 and 60 periods to view the price action during the last four hours and the last hour in search of potentiall price channels. Visual mode speed set at 50x.

Note that the averages by nature have a strong lag but it seems that the lines act as support and resistance and they give an idea of the dispersion or degree of volatility.

I think that optimize periods to try to know which ones are using high frequency traders, (if they are using this statistics methods), is beyond the possibilities of a discretionary trader and for this reason I do not recommend the indicator for discretionary traders.

Please, be careful out there.

 

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;


namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class PriceChannel : Indicator
    {
        [Parameter(DefaultValue = 200)]
        public int numBars { get; set; }

        private double sum_x, sum_x2, sum_y, sum_xy;
        private int start, end;
        private double a, b;
        private double maxDeviation, sumDeviation;
        private double price;
        private double stdDeviation, doubleDeviation;
        private double pr1, pr2;

        protected override void Initialize()
        {
        }

        public override void Calculate(int index)
        {
            end = Chart.LastVisibleBarIndex;
            start = end - numBars + 1;

            sum_x = 0;
            sum_x2 = 0;
            sum_y = 0;
            sum_xy = 0;
            for (int i = start; i <= end; i++)
            {
                sum_x += 1.0 * i;
                sum_x2 += 1.0 * i * i;
                sum_y += Bars.ClosePrices[i];
                sum_xy += Bars.ClosePrices[i] * i;
            }

            a = (numBars * sum_xy - sum_x * sum_y) / (numBars * sum_x2 - sum_x * sum_x);
            b = (sum_y - a * sum_x) / numBars;

            maxDeviation = 0;
            sumDeviation = 0;
            for (int i = start; i <= end; i++)
            {
                price = a * i + b;
                maxDeviation = Math.Max(Math.Abs(Bars.ClosePrices[i] - price), maxDeviation);
                sumDeviation += Math.Pow(Bars.ClosePrices[i] - price, 2.0);
            }

            stdDeviation = Math.Sqrt(sumDeviation / numBars);
            doubleDeviation = stdDeviation + stdDeviation;

            pr1 = a * start + b;
            pr2 = a * end + b;

            var center = Chart.DrawTrendLine("center", start, pr1, end, pr2, Color.Gray, 2, LineStyle.Solid);
            var upperDeviation = Chart.DrawTrendLine("upperDeviation", start, pr1 + stdDeviation, end, pr2 + stdDeviation, Color.DimGray, 1, LineStyle.Lines);
            var lowerDeviation = Chart.DrawTrendLine("lowerDeviation", start, pr1 - stdDeviation, end, pr2 - stdDeviation, Color.DimGray, 1, LineStyle.Lines);
            var upperDoubleDeviation = Chart.DrawTrendLine("upperDoubleDeviation", start, pr1 + doubleDeviation, end, pr2 + doubleDeviation, Color.DimGray, 1, LineStyle.Lines);
            var lowerDoubleDeviation = Chart.DrawTrendLine("lowerDoubleDeviation", start, pr1 - doubleDeviation, end, pr2 - doubleDeviation, Color.DimGray, 1, LineStyle.Lines);
            var top = Chart.DrawTrendLine("top", start, pr1 + maxDeviation, end, pr2 + maxDeviation, Color.Red, 1, LineStyle.Solid);
            var bottom = Chart.DrawTrendLine("bottom", start, pr1 - maxDeviation, end, pr2 - maxDeviation, Color.Green, 1, LineStyle.Solid);
        }

    }
}
Comments

juliahenry230400 - May 05, 2022 @ 11:35

This article is very good, I am also interested in this problem and have many problems. This is really useful information for me. Thanks for sharing solitaire spider free

among012a - May 05, 2022 @ 11:55

This is an excellent article! I'd like for everyone to know how useful the information in your post is. On this subject, your viewpoints are identical to mine. Because I know, I will check your blog every day. It has the potential to be really beneficial to me.

infected days

robertmayy19 - May 07, 2022 @ 10:43

Two standard deviations, two double deviations, and three more lines, the risk is quite high. This is what I am concerned about. trap the cat

sunnyhal189 - May 12, 2022 @ 11:24

I heard from my friend about your article, it was really helpful. I hope you continue to write more great articles. Thank you very much gartic phone

natasha.evans266 - May 14, 2022 @ 05:11

This is an excellent article. This is, in my opinion, one of the best posts ever written. Your work is excellent and inspiring. Thank you very much Waffle

0