//@Name:Price/Trend Ratio //@Description:Returns the value of the price as the percentage of its position in relation to the trend line. //@Returns:Number //@Width:60 //@Update:Periodic,30 //Author: ShareScript Support // 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 trPer = 20; var trType = 0 function init(status) { if (status == Loading || status == Editing) { trType = storage.getAt(0); trPer = storage.getAt(1); } if (status == Adding || status == Editing) { dlg = new Dialog("Setup",150,45); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("DL1",8,-1,80,-1,["Linear Scale","Log Scale"],"","",trType); dlg.addIntEdit("INT1",8,-1,-1,-1,"","Trend period",trPer,0,5000); if (dlg.show()==Dialog.Cancel) return false; trType = dlg.getValue("DL1"); trPer = dlg.getValue("INT1"); storage.setAt(0, trType); storage.setAt(1, trPer); } setTitle("Price/ "+trPer+(trType?" Log":"")+" Trend"); } function getVal(share) { if (trPer==0) var data = share.getCloseArray(); else var data = share.getCloseArray(trPer); var mid = share.getIMid(); if (mid != undefined && mid>0) data[data.length] = mid; if (data.length<2) return; if (trPer==0) var trend1 = new Trend(data.length); else var trend1 = new Trend(trPer); for (var i=0;i