//@Name:Multiday Pivot Points //@Description: Draws Pivot Points based on the Previous days' OHLC on each day of the intraday graph //@Env:Production //@Type:Intraday // 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 pen1 = 0; var pen2 = 1; var pen3 = 2; var width1 = 0; var width2 = 0; var width3 = 0; //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); width1 = storage.getAt(3); width2 = storage.getAt(4); width3 = storage.getAt(5); colour1 = storage.getAt(6); colour2 = storage.getAt(7); colour3 = storage.getAt(8); } if (status == Adding || status == Editing) { var dlg = new Dialog("Alternative Pivot Lines", 200, 80); dlg.addOkButton(); dlg.addCancelButton(); dlg.addGroupBox(5,5,135,70,"Line Properties"); dlg.addColLinePicker("VAL1",100,15,-1,-1,"Pivot Point","",colour1,pen1,width1); dlg.addColLinePicker("VAL2",100,35,-1,-1,"First Support/Resistance","",colour2,pen2,width2); dlg.addColLinePicker("VAL3",100,55,-1,-1,"Second Support/Resistance","",colour3,pen3,width3); if (dlg.show() == Dialog.Cancel) return false; colour1 = dlg.getValue("VAL1").colour; pen1 = dlg.getValue("VAL1").pen; width1 = dlg.getValue("VAL1").width; colour2 = dlg.getValue("VAL2").colour; pen2 = dlg.getValue("VAL2").pen; width2 = dlg.getValue("VAL2").width; colour3 = dlg.getValue("VAL3").colour; pen3 = dlg.getValue("VAL3").pen; width3 = dlg.getValue("VAL3").width; } storage.setAt(0, pen1); storage.setAt(1, pen2); storage.setAt(2, pen3); storage.setAt(3, width1); storage.setAt(4, width2); storage.setAt(5, width3); storage.setAt(6, colour1); storage.setAt(7, colour2); storage.setAt(8, colour3); } function onNewChart() { clearDisplay(); draw(); } function onNewBar() { clearDisplay(); draw(); } function draw() { var pivot=0; var res1=0; var res2=0; var sup1=0; var sup2=0; var baseData = getShare("UKI:UKX").getPrice().date; if (bars[0].date-86400000>baseData) date=new Date(baseData); else date = new Date(bars[0].date-86400000); var price = getCurrentShare().getPriceOnDate(date); if (price==undefined) return; 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) setPenStyle(pen1,width1,colour1); beginPath(); for (var i=0;i0 && bars[i].dateNum!=bars[i-1].dateNum) { endPath(); drawPath(); beginPath(); if (bars[i].date-86400000>baseData) date=baseData; else date = new Date(bars[i].date-86400000); price = getCurrentShare().getPriceOnDate(date); if (price==undefined) pivot=null; else pivot = (price.high + price.low + price.close) / 3 moveTo(i,pivot); } lineTo(i,pivot); } endPath(); drawPath(); setPenStyle(pen2,width2,colour2); beginPath(); for (var i=0;i0 && bars[i].dateNum!=bars[i-1].dateNum) { endPath(); drawPath(); beginPath(); if (bars[i].date-86400000>baseData) date=baseData; else date = new Date(bars[i].date-86400000); price = getCurrentShare().getPriceOnDate(date); if (price==undefined) res1=null; else { pivot = (price.high + price.low + price.close) / 3 res1 = pivot + (pivot - price.low) } moveTo(i,res1); } if (i==0) { moveTo(i,res1); continue; } lineTo(i,res1); } endPath(); drawPath(); beginPath(); for (var i=0;i0 && bars[i].dateNum!=bars[i-1].dateNum) { endPath(); drawPath(); beginPath(); if (bars[i].date-86400000>baseData) date=baseData; else date = new Date(bars[i].date-86400000); price = getCurrentShare().getPriceOnDate(date); if (price==undefined) sup1=null; else { pivot = (price.high + price.low + price.close) / 3 sup1 = pivot - (price.high - pivot) } moveTo(i,sup1); } if (i==0) { moveTo(i,sup1); continue; } lineTo(i,sup1); } endPath(); drawPath(); setPenStyle(pen3,width3,colour3); beginPath(); for (var i=0;i0 && bars[i].dateNum!=bars[i-1].dateNum) { endPath(); drawPath(); beginPath(); if (bars[i].date-86400000>baseData) date=baseData; else date = new Date(bars[i].date-86400000); price = getCurrentShare().getPriceOnDate(date); if (price==undefined) res2=null; else { pivot = (price.high + price.low + price.close) / 3 res2 = pivot + (price.high - price.low) } moveTo(i,res2); } if (i==0) { moveTo(i,res2); continue; } lineTo(i,res2); } endPath(); drawPath(); beginPath(); for (var i=0;i0 && bars[i].dateNum!=bars[i-1].dateNum) { endPath(); drawPath(); beginPath(); if (bars[i].date-86400000>baseData) date=baseData; else date = new Date(bars[i].date-86400000); price = getCurrentShare().getPriceOnDate(date); if (price==undefined) sup2=null; else { pivot = (price.high + price.low + price.close) / 3 sup2 = pivot - (price.high - price.low) } moveTo(i,sup2); } if (i==0) { moveTo(i,sup2); continue; } lineTo(i,sup2); } endPath(); drawPath(); setInfoText("Pivot = "+pivot.toFixed(2)+"\nRes1 = "+res1.toFixed(2)+"\nSup1 = "+sup1.toFixed(2)+"\nRes2 = "+res2.toFixed(2)+"\nSup2 = "+sup2.toFixed(2)); }