The "travelling painter" is a rather enigmatic character, who was hired by Hamperdink to paint his new barn. Despite him not knowing Hamperdink, he painted a pattern of a hex sign at no extra charge, as a gift to the new baby Elvira was expecting.
The hex sign was that of the Triple Distelfink, which stands for triple good luck, combined with the sign for good wishes to a new born child. He also painted an inverted triple distelfink on the back of the barn, meaning all bad luck would be behind them.
The sign of the Triple Distelfink appears to have actual magical abilities, somehow, as it did make Daphne, Elvira's baby, extremelly lucky, and so does the inverted sign, as it rendered Gladstone (Daphne's son), once struck by lightning while standing in front it, unlucky for that day every year.
Gladstone was many years later struck by lighting again, while in front of the original sign, cancelling the effects of the inverted one.