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

Re: Andrews Median line



PureBytes Links

Trading Reference Links

Jimmy

Hope this help.

Paul Williams
(programmer www.futurenets.co.uk)

{ ======================================
This is my implementation of some aspects of Andrews Pitchforks. You are
welcome to use this code freely. You may redistribute it provided you
include this comment block, plus a description of any changes you make.

If you extend it, or adapt it to other uses, I'd appreciate a look at what
you've done. Thanks.

Gregory Wood
SwissFranc@xxxxxxxxxxxxxxxx

12/18/96 v1.0 - Initial distribution
01/08/96 v1.1 - Added median lines
01/15/96 v1.2 - Added TL_Thick, user-customizable colors (see "SET COLORS
HERE")
01/16/96 v1.3 - Removed projections to make room for up to 7 pitchforks
========================================

SETUP

Set Plot1 and Plot2 to be large points.
Note that the trendlines use the default trendline settings

USAGE

Use the text tool to label swing high/lows with "A", "B" and "C", then
refresh the indicator (clicking "Status" twice causes the indicator to
recalculate). Be sure to put the label above the bar's high for a swing
high, and below the low for a swing low.

You can display other groups of points by using labels "Ax", "Bx" and "Cx",
where 'x' is 1, 2, or 3, e.g. "A3", "B3", "C3".

Note that you can use the pointer tool to move the points anytime. Then to
view the new Pitchfork, refresh the indicator.

Use the Proj values to place a dot at a time expansion. Try values like
.618, 1.0, 1.618 etc. Then use Diff to control how near the dot needs to
be to the close for it to be seen. (This keeps the chart from shrinking.)

Use Median to add median lines.

Set MyColor (below) to be the colors for each Pitchfork



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++

Notes to Chris Cheatham version dated 2/25/01

Greg's original work is outstanding.  I took it a step further and added a
few more

variables/enhancements.
Unfortunately due to needing to organize for  memory efficiency, my adoption
is not as easy to

follow as the original.
The engine works about the same though.

Additions:
1.  Made two versions -- one for log scale and one for linear scale.
2.  Added codes for various offsets of the start point (point A):
      Offset  -- "O" added to end of point A offsets point A 50% of AB
distance toward B   (for

example, AO or A1O).
      Reverse Offset  -- "R" added to end of point A offsets point A 50% of
AB distance away from

B   (for example, AR or A1R).
      Shoulder Pattern  --  "S" added to end of point A moves point A to the
price of point C.

(for example, AS or A1S).
      You don't have to add the codes to point B or point C.
3.  Ability to pick letters to use for marking pivots so as not to conflict
with possible ABC

Elliott labels.
     (point1, point2, point3)  You must have the quotes in the input box or
it will not work.

Use CAPITAL letters.
4.  Uses the color of the 1st point text, e.g., "A," to determine the color
or the channels.
     automatically colors "B" and "C" to match "A." So if you want to change
the color of a set

of channels,
     just change "A" and refresh indicator.
5.  Added input switch for changing alert characteristics of channels.
6.  Added input switch for changing style characteristics of channels.

Deletions:
1.  Will not actually plot anything -- just draws channels.
2.  No longer has the TLs connecting A to B and A to C.
3.  Only allows 4 sets of channels per use, instead of 7 in original
version.


Other:
1.  I have noticed that on occasion with  log charts, the lines will not be
parallel the first

time drawn.
     If this happens just refresh the indicator and it should be fine.
2.  The log version uses 2 non-Omega user functions, Log10, and TLValueLog.
3.  I have been told that neither the original nor my versions works with
2000i products.  Have
not tried it and not sure why.

Good Luck,
Chris Cheatham
Nchrisc@xxxxxxxxxx


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++
UPDATE TO VERSION 4.01:

1.  Fixed Log scale need to refresh an extra time problem
2.  Fixed a little bug that caused letters to continue be moved if H= C
3.   Noted a difference between code and documentation on reverse offset -
actually is coded as

100% of A-B instead of 50%.  Upon reflection this seems better than my
original intent.  Did not
change code.

Addendum:  From Peter Ryan, Code-List 6 Apr 1999 22:27:13 +0800
"I found an error in the Andrew's Pitchfork v2 indicator posted in November.

The statement "while handl > 0 begin" should read "while handl >= 0 begin"

I found that if the only objects on the chart were A, B and C, then the
first object reference used is zero.  The existing logic would ignore the
first text label, and produce nothing."

Also by Wayne Mathews:
1.  " the "for xx = 0 to 6  begin" loop to activate
 "TL_SetExtRight(plots[xx],true);" does not work for me in TS2K. I commented
out
 the "SetExRight" and substituted just before the for loop code the
following.

 TL_SetExtRight(handla,true);TL_SetExtRight(handlb,true);
 TL_SetExtRight(handlc,true);
 TL_SetExtRight(handlb1,true);TL_SetExtRight(handlb2,true);
 TL_SetExtRight(handlc1,true);TL_SetExtRight(handlc2,true);"

2. The line "if vv[jj,ii] > mpt then begin" should read "if vv[jj,ii] > C
then begin"

3. To more easly read the code

 vv2[0,ii] = iff(codea[0,ii] = "O",  vv[0,ii] /2 + vv[1,ii]  /2,
iff(codea[0,ii] = "R",
   vv[0,ii] + iff(vv[0,ii] >vv[1,ii] , 1,-1)  *   AbsValue(vv[0,ii]  -
vv[1,ii] )  ,
    iff(codea[0,ii] = "S",   vv[2,ii],    vv[0,ii]))) ;

I have rewritten it as (but not substituted it here)

if codea[0,ii] = "O" then
 vv2[0,ii]= (vv[0,ii]  + vv[1,ii] ) /2
else
 if codea[0,ii]="R" then
  if vv[0,ii]>vv[1,ii] then
     vv2[0,ii]= vv[0,ii]+1* AbsValue(vv[0,ii]- vv[1,ii]  )
  else
        vv2[0,ii]= vv[0,ii]+(-1* AbsValue(vv[0,ii]- vv[1,ii]))
 else
  if codea[0,ii]="S" then
     vv2[0,ii]= vv[2,ii]
  else
     vv2[0,ii]= vv[0,ii];

}



input:   Median(1), Beep(0), Thick(0), Style(0),  Point1("A"), Point2("B"),
Point3("C");

if currentbar = 1 then begin
array:abc[3]("");
abc[0] = point1;  abc[1] = point2;  abc[2] = point3;

array:nums[4]("");
nums[0] = "";  nums[1] = "1";  nums[2] = "2";  nums[3] = "3";
end;

array:code[4]("");
code[0] = "";  code[1] = "S";  code[2] = "O"; code[3] = "R";

array:dd[3,4](0),tt[3,4](0),vv[3,4](0),bb[3,4](0),hh[3,4](0), vv2[3,4](0),
plots[7](0) ,

codea[3,4]("");
var: fvv(0),  pvv(0), fbb(0), pbb(0), pvv2(0),PVVB(0), PVVC(0),   ii(0),
jj(0) ,  kk(0), xx(0) ;
var: handl(0), handlA(0), handlB(0), handlC(0), handlB1(0), handlC1(0),
handlB2(0), handlC2(0),

ss("") ;


if currentbar = 1 then begin
  handl = text_getfirst(2);
  while handl >= 0 begin
    ss =  text_getstring(handl);
    for ii = 0 to 3 begin
      for jj = 0 to 2 begin
      for kk = 0 to 3 begin
        if ss = abc[jj] + nums[ii] + code[kk] then begin
          tt[jj,ii] = text_gettime(handl);
          dd[jj,ii] = text_getdate(handl);
          vv[jj,ii] = text_getvalue(handl);
            hh[jj,ii] = handl;
      codea[jj,ii] = RightStr(text_getstring(hh[jj,ii] ),1) ;

        end;
       end;

    end;
    end;
  handl = text_getnext(handl,2);
  end;
end;



for ii = 0 to 3 begin
for jj = 0 to 2 begin
if time = tt[jj,ii] and date = dd[jj,ii] then begin
bb[jj,ii] = currentbar;

if vv[jj,ii] > C  then begin
 vv[jj,ii] = h;
 Text_SetLocation(hh[jj,ii],dd[jj,ii],tt[jj,ii],h);
 Text_SetStyle(hh[jj,ii],2,1);
 Text_SetColor(hh[jj,ii],Text_GetColor(hh[0,ii]));
end else begin
 vv[jj,ii] = l;
 Text_SetLocation(hh[jj,ii],dd[jj,ii],tt[jj,ii],l);
 Text_SetStyle(hh[jj,ii],2,0);
 Text_SetColor(hh[jj,ii],Text_GetColor(hh[0,ii]));
end;

if c<>C then   plot1(vv[jj,ii],"Selection");

vv2[0,ii] = iff(codea[0,ii] = "O",  vv[0,ii] /2 + vv[1,ii]  /2,
iff(codea[0,ii] = "R",
   vv[0,ii] + iff(vv[0,ii] >vv[1,ii] , 1,-1)  *   AbsValue(vv[0,ii]  -
vv[1,ii] )  ,
    iff(codea[0,ii] = "S",   vv[2,ii],    vv[0,ii]))) ;

if jj = 2 then begin

fbb = bb[1,ii] / 2 + bb[2,ii] / 2;

 fvv = vv[1,ii] / 2 +vv[2,ii] / 2;
 pvv = TLValue(vv2[0,ii],bb[0,ii],fvv,fbb,currentbar);
 pvvB =TLValue(vv[1,ii],bb[1,ii], fvv +  vv[1,ii] - vv2[0,ii]

,fbb+bb[1,ii]-bb[0,ii],currentbar);
 pvvC = TLValue(vv2[0,ii] - (fvv - vv[2,ii]  )   ,

bb[0,ii]+(bb[2,ii]-fbb),vv[2,ii],bb[2,ii],bb [1,ii]);


handlA = TL_New(dd[0,ii],tt[0,ii], vv2[0,ii],date,time,pvv);
handlB = TL_New(dd[1,ii],tt[1,ii],vv[1,ii],date,time,pvvB);
handlC = TL_New(dd[1,ii],tt[1,ii],pvvC,date,time,vv[2,ii]);

if median = 1 then begin
    handlB1 = TL_New(dd[1,ii],tt[1,ii], vv[1,ii] - (vv[1,ii]- pvvC)/4,
date,time, pvvB - (pvvB

- vv[2,ii])/4 ) ;
    handlB2 = TL_New(dd[1,ii],tt[1,ii], vv[1,ii] + (vv[1,ii] - pvvC)/4 ,
date,time, pvvB+ (pvvB

- vv[2,ii])/4 ) ;
    handlC1 = TL_New(dd[1,ii],tt[1,ii], pvvC+ (vv[1,ii] -pvvC)/4,
date,time,   vv[2,ii] + (pvvB

- vv[2,ii] )/4) ;
    handlC2 = TL_New(dd[1,ii],tt[1,ii], pvvC-(vv[1,ii] -pvvC)/4, date,time,
vv[2,ii]- (pvvB -

vv[2,ii] )/4);
 end;

plots[0] = handla;
plots[1] = handlb;
plots[2] = handlc;
plots[3] = handlb1;
plots[4] = handlb2;
plots[5] = handlc1;
plots[6] = handlc2;


TL_SetExtRight(handla,true);TL_SetExtRight(handlb,true);
TL_SetExtRight(handlc,true);
TL_SetExtRight(handlb1,true);TL_SetExtRight(handlb2,true);
TL_SetExtRight(handlc1,true);TL_SetExtRight(handlc2,true);


for xx = 0 to 6  begin
 TL_SetStyle(plots[xx],style);
 TL_SetSize(plots[xx],thick);
 TL_SetAlert(plots[xx],beep);
{ TL_SetExtRight(plots[xx],true);
} TL_SetColor(plots[xx] , Text_GetColor(hh[jj,ii]));
end;
end;
end;
end;
end;





----- Original Message -----
From: "Jimmy Snowden" <jhsnowden@xxxxxxx>
To: <Omega-list@xxxxxxxxxx>
Sent: Monday, January 06, 2003 4:13 PM
Subject: Andrews Median line


> Omega-list,
>
> Does anyone have TS2ki code for the Andrews Median line or Pitchfork?
> I would like to take a look at it.
>
> --
> Best regards,
>  Jimmy                          mailto:jhsnowden@xxxxxxx
>