Announcement

Collapse
No announcement yet.

drawText BUTTON Flags

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

  • drawText BUTTON Flags

    Hi,

    I saw those drawText BUTTON Flags (BUTTON_RIGHT, BUTTON_LEFT, BUTTON_LEFTDBLCLK) in the help file and I could not understand how/where they are used.

    Anyone out there to tell?

    thanks

  • #2
    Here is an example:

    Click on button and it will toggle a band on and off. Double-click in the indicator and it will draw a blue vertical bar where you double-clicked.

    Chris

    PHP Code:
     // external variables
    var cPriceBarColor        Color.red;
    var 
    bButtonPressed        false;
    var 
    bDrawBand            false;

    //== PreMain function required by eSignal to set things up
    function preMain() {

        
    setPriceStudyfalse );
        
    setStudyTitle"Button Demo" );
        
    setShowCursorLabelfalse );
        
    setDefaultBarFgColorcPriceBarColor );
        
    setDefaultBarThickness3);

    }

    //== Main processing function
    function main( ) {
    var 
    xFlags Text.ONTOP Text.BUTTON Text.RELATIVETOLEFT Text.RELATIVETOBOTTOM;
        
        
    // called when script initializes
        
    if (getBarState() == BARSTATE_ALLBARS) {
            return 
    null;
        }
        
    nResult = ( high() - high( -) ) / low() ;

        if ( 
    isLastBarOnChart() && bDrawBand == true ) {
            
    addBand0PS_SOLID5Color.black, -66 );
        }
        
    drawTextAbsolute(020" Toggle Band @URL=EFS:changeColor",  Color.blackColor.greyxFlags "Courier New"11, -55);     
        return( 
    nResult );
    }

    //== function determines if a button was pressed
    function getButtonPressed(nButtonPressed) {
        if(
    nButtonPressed == BUTTON_LEFT) {
            return(
    1);
        }
        else {
            return(
    0);
        }
    }
    //== performs a specific task if our button was pressed
    function changeColornButtonPressed ) {
        if ( 
    getButtonPressednButtonPressed ) == ) {
           
    bButtonPressed true;
           
    bDrawBand = !bDrawBand;
           
    clearBands();
           
    main();
        }
        return;

    Comment

    Working...
    X