How is it possible to code Simple Moving Avergae of exprassion? Is it possible to do it in 1 line like this Average((Close+Low+High-Open)/2)or should I make ALL calculation by hand? Please help ASAP.
Announcement
Collapse
No announcement yet.
Please Help ! ! !
Collapse
X
-
Re: Reply to post 'Re: Reply to post 'Please Help ! ! ! ''
Hi Alex,
if it possible tell me the code or tell me how to code it with formula
wizard this simple formula:
BollingerBands of (high - open)
without re-writing the Bollinger Bands code !!!
WAITING FOR YOUR REPLY ! ! !
my best,
Young
ffec> Hello youngtrader,
ffec> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffec>
Comment
-
Hi Young,
I think it's impossible to write BollingerBands(high - open) as is, but try to use the following solution to not modify BollingerBands formula every time:
Code:function main(Length) { if(Length == null) Length = 20; BBArray = new Array(); for(i = 0; i < Length; i++) BBArray[i] = (high(-i) - open(-i)); return new Array(BollingerBands(BBArray,Length,Top=1),BollingerBands(BBArray,Length,Bot=-1)); } function BollingerBands(Array,Length,Type) { if(Length == null) Length = 55; if(StdDev == null) StdDev = .5; var i; var vSum = 0.0; var BBTop; var BBBot; var SumSqr = 0; var StdDev = 0; for(i = 0; i < Length; i++) vSum += Array[i]; if(Length != 0) for(i = 0; i < Length; i++) SumSqr += (Array[i] - vSum / Length) * (Array[i] - vSum / Length); StdDev = Math.sqrt(SumSqr / Length); BBTop = vSum / Length + StdDev * StdDev; BBBot = vSum / Length - StdDev * StdDev; if(Type == 1) return BBTop; else if(Type == -1) return BBBot; }
If you have any further questions or require additional assistance please let me know.
Regards,
Andy
Comment
Comment