I have a rectangle on my chart where the last position is described with
date of entry - entry price - stoploss - current profit/loss
Now I would like to switch the line of stoploss from
initial stop to breakeven stop to trailing stop depending on the actual situation.
The problem is that apparently the previous entry is not overwritten with the new one,
but the texts appear one above the other. I use the function GfxTextOut to write
the texts in the rectangle. If I try to refresh the line with GfxSetTextAlign(0,0,1)
the line remains completely empty. So how can I replace the old text with the new one
only for this line ?
@Achalendra, I'm not sure to properly understand your question, but probably you need to check the usage of the GfxSetBkMode() function.
In any case, posting your code will help us to comprehend the issue better.
@beppe , thank you very much for your answer. In my code GfxSetBkMode is set to 1,
if I set it to 2 it's similar to the GfxSetTextAlign, all fields remain empty.
Here is the code
GfxSelectFont( "Tahoma", 11, 710 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( SelectedValue( LastSignal ) == 1 )
{
GfxSelectSolidBrush( colorBlue );
Datetim = "" + ValueWhen( Buy, Day(), 1 ) + "/" + ValueWhen( Buy, Month(), 1 ) + "/" + ValueWhen( Buy, Year(), 1 ) + " " + ValueWhen( Buy, Hour(), 1 ) + ":" + ValueWhen( Buy, Minute(), 1 );
}
else
{
GfxSelectSolidBrush( colorOrange );
Datetim = "" + ValueWhen( Short, Day(), 1 ) + "/" + ValueWhen( Short, Month(), 1 ) + "/" + ValueWhen( Short, Year(), 1 ) + " " + ValueWhen( Short, Hour(), 1 ) + ":" + ValueWhen( Short, Minute(), 1 );
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth" );
Left = 1100;
width = 310;
x = 1.5;
x2 = 245;
y = pxHeight / 1;
IIf(changestop,GfxSetTextAlign( 0|0|1 ),GfxSetTextAlign( 0|0|0 ));
GfxSelectPen( colorLightBlue, 1 );
GfxRoundRect( x, y - 100, x2, y , 12, 8 ) ;
GfxTextOut( ( "" + Datetim + " " ), 20, y - 90 );
GfxTextOut( ( "" + sig + " Entry" ), 20, y - 70 );
GfxTextOut( ( ": " + entry ), 110, y - 70 );
GfxTextOut( ( " Current " ), 15, y - 30 );
GfxTextOut( ( ": " + WriteVal( IIf( sig == "BUY", ( C - entry ), ( entry - C ) ), 2.2 ) ), 110, y - 30);;
iif (iniloss,GfxTextOut( ( " Ini Stop" ), 15, y - 50 ),GfxTextOut( ( " Even Stop" ), 15, y - 50 ));
iif (iniloss,GfxTextOut( ( ": " + inistop + " (" + inistopL + ")"), 110, y - 50 ),GfxTextOut( ( ": " + evenstop ), 110, y - 50 ));
x = 290;
x2 = 500;
...and the result looks like this
one sees the 3. line contains both texts one above the other.
@Achalendra try to change these lines:
// iif (iniloss,GfxTextOut( ( " Ini Stop" ), 15, y - 50 ),GfxTextOut( ( " Even Stop" ), 15, y - 50 ));
textIniLoss1 = WriteIf(iniLoss, " Ini Stop", " EvenStop");
GfxTextOut(textIniLoss1, 15, y - 50 );
// iif (iniloss,GfxTextOut( ( ": " + inistop + " (" + inistopL + ")"), 110, y - 50 ),GfxTextOut( ( ": " + evenstop ), 110, y - 50 ));
textIniLoss2 = WriteIf(iniloss, ": " + inistop + " (" + inistopL + ")", ": " + evenstop);
GfxTextOut(textIniLoss2, 110, y - 50 );
Moreover, you need also to fix this other line (even if it is not clear to me why you want to use a text align of TA_UPDATECP = 1 );
// IIf(changestop,GfxSetTextAlign( 0|0|1 ),GfxSetTextAlign( 0|0|0 ));
GfxSetTextAlign(IIf(changestop, 1, 0));
thank you very much ! This works indeed. I think I got it now. The other line is not important, it was just another trial to resolve this problem, I only forgot to delete it...