Display indicator on unhide

Created at 18 Sep 2024, 19:23
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!
VIZAINT's avatar

VIZAINT

Joined 18.09.2024

Display indicator on unhide
18 Sep 2024, 19:23


I have created this indicator and it works perfectly except that when I want to hide it for a moment and then show it, the boxes on rigth are not drawn.
I have tried different methods that I know of and I cannot get rid of this error. The only thing is that if I change the timeframe and the graph is redrawn, everything goes back to normal. Does anyone have another idea?


@VIZAINT
Replies

PanagiotisCharalampous
19 Sep 2024, 06:35

Hi there,

Please share your indicator code so that we can reproduce it.

Best regards,

Panagiotis


@PanagiotisCharalampous

VIZAINT
19 Sep 2024, 07:13 ( Updated at: 19 Sep 2024, 09:34 )

Display indicator on unhide -Code

Nothing out of the ordinary, there is a method of creating the box and then in Calculation it is repeated 10 times, to form part of the vertical line on the right.

public override void Calculate(int index) {
for (int ib = 0; ib < 10; ib++)
               {
                   ////////////
                   ///---------------
                  ///////////

                   DrawMyRectangle(ib, index, Start, End, currentPrice, by10, MaxBoxIndex, MinBoxIndex);

               }
}

 

public ChartRectangle DrawMyRectangle(int ib, int ind, int start, int end, double currPrice, double by10, double MaxBoxIndex, double MinBoxIndex)
       {
           double sum = Xcind(ind, start, end);
           List<double> mSum = new();
           mSum.Add(sum);

           var Minut = TimeFrame.GetHashCode();
           var newOffset = Minut * OffsetBox;
           var topbx = by10 - (by10 * 0.1);
           var btmbx = by10 - (by10 * 0.9);
           var newColor = sum > 0 ? Color.FromArgb(TranspBox, UpColor) : Color.FromArgb(TranspBox, DownColor);

          ////////////
          ///---------------
         ///////////

           return rec;
       }


@VIZAINT

PanagiotisCharalampous
19 Sep 2024, 09:35

RE: Display indicator on unhide -Code

VIZAINT said: 

Nothing out of the ordinary, there is a method of creating the box and then in Calculation it is repeated 10 times, to form part of the vertical line on the right.

public override void Calculate(int index) {
for (int ib = 0; ib < 10; ib++)
               {
                   ////////////
                   ///---------------
                  ///////////

                   DrawMyRectangle(ib, index, Start, End, currentPrice, by10, MaxBoxIndex, MinBoxIndex);

               }
}

 

public ChartRectangle DrawMyRectangle(int ib, int ind, int start, int end, double currPrice, double by10, double MaxBoxIndex, double MinBoxIndex)
       {
           double sum = Xcind(ind, start, end);
           List<double> mSum = new();
           mSum.Add(sum);

           var Minut = TimeFrame.GetHashCode();
           var newOffset = Minut * OffsetBox;
           var topbx = by10 - (by10 * 0.1);
           var btmbx = by10 - (by10 * 0.9);
           var newColor = sum > 0 ? Color.FromArgb(TranspBox, UpColor) : Color.FromArgb(TranspBox, DownColor);

          ////////////
          ///---------------
         ///////////

           return rec;
       }

hi there,

I would need the full source code of the indicator to assist further


@PanagiotisCharalampous

VIZAINT
19 Sep 2024, 10:05

Display indicator on unhide - Copyright

Thank you for your interest, but it is impossible due to copyright. I will find a solution on my own.


@VIZAINT

VIZAINT
27 Sep 2024, 16:52 ( Updated at: 27 Sep 2024, 16:53 )

Display indicator on unhide - example

I have prepared this example, to check on the chart, it hides it for a while depending on the timeframe, if it is a minute, then something more than 1 minute and then unhide. The rectangle does not appear

img desrcip - the result of code

//--------------------------------------------------------------------------------//

public override void Calculate(int index)
        {
            DateTime openDay = DateTime.Now;
            var Start = new DateTime(openDay.Year, openDay.Month, openDay.Day, openDay.Hour - 5, 0, 0, DateTimeKind.Utc);
            var End = new DateTime(openDay.Year, openDay.Month, openDay.Day, openDay.Hour, 0, 0, DateTimeKind.Utc);
            var Rect = Chart.DrawRectangle("Rect", Start, Chart.TopY, End, Chart.BottomY, Color.FromArgb(50, Color.Crimson));
            Rect.IsFilled = true;
        }


@VIZAINT