//@Name:VWMA //@Description:Volume Weighted Moving Average. // Care has been taken in preparing this code but it is provided without guarantee. // You are welcome to modify and extend it. Please add your name as a modifier if you distribute it. var period = 20; var lineCol = Colour.Red; var linePen = Pen.Solid var lineWidth = 0; function init(status) { if (status == Loading || status == Editing) { period = storage.getAt(0); lineCol = storage.getAt(1); linePen = storage.getAt(2); lineWidth = storage.getAt(3); } if (status == Adding || status == Editing) { dlg = new Dialog("VWMA Setup",160,50); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",8,8,-1,-1,"","Period",period,2,1000); dlg.addColLinePicker("LN1",70,8,-1,-1,"","",lineCol,linePen,lineWidth) if (dlg.show()==Dialog.Cancel && status == Adding) return false; period = dlg.getValue("INT1"); lineCol = dlg.getValue("LN1").colour; linePen = dlg.getValue("LN1").pen; lineWidth = dlg.getValue("LN1").width; storage.setAt(0, period); storage.setAt(1, lineCol); storage.setAt(2, linePen); storage.setAt(3, lineWidth); } setRange(Range.Parent); setSeriesColour(0, lineCol); setSeriesLineStyle(0, linePen, lineWidth); } function getGraph(share, data) { var ma1 = new MA(period, MA.Simple); var ma2 = new MA(period, MA.Simple); var VWMA = [] for (var i=0;i0) VWMA[i] = av1/av2; else VWMA[i] = null; } return VWMA; }