Hi David
I've added a "Start Price" input that gives you the ability to over-ride the CLOSE with a different value. Using a default of zero allows the CLOSE to set the "Start Price". The "Cost" variable now selects CLOSE when the Start Price is zero or the adjusted start price when other than zero.
If you're trading a market other than the US then the nominal number of days in a trading year might need to be changed from 252. The first draft of this indicator (not posted) used the actual number of daily bars per year. The problem with that was that the start date needed to be at least one year earlier than the last data bar.
This indicator should also work with weekly data if the 252 constant is replaced by 52.
Regards
Roy
{Annual % Target}
{Roy Larsen, 1/3/2016}
Pc:=Input("Annual % Target",-99,199,20);
Sp:=Input("Adjust Start Price",0,999,0);
Dy:=Input("Open Trade Day",1,31,1);
Mn:=Input("Month",1,12,1);
Yr:=Input("Year" ,1980,2020,2013);
Shft:=Input("Blank Rightmost Bars",0,999,0);
Buy:=(DayOfMonth()>=Dy AND Month()=Mn AND Year()
=Yr) OR Year()>Yr OR (Year()=Yr AND Month()>Mn);
Buy:=Buy*Alert(Buy=0,2);
Cost:=(Cum(Buy)=1)*Buy*If(Sp=0,C,Sp);
Hold:=LastValue(Highest(Cost));
Plot:=Cum(Cost+(Hold*(Pc/100)/252)*(Ref(Cum(Cost>0),-1)));
Ref(Ref(ValueWhen(1,Plot<>0,Plot),-Shft),Shft);
Edited by user Monday, February 29, 2016 7:43:30 PM(UTC)
| Reason: Not specified