ADX on Chart

Created at 22 Jan 2014, 20:37
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!
ST

StBechstedt

Joined 22.01.2014

ADX on Chart
22 Jan 2014, 20:37


Hello,

can somebody help me display the current ADX value right on the chart???

I found a similar indicator that draws the current spread on the chart:

/algos/indicators/show/331

Since I'm not a programmer I just can't get it to work with the value of the ADX.

It also would be great if the text can change colors depending on a rising or falling ADX value.

Any help would be much appreciated.

Thanks.

 

 


@StBechstedt
Replies

Old Account
23 Jan 2014, 09:52

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]

 


@Old Account

StBechstedt
23 Jan 2014, 14:23

Can you explain that a little bit further please???


@StBechstedt

Old Account
23 Jan 2014, 18:49

RE:

StBechstedt said:

Can you explain that a little bit further please???

// -------------------------------------------------------------------------------
//
//    This is a Template used as a guideline to build your own Robot. 
//
// -------------------------------------------------------------------------------
 
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
 
namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
    public class DrawSpread : Indicator
    {
 
        protected override void Initialize()
        {
            // Initialize and create nested indicators
        }
 
        public override void Calculate(int index)
        {
            // Calculate value at specified index            
            DisplaySpreadOnChart();            
        }
 
 
 
        private void DisplaySpreadOnChart()
        {
            var spread = Math.Round(Symbol.Spread/Symbol.PipSize, 2);
            string text = string.Format("{0}", spread);
            ChartObjects.DrawText("Label", "Spread:", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("spread", text.PadLeft(12), StaticPosition.TopLeft, Colors.White);
        }
    }
}

If to look where it says: [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]

if it is true it's on the chart, if it's false it won't be on the chart


@Old Account

StBechstedt
23 Jan 2014, 22:49

Yes I understand that.

But how do I code the rest to show me the current ADX value???


@StBechstedt

ErikD
24 Jan 2014, 01:14

// -------------------------------------------------------------------------------
//
//   This will draw the value of the ADX on the chart
//
// -------------------------------------------------------------------------------

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
    public class DrawSpread : Indicator
    {
        [Parameter(DefaultValue = 25)]
        public int Period { get; set; }

        private DirectionalMovementSystem _dms;


        protected override void Initialize()
        {
            _dms = Indicators.DirectionalMovementSystem(Period);
        }

        public override void Calculate(int index)
        {

            DisplayADXChart();
        }



        private void DisplayADXChart()
        {

            string text = string.Format("ADX: {0}", _dms.ADX.LastValue);
            ChartObjects.DrawText("Label", "ADX:", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("adx", text.PadLeft(12), StaticPosition.TopLeft, Colors.White);
        }
    }
}

 


@ErikD

StBechstedt
24 Jan 2014, 15:19

Thanks so much. That worked.


@StBechstedt