Monte Carlo Q&A thread
Author: joannakim
Creation Date: 6/27/2011 1:46 PM
profile picture

joannakim

#1
Hi. I have been struggling with this problem for quite a while now. When I perform MC on certain periods: in my case, around 2008, give or take,the Net Profit Percentage returns huge numbers: in thousands of percents per year which I know is wrong. Single back tests on the same periods seem to act normally and correctly, and seem to produce the correct APRs in the same periods, but when I do MC on those correct back tests, I get these gigantic return percentage numbers.

I discussed this problem with a colleague of mine who is a very experienced back tester, and who uses another software other than WLP, his guess was that these MCs might be taking all the trades rather than 5 trades allowed per day by the strategy since I had set the position size to 20% of equity.

Have you heard of this problem from others, and what should I do? I ran many many MC runs, but it consistently does what I just described. Earlier periods such as the early 2000s do not seem to produce the same errors. They seem to be fine.
profile picture

Cone

#2
There are different Monte Carlo settings, and the one(s) you choose should depend on the type of strategy you're modeling.

For example, a typical 92% dip-buying strategy may get a few trades here and there, working with almost no exposure until the days of real panic in the markets at which time it's 100% (or more) exposed. If you didn't choose to "Maintain Date Clustering", you'd be equally distributing gains throughout the test period and all the MC Equity Curves would likely appear to have a nice steady upward slope with almost no drawdown - quite unlike the baseline Equity curve.

And that's probably the key. Do the MC equity curves look similar to the baseline? If not, the MC Settings are probably not set to model your system correctly, which is not an MC error.
profile picture

joannakim

#3
What do you mean by "baseline?" do you mean the equity curve on the "Equity + Drawdown %?"

Also I checked my MC settings, and the "Maintain date Clustering" has been checked. What is " Maintain date Clustering" any way?
profile picture

Cone

#4
You have to run a Portfolio Simulation backtest to generate trades for MC-Lab to use. That's the baseline simulation.

QUOTE:
Also I checked my MC settings, and the "Maintain date Clustering" has been checked.
I only gave an example of a type of strategy that should use this option. I don't know anything about what you're doing.

For descriptions of all the MC-Lab Settings see User Guide > MonMonte Carlo-Lab > Monte Carlo Settings
profile picture

joannakim

#5
Thanks Cone for the suggestion on the User Guide. I read the section over and over again, and many things/words seem difficult for me to understand. E. G.:

1. On the Trade Scramble, I don't understand what they mean when they said that the starting dates of all of the raw trades were randomized. I thought that each raw trade had a specific date. Why and how would they change the start date of the raw trades?

2. On the Trade Scramble and Randomize, it said that the bar by bar returns of each raw trade are randomized. I simply do not understand what that means.

3. I do not understand what Trade Synthesize does.

I probably have more questions, but I think I could start with the above 3. Thanks for your help.
profile picture

Cone

#6
1. The way the trades are scrambled is by changing their starting dates. In other words, MC-Lab changes order of the trades by change their starting dates. This is done for every MC simulation. There's nothing else to it.

2. User Guide > Monte Carlo-Lab > Raw Trades Info.
When you click on a "Raw Trade" you see its price progress from one bar to the next. Convert those difference to percentages, and that's the bar-by-bar return. The order of these returns are randomized.

3. Re: Trade Synthesize
In the Trade Scramble and Randomize, the bar-by-bar returns are scrambled for each trade, but the trade will always give you the same overall return. Trade Synthesize grabs the bar-by-bar returns from the entire list of trades to create "synthetic" trades - these trades not real and not even part of the simulation. It's the most random you can get.
profile picture

joannakim

#7
1. So, when MC Lab changes the trades' starting dates to change the order of the trades,do the return that had been achieved by the trade on the actual or real trade dates remain the same? In other words, does MC just change the trade dates to change the order of the trades without changing the return that the real trade achieved? Thanks.
profile picture

Cone

