[description=DJB - Display Bought price line plus percentage movement for stocks owned; author = Bleakley, Des ; target=PRICE; ] printposition := CLOSE; lastbar := barnumber = lastvalue( barnumber ); thisbardate := now(); prevbardate := hist( now(),1); daysdiff := datediff(prevbardate, thisbardate); period := if ( daysdiff <7, "DAILY", if ( daysdiff <20, "WEEKLY", if ( daysdiff < 50, "MONTHLY", if ( daysdiff<100, "QUARTER", if ( daysdiff > 300, "YEARLY", "ERR"))))); { **** Test for owned shares **** **** EDIT THESE TWO BLOCKS OF SCRIPT TO INSERT YOUR OWNED STOCKS **** MAKE SURE THE OPEN & CLOSE BRACKETS MATCH IN NUMBER } boughtprice := if ( security.symbol = "ALL", 22.506, if ( security.symbol = "ALU", 11.632, if ( security.symbol = "APX", 8.001, if ( security.symbol = "XXX", 100, if ( security.symbol = "XXX", 100, 0 ))))); iownthis := boughtprice > 0; [name = H1;color=brown;linestyle=dash;width=1;]; if (iownthis, boughtprice, undefined); stockboughtdate := if( security.symbol = "ALL", date(2017,10,11), if( security.symbol = "ALU", date(2017,10,16), if( security.symbol = "APX", date(2017,12,18), if( security.symbol = "XXX", date(2018, 1, 8), if( security.symbol = "XXX", date(2017,10,4), now() ))))); [name="d";color=brown;linestyle=verticalmarker;width=1]; iownthis AND period="DAILY" AND datediff(stockboughtdate,now()) =0; {DAILY} [name="w";color=brown;linestyle=verticalmarker;width=1]; iownthis AND period="WEEKLY" AND datediff(stockboughtdate,now()) <=7 AND datediff(stockboughtdate,now()) >1; {WEEKLY} days := datediff( stockboughtdate, now ); daysheld := if ( days =0,1, days); pricechange := CLOSE - boughtprice; pricechangepercent := (pricechange / boughtprice)*100; annualpricechangepercent := (pricechangepercent / daysheld)*365; Rdaysheld := round( if ( days =0,1, days)); Rpricechangepercent := round ( pricechangepercent,2); Rannualpricechangepercent := round( annualpricechangepercent,0); { DISPLAY RETURN ON THIS STOCK - BLUE IF WINNING, RED IF LOSING } [name=summary;linestyle=text;fontstyle=bold;fontsize=8;color=blue;textalign=above,left;dp=2;]; [name=U;color=blue;]; if ( iownthis AND lastbar AND Rpricechangepercent >0 , ". "+Rpricechangepercent+"%"+Rdaysheld+"d("+Rannualpricechangepercent+"%PA)", undefined); printposition; [name=D;color=red;]; if ( iownthis AND lastbar AND Rpricechangepercent <0 ,". "+Rpricechangepercent+"%"+Rdaysheld+"d("+Rannualpricechangepercent+"%PA)", undefined); printposition;