Price channel

Created at 23 May 2013, 01:45
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
LG

Lgon

Joined 22.04.2013

Price channel
23 May 2013, 01:45


Hello,

I'm looking for a simple and popular indicator - price channel (tipically it plot in the chart a channel with the 20-period high and low).

I didn't find it on cTrader nor in the forum.

Could you please?

Thanks


@Lgon
Replies

lec0456
24 May 2013, 06:18

I am really glad you asked this question and that it was answered in the way it was.  I followed the link and read a very important requirement for the price channel.

 It said, "The Price Channel formula does not include the most recent period. Price Channels are based on prices prior to the current period. A 20-day Price Channel for October 21 would be based on the 20-day high and 20-day low ending the day before, October 20. A channel break would not be possible if the most recent period was used."

I had created a price channel indicator like the one posted by "adaled".  it used the maximun and minimum fuctions.  But this is incorrect because they use the current period in there calculations.  Actually, there is a sample indicator included with the installation of cAlgo called Sample Price Channels, it calculates the channel correctly like described on the Stock Charts.Com website:

 

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true)]
    public class SamplePriceChannels : Indicator
    {
        [Parameter(DefaultValue = 20)]
        public int Periods { get; set; }

        [Output("Upper", Color = Colors.Pink)]
        public IndicatorDataSeries Upper { get; set; }

        [Output("Lower", Color = Colors.Pink)]
        public IndicatorDataSeries Lower { get; set; }

        [Output("Center", Color = Colors.Pink)]
        public IndicatorDataSeries Center { get; set; }

        public override void Calculate(int index)
        {
            double upper = double.MinValue;
            double lower = double.MaxValue;

            for (int i = index - Periods; i <= index - 1; i++)
            {
                upper = Math.Max(MarketSeries.High[i], upper);
                lower = Math.Min(MarketSeries.Low[i], lower);
            }

            Upper[index] = upper;
            Lower[index] = lower;
            Center[index] = (upper + lower) / 2;
        }
    }
}




@lec0456

adaled
24 May 2013, 09:19

Thanks for pointing that out. I was wondering why there were no crossings :) Thanks.


@adaled

Lgon
24 May 2013, 11:04

Many thanks. It works just perfectly!

To support: I believe it should be part of he platform, together with many other standard and popular indicators (ichimoku, PSAR, ..)


@Lgon

cAlgo_Fanatic
24 May 2013, 12:52

Parabolic SAR is already included. We will add more indicators in the platform in the future.


@cAlgo_Fanatic

cAlgo_Fanatic
24 Jul 2013, 15:20

RE:
Lgon said:

Many thanks. It works just perfectly!

To support: I believe it should be part of he platform, together with many other standard and popular indicators (ichimoku, PSAR, ..)

Three new standard indicators have been added to cTrader/cAlgo: Average True Range, Ichimoku Kinko Hyo and Donchian Channel. 


@cAlgo_Fanatic