#8
Trade Scramble scrambles the sequence of the raw trades from baseline simulation by changing their entry dates. For the Trade Scramble (only) option, bar-by-bar returns are not Randomized. That would be Trade Scramble and Randomize.

Note that "raw trades" are ALL the trades generated by the simulation - even the ones that were rejected by the baseline simulation. (I just wanted to make sure you didn't miss this in the User Guide > Monte Carlo-Lab > Raw Trades Information discussion.)
profile picture

joannakim

#9
No, Cone. I did not miss the fact about the raw trades. I have been reading the page many times.

Also I do not believe that the Trade Scramble scrambles the sequence of the raw trades from the baseline simulation. Trade Scramble work with raw trades and not with the base line simulation. It generates entirely new equity curve from scratch and not from the baseline simulation. That is what separates it from Equity Scramble.
profile picture

Cone

#10
That's right and that's what I was trying to clarify. When I talk about "raw trades from the baseline simulation", I'm referred to all of the raw, non-sized trades that were created (accepted or rejected) in the initial backtest.
profile picture

joannakim

#11
Okay, so it is good to know that we are on the same page on that one.

1. I, however, do not understand what " randomize" means. The word is used repeatedly in the User Guide, but does that simply mean to change the order or could it mean something else?

2. Also when you said: :" bar by by returns are 'scrambled'," what does the word "scramble" mean?

3. And what would be the purpose or the point of changing the order of the trades? I don't understand what that would accomplish.

4. What does "serial correlation" mean as in " Maintain Serial Correlation?"

profile picture

Cone

#12
1. It means to change the order (starting dates) of the trades in a random way.

2. Scrambled means to change the order of the bar-by-bar returns in a random way.

3. If fixed dollar sizing were used, it wouldn't change the final outcome, but it would change the equity curve shape, affecting drawdown and related metrics. If sizing were based on the equity curve, then it would also change the outcome.

4. I don't know how to say it any differently than the User Guide does: This option forces the randomized trades to maintain the same win/loss sequence of the trades in the raw trade list. This can help the Monte Carlo simulations to more accurately model the events and trends that occurred during the testing period.
profile picture

joannakim

#13
Hi Cone.

1. Where in User Guide did you find the definition of Serial Correlation because when I typed the work in the search box, I was sent to the same page where Serial Correlation was mentioned as an option but did not provide the definition.

In fact that option above this one: Maintain Win Loss Sequence seems to do the same thing that you described as what Serial Correlation would do except that it does it on the raw trades list.

2. There seems to be 2 different randomization modes for MC: Equity Curve Scramble and Trade Randomization. With regard to Trade Randomization method, does this method always take all the raw trades ( albeit randomized)even though the baseline simulation was set at portfolio testing mode with specific position sizing selected?

3. The definitions of " Randomize" in "Trade Scramble and Randomize" and " Trade Synthesize" seem almost identical to me. I can't seem to see any difference. The User Guide says under Trade Scramble and Randomize:" but additionally, the bar by bar returns of each raw trade are randomized," and it says under Trade Synthesize: " but the bar by bar returns of each raw trade are synthesized. Each bar by bar return is synthesized by selecting a random bar by bar return from the complete list of bar by bar returns for all raw trades."
profile picture

Cone

#14
1. Serial Correlation is the Pearson Correlation coefficient of the equity curve returns (not really, see post on 7/5/2011 10:29 AM for a correct explanation). Specifically, the option should cause MC-Lab to re-generate runs until the PCC of MC run the is within about +/-0.1 of the PCC of the baseline.

2. Yes, of course, but the Position Sizing specified is also applied to the MC runs. Raw trades don't have a "size", so they have to be sized again for the MC runs.

3. I'll give it one more shot. Trade Scramble changes the dates that a trade is entered/started/put on. Once a trade starts, the bar-by-bar returns of the real trade are not altered by MC-Lab in a pure Trade Scramble. TS&R also alters/changes/randomizes the sequence of the bar-by-bar returns of the trade (Again, it doesn't change the overall trade profit, but it does affect the equity curve). Synthesize takes ALL of the bar-by-bar returns of ALL the raw trades and randomizes them. Then it creates synthetic trades by starting with the entry price of one of the raw trades and multiplying it by random bar returns for the trade length. So if the raw trade was bought at $30.25 and exited 5 bars later, 30.25 would be multiplied by 5 random bar returns from all of the raw trades to synthesize a new trade.

