Hello everybody,

I found a Monte Carlo Simulation for Option pricing, which is relatively useful for my studying. Nevertheless, I also want to understand how this think works. And I do not get what is the purpose of the variable A and P. I'm also not really sure about this: If (j - 1) / 250 - lnt((j - 1) / 250) = 0 And j > 1 Then p = p + 1

Could somebody explain it to me? I'm new into programming and this procedures.


c is Call(option), S is the current Stock Price, X is the Strike Price, T is the Time, Z is the volatility, r is the risk free rate, q is the dividend, n is the number of steps
and nlter is die number of Simulations.

Here is the Code:
Function EuropäischeOptionMonteCalro(c As String, S As Double, x As Double, T As Double, z As Double, r As Double, q As Double, n As Double, nlter As Double) As Double

Dim dt, e, dlns, price, SimVar(), PayVar() As Double

ReDim SimVar(nlter, n + 1)
ReDim PayVar(nlter)
dt = T / n
a = 0
For i = 1 To nlter
SimVar(i + a, 1) = S

Randomize
p = 0
For j = 1 To n
If (j - 1) / 250 - lnt((j - 1) / 250) = 0 And j > 1 Then p = p + 1
e = WorksheetFunction.NormSInv(Rnd())

dlns = (r - q - z ^ 2 / 2) * dt + z * e * dt ^ 0.5

If j - 250 * p = 1 And p > 0 Then
SimVar(i + p + a, 2) = SimVar(i + p - 1 + a, 251) * Exp(dlns)
Else
SimVar(i + p + a, j - 250 * p + 1) = SimVar(i + p + a, j - 250 * p) * Exp(dlns)

End If

' Call Option oder Put Option Optionsformel
Next j
If c = "C" Then
PayVar(i) = WorksheetFunction.Max(SimVar(i + p + a, j - 250 * p) - x, 0) * Exp(-r * T)
ElseIf c = "P" Then
PayVar(i) = WorksheetFunction.Max(x - SimVar(i + p + a, j - 250 * p), 0) * Exp(-r * T)

End If

a = a + p
Next i
price = 0
temp = 0
For i = 1 To nlter
price = price + PayVar(i)

Next i
price = price / nlter

EuropäischeOptionMonteCalro = price

End Function
Many thanks in advance and best regards

Flappi