Announcement

Collapse
No announcement yet.

How to draw a solid rectangle

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to draw a solid rectangle

    I must be missing something simple...

    I'd like to draw solid colored rectangles--here's an example of an EFS that does it:



    Changing the bar background color for a range of bars doesn't do it--it's dependent on bar thickness and horizontal scaling (you can end up with a cluster of thick vertical lines, like a diced rectangle). If I use drawLineRelative and make it a thick line, the corners are rounded.

    Any tips?
    Last edited by codehead; 11-08-2010, 09:06 AM.

  • #2
    Yes, you have to use the following.

    setBarBgColor(Color.red, 0, 9999999, 0 );

    The parameters are as follows :

    Color
    Pane
    Color to HIGH
    Color to LOW

    The PANE is related to the cursor window outputs. You will need one cursor window output for each unique item you wish to draw.

    So, if I wanted to draw a green rectangle between $12 and $14 on a chart, I would do it like this.

    setBarBgColor(Color.green, 0, 14, 12 );
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Originally posted by Doji3333
      Yes, you have to use the following.

      setBarBgColor(Color.red, 0, 9999999, 0 );
      Doh... I already know that, thanks... my memory was faulty ("Changing the bar background color for a range of bars doesn't do it--it's dependent on bar thickness and horizontal scaling (you can end up with a cluster of thick vertical lines, like a diced rectangle)"). Actually, the diced rectangle is what happens when you try it with vertical lines and controlling the line thickness...

      Sorry, I remember now why I couldn't use setBarBgColor--it's because I can't use it for future bars. That is, bars that haven't been printed yet. For some things I'd like to have zones in place ahead of time. A simple example would be if you wanted to have shaded time zones during the day--lets say you expect a turn time in the range of 10:30-11:00.

      Anyway, thanks for the reply--it's been a while, and I attributed a certain problem to the wrong solution. I do wish eSignal was better about drawing simple things on the screen. Ninja is so much better about that--eSig is pretty archaic about its graphics capabilities.
      Last edited by codehead; 11-09-2010, 09:21 AM.

      Comment


      • #4
        maybe you can try drawing 4 lines to create a rectangle that outlines the background color. I've done some advanced line drawing routines before using arrays.
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          Originally posted by Doji3333
          maybe you can try drawing 4 lines to create a rectangle that outlines the background color. I've done some advanced line drawing routines before using arrays.
          That's not the issue... it's that I want a shaded zone in the future, ahead of the current bar. You can draw lines in the future, but you can't setBarBgColor in the future--those bars don't exist yet.

          BTW, a more subtle quirk about drawing lines in the future: If you're looking at past bars on a daily chart, there are no bars for days on which the market is closed (weekends, holidays), but there are in future bars. So and future lines that coincide with specific days (that is, say you put a bar out on Tuesday, December 14, 2010, so that the cursor window shows that that date when you hover over that line), you have to move the lines as future market-closed bars are "removed" from the chart, and market-open bars scroll to the left. That is, at this moment, Monday is six bars into the future. But on Monday, you'll find that there are only four more bars on the chart than there are right now. because of this, you have to re-evaluate where those bars in the future are, and reposition them as necessary.

          Here's an example, a moon-phase study I wrote; obviously, if you care about full moons relative to the market, you're very interested in how soon the next one is--here it's apparent that it's spaced at a greater distance than the ones in the past, because the future includes weekends for now:



          Just pointing out some of the complexities in dealing with future bars. I do wish we could set the background of future bars though, and that would be consistent with the current method and issues with drawing lines at future bars. Or, simply improve the relatively weak collection of drawing primitives in eSignal and let me draw a shaded rectangle--user defined pixel maps would be nice too.

          Comment

          Working...
          X