Is this the best way/correct way to code the Exponential Bollinger Bands?? I want to know if my formula is correct.
1) I wouldn't use:
as sometimes it has happend that 2 is reagarded as int and iStdDev is converted accordiungly - to be fail safe write 2.0*iStdDev(..)
2) iStdDev(0,..) is wrong! Either use NULL or better _Symbol: iStdDev(_Symbol,...).
3) You'll be in trouble if the chart is not m15! Either write iStdDev(_Symbol, 0,...) (for the timframe of the chart or you have to calculate the correct value of i using iBarshift(),...
Why don't you search (google) for existing code - faster, no errors, better base to learn to code and the mathematics!
No, it's not, your deviation should be based on ML (EMA) values. You are calculating Standard Deviation of Close prices.
Look at "Bands.mq4" in Mql4\Indicators. It's Bollinger bands mql4 source code and you will just have to modify it (understand it before).