Announcement

Collapse
No announcement yet.

Up and Down Arrows using 'AboveBar' and 'BelowBar' tools introduced in EFS2

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

  • Up and Down Arrows using 'AboveBar' and 'BelowBar' tools introduced in EFS2

    I put together a simple efs that uses the new 'AboveBar' and 'BelowBar' tools introduced in EFS2 for some troubleshooting work I was doing and thought it may be of interest.

    PHP Code:
    //Sample button Application that places arrows on the chart using new EFS 2 BelowBar and AboveBar tools
    // S. Hare 5/27/2005
    function preMain() { 
      
    setPriceStudy(true); 
      
    setStudyTitle("Up-n-Down Arrows"); 
      
    setShowCursorLabel(false);


    function 
    main() { 
        
    verifyBuild719 );  


    function 
    onLButtonDblClkbarIndexyValue) {
        if(
    yValue Math.max(open(barIndex),close(barIndex)))DownArrow(barIndexyValue"down");
        else if(
    yValue Math.min(open(barIndex),close(barIndex)))UpArrow(barIndexyValue"up");
    }

    function 
    UpArrow(barIndexyValuetmp){
        
    drawShapeRelative(barIndexBelowBar2,Shape.UPARROWnullColor.redText.PRESET|Text.CENTER,tmp);
        
    debugPrintln("20: UpArrow, barindex = "+barIndex+" yValue = "+yValue.toFixed(2));
    }
    function 
    DownArrow(barIndexyValuetmp){
        
    drawShapeRelative(barIndexAboveBar2,Shape.DOWNARROWnullColor.redText.PRESET|Text.CENTER,tmp);
        
    debugPrintln("24: DownArrow, barindex = "+barIndex+" yValue = "+yValue.toFixed(2));

    Here is a small screenshot of the arrows it places on the screen when you doubleclick the left mouse button either above or below the price bars. If you click above the pricebars, a down arrow appears. Conversly, if you click below the price bar, an up arrow appears. Note that the Text.PRESET flag was also added in EFS2 to allow the use of these features with the EFS1 'drawShapeRelative()' command.



    Here is a copy of the efs for download.
    Attached Files

  • #2
    that's great stuff , Steve. Thanks for sharing.

    quick question: which one of the two is more computationally intensive (or rather CPU intensive)? drawTextRelative(,,,) or drawTest Absolute(,,,)?

    I am drawing text buttons in the Price Pane using drawTextRelative(-5, vPos, ...) and set vPos dynamically to close()+/- a spread, but noticing buttons are getting redrawn every price change....would really like to fix these buttons with a constant vPos but can't figure out the scaling in the price pane...any advice?

    Thanks,

    ziggy

    Comment


    • #3
      Z11,

      I can say with absolute certainty that they take relatively the same amount of resources. Differentiating the resource requirements can be accomplished if you really want to. If you would like to time them to be absolutely sure, create a function that will run one of them 10000 times and time it before and after the function is done and ditto for the other one. Output the measured time using debugprintln. That should tell you for certain which is more resource intensive.

      My recomendation for your second point... Once you have drawn the text button on the screen, you need to control how often the button is re-drawn. Right off the top of my head, you should probably establish a range where the button would not be redrawn. Once you establish the range, simply do not redraw the button unless it exceeds the range. Next, you need to have the capabilitty to modify the range, if this is the case, you should probably add it as an editable parameter in your study.

      - if this does not work out, perhaps you should post the question in a different thread, more related to to the subject at hand as your question is more related to efs studies and not efs2 developement...imho, it would get more attention there.

      Comment


      • #4
        Problems combining drawShapeRelative and the AboveBar / BelowBar tools

        I can't get this code to work:

        drawShapeRelative(0, AboveBar3, Shape.DOWNARROW, null, Color.white,Text.PRESET|Text.CENTER, "d3"+rawtime());

        Does it work in eSignal? Am I missing something? Does it need to be in a called function, ala Steve Hare's example on this page?

        Would appreciate any insights.

        SM

        Comment


        • #5
          Re: Problems combining drawShapeRelative and the AboveBar / BelowBar tools

          SM
          The line of code you posted is working fine at my end [used as is in main]
          That said there is technically an error in your syntax ie the flags should be Shape.XXX and not Text.XXX however that error is currently ignored by the efs engine on 10.x [due to a bug with the flags of this function]
          Alex


          Originally posted by Steven Miller
          I can't get this code to work:

          drawShapeRelative(0, AboveBar3, Shape.DOWNARROW, null, Color.white,Text.PRESET|Text.CENTER, "d3"+rawtime());

          Does it work in eSignal? Am I missing something? Does it need to be in a called function, ala Steve Hare's example on this page?

          Would appreciate any insights.

          SM

          Comment


          • #6
            Hi, Alexis, thanks.

            I'm attempting to use this line of code in a called function, conditional upon an if-statement that I know (in this instance) is true.

            Are there other known bugs with the flags or other elements of the drawShapeRelative function?

            Does this line of code work for you in a generic called function, or in an efsInternal function?

            Thanks,

            SM

            Comment


            • #7
              SM
              It will work in a called function [which BTW is the construct used by the Formula Wizard]
              Alex


              Originally posted by Steven Miller
              Hi, Alexis, thanks.

              I'm attempting to use this line of code in a called function, conditional upon an if-statement that I know (in this instance) is true.

              Are there other known bugs with the flags or other elements of the drawShapeRelative function?

              Does this line of code work for you in a generic called function, or in an efsInternal function?

              Thanks,

              SM

              Comment

              Working...
              X