Announcement

Collapse
No announcement yet.

Buttons with setComputeOnClose

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

  • Buttons with setComputeOnClose

    It seems that if you have a text button that you want to be mouse- clickable and do something, it only works and if there is NO "setComputeOnClose" statement in Premain(). Is this correct? Is there some way to have a button on your chart that still will do something (like change a value of a variable) even if there is "setComputeOnClose?"

  • #2
    My Solution

    I use buttons all the time and write my code to calculate all EB OF BAR functions at the BEGINNING OF A NEW BAR. This way, the code actually runs in realtime, but handles all END OF BAR functions in a unique condition (if statement) based on the formation of a new bar.

    This way, I can have END OF BAR functions and REALTIME functions running at the same time. The only trick is you have to shift all END OF BAR function BACK ONE BAR (-1).

    Here is an example..

    PHP Code:
    var nLastRawTime 0;
    var 
    BarCount 0;


    function 
    main() {

      
    //  EDIT BUTTON
       
    drawTextPixel(4,10" Edit "+"@URL=EFS:Editbutton" Color.blackColor.RGB(0xE00xE00xE0), Text.FRAME Text.ONTOP Text.RELATIVETOLEFT Text.RELATIVETOBOTTOMnullvFontSize"CEdit");

     
    //  New Bar Function
     
    if (getValue("rawtime"0) != nLastRawTime) {
       
    nLastRawTime getValue("rawtime"0);
       
    BarCount += 1;

      
    // Test sample entry condition
       
    if ( (high(-1) > high(-2)) && (close(-1) > close(-2)) ) {
         
    //  Fire entry order
       
    }
     } else {
       
    //  Realtime code portion.
       //  Used for stops, profit targets and others
     
    }

      return;
    }


    function 
    Editbutton() {
    Alert.playSound("click.wav");
     
    askForInput("Edit Your Settings");

    Brad Matheny
    eSignal Solution Provider since 2000

    Comment

    Working...
    X