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

Gann - swing update



PureBytes Links

Trading Reference Links

This is an update to Gann-Swing  indicators I had posted several
months back. Most of the code has been improved and I have
modified the swing definition slightly. It is my suggestion to read
the attached word.doc file and completely reinstall the 'Expert Advisor".
I will follow up this post with some charts.

  Best wishes,
      Adam Hefner.
VonHef@xxxxxxxxxxxxx
---------------------------------------
name: GANN-HiLo

      {HiLo  4/27/99}
Lb:=Input("Look-Back Periods?",2,10,3);
HLd:=If(CLOSE>Ref(Mov(H,Lb,S),-1),
      {then}1,
      {else}If(CLOSE<Ref(Mov(L,Lb,S),-1),
            {then}-1,
            {else}0));
HLv:=ValueWhen(1,HLd<>0,HLd);
HiLo:=If(HLv=-1,
      {then}Mov(H,Lb,S),
      {else}Mov(L,Lb,S));
HiLo;
------------------------------------------
name: GANN-Swing

      {Gann-Swing 4/27/99}
 {Market swing is defined as:
  Up   = 2 higher highs,
  Down = 2 lower lows.}
Us:=BarsSince(Sum(H>Ref(H,-1),2)=2);
Ds:=BarsSince(Sum(L<Ref(L,-1),2)=2);
Hc:=HighestSince(1,Us=0,H);
Lc:=LowestSince(1,Ds=0,L);
Sd1:=If(Us=0,
     {then}If((L<>Lc) AND (Ref(L,-1)<>Lc),
           {then}1,
           {else}0),
     {else}If(Ds=0,
           {then}If((H<>HC) AND (Ref(H,-1)<>Hc),
                 {then}-1,
                 {else}0),
           {else}0));
Sd2:=If(Sd1=1,
     {then} If(Ref(BarsSince(Sd1=1),-1) >
               Ref(BarsSince(Sd1=-1),-1),
            {then}1,
            {else}0),
     {else} If(Sd1=-1,
            {then}If(Ref(BarsSince(Sd1=1),-1) <
                  Ref(BarsSince(Sd1=-1),-1),
                  {then}-1,
                  {else}0),
            {else}0));
TD1:=ValueWhen(1,Sd2<>0,Sd2);
Td1;
--------------------------------------------
name: GANN-Trend

      {Gann-Trend  4/27/99}
 {Swing Direction}
Sd:= FmlVar("GANN-Swing","TD1") ;
 {Swing Change High}
Sch:=If(Sd=1 AND Ref(sd,-1)=-1,
     {then}1,
     {else}0);
 {Swing Change Low}
Scl:=If(Sd=-1 AND Ref(Sd,-1)=1,
     {then}1,
     {else}0);
 {Peak Value}
Pv:=If(Scl=1,
    {then}HighestSince(1,Sch=1,H),
    {else}0);
 {Trough Value}
Tv:=If(Sch=1,
    {then}LowestSince(1,Scl=1,L),
    {else}0);
 {Trend Direction}
Td:=If(H>ValueWhen(1,Pv>0,Pv),
    {then}1,
    {else}If(L<ValueWhen(1,Tv>0,Tv),
          {then}-1,
          {else}0));
 {UpTrend=1 DownTrend =-1}
Tdv:=ValueWhen(1,Td<>0,Td);
Tdv
------------------------------------------
name: GaW-Swing

     {Weekly Swing  4/27/99}
     {Market swing is defined as:
               Up   = 2 higher highs,
               Down = 2 lower highs }
 {Weekly High/Low}
Dw:=If(DayOfWeek()<=Ref(DayOfWeek(),-1),1,0);
Wh:=If(Dw=1,
    {then}Ref(HighestSince(1,Dw=1,H),-1),
    {else}0);
Wl:=If(Dw=1,
    {then}Ref(LowestSince(1,Dw=1,L),-1),
    {else}0);
Hv1:=ValueWhen(1,Wh>0,Wh);
Hv2:=ValueWhen(2,Wh>0,Wh);
Hv3:=ValueWhen(3,Wh>0,Wh);
Lv1:=ValueWhen(1,Wl>0,Wl);
Lv2:=ValueWhen(2,Wl>0,Wl);
Lv3:=ValueWhen(3,Wl>0,Wl);
Us:=BarsSince((Hv1 > Hv2) AND (Hv2 > Hv3));
Ds:=BarsSince((Lv1 < Lv2) AND (Lv2 < Lv3));
Hc:=Ref(HighestSince(1,Us=0 AND Ref(Us,-1)>0,H),
        -1);
Lc:=Ref(LowestSince(1,Ds=0 AND Ref(Ds,-1)>0,L),
        -1);
 {Swing direction Calculation}
Sd1:=If(Us=0 AND Dw=1,
     {then}If((Lv1<>Lc) AND (Lv2<>Lc),
           {then}1,
           {else}0),
     {else}If(Ds=0,
           {then}If((Hv1<>Hc) AND (Hv2<>Hc),
                 {then}-1,
                 {else}0),
           {else}0));
Sd2:=If(Sd1=1,
     {then} If(Ref(BarsSince(Sd1=1),-1) >
               Ref(BarsSince(Sd1=-1),-1),
            {then}1,
            {else}0),
     {else} If(Sd1=-1,
            {then}If(Ref(BarsSince(Sd1=1),-1) <
                  Ref(BarsSince(Sd1=-1),-1),
                  {then}-1,
                  {else}0),
            {else}0));
TD1:=ValueWhen(1,Sd2<>0,Sd2);
TD1
-------------------------------------------
name: GaW-Trend

 {Weekly Trend  4/27/99}
 {Swing Direction}
Sd:= FmlVar("GaW-Swing","TD1") ;
 {Swing Change High}
Sch:=If(Sd=1 AND Ref(sd,-1)=-1,
     {then}1,
     {else}0);
 {Swing Change Low}
Scl:=If(Sd=-1 AND Ref(Sd,-1)=1,
     {then}1,
     {else}0);
 {Peak Value}
Pv:=If(Scl=1,
    {then}HighestSince(1,Sch=1,H),
    {else}0);
 {Trough Value}
Tv:=If(Sch=1,
    {then}LowestSince(1,Scl=1,L),
    {else}0);
 {Trend Direction}
Td:=If(H>ValueWhen(1,Pv>0,Pv),
    {then}1,
    {else}If(L<ValueWhen(1,Tv>0,Tv),
          {then}-1,
          {else}0));
 {UpTrend=1 DownTrend =-1}
Tdv:=ValueWhen(1,Td<>0,Td);
Tdv
------------------------------------



Attachment Converted: "c:\eudora\attach\Gann Weekly Expert.doc"