Announcement

Collapse
No announcement yet.

How to get signal icons to stack on price bar...

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

  • How to get signal icons to stack on price bar...

    Hello,

    I'm usng drawTextRelative in my EFS code and have regular instances where a given price bar (the high or low) qualifies for two signals (at the same time) in which case...say two...indicator icons are overwriting each other.

    Is there any code that I can include in the fuction drawTextRelative that would allow them to stack on each other?

    current example of code:

    drawTextRelative(0, low(0), "~", Color.red, null, Text.Center|Text.Top, "Arial", 20, gID());

    Any help is much appreciated,

    Thanks

    gguindon

  • #2
    why don't you create a "iconsonBar" variable and reset it to ZERO for each new bar. That way, you could control how many "triggers" are found on each bar and increment the icons different based on the number of triggers found.

    I use a rotating variable to control and display some information at the top of the charts using DrawTextRelative.

    First I setup a rotating variable..

    var toplevelstat = 0;

    Then, when I draw the information on the chart, I increment it as needed.

    function drawstat() {
    var tempy = 10;
    if (toplevelstat == 1) { tempy = 30; }

    drawTextRelative(0, tempy, " TEXT ", Color.black, null, Text.ONTOP | Text.CENTER | Text.RELATIVETOTOP, null, 9, nBarCounter+"Stat");

    toplevelstat++;
    if (toplevelstat > 1) { toplevelstat = 0; }
    }

    What this does is offset the drawing of the status variable up and down with each new draw request. Thus, attempting to prevent the text from drawing on top on other text.

    The first item is drawn near the top of the chart, the second is drawn a bit lower, the third is drawn nears the top again and it just keeps rotating like this for each draw function.

    Hope this helps?
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks Doji3333 - but I believe your solution is contingent on the fact that I have all drawing functions within one script - doesn't it?

      My indicators are each located within their own scripts such that an icon is placed at (say) the top of a intraday bar...next script is run when last script to run is finished with each script placing it's icon at the top (of the price bar) when criteria is met.

      I was wondering if there was a built in function to say..."oh there is an icon at the top of this bar already...have to place next icon on top of what's already there"...the next script needs to be able to determine if an icon is already there.

      Is there a function that could identify the top of a price bar - with an icon already on top - as being the top of the icon (already on top)?

      gg

      Comment


      • #4
        have a look at Global Values, they allow you to communicate between scripts.
        Take acount of:
        All scripts on one chart but not other charts will need to communicate, I can't remember if there is a function to call that gives a unique per chart ID, if not you may need a script parameter. Once you have that you can create "per chart" global variable names.

        Scripts are called in a fixed order (at each chart tick), also I camn't remember it, either it won't matter, or the scripts will have to learn or you need to sort it out manually (latter most troublesome , don't forget that a script reload needs thinking about).

        Then, with a per bar reset, you can have a shared variable that counts the per bar annotations or whatever.

        gl

        Comment

        Working...
        X