Let's go about this another way. How would you go about creating your own Monte Carlo Simulator? Once you tell me, I can tell you which options MC-Lab corresponds to your design.
profile picture

joannakim

#15
Hi Cone. first of all, I would like to tell you how thankful I am to you for answering my questions. I have been wrestling/struggling with MC for a long time, and it is very comforting to know that someone is out there for me to talk to.

1. I do not know what Person Correlation coefficient is, do you? If the +/- 0.1 of the PCC of the baseline means that the Median Value or the Average Value of the returns of the MC simulations should be within 10% of the return of the initial baseline run, my MC run with that option ( Serial Correlation) checked, is not producing returns that close to the baseline run returns. In fact those MC runs of mine are producing Median and Average return percentage numbers that are soooooooooo far away from the return percentages of the initial baseline runs.

2. If the MC runs are adhering to the Position Sizing that I specified, they cannot take ALL the raw trades. This is a very critical point that I have been wrestling with. For example, I have my position sizing specified at 20% equity. When I look at the Raw Trades tab of MC, there are many days when there are a lot more raw trades than 5 in which case, the maximum number of positions that the portfolio can take is 5 since after that there is no more money left. This goes directly against the notion that under the Trade Randomization, the MC runs would take ALL that raw trades.

3. This is such a great suggestion! I would really love this.

What I would like my MC to do is: take up to 5 trades in a day ( since my position sizing is set at 20% equity and margin is set at 1:1 which I presumed means that I am not using margin,)but chose different combination of trades. For example, if there were 15 raw trades in a given day, take different 5 trades for each MC run: take trades 1,3, 6,7,9, during the first run ( out of say, 1000 simulation runs,) and then in the second simulation run, take trades 6,8,9,12,14 and so forth. There should be so many possible combinations that even if I set MC at 5000 runs, it should not be able to exhaust all the possible combinations.

What I would also like to see is for the MC to take the first 5 trades. So if there were 9 raw trades in a certain day, it would take the first 5 trades that came along. And maybe this would have to do with doing intraday coding and testing, but what do you think?

Thank you so much once again Cone. The MC has been so much struggle for me for a very long time.
profile picture

Cone

#16
QUOTE:
I do not know what Person Correlation coefficient is, do you?
I've never heard of the "Person Correlation", but if you search the web for "Pearson Correlation", you'll have lots of reading material to study this week.

Anyway, I wasn't precise in saying that Serial Correlation is the Pearson Correlation Coefficient. Here's an accurate description of how Serial Correlation is calculated to add to your reading on Pearson.

QUOTE:
If the +/- 0.1 of the PCC of the baseline means that the Median Value or the Average Value of the returns
No, it doesn't mean that at all.

QUOTE:
This goes directly against the notion that under the Trade Randomization, the MC runs would take ALL that raw trades.
We never said that each MC run "takes all the trades". We've stated (in other words) that MC-Lab uses/chooses/picks trades from the raw trades list, not just the trades accepted in the baseline Portfolio Simulation.

QUOTE:
What I would like my MC to do is: take up to 5 trades in a day...
I see. MC-Lab's option to "Maintain Date Clustering" (without "Trade Recycling") is almost what you want, but not exactly. When date clustering is enabled, the dates on which the trades occur are preserved, but any trade from the raw trades list can be inserted into those dates (not just the ones that occurred on that date). For sure it fulfills your requirement for the inability to "exhaust all the possible combinations", but the choice of where the trades can land is much less selective than you want.

Although I can see your point, my feeling is that the feature that you're suggesting (which is akin to pressing "Go" in the Strategy Window multiple times) would generally not provide a broad measure of randomality between MC runs, but, it would depend on the pool of trades from which to choose on each bar. Anyway, we can investigate if adding that option makes sense.
profile picture

