General Topics
Markets
Technical Topics
Brokerage Firms
Community Lounge
Site Support

# Using YASAI for Monte Carlo

Discussion in 'Technical Analysis' started by feng456, Dec 27, 2011.

1. ### feng456

ok im trying to figure out how to do monte carlo analysis...

lets say i have the following:

Jan 2011
5 pts
-5
5
-5
5
5
Total: 10 pts

Feb 2011
5 pts
-5
5
5
Total: 10 pts

March 2011

5
-5
-5
-5
-5
Total: -15 pts

how would i use YASAI to run monte carlo on this?

2. ### abattia

I would do this as follows (there may be other ways to do it, too)â¦

8 winners (each @ +5);
7 losers (each @ -5)
-> Prob of winning = 8/15
[BTW, Feb total is +15 pts, not +10 pts]

Column A
Cell A2: 1
Cell A3: 2
Cell A4: 3
.
.
Cell A16: 15

Column B
Cell B1: âWon/Lostâ
Cell B2: =genBinomial(1,8/15)
Cell B3: =genBinomial(1,8/15)
.
.
Cell B16: =genBinomial(1,8/15)

Column C
Cell C1: âPnLâ
Cell C2: =if(B2=1,5,-5)
Cell C3: =if(B3=1,5,-5)
.
.
Cell C16: =if(B16=1,5,-5)

Column D
Cell D1: âTotal PnLâ
Cell D2: =simOutput(SUM(C2:C16))

Now run the sim, and your results will be on a new tab.

3. ### feng456

Thank you very very much!

4. ### abattia

Column A
Cell A2: =1
Cell A3: =2
.
.
Cell A8: =7

Column B
Cell B1: =âHistorical PnLâ
Cell B2: =-5
Cell B3: =-5
Cell B4: =2
.
.
Cell B8: =-5

Column C
Cell C1: =âHistorical Frequencyâ
Cell C2: =1/7
Cell C3: =1/7
.
.
Cell C8: =1/7

Column D
Cell D2: =1
Cell D3: =2
Cell D4: =3
.
.
Cell D8: =8

Column E
Cell E1: =âSimulated PnLâ
Cell E2: =genTable(B\$2:B\$8,C\$2:C\$8)
Cell E3: =genTable(B\$2:B\$8,C\$2:C\$8)
.
.
Cell E8: = genTable(B\$2:B\$8,C\$2:C\$8)

Column F
Cell F1: =âTotal Simulated PnLâ
Cell F2: =simOutput(SUM(E2:E8))

Now run the sim, and your results will be on a new tab.

5. ### feng456

Thanks very much again. I did try to do it first but nothing came up because well it was totally wrong.

6. ### abattia

It's working for me. Not sure what you are doing differently...
a) NB - content of cell D8 should be 7 (not 8, as I wrote), but that shouldn't make a difference to your simulation
b) check again Columns B, C, E & F against what I wrote; the problem will lie somewhere there, I suspect

Good luck! Hope you can sort it out!

7. ### feng456

same result...i swear i checked it...