How to plot a monte carlo simulation

I am trying to price a call option using a monte carlo simulation and I have priced it, but I want to plot how it changes given the number of steps. My code is as follows:
function Value=cw2q6(S,E,T,r,sigma,A,M)
S=100;
E=90;
T=2;
r=0.03;
sigma=0.2;
A=110;
M=10000;
C = zeros(1,M);
for i=1:M
psi=randn;
ST = S*exp((r-0.5*sigma^2)*T+sigma*psi*sqrt(T));
if ST>E
payoff = A;
elseif ST==E
payoff = A/2;
elseif ST<E
payoff = 0;
end
C(1,i)=payoff*exp(-r*T);
end
Value = sum(C)/M;
end
I know that as I increase the number of steps the answer gets more accurate, I just want to show how the accuracy changes as we increase the number of steps. Any help is appreciated.

Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Asked:

on 19 Mar 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!