Hello,

I am in the process of moving my trading system analysis from MATLAB to Amibroker AFL. I've searched this forum for integral() or quad() and read the list of functions published here: https://www.amibroker.com/guide/a_funref.html as well as general google searches.

I would like to replace the MATLAB function: integral( fun, xmin, xmax ) which numerically integrates function "fun" from "xmin" to "xmax" using global adaptive quadrature and default error tolerances.

My specific application is to implement Espen Haug's benchmark option pricing for american options with discrete dividends:

```
function callprice = DiscreteDividend( s, k, r, t, vol, d, dt )
%code by written by a. biao at www.mathfinance.cn
%based upon E. Haug, "Back to Basics: A New Approach to the Discrete Dividend Problem", 2003;
%s: current stock price;
%k: strike price;
%r: risk-free interest rate;
%t: time to maturity of option;
%vol: volatility;
%d: discrete dividend amount
%dt: dividend time
Haug2003 = exp( -r * dt ) * ( integral( @( x ) blsprice( x - d, k, r, t - dt, vol, 0 ) .* lognpdf( x, lns + ( r - 0.5 *vol^2 ) * dt, vol * sqrt( dt ) ), d, k + d ) ...
+ integral( @( x ) blsprice( x - d, k, r, t - dt, vol, 0 ) .* lognpdf( x, lns + ( r - 0.5 * vol^2 ) * dt, vol * sqrt( dt ) ), k + d, 20 * s ) );
callprice = Haug2003;
```

Thank you for any help in pointing me in the right direction for accomplishing this in Amibroker AFL.

Kind regards,