Bonsoir,
Y-a-t-il un soucis de synthaxe dans l'écriture de ma boucle while, la boucle ne s'arrête pas de tourner, par ailleurs quel est l'équivalent de l'instruction c++ break svp;
Le bouton CDOMC lance la Sub
cf fichier en pièce jointe
Cdt
Ludo
Function partieentiere(x As Double) As Long
partieentiere = Int(x)
End Function
Sub CDOPRICE()
Dim Barrierenonfranchise As Integer
''Get data
St = Worksheets("Feuil1").Cells(3, 1)
t = Worksheets("Feuil1").Cells(3, 6)
K = Worksheets("Feuil1").Cells(3, 2)
K2 = Worksheets("Feuil1").Cells(5, 2)
r = Worksheets("Feuil1").Cells(3, 4)
M = Worksheets("Feuil1").Cells(3, 5)
sigma = Worksheets("Feuil1").Cells(3, 3)
N = Worksheets("Feuil1").Cells(5, 6)
epsilon = Worksheets("Feuil1").Cells(12, 7)
L = Worksheets("Feuil1").Cells(17, 2)
div = Worksheets("Feuil1").Cells(17, 5)
Barrierenonfranchise = 1
Dim Stplusdt As Double
Dim i As Long
Dim j As Long
For i = 1 To N
While (Barrierenonfranchise = 1 Or j <> M * 260)
For j = partieentiere((t + 1) * 260) To M * 260
Randomize
unif = Rnd
z = WorksheetFunction.NormInv(unif, 0, 1)
Stplusdt = St * Exp((r - 0.5 * WorksheetFunction.Power(sigma, 2)) * (M - j / 260) + sigma * WorksheetFunction.Power(M - j / 260, 0.5) * z)
If Stplusdt < L Then
Barrierenonfranchise = 0
End If
Next
Wend
If Barrierenonfranchise = 1 Then
If (St > L) Then
moyenneCDO = moyenneCDO + partiepositive(St * Exp((r - 0.5 * WorksheetFunction.Power(sigma, 2)) * (M - t) + sigma * WorksheetFunction.Power(M - t, 0.5) * z) - K)
ElseIf (St < L) Then
moyenneCD0 = 0
End If
ElseIf Barrierenonfranchise = 0 Then
moyenneCD0 = 0
End If
Next
Worksheets("Feuil1").Cells(23, 4) = moyenneCDO / N
End Sub