4. Arrange several balls of two colors, red and black, in a row, requiring that both colors of balls must appear, and any two balls separated by 5 or 10 balls must be of the same color. Arrange according to this requirement, the maximum number of balls that can be placed is.
4. 15.

Label the positions of these balls in order as $1,2, \cdots$.
According to the problem, when $|i-j|=6$ or 11, the $i$-th ball and the $j$-th ball are the same color, denoted as $i \sim j$.

Thus, $6 \sim 12 \sim 1 \sim 7 \sim 13 \sim 2 \sim 8 \sim 14 \sim 3 \sim 9$ $\sim 15 \sim 4 \sim 10,5 \sim 11$.
Therefore, 15 balls can be placed according to the requirement.
If the number of balls is more than 15, then $10 \sim 16 \sim 5$. Thus, the colors of the balls numbered 1 to 16 are all the same. Further, it can be known that all the balls have the same color, which does not meet the requirement.

Therefore, according to this requirement, the maximum number of balls that can be placed is 15.