[description=DJB - Display stats regarding share portfolio - use on daily data; category = DESB; author = Bleakley, Des ; target=PRICE; ] printposition := highest ( CLOSE, 10 ) *1.1; lastbar := barnumber = lastvalue( barnumber ); { **** Test for owned shares - XXX are blank slots **** } sharebuycost1 := if ( security.symbol = "AGL", 20.942, if ( security.symbol = "ALL", 16.888, if ( security.symbol = "BHP", 24.889, if ( security.symbol = "BRG", 10.431, if ( security.symbol = "XXX", 9.484, if ( security.symbol = "XXX", 77.095, if ( security.symbol = "XXX", 12.233, 0))))))); iownthis1 := sharebuycost1 > 0; [name = H1;color=blue;linestyle=solid;width=1;]; if(iownthis1, sharebuycost1, undefined); buydate1 := if( security.symbol = "AGL", date(2016,11,28), if( security.symbol = "ALL", date(2017,2,27), if( security.symbol = "BHP", date(2017,3,13), if( security.symbol = "BRG", date(2017,3,13), if( security.symbol = "XXX", date(2016,11,28), if( security.symbol = "XXX", date(2016,11,14), if( security.symbol = "XXX", date(2017,3,6), 0))))))); [name="";color=blue;linestyle=verticalmarker;width=1]; iownthis1 AND buydate1=now(); numshares1 := if ( security.symbol = "AGL", 476, if ( security.symbol = "ALL", 1200, if ( security.symbol = "BHP", 11100, if ( security.symbol = "BRG", 2000, if ( security.symbol = "XXX", 2789, if ( security.symbol = "XXX", 2319, if ( security.symbol = "XXX", 20900, 0))))))); { **** If you own a second parcel of shares, put them here **** } sharebuycost2 := if ( security.symbol = "AGL", 24.508, if ( security.symbol = "XXX", 12.501,0)); iownthis2 := sharebuycost2 > 0; [name=H2;color=magenta;linestyle=line;width=1;]; if(iownthis2, sharebuycost2, undefined); buydate2 := if( security.symbol = "AGL", date(2017,2,20), if( security.symbol = "XXX", date(2017,2,20), 0)); [name="";color=magenta;linestyle=verticalmarker]; iownthis2 AND buydate2=now(); numshares2 := if ( security.symbol = "AGL", 524, if ( security.symbol = "XXX", 943, 0)); { **** Display share statistics **** } days1 := datediff( buydate1, now ); daysheld1 := if ( days1 =0,1, days1); Rdaysheld1 := round( if ( days1 =0,1, days1)); pricechange1 := CLOSE - sharebuycost1; pricechangepercent1 := (pricechange1 / sharebuycost1)*100; annualpricechangepercent1 := (pricechangepercent1 / daysheld1)*365; Rpricechangepercent1 := round ( pricechangepercent1,2); Rannualpricechangepercent1 := round( annualpricechangepercent1,0); buycost1 := round ( (numshares1*sharebuycost1) / 1000, 3 ); currentvalue1 := round ( (numshares1*CLOSE) / 1000, 3 ); profit1 := round(numshares1*CLOSE - numshares1*sharebuycost1); yesterdayclose1 := hist( CLOSE, 1); todaychange1 := CLOSE - yesterdayclose1; todaychangepc1 := round ( (todaychange1 / yesterdayclose1) * 100, 2); [name=own1;linestyle=text;textalign=below,centre;fontstyle=bold;fontsize=9;color=blue]; if ( iownthis1 AND lastbar ,security.symbol+" Buy Price : "+sharebuycost1+" Change : "+Rpricechangepercent1+"% in "+Rdaysheld1+" days = "+Rannualpricechangepercent1+"%PA - TODAY : "+todaychangepc1+"%", undefined); printposition; if ( iownthis1 AND lastbar ,"Num Shares : "+numshares1+" Value : $"+currentvalue1+"K Profit : $"+profit1+" - ROC: "+round(ROC(C,126,%))+"%", undefined); printposition*0.98; days2 := datediff( buydate2, now ); daysheld2 := if ( days2 =0,1, days2); Rdaysheld2 := round( if ( days2 =0,1, days2)); pricechange2 := CLOSE - sharebuycost2; pricechangepercent2 := (pricechange2 / sharebuycost2)*100; annualpricechangepercent2 := (pricechangepercent2 / daysheld2)*365; Rpricechangepercent2 := round ( pricechangepercent2,2); Rannualpricechangepercent2 := round( annualpricechangepercent2,0); buycost2 := round ( (numshares2*sharebuycost2) / 1000, 3 ); currentvalue2 := round ( (numshares2*CLOSE) / 1000, 3 ); profit2 := round(numshares2*CLOSE - numshares2*sharebuycost2); yesterdayclose2 := hist( CLOSE, 1); todaychange2 := CLOSE - yesterdayclose2; todaychangepc2 := round ( (todaychange2 / yesterdayclose2) * 100, 2); [name=own2;linestyle=text;textalign=below,centre;fontstyle=bold;fontsize=9;color=magenta]; if ( iownthis2 AND lastbar ,security.symbol+" Buy Price : "+sharebuycost2+" Change : "+Rpricechangepercent2+"% in "+Rdaysheld2+" days = "+Rannualpricechangepercent2+"%PA - TODAY : "+todaychangepc2+"%", undefined); printposition*0.96; if ( iownthis2 AND lastbar ,"Num Shares : "+numshares2+" Value : $"+currentvalue2+"K Profit : $"+profit2+" - ROC: "+round(ROC(C,126,%))+"%", undefined); printposition*0.94;