Exeption Rule on a specific Date

Created at 02 Feb 2016, 11:24
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!
MaVe's avatar

MaVe

Joined 24.08.2015

Exeption Rule on a specific Date
02 Feb 2016, 11:24


For this Line:

ChartObjects.DrawLine("pClose" + today, today1, close, today2, close, Colors.Blue, 1, LineStyle.Lines);

I need a kind of "Exeption Rule":

When the Date=Monday then the line has to be solid and overrules the above line.


@MaVe
Replies

whis.gg
02 Feb 2016, 14:33

RE:

Does that work?

LineStyle lineStyle;
Colors color;

if (DateTime.UtcNow.DayOfWeek == DayOfWeek.Monday)
{
   lineStyle = LineStyle.Solid;
   color = Colors.Red;
}
else
{
   lineStyle = LineStyle.Lines;
   color = Colors.Blue;
}

Or short version.

bool isMonday = DateTime.UtcNow.DayOfWeek == DayOfWeek.Monday;
var lineStyle = isMonday ? LineStyle.Solid : LineStyle.Lines;
var color = isMonday ? Colors.Red : Colors.Blue;

 


@whis.gg