If I was making random buys for, say $100 worth of shares and selling at random times my gains would would increase by the degree of the slope of the price series. But what if I modified the losses to be larger than they were? How much would I have to increase the losses by a factor of in order for the slope of the price chart to be flat?
What change to the losses would make random buying and selling reflect a price chart that was flat, had a slope of 0 instead of a slope of 0.4? In other words, I want all gains and losses to add up to zero.
So, to do this I would multiply all losses by something like 1.4? Would adding just a one to the slope do it? What is the formula for this?
Thank you.

I'll call random variable $X$ the increase or decrease in your the $y$-axis each step. So, $\mathbb{E}[X] = 0.4$ is the slope of the trend line.
We can break this up into the increase and decrease case.
$$ \mathbb{E}[X] = \mathbb{E}[X|X\ge0]P(X \ge 0) + \mathbb{E}[X|X<0]P(X < 0) .$$
Now consider random variable $Y$ to be the modified version of $X$ after multiplying all the drops. You want $\mathbb{E}[Y] = 0$ and we'll assume $\mathbb{E}[X|X\ge0] = \mathbb{E}[Y|Y\ge0]$, and $P(X \ge 0) = P(Y \ge 0)$, which also means$P(X < 0) = P(Y < 0)$ since $P(X \ge 0) = 1-P(X < 0)$. Interpretation is we don't change how likely a drop is or the expected value of an increase, only change the expected value of a drop. Then, we have
$$ \mathbb{E}[Y] = 0 = \mathbb{E}[X|X\ge0]P(X \ge 0) + \mathbb{E}[Y|Y<0]P(X < 0) .$$
If you want to know $\frac{\mathbb{E}[Y|Y<0]}{\mathbb{E}[X|X<0]}$, i.e. the value to multiply the drops by, you can work out the algebra and find that
$$ \frac{\mathbb{E}[Y|Y<0]}{\mathbb{E}[X|X<0]} = -\frac{\mathbb{E}[X|X\ge0]P(X \ge 0)}{\mathbb{E}[X|X<0]P(X < 0)} = 1-\frac{\mathbb{E}[X]}{\mathbb{E}[X|X<0]P(X < 0)}.$$
In other words, knowing that $\mathbb{E}[X] = 0.4$ is not enough to answer your question. You also need the value of $\mathbb{E}[X|X<0]P(X < 0)$, which you can interpret as the average drop value multiplied by the probability of a drop.
Edit: "increase" = "gain", and "decrease" = "drop" = "loss", sorry if my terminology is sloppy