I can provide a solution which adds the short side breakout to the original code. However the rest of your request is beyond the scope of what I can provide for no charge in the Q&A forum.
Here is a version of the code which includes both the breakout long as well as the breakout short:
input spanOfBase = 25;
input maxPrctCorrection = 10;
input spanOfBreakoutHigh = 42;
input spanOfBreakoutLow = 42;
def flatBaseHigh = highest(high[1], spanOfBase);
def flatBaseLow = lowest(low[1], spanOfBase);
def percentMaxCorrection = AbsValue(100 * (flatBaseLow / flatBaseHigh - 1));
def withinPrctCorrectionLimits = percentMaxCorrection <= maxPrctCorrection;
def highShade = if withinPrctCorrectionLimits then flatBaseHigh else flatBaseLow;
def lowShade = if withinPrctCorrectionLimits then flatBaseLow else flatBaseHigh;
def flatBase = highShade > lowShade;
def highestHighForBreakout = Highest(high[1], spanOfBreakoutHigh);
def lowestLowForBreakout = Lowest(low[1], spanOfBreakoutLow);
def currentBreakoutHigh = high > highestHighForBreakout;
def currentBreakoutLow = low < lowestLowForBreakout;
# only one of these can be scanned for at one time. Use "#" comment marks to turn off
# the one you don't need
#plot flatBaseFormation = flatBase and currentBreakoutHigh == 0;
#plot breakoutSignal = currentBreakoutHigh and currentBreakoutHigh[1] == 0 and flatBase;
plot breakoutSignalShort = currentBreakoutLow and currentBreakoutLow[1] == 0 and flatBase;