I have written the following code to plot % chg in price of ticker
from starting date to ending date (using parameters). I have to
problems:
1. when I change the date it crashes, point to from date in the title.
2. when it works, it draws a horizontal line from first visible bar
to the starting date. I want to eliminate this line. TIA
dt=DateTime();
StartDate = ParamDate ( "Start Date" , Date () );
EndDate = ParamDate ( "End Date" , Date () );
StartDateBar = LastValue(ValueWhen ( DateNum () == StartDate,
BarIndex ()));
EndDateBar = LastValue(ValueWhen( DateNum () == EndDate, BarIndex
() ));
Ticker = 0;
for (Bar = StartDateBar; Bar < EndDateBar-1; Bar++)
{
ticker[bar] = 100 *(( C[Bar] - C[ StartDateBar ])/C[StartDateBar ]);
//_TRACE("Bar: " + Bar + " StartDateBar " + C[ StartDateBar ] + " C
[Bar] " + C[Bar]);
}
Plot( ticker, Name(), colorBlue );
SetChartOptions( 1, chartShowDates );
PlotGrid( 0, colorYellow );
Title = "From: " + WriteVal(dt[StartDateBar],formatDateTime) + "
To: " + Date() + " - " + "{{VALUES}}" + "\n" +
Interval(2) + " - " + _DEFAULT_NAME();