Text Drawings at Last Bar Issue ( Stops when New Bar Occurs )

Created at 07 Oct 2020, 14:38
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!
JO

Jobauma

Joined 07.10.2020

Text Drawings at Last Bar Issue ( Stops when New Bar Occurs )
07 Oct 2020, 14:38


Hi.

I have problems to find information on this matter. I have even tried to add initial removing object code to the indicator, but it doesn't work. The issue is when the bar closes, and a new one appears, the drawings stop at the previous bar, and there are no new drawings for the next one. By the way, the whole indicator stops plotting when this happens. :P

Code:

// Create Average True Range Pips ( Length 5/13 )

// B Remove

Chart.RemoveObject("Pips ATR A");
Chart.RemoveObject("Pips ATR B");

// A Create

// A 5

var Pips_ATR_A = Chart.DrawText("Pips ATR A", (m_ATR_Pips_A.Result[Index] / Symbol.PipSize).ToString("0.#"), Bars.Count, Bars.ClosePrices[Index], Color.Green);
Pips_ATR_A.VerticalAlignment = VerticalAlignment.Top;
Pips_ATR_A.HorizontalAlignment = HorizontalAlignment.Right;

// B 13

var Pips_ATR_B = Chart.DrawText("Pips ATR B", (m_ATR_Pips_B.Result[Index] / Symbol.PipSize).ToString("0.#"), Bars.Count, Bars.ClosePrices[Index], Color.DarkRed);
Pips_ATR_B.VerticalAlignment = VerticalAlignment.Bottom;
Pips_ATR_B.HorizontalAlignment = HorizontalAlignment.Right;

I hope that somebody can help me. :)


@Jobauma
Replies

Jobauma
07 Oct 2020, 14:53

RE:

I found out that the problem is not related to the drawings are created. There is something wrong with the indicator. :P


@Jobauma

Jobauma
07 Oct 2020, 15:24

I found out the issue. :D

I use "double[]"-s for my MAs.

The solution was to multiply "Bars.Count" with "2". :P

Here is the code:

protected override void Initialize()
{
    // Initialize: Bars Count

    int BarsCount = Bars.Count * 2;



    // MAs

    m_MA = new double[BarsCount];
}

 


@Jobauma