Hello! I'm really a beginner in vba and programming.
I have to write a macro that simulates a binomial distribution where the price of something can only go up or down with the probability of p that is 50% this time.
My variables:
S=100 (the basic value)
u=1,1 (how much the value goes up in each experiment if it goes up)
d=1/u (how much the value goes down in each experiment if it goes down)
p=0.5 (probability)
n=400 (number of experiments)
I did not declarated these variables, because i want the macro to read these values from specific cells.
My code (for the first step):
Sub BINOM() S = Range("L4").Value u = Range("M4").Value d = Range("N4").Value p = Range("O4").Value n = Range("P4").Value v = Rnd() If v > p Then Range("B2").Value = S * u Else Range("B2").Value = S * d End If End Sub
The result of the second experiment (that should be written in the B3 cell) has to be calculated from the result of the first experiment and so on but not with using the same random number...
I hope someone helps me because i don't really know how to start with.