PureBytes Links
Trading Reference Links
|
-- I wrote:
> To the original poster: You might consider simply
> tracking this manually and having two inputs to your
> strategy which you adjust on a weekly basis.
Then Gary wrote:
> That works great for an indicator you just want to
> use for discretionary trading. Won't help much to
> backtest a strategy, though.
I'm not so sure... :-)
You set the inputs to whatever the appropriate values would have been at the start of the chart 33 weeks ago (13000 5-min bars =~ 33 weeks). Then the 52-week high and low can easily and automatically be adjusted for any changes that take place during the time covered by the chart:
Inputs:
AnHigh(20000),
AnLow(0);
{Set these to the appropriate levels that they would have had at the time of the first bar on the 5-minute chart}
Var:
AH(0),
AL(0),
AHHold(0),
ALHold(0);
If BarNumber = 1 then begin
AH = AnHigh;
AL = AnLow;
End;
If H > AH then AHHold = H;
If L < AL then ALHold = L;
{Keeps any newly struck 52-week high in AHHold and newly struck 52-week low in ALHold}
If DatetoJulian(Date) - DatetoJulian(Date[1]) > 1 and AHHold > AH then AH = AHHold;
If DatetoJulian(Date) - DatetoJulian(Date[1]) > 1 and ALHold < AL then AL = ALHold;
{Above two statements adjust 52-week H & L (AH and AL) each week. I'm assuming that we adjust this on a weekly basis. We could adjust it constantly very easily...}
If {Buy Conditions} and C > AH then Buy;
If {Sell Conditions} and C < AL then Sell;
You set the inputs once and you can backtest over the whole 13000 bars...
Good trading,
OM
|