Drawing Trendline on Indicator Window

Created at 04 Sep 2021, 14:59
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!
JI

jiduxiyanghong.gujin

Joined 04.09.2021

Drawing Trendline on Indicator Window
04 Sep 2021, 14:59


Is it possible to draw a trendline on an indicator window instead of chart window? It seems mentioned nowhere.


@jiduxiyanghong.gujin
Replies

amusleh
06 Sep 2021, 13:00

Hi,

You can draw all chart objects on your indicator window by using IndicatorArea instead of Chart:

using cAlgo.API;
namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ChartTrendLineSample : Indicator
    {
        protected override void Initialize()
        {
            var trendLine = IndicatorArea.DrawTrendLine("trendLine", Chart.FirstVisibleBarIndex, Bars.LowPrices[Chart.FirstVisibleBarIndex], Chart.LastVisibleBarIndex, Bars.HighPrices[Chart.LastVisibleBarIndex], Color.Red, 2, LineStyle.Dots);
            trendLine.IsInteractive = true;
        }
        public override void Calculate(int index)
        {
        }
    }
}

 


@amusleh