Set text_setBGcolor for textbox
Posted: Sep 12 2012
Hi
Can someone help me with the problem I have with setting different background colors according 3 conditions.
I would like to have the background of a textbox colored black in case positionprofit = 0. When positionprofit > 0 then the color need to be green and with positionprofit < 0, color red.
This is the code I use to give it one color
This I tried to get the three different colors, but I think textbox formatting is not working in a condition?
The text will work with above code but only with color black (the first color that was seen by MC?)
For value5 I also tried the following:
This will work for the green and red color of the background, but how do I add a third condition in the iff statement for the situation positionprofit = 0 and then color black.
Can someone help me with the problem I have with setting different background colors according 3 conditions.
I would like to have the background of a textbox colored black in case positionprofit = 0. When positionprofit > 0 then the color need to be green and with positionprofit < 0, color red.
This is the code I use to give it one color
Code: Select all
// Create textbox
once begin
textobj_profit_loss = Text_new_s(juliantodate(getappinfo(airightdispdatetime)),
Getappinfo(airightdispdatetime) - oneminute,
getappinfo(aihighestdispvalue) + ((Minmove / PriceScale) * ticksOffSetTop_profit),
Text(headerstr_profit_loss, Boxstr_8,Boxstr_9, Boxstr_10));
// Textbox formatting
value1 = Text_SetStyle(TextObj_profit_loss, 1, 0);
value2 = Text_SetFontName(TextObj_profit_loss, Text_FontName);
value3 = Text_SetBorder(TextObj_profit_loss, Text_DisplayBorder);
value4 = Text_SetSize(TextObj_profit_loss, Text_FontSize);
value5 = Text_SetBGColor(TextObj_profit_loss, black);
value6 = Text_SetColor(TextObj_profit_loss, Text_FontColor);
// Update the textboxs location and text
value7 = Text_SetLocation_s(TextObj_profit_loss,
JulianToDate(GetAppInfo(airightDispDateTime)),
datetime2eltime_s(GetAppInfo(airightDispDateTime) - oneMinute),
GetAppInfo(aihighestDispValue) - ((MinMove / PriceScale) * TicksOffSetTop_profit));
value8 = Text_SetString(TextObj_profit_loss, Text(headerstr_profit_loss, newline, boxStr_8, newline, newline, boxstr_9, newline, boxstr_10));
Code: Select all
If positionprofit > 0 then begin
value1 = Text_SetStyle(TextObj_profit_loss, 1, 0);
value2 = Text_SetFontName(TextObj_profit_loss, Text_FontName);
value3 = Text_SetBorder(TextObj_profit_loss, Text_DisplayBorder);
value4 = Text_SetSize(TextObj_profit_loss, Text_FontSize);
value5 = Text_SetBGColor(TextObj_profit_loss, green);
value6 = Text_SetColor(TextObj_profit_loss, Text_FontColor);
end;
If positionprofit = 0 then begin
value1 = Text_SetStyle(TextObj_profit_loss, 1, 0);
value2 = Text_SetFontName(TextObj_profit_loss, Text_FontName);
value3 = Text_SetBorder(TextObj_profit_loss, Text_DisplayBorder);
value4 = Text_SetSize(TextObj_profit_loss, Text_FontSize);
value5 = Text_SetBGColor(TextObj_profit_loss, black);
value6 = Text_SetColor(TextObj_profit_loss, Text_FontColor);
end;
if positionprofit < 0 then begin
value1 = Text_SetStyle(TextObj_profit_loss, 1, 0);
value2 = Text_SetFontName(TextObj_profit_loss, Text_FontName);
value3 = Text_SetBorder(TextObj_profit_loss, Text_DisplayBorder);
value4 = Text_SetSize(TextObj_profit_loss, Text_FontSize);
value5 = Text_SetBGColor(TextObj_profit_loss, red);
value6 = Text_SetColor(TextObj_profit_loss, Text_FontColor);
end;
For value5 I also tried the following:
Code: Select all
value5 = Text_SetBGColor(TextObj_profit_loss, iff(positionprofit > 0, green, red);