Trying to draw right extended rectangle, need help

Dear Seniors,

I have use following code to write rectangle as per my requirements, but want to draw right extended rectangle. Kindly let me know what change need to do for expected drawing output.

GfxSetZOrder(-5);
GfxSetCoordsMode(1);
GfxSetBkMode(1);
GfxSelectPen(ColorRGB( 065, 000, 065), 0, 1);
GfxSelectSolidBrush( ColorRGB( 065, 000, 065) );
i = Barcount;
GfxRectangle(i, Entry[i-Offset], i-Offset, SL[i-Offset]); 

YesBank

Thank you in advance..

Your Junior

GfxRectangle( x1, y1, x2, y2 )
RETURNS NOTHING
FUNCTION: Draws a rectangle using the current pen. The interior of the rectangle is filled using the current brush.

Parameters

  • x1 - x-coordinate of the upper left corner of the rectangle
  • y1 - y-coordinate of the upper left corner of the rectangle
  • x2 - x-coordinate of the lower right corner of the rectangle
  • y2 - y-coordinate of the lower right corner of the rectangle

Hello,
If you break down the GFXrectangle Coordinates you could interpret what is going on.
The X coordinates relate to Bars and the Y coordinates relate to price.

The first X1 coordinate is the Start bar and the next X2 coordinate is the End bar. So to extend past
last bar : X2 + 1 etc.

just change GfxSetCoordsMode() 's mode to 2
then use the value of status("pxwidth" ) or status("pxchartwidth") ,
by placing it on third argrument of GfxRectangle , you are able to extend your rectangle

And where you got it from? By yourself?
I don't think so.

So why do start new thread (just for extending the same one to right side of chart) if there already is such thread there?

Now, if you want to extend to right then add lastvisiblebarindex (for example)

GfxSetZOrder(-5);
GfxSetCoordsMode(1);
GfxSetBkMode(1);
GfxSelectPen(ColorRGB( 065, 000, 065), 1, 0);
GfxSelectSolidBrush( ColorRGB( 065, 000, 065) );
i = Barcount;
lvbi = Status( "lastvisiblebarindex" );
GfxRectangle(i-Offset, Entry[i-Offset], lvbi, SL[i-Offset]); 

Plot( C, "Price", colorDefault, styleCandle );
2 Likes

Some useful article that also may help you in achieving your goal

How to convert from bar-value to pixel co-ordinates
Status
GfxSetCoordsMode

Hi Fxshrat,

Thank you again for that tidbit of knowledge.

This correlates to the number of Blank bars that have been set to the right and this will fill up that space.