Announcement

Collapse
No announcement yet.

mouse functions

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

  • mouse functions

    Hi,
    i am trying to change the mouse functions example of the EFS Function reference to draw also a horziontal line in the advanced chart from the point and at the level where i click left with the mouse, but i do not know how to insert the correct variables in the drawlinerelative() function.

    Thought i could change the part in the formula like below, but it doesn't work.

    ... function updateClickInfo(barIndex, yValue) {

    drawTextAbsolute(5,20 , "Clicked bar " + barIndex + " at " + yValue.toFixed(2),

    Color.white, Color.navy, Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.BOL D,

    null, 14, "ClickInfo");

    drawLineRelative( -barIndex, yValue, -barIndex, yValue, PS_SOLID, 1, Color.blue, x);

    } ...

    Suspect that "barIndex" and "yValue" are not the types of variables that drawLineRelative() needs, but how can i get the right ones.

    I also didn't find out what yValue.toFixed(2) means.

    Can someone help me please?

    Regards
    Robert

  • #2
    Not sure (yet) about the line drawing but the .toFixed(2) is a standard javascript function call to return a string from a number that is fixed to 2 decimal places.

    So if your value is 12.5 it will return 12.50.

    Also for the drawLineRelative you have x1 and x2 the same so even if it shows (which I'm not sure it will) it will be an extremely small line. You are better off with:

    drawLineRelative(getCurrentBarIndex(), yValue, getCurrentBarIndex() + 50, yValue, PS_SOLID, 1, Color.blue, "x")

    That should extend the line 50 points from the value dictated by the getCurrentBarIndex function.

    If you are looking for the yValue anywhere I suggest something like the close() parameter. I'm still working out mouse stuff myself.

    HTH

    Comment


    • #3
      A little help....

      barindex should return a -x to 0 value (for the bar you clicked on). So, you are trying to draw a line from/to the same point - thus no line..

      ... function updateClickInfo(barIndex, yValue) {

      drawTextAbsolute(5,20 , "Clicked bar " + barIndex + " at " + yValue.toFixed(2),

      Color.white, Color.navy, Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.BOL D,

      null, 14, "ClickInfo");

      drawLineRelative( barIndex, yValue, 3, yValue, PS_SOLID, 1, Color.blue, "Testline");

      } ...

      The change I made will draw the line from the point of "click" to 3 bars to the right of the current bar.
      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        Thank you. Exactly what i needed.

        My goal is to set Buy-/Sellstop Orders at the mouseclicklevel and draw a line from there.
        Left mouseclick above current price is a Buystop-Order and Left mouseclick below is a Sellstop-Order.

        Now i see how this is accomplished. First i put drawLineRelative() into function main() and needed quite a while to understand where to put it. But the same x's for linestart und -end really gave me a hard time Also the "-barIndex" instead of "barIndex" for me was hard to see without your solution. barIndex is already negative, right?

        Also thank you muthaf for explaining the .toFixed(2) and enlightening me that i made a onepoint-line .
        I found also interesting exmaples from FibbGann by searching for "mouse" in this forum.

        I will post my solution when i'm finished with my ordertool.
        Hope it is not impossible.

        Regards
        robert

        Comment

        Working...
        X