I am looking for some assistance on how to incorporate a martingale setup into my script.

I am using a modified moving average crossover and have set the take profit to be either on the moving average cross or when there is a higher equity: Equity > (Capital + WinTotal)

Normally you would double up on the losses but I am trying to double up on the wins as well. Basically regardless of win or lose the next trade needs to increase in lot size if there is not a new Equity high.

I have tried the following:
Lots = pow(1.5,LossStreakTotal);

This doesn't work for winning trades when there is no new Equity high.

I also tried:
float lots_test = 1;
if EMA1 > EMA2 and Equity < Total)
lots_test += lots_test + 1;
else if EMA1 < EMA2 and Equity < Total
lots_test += lots_test + 1;
else lots_test = 1;

Any ideas?

Thank you!