Quote from xelite777:
So in both cases (win or lose) this pseudo code will double the size of the bet (trade) only once, right?
The pseudo-code is just an example. It will have to be tweaked to fit into his overall logic. It won't work otherwise.
In the previous example, the sample code runs in a loop. In the martingale, it exits the loop when result == win. In the anti-martingale, when result == loss. Both reset bet_size to 1.
The system will need to check the results of the last trade to see if it's a loser(winner). If it is, then it needs to determine how many losers(winners) in a row the system had. Then figure out the new bet size.
A more enhanced pseudo-code example:
last_trade_result (bet_system) {
if (bet_system == "martingale") {
status_check = "loss";
} else if (bet_system == "anti-martingale") {
status_check = "win";
}
streak = 0;
counter = -1;
while (counter < 0) {
status = closed_trades[counter];
if (status == status_check) {
streak++;
counter--;
} else {
counter = 0;
}
}
return streak;
}
system_streak = last_trade_result("martingale");
/* system_streak = last_trade_result("anti_martingale"); */
/* I'll leave it to OP to figure out the initial bet size and how to maintain variable persistence between runs */
bet_size = get_original_bet_size();
/* if system_streak is < 0, something's wrong */
bet_size *= power(2, system_streak);