//@Name:Pivot Points //@Description:Draws Pivot Points based on the previous Daily/Weekly/Monthly Close //@Env:Production // 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 = 16711680; var colour2 = 65025; var colour3 = 255; var colour4 = 255; var pen1 = 0; var pen2 = 1; var pen3 = 2; var pen4 = 3; var width1 = 0; var width2 = 0; var width3 = 0; var width4 = 0; var dataList = ["Daily","Weekly","Monthly"]; var dataChoice = 0; var useIntra = 1; var ppSwitch = 1; var sup1Switch =1; var sup2Switch =1; var sup3Switch =1; var res1Switch =1; var res2Switch =1; var res3Switch =1; var show = 1 //Draws the Dialog box and stores the values set so that they can be recalled either when starting the program or when edditing the indicator. function init(status) { if (status == Loading || status == Editing) { pen1 = storage.getAt(0); pen2 = storage.getAt(1); pen3 = storage.getAt(2); pen4 = storage.getAt(3); width1 = storage.getAt(4); width2 = storage.getAt(5); width3 = storage.getAt(6); width4 = storage.getAt(7); colour1 = storage.getAt(8); colour2 = storage.getAt(9); colour3 = storage.getAt(10); colour4 = storage.getAt(11); dataChoice = storage.getAt(12); ppSwitch = storage.getAt(13); sup1Switch = storage.getAt(14); sup2Switch = storage.getAt(15); sup3Switch = storage.getAt(16); res1Switch = storage.getAt(17); res2Switch = storage.getAt(18); res3Switch = storage.getAt(19); useIntra = storage.getAt(20); } if (status == Adding || status == Editing) { dialog(0); } buttonHandle = createButton("Settings....", onButton0); buttonHandle = createButton("Off", onButton1); } function onButton0() { dialog(1) } function onButton1() { if (show==1) { show = 0; clearDisplay(); setButtonText(1, "On"); } else if(show==0) { show=1; setButtonText(1,"Off"); onNewChart(); } } function onNewChart() { clearDisplay(); if (show==1)draw(getCurrentShare()); } function onNewBar() { clearDisplay(); if (show==1)draw(getCurrentShare()); } function draw(share) { var pivot=0; var res1=0; var res2=0; var sup1=0; var sup2=0; var res3=0; var sup3=0; var data = getData(share,dataChoice,useIntra); if (dataChoice == 0) { var price = data[data.length-1]; pivot = (price.high + price.low + price.close) / 3 res1 = pivot + (pivot - price.low); sup1 = pivot - (price.high - pivot); res2 = pivot + (price.high - price.low); sup2 = pivot - (price.high - price.low); res3 = pivot + 2*(price.high - price.low); sup3 = pivot - 2*(price.high - price.low); } else if (dataChoice == 1) { var price = data[data.length-2]; pivot = (price.high + price.low + price.close) / 3 res1 = pivot + (pivot - price.low); sup1 = pivot - (price.high - pivot); res2 = pivot + (price.high - price.low); sup2 = pivot - (price.high - price.low); res3 = pivot + 2*(price.high - price.low); sup3 = pivot - 2*(price.high - price.low); } else if (dataChoice == 2) { var price = data[data.length-2]; pivot = (price.high + price.low + price.close) / 3 res1 = pivot + (pivot - price.low); sup1 = pivot - (price.high - pivot); res2 = pivot + (price.high - price.low); sup2 = pivot - (price.high - price.low); res3 = pivot + 2*(price.high - price.low); sup3 = pivot - 2*(price.high - price.low); } if (ppSwitch==1) { setPenStyle(pen1,width1,colour1); beginPath(); for (var i=0;idata[data.length-1].high?idata[0].high:data[data.length-1].high), low:(idata[0].lowdata[data.length-1].high?idata[0].high:data[data.length-1].high), low:(idata[0].low