Weird drawrectangle behaviour.

Created at 17 Nov 2018, 19:04
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!
SH

Shares4UsDevelopment

Joined 14.10.2018

Weird drawrectangle behaviour.
17 Nov 2018, 19:04


Hi.
This code draws the text but not the rectangle.

string name="box";
ChartRectangle MyZone = (ChartRectangle)ThisChart.FindObject(Name);
ChartText MyZoneText = (ChartText)ThisChart.FindObject(Name + "t");
if (MyZone == null)
{
    MyZone = ThisChart.DrawRectangle(Name, Start, 1.134, End, 1.144, "00FFFFFF", 1);
    MyZoneText = ThisChart.DrawText(Name + "t", "", Start, 1.134, "00FFFFFF");
}
MyZone.IsFilled = true;
MyZone.IsInteractive = false;
MyZone.Time1 = Start;
MyZone.Time2 = (End == DateTime.MaxValue) ? ThisChart.MarketSeries.OpenTime[ThisChart.LastVisibleBarIndex] : End;
MyZone.Y1 = Min;
MyZone.Y2 = Max;
MyZone.Thickness = 1;
string Opacity = PadLeft(Strength, "0", 2);
MyZone.Color = string.Concat(Opacity, BaseColor);
MyZone.Comment = Comment;
              
MyZoneText.Color = string.Concat("ff", BaseColor);
MyZoneText.Time = Start.AddMinutes((End.Minute - Start.Minute) / 2);
MyZoneText.Y =this.isSupplyZone? Min:Max;
MyZoneText.Text = Comment;

Anyone an idea Why?
2nd question: is tehre a way to extend a rectangle into infinity?

Best rgds,
ton


@Shares4UsDevelopment
Replies

PanagiotisCharalampous
19 Nov 2018, 12:10

Hi Ton,

Can you share the full source code with us? We cannot have a complete undestanding of what you are doing with this snippet only. For example, we do not know what Start and End represent and what values they might have.

Best Regards,

Panagiotis


@PanagiotisCharalampous

Shares4UsDevelopment
19 Nov 2018, 15:06

RE:

Hi Panagiotis.

Thnks for your reply. In the meanwhile I found the Error. 

The MyZone.Color = string.Concat(Opacity, BaseColor);

statement gave a string lconsiting only of numbers and that gave an error. It was notinterpreted as Hex i guess.

changing the statement to fromargb(.....) solved the issue..

But i'd still like the 2nd Question (extend a rectangle into infinity) to get an answer.

Best rgds,

Ton

 


@Shares4UsDevelopment

PanagiotisCharalampous
19 Nov 2018, 15:32

Hi Ton,

You cannot draw an infinite rectangle. It would not be a rectangle then, but two lines. Try setting extreme values.

Best Regards,

Panagiotis


@PanagiotisCharalampous