[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weekly moving avg on Daily chart



PureBytes Links

Trading Reference Links

Adam,

Here's the weekly high code I posted the other day.
For last week's high, just plot this first indicator
"//Previous "n" weeks high "
and select 1 as the lookback period.  I've included the other
stuff because if you missed one you probably missed them all.

Ken
--
mailto:divenfish@xxxxxxxxxxxxx


 ============================
    --//Previous "n" weeks high--

n:=Input("Lookback period",1,500,4);
If(DayOfWeek()>=1 AND DayOfWeek()<=
   Ref(DayOfWeek(),-1),Ref(HighestSince(n,
     DayOfWeek()<=Ref(DayOfWeek(),-1),H),-1),{PREV}
      ValueWhen(1,DayOfWeek()>=1 AND
    DayOfWeek()<=Ref(DayOfWeek(),-1),
   Ref(HighestSince(n,DayOfWeek()<
  Ref(DayOfWeek(),-1),H),-1)))

============================

      --//Current week high-to-date--

HighestSince(1,DayOfWeek()>=1 AND
DayOfWeek()<=Ref(DayOfWeek(),-1) ,H)

=================================

    --//Previous QTR high--

      {first trading day of apr}
apr1:=Month()=4 AND Ref(Month()=3,-1);
      {first trading day of jly}
jly1:=Month()=7 AND Ref(Month()=6,-1);
      {first trading day of oct}
oct1:=Month()=10 AND Ref(Month()=9,-1);
    {first trading day of jan}
jan1:=Month()=1 AND Ref(Month()=12,-1);

If(jan1,HighestSince(1,oct1,H),
   If(apr1,HighestSince(1,jan1,H),
      If(jly1,HighestSince(1,apr1,H),
      If(oct1,HighestSince(1,jly1,H),PREV))));

==================================

    --//Current QTR high-to-date--

       {first trading day of apr}
apr1:=Month()=4 AND Ref(Month()=3,-1);
       {first trading day of jly}
jly1:=Month()=7 AND Ref(Month()=6,-1);
    {first trading day of oct}
oct1:=Month()=10 AND Ref(Month()=9,-1);
    {first trading day of jan}
jan1:=Month()=1 AND Ref(Month()=12,-1);

If(BarsSince(jan1)<BarsSince(apr1),
    HighestSince(1,jan1,H),
     If(BarsSince(apr1)<BarsSince(jly1),
      HighestSince(1,apr1,H),
       If(BarsSince(jly1)<BarsSince(oct1),
        HighestSince(1,jly1,H),
         If(BarsSince(oct1)<BarsSince(jan1),
          HighestSince(1,oct1,H),0))))

===========================

    --//Previous year high--

jan1:=Month()=1 AND Ref(Month()=12,-1);
ValueWhen(1,jan1,HighestSince(1,Ref(jan1,-1),H))

===============================

    --//Current year high-to-date--

 jan1:=Month()=1 AND Ref(Month()=12,-1);
HighestSince(1,jan1,H)

===============================