joannakim

#17
So, did you mean to say that the closet thing is to: select " Trade Scramble," then select "Maintain Date Clustering" only?

And I am presuming that I would leave Memory Usage Mode at Normal.

And if I do this with " 20% equity" selected as Position Size, would the MC Simulation runs take only up to 5 trades in a given day and not all the raw trades in a given day? I realize that the start date of each trade would be changed to another day that had trades.
profile picture

Cone

#18
QUOTE:
So, did you mean to say that the closet thing is to: select " Trade Scramble," then select "Maintain Date Clustering" only?
Yes.

QUOTE:
And I am presuming that I would leave Memory Usage Mode at Normal.
Doesn't impact the results.

QUOTE:
And if I do this with " 20% equity" selected as Position Size, would the MC Simulation runs take only up to 5 trades in a given day and not all the raw trades in a given day?
Of course.

QUOTE:
I realize that the start date of each trade would be changed to another day that had trades.
There's a random chance that some trades will "land" on their original dates too in each MC run.
profile picture

joannakim

#19
Hi Cone. If MC runs are only taking a maximum of 5 trades in a given day due to my position sizing that was specified at 20%, then how can the MC runs maintain the same win loss sequence as the raw trades when Maintain Win/loss Sequence is selected since there would be a lot more raw trades than the trades that are selected in the runs?
profile picture

Cone

#20
The Win/Loss option causes the raw trade scramble to keep the same win/loss sequence as the original list. In other words ,if the original list has the order W-L-L-W-W-W-L..., then the scrambled list will have the order W-L-L-W-W-W-L.... It doesn't have anything to do with your position sizing.

That said, it seems to me that the Win/Loss option is (or should be) mutually exclusive to Date Clustering. I'll check on that, but for now, don't select Win/Loss if you want Date Clustering, and vice-versa.
profile picture

Cone

#21
Today we'll take advantage of the fact that the Extra Performance Visualizers need to be recompiled for 6.3 compatibility. Monte Carlo-Lab will have the following changes:

1. Remove Multi-Core support. We're doing this due to a potential thread-safe issue when building the equity curve that can lead to erratic results. We'll revisit multi-core again at a future date.

2. New option for Same Date Scramble as discussed above. In a nutshell the option will provide the same result as you'd achieve by randomizing Position priority.
profile picture

nikitao

#22
Please tell more about "Same Date Scramble"
profile picture

Eugene

#23
The option to scramble trades on the same date is similar to scrambling the priorities of positions over many simulations. It's designed to help for backtests that create and reject a lot of trades on the same dates, like dip buyers using multiple Limit orders. The baseline Trade Scramble method does not particularly suit these strategies, unrealistically smoothing the equity curve since trades are distributed anywhere in the simulation instead of sticking to a particular bar on which many dips may have occurred at the same time.
profile picture

07nioe

#24
Hi,

I am not able to interpret the bar-by-bar Distribution graph in the MCV. For example: my strategy shows a on the x-axis 2% with a y-axis value of 5895,00. This is the center bar of the distribution graph. What does this mean?

Thank you for help.

Best
Niels
profile picture

Eugene

#25
Hi Niels,

According to the Wealth-Lab User Guide > Monte Carlo-Lab > Profit & Drawdown Analysis, the distribution displays the number of runs that have a net profit (Profit View) or a maximum drawdown % (Drawdown View) within a specified range. That's how many runs occurred in the 2% bin.
profile picture

Cone

#26
"Profit & Drawdown Analysis" answers the wrong question :)

Bar by bar returns simply shows you the distribution of percentage return from one bar to the next in the base series, e.g.., if AAPL closed at 200 on Monday and closed at 220 on Tuesday, this would represent a single sample in the 10% bin.

There's little reason to concern yourself with this graph, it's not really part of the MC analysis, rather just showing you a distribution of the input series returns.
profile picture

07nioe

#27
Thanks. It is not the analysis tab but the bar by bar returns. I think the graph has a different meaning.