issue making a Power Bar go back down

I have a power meter that is used to hit a ball. My issue is that when the meter fills up I need the bar to reverse or go back down(although it’s a horizontal bar). I posted the part of code to fill the power meter which works fine and the ball is hit based on where the bar is, just need to know if there is a way to reverse it. I originally tried to use Mathf.PingPong for this, which worked, but I couldn’t get it to not run continuously. Any help would be really appreciated.

function OnGUI(){
speed = Time.time * 1.1; 

GUI.DrawTexture(Rect(Screen.width/2 - 250, Screen.height/2 + 300, size.x * Mathf.Clamp01(speed), 40), fill);

Pseudo code as follows:

bool goingUp = true;

if (goingUp) { 
    // Run your code to make it bigger here
    if(//bool check to see if at max size){
        goingUp = false
} else {
    // Run your code to make it smaller here   
    if(//bool check to see if at min size){
        goingUp = true