//@Name:Periods Ago Flag //@Description: Draws an arrow on the chart a specified number of trading days ago. // 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. // Coded by: Phil Tolhurst, ShareScope Support var colour1 = Colour.LightGreen var period = 25; function init(status) { if (status == Loading || status == Editing) { colour1 = storage.getAt(0); period = storage.getAt(1); } if (status == Adding || status == Editing) { var dlg = new Dialog("Periods Ago Flag", 290, 60); dlg.addOkButton(); dlg.addCancelButton(); dlg.addGroupBox(5,5,220,30,"Properties.."); dlg.addColPicker("VAL1",190,16,-1,-1,"Arrow Colour","",colour1); dlg.addNumEdit("VAL2",100,16,-1,-1,"No. of Periods Ago: " ,"",period); if (dlg.show() == Dialog.Cancel) return false; colour1 = dlg.getValue("VAL1"); period = dlg.getValue("VAL2"); storage.setAt(0, colour1); storage.setAt(1, period); } setTitle("Flag @ "+period+" periods ago"); } function onNewChart() { clearDisplay(); draw(); } //Updates the graph if the data is updated, so when a new bar is added. function onNewBarUpdate() { clearDisplay(); draw(); } function draw() { //Draw Arrow if(bars.length>period) { setBrushColour(colour1); drawSymbol(bars.length-(1+period), bars[bars.length-(1+period)].high*1.01, Symbol.TriangleDown, "", BoxAlign.Centre|BoxAlign.Above); } }