Announcement

Collapse
No announcement yet.

Button to Hide/Show Pivots.

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

  • Button to Hide/Show Pivots.

    Hi,

    I'm trying to add a Hide/Show button to my pivot EFS but no luck...

    I attached the pivot EFS and some botton efs that I'm trying to play with... (Maybe this button is not suitable for what I want)

    Please help me with how to make this.

    Kind Regards,

    ser-E
    Attached Files

  • #2
    EFS
    Attached Files

    Comment


    • #3
      This is not a new study suggestion!

      There is bunch of pivots EFS files with this function, I just dont know how to put it to my pivots.

      The message created in the right forum.

      Comment


      • #4
        ser-E, Hi
        I was doing some button work so have added one to your floor for you, and make a few other changes, still a "work in progress" perhaps, but does the job

        PHP Code:
        // ser-E post, with Dave180 edits to add button, and some efficiency changes....
        function preMain() {
            
        setPriceStudy(true);
            
        setStudyTitle("Floor");

            
        // vPP
            
        setDefaultBarStyle(PS_SOLID0);
            
        setDefaultBarFgColor(Color.RGB(0,0,0), 0);
            
        setDefaultBarThickness(20);
            
        setPlotType(PLOTTYPE_FLATLINES0);
            
        // fR1
            
        setDefaultBarStyle(PS_DASH1);
            
        setDefaultBarFgColor(Color.RGB(0,0,255), 1);
            
        setDefaultBarThickness(21);
            
        setPlotType(PLOTTYPE_FLATLINES1);
            
        // fS1
            
        setDefaultBarStyle(PS_DASH2);
            
        setDefaultBarFgColor(Color.RGB(0,0,255), 2);
            
        setDefaultBarThickness(22);
            
        setPlotType(PLOTTYPE_FLATLINES2);
        }

        var 
        bCurrentDay false;
        var 
        mbDrawFloor true;
        var 
        mbReloadNextTick  false

        function Tbutton(Tbutton) {// Not happy with variable and function having same name, but seems to work, obviously I need to read Javascript scoping rules.
            //debugPrint("Tbutton: " + Tbutton + ", " + BUTTON_LEFT + ", " + BUTTON_RIGHT + "\n"); 
            
        debugPrint("Tbutton: Flip Floor\n"); 
            
        mbDrawFloor = !mbDrawFloor
            
        // Nice to have a "Reloading..." message, but changing the button text followed by reloadEFS(); has no effect.
            
        if (false) {
                
        // In a fast-ticking market this will work (change condition to true)....
                
        mbReloadNextTick true// Now we wait for a tick at main()
                
        drawTextPixel(20,50"ReLoading..." Color.blackColor.RGB(0xE00xE00xE0), Text.FRAME Text.ONTOP Text.RELATIVETOLEFT Text.RELATIVETOBOTTOMnull33null);
            } else {
                
        // No effect!    drawTextPixel(20,50, "ReLoading..." , Color.black, Color.RGB(0xE0, 0xE0, 0xE0), Text.FRAME | Text.ONTOP | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, null, 33, null);
                
        reloadEFS();
            }
        }

        var 
        mbDoneSingleInit false;
        var 
        maFloor null;
        function 
        main() {

            if (
        mbReloadNextTick) {
                
        mbReloadNextTick false;
                
        reloadEFS();
                return;
            }
                
            if(!
        mbDoneSingleInit){
               
        //drawTextPixel(20,50, " ReloadLevels "+"@URL=EFS:Tbutton" , Color.black, Color.RGB(0xE0, 0xE0, 0xE0), Text.FRAME | Text.ONTOP | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, null, 33, null);
               
        mbDoneSingleInit true;
            }

            if(
        getBarState()==BARSTATE_ALLBARS){
                
        debugPrint("Floor ALLBARS:: mbDrawFloor: " mbDrawFloor "\n");
                
        bCurrentDay=false;
                
        drawTextPixel(20,50, (mbDrawFloor?" Hide Pivots " " Show Pivots ") + "@URL=EFS:Tbutton" Color.blackColor.RGB(0xE00xE00xE0), Text.FRAME Text.ONTOP Text.RELATIVETOLEFT Text.RELATIVETOBOTTOMnull33null);
            }
            if(
        getBarState()==BARSTATE_NEWBAR){  // efficiency
                //if (bCurrentDay == false && getDay(0) != getDay(-1)){ 
                
        if (getDay(0) != getDay(-1)){  // If chart is open at midnight this change might update the pivots, untested
                    
        var xTime getValue("time");
                    var 
        xDate = new Date(); 
                    
        // Is there a potential time zone issue here? Candle time zone can be changed by user,
                    // and may differ from PC timezone
                    // just because the candle day (ie getDay()) changes the Date() may not be correct?
                    // Use of rawtime (is UTC based) could be better?
                    // 
                    
        var sTime = (xTime.getMonth()+1+"/"+xTime.getDate()+"/"+xTime.getFullYear()); 
                    var 
        sToday = (xDate.getMonth()+1+"/"+xDate.getDate()+"/"+xDate.getFullYear()); 
                    if ( 
        sTime == sToday ) { 
                        if (
        bCurrentDay) { 
                            
        debugPrint("test this, current day has rolled\n");
                        }
                        
        bCurrentDay true
                        
        // This only needs computing once, save some cpu, energy, planet etc
                            
        xHigh  high(inv("D"));
                            
        xLow   low(inv("D"));
                            
        xClose close(inv("D")); 
                        var 
        vHigh  xHigh.getValue(-1);
                        var 
        vLow   xLow.getValue(-1);
                        var 
        vClose xClose.getValue(-1);
                        
        vPP = (vHigh vLow vClose) /3;
                        
        //Floor's
                        
        fR1 = (vPP) - vLow;
                        
        fS1 = (vPP) - vHigh;
                        
        maFloor = new Array(vPP,fR1,fS1); // save results
                                 

                } 
            }
            if (
        bCurrentDay==false){
                return;
            }  
            if (!
        mbDrawFloor){
                return;
            }  

        /*        xHigh  = high(inv("D"));
                xLow   = low(inv("D"));
                xClose = close(inv("D")); 
            var vHigh  = xHigh.getValue(-1);
            var vLow   = xLow.getValue(-1);
            var vClose = xClose.getValue(-1);
            vPP = (vHigh + vLow + vClose) /3;
            //Floor's
            fR1 = (2 * vPP) - vLow;
            fS1 = (2 * vPP) - vHigh;
            maFloor = new Array(vPP,fR1,fS1);
        */
           
            
        return maFloor// new Array(vPP,fR1,fS1); 

        Comment


        • #5
          Dave180,

          Thank you so much for your help! I really appreciate that.

          It look's like it's working good, Why did you say that it's still a "work in progress" ? What's need to be fixed in your opinion ?

          Kindest regards,

          ser-E

          Comment


          • #6
            ... Only because I wouldn't like you to think all my code gets left looking like that!

            It works agreed, I would want to clean up the code to check for further efficiencies and "harmonise" it for ease of future maintainability, that's all.

            Glad it helps.

            Dave

            Comment

            Working...
            X