--- In amibroker@xxxxxxxxxxxxxxx, "a1ex_douglas"
<a1ex_douglas@xxxx> wrote:
> Is there a way to set the start date for the
"Relative Performance"
> Indicator?
As it is, it simply resets all securities to "0" at the
> far left-hand side of the screen and allows the
relative performance
> to unfold across the screen - but there doesn't
appear t obe an easy
> way to elect which date is the first visible date
on the screen (&
> thus the first date of the "Relative
Performance").
>
> Any ideas?
>
> Many thanks,
> Alex.
Alex,
Take a look at the following code. It may be of
help.
By using a variable in BarCount – 1, (ie: BarCount –X)
and
using the Param Function, one could also change the
ending
date of the comparison if needed. As written, the ending
date of
the comparison is always the last bar of the current
symbol.
Regards,
Tony
_SECTION_BEGIN
(
"_Relative
Strength"
);
//Sector Relative
Strength
//Sector by Groups Plots vs S&P
500
SetBarsRequired
(
100000
,
0
);
LookbackPeriod
=
Param
(
"Lookback"
,
21
,
21
,
252
,
21
);
StartBar
= (
BarCount
-
1
) -
LookbackPeriod;
GraphXSpace
=
5
;
Index
=
Foreign
(
"$INX"
,
"Close"
,
True
);
TempIndex
=(Index/Index[StartBar]-
1
)*
100
;
PercentChangeIndex
=
IIf
(
BarIndex
() >=
StartBar,TempIndex,
Null
);
Plot
(PercentChangeIndex,
"Index"
,
colorBlack
,
styleDots
);
TempSymbol
=(
Close
/
Close
[StartBar]-
1
)*
100
;
PercentChangeSymbol
=
IIf
(
BarIndex
() >=
StartBar,TempSymbol,
Null
);
Plot
(PercentChangeSymbol,
"Symbol"
,
colorRed
,
styleDots
);
Title
=
"Relative Strength vs S&P
500, last "
+
WriteVal
(LookbackPeriod,
3.0
) +
" days"
+
"\n"
+
"\n"
+
"S&P
500 (fine
black dotted)"
+
"\n"
+
"Symbol "
+
FullName
() +
" (fine red
dotted)"
;
_SECTION_END
();