# Implied Volatility AFL

Does anyone have Implied Volatility AFL (reverse Black Scholes using Newton Raphson)?

you can check the Black scholes AFL as given below , right click on parameter to set Implied Volatility etc

//------------------------------------------------------------------------------
//
// Black Scholes Option Pricing returns the Fair Value of call and put
// options.
//
//------------------------------------------------------------------------------

StockPrice = Param(â€śstockPriceâ€ť,81,1,200,1); //Stock Price
Timedays = Param(â€śDaysToExpireâ€ť,30,1,300,1); //Time to expiry ( days to exp/365 )
StrikePrice = Param(â€śStrikePriceâ€ť,75,1,300,1); //strike Price of Option to evaluate
InterestRate= Param(â€śInterestRateâ€ť,0.06,0.01,0.11,0.001); //prevailing interest rate
VKnown =Param(â€śVolatilityâ€ť,0.30,0.10,0.50,0.001);//You can insert Known volatility here , Implied Volatility.

x = (ln(stockPrice/strikePrice) + (interestrate + Vknown*Vknown/2)timedays)/(Vknownsqrt(timedays));

P = 0.2316419;
bb1 = 0.31938153;
bb2 = -0.3565638;
bb3 = 1.78147794;
bb4 = -1.821256;
bb5 = 1.33027443;

pi = 3.141592654; // PI

A2 = 1/sqrt(2pi);
A3 = exp(-(x^2)/2);
y= a2
a3;
A4 = exp(-interestratetimedays);
t1 = 1/(1+ P
x);
A5=(bb1t1)+(bb2t1^2) +( bb3t1^3)+(bb4t1^4)+(bb5t1^5);
/
***********************************************************/
//Standard Normal Distribution Function of ( x )

N = 1- y *A5 ;

/***********************************************************/
// Solves for ( X1 )
X1=x-Vknown
sqrt(TIMEdays);

y1=1/sqrt(2pi);
N0=exp(-(x1^2)/2);
T2=1/(1+ P
X1);
A6=(bb1t2)+(bb2t2^2) +( bb3t2^3)+(bb4t2^4)+(bb5t2^5);
A7=exp(-interestrate
timedays);
y2=y1*n0;

//
/
Standard Normal Distribution Function OF ( x1 )
/
/
*/
N2= 1-y2 * A6;

/************ CALL OPTION FAIR VALUE************/
Call = stockPrice * N - strikePrice * A4 * N2;

/************ PUT OPTION FAIR VALUE*************/

Put = Call - stockprice + strikeprice*A7;

Filter = 1;
SetOption(â€śnodefaultcolumnsâ€ť,1);
100,â€śVolatility%â€ť,1.2);