Recovery Strategy Simulator

Post Reply
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Recovery Strategy Simulator

Post by gaheitman »

A few PMs today with Mike (magft) inspired me to write the attached indicator. I wanted to "see" the difference between some of the recovery systems that have been offered lately. I was originally going to write a simulator in VB or Delphi, but decided I might as well use a tool that we are all familiar with and that can be easily extended (and de-bugged :>) by many of us. So I wrote an indicator that will simulate trades and play through the various recovery scenarios.

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;
What it does

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.
pic_01 2012-01-16 18.19.gif
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
You do not have the required permissions to view the files attached to this post.
magft
Trader
Posts: 195
Joined: Tue Nov 15, 2011 9:59 pm
Location: East Midlands, UK

Re: Recovery Strategy Simulator

Post by magft »

Nice work, i'll have a look at the code to see if there is anything a miss but i bet you've done a good job as usual.

Mike
User avatar
ironrick
Trader
Posts: 85
Joined: Wed Nov 16, 2011 7:04 pm
Location: North Idaho Boy, USA

Re: Recovery Strategy Simulator

Post by ironrick »

George,

Any chance we could get more of the subtext behind this?

Besides showing all the stats -- which is useful and super interesting in itself -- is the tool an attempt to prove a for or against position in regards to the whole "Theory of Recovery Methods"? Ie. Do they work or not, are they worth the risk, is there really and actually any such beast as a "recovery trade" or is it just another trade etc...

I personally have banned the idea from my trading vocab. I don't "believe in" any form of recovery trade, but simply move on to the next opportunity. (Note: this is different from some valid forms of hedging...)

Further conversation beyond your answer needs to be in the appropriate forum section so we don't clutter this one... :) Not wanting to start a war... :shock:

Just wondered where you personally were coming from and the circumstances around your decideing to code this indi.

Which is VERY cool by the way.

Rick
"A problem well put is half solved."
Post Reply

Return to “Utilities”