What you tell it
Win/Loss ratio of your system - If you win 45% or the time, you enter 0.45.
Reward/Risk ratio - If you TP is 2.5 times your SL, you enter 2.5.
Iterations - The number of cycles you want to simulate. Each cycle ends when you are in profit.
Recovery Method - One of Shakey, Blackjack, Martingale
Martingale multiplier - If you want to double with each loss, enter 2. You can also enter 1.33 or 1.5 or any other number. You can also enter 1, which simulates no recovery.
Official parameters:
Code: Select all
extern double win_percent = 0.50;
extern double reward_units = 2; //(enter 2 for risk/reward of 1:2)
extern int iterations = 1000;
extern bool UseShakey=true;
extern bool UseBlackjack=false;
extern bool UseMartingale=false;
extern double MartingaleMultiplier=1.5;
extern color TextColor=Black;
For each iteration, it simulates a cycle by randomly determining if you have a win or not and adding that result to your current running balance. If at the end of a trade you are in profit, the cycle is over. If you are at a loss, it modifies the unit size according to the recovery rules and simulates the next trade.
The number of trades needed to end recovery is captured and stored in an array for later display. Any trade sequences over 100 trades long are stored in the 100th bin, but the max is reported separately.
Output
The indicator opens a sub-window of the main chart, and charts the percentage of trades that exited after each number of trades. For example, it you have a winning percent of 60%, you should see that the bar labelled "1" is about 60%. It also charts the cumulative percent as a line, so you can see where 90 percent of the trades will close out, etc.
There are also some labels that report additional information, such as the max trades needed to end a sequence and the max units reached. It also shows a comparison of return/trade with and without using recovery, which is fairly interesting.
It should all be clear in the picture. You'll likely have to scroll back in time to get to the interesting bits.
This is the result of a few spare hours today, so I am sure there are bugs. If anyone sees anything let me know and I'll get a new version up asap.
George