More Information about: Link: 1) http://www.onlinetradingconcepts.com/TechnicalAnalysis/MovingAverageEnvelopes.html |
Source Code "Envelopes": |
||
function init() { Envelopes.createParameter("Period", 14); Envelopes.createParameter("Shift", 0); Envelopes.createParameter("Devitation", 8.5); Envelopes.createBuffer("EnvelopesUpper"); Envelopes.setBufferColor("EnvelopesUpper", "lime"); Envelopes.setBufferDrawStyle("EnvelopesUpper", DrawStyle.LINE); Envelopes.createBuffer("EnvelopesLower"); Envelopes.setBufferColor("EnvelopesLower", "red"); Envelopes.setBufferDrawStyle("EnvelopesLower", DrawStyle.LINE); Envelopes.setAutoChangeMaxMin("EnvelopesUpper", "EnvelopesLower"); } function start() { Envelopes.label = "Envelopes(" + Envelopes.parameter("Period") + "," + Envelopes.parameter("Shift") + "," + Envelopes.parameter("Devitation") + ")"; var smaBuf = Shared.sma(Envelopes.parameter("Period"), Shared.close()); var devitation = Envelopes.parameter("Devitation"); var num = Shared.numberOfQuotes(); var upperBuf = new Array(num); var lowerBuf = new Array(num); for (var i = 0; i < num; ++i) { upperBuf[i] = smaBuf[i] * (1 + devitation / 100); lowerBuf[i] = smaBuf[i] * (1 - devitation / 100); } Envelopes.setBufferData("EnvelopesUpper", upperBuf); Envelopes.setBufferData("EnvelopesLower", lowerBuf); } |