plot middle of bar indicator

Created at 27 Mar 2022, 11:21
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!
RJ

rjalopes

Joined 01.07.2021

plot middle of bar indicator
27 Mar 2022, 11:21


Hi everyone is it possible for someone to show me how to build a indicator to plot a line in the middle of the  individual bars just the same way i use Simple moving average with 1 period and (high+Low)/2 ,but instead of the continuous line of MA, individual lines like the open and close indicator?

Thank You.


@rjalopes
Replies

amusleh
28 Mar 2022, 10:19

Hi,

Do you mean something like this:

using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
        private int _lasyBarIndex;

        protected override void Initialize()
        {
        }

        public override void Calculate(int index)
        {
            if (_lasyBarIndex == index) return;

            _lasyBarIndex = index;

            var bar = Bars[index];

            var barMiddle = bar.Low + ((bar.High - bar.Low) / 2);

            Chart.DrawTrendLine(index.ToString(), index, barMiddle, index + 1, barMiddle, Color.Red);
        }
    }
}

 


@amusleh

rjalopes
29 Mar 2022, 05:34 ( Updated at: 29 Mar 2022, 05:37 )

RE:

amusleh said:

Hi,

Do you mean something like this:

using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
        private int _lasyBarIndex;

        protected override void Initialize()
        {
        }

        public override void Calculate(int index)
        {
            if (_lasyBarIndex == index) return;

            _lasyBarIndex = index;

            var bar = Bars[index];

            var barMiddle = bar.Low + ((bar.High - bar.Low) / 2);

            Chart.DrawTrendLine(index.ToString(), index, barMiddle, index + 1, barMiddle, Color.Red);
        }
    }
}

Sorry for the the late reply amusleh, Thank you  that is  exactly what i want .

 


@rjalopes