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

Re: Andrews methods - review



PureBytes Links

Trading Reference Links

Ed & List,

Sorry on the attachment.I dont know what the problem was but here is
the code you can paste in the PowerEditor.

Alan.
###################################################

input: TL_Thick(1);
{ ======================================
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/28/97 v2.0 - Configured for freeware post at http://www.stenbros.com/
========================================}

{ 
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.

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

if currentbar = 1 then begin { initialize control arrays }
   array: MyColor[7](0);
      MyColor[0] = tool_red;        { <=========== SET COLORS HERE }
	MyColor[1] = tool_blue;
	MyColor[2] = tool_yellow;
	MyColor[3] = tool_cyan;
	MyColor[4] = tool_green;
	MyColor[5] = tool_white;
	MyColor[6] = tool_darkyellow;
   array:abc[3]("");  { The basic point labels }
      abc[0] = "A";
      abc[1] = "B";
      abc[2] = "C";
   array:nums[7]("");  { The way to distinguish one series of points
from another, A-B-C, A1-B1-C1, etc }
      nums[0] = "";
      nums[1] = "1";
      nums[2] = "2";
      nums[3] = "3";
      nums[4] = "4";
      nums[5] = "5";
      nums[6] = "6";
      var: inums(7);
end;

array:dd[3,7](0),tt[3,7](0),vv[3,7](0),bb[3,7](0),hh[3,7](0);
var: tft(0), fdd(0), fvv(0), ptt(0), pdd(0), pvv(0), fbb(0), pbb(0),
pvv2(0);
var: ii(0), jj(0), mm(0);
var: handl(0), handlA(0), handlB(0), handlC(0);
var: ss("");
var: y1(0), y2(0);

if currentbar = 1 then begin { examine all the text strings and save
some info about the ones we recognize }
   handl = text_getfirst(2);
   while handl > 0 begin
      ss = text_getstring(handl);
      for ii = 0 to inums - 1 begin
         for jj = 0 to 2 begin { look for well-formed strings }
            if ss = abc[jj] + nums[ii] then begin { save the item's
date, time, value and handle }
               tt[jj,ii] = text_gettime(handl);
               dd[jj,ii] = text_getdate(handl);
               vv[jj,ii] = text_getvalue(handl);
               hh[jj,ii] = handl;
            end;
         end;
      end;
      handl = text_getnext(handl,2); { IMPORTANT -- infinite loop if
this is missing!  }
   end;
end;

for ii = 0 to inums - 1 begin { check each series... }
   for jj = 0 to 2 begin { check each point }
      if time = tt[jj,ii] and date = dd[jj,ii] then begin { we've
found a selected point }
         bb[jj,ii] = currentbar; { remember where we found it }
         if vv[jj,ii] > c then begin { move the label above the bar
and center it }
            vv[jj,ii] = h;
           
Text_SetLocation(hh[jj,ii],text_GetDate(hh[jj,ii]),text_GetTime(hh[jj,ii]),h);
            Text_SetStyle(hh[jj,ii],2,1);
         end else begin { move the label below the bar and center it }
            vv[jj,ii] = l;
           
Text_SetLocation(hh[jj,ii],text_GetDate(hh[jj,ii]),text_GetTime(hh[jj,ii]),l);
            Text_SetStyle(hh[jj,ii],2,0);
         end;
         plot1(vv[jj,ii],"Selection"); { show the user which point we
used for the calculations }
         if jj = 2 then begin { we're at the third point, generally
the Cx }
		handl = TL_New(dd[0,ii],tt[0,ii],vv[0,ii],dd[1,ii],tt[1,ii],vv[1,ii]);
            TL_SetExtLeft(handl,false);
            TL_SetExtRight(handl,false);
		TL_SetColor(handl,MyColor[ii]);
		TL_SetSize(handl, TL_Thick);

		handl = TL_New(dd[0,ii],tt[0,ii],vv[0,ii],dd[2,ii],tt[2,ii],vv[2,ii]);
            TL_SetExtLeft(handl,false);
            TL_SetExtRight(handl,false);
		TL_SetColor(handl,MyColor[ii]);
		TL_SetSize(handl, TL_Thick);

            fbb = bb[1,ii] / 2 + bb[2,ii] / 2;
            fvv = vv[1,ii] / 2 + vv[2,ii] / 2;
            pvv = TLValue(vv[0,ii],bb[0,ii],fvv,fbb,currentbar);
            handlA = TL_New(dd[0,ii],tt[0,ii],vv[0,ii],date,time,pvv);
            TL_SetExtRight(handlA,TRUE);
		TL_SetColor(handlA,MyColor[ii]);
		TL_SetSize(handlA, TL_Thick);

            pvv =
TLValue(vv[1,ii],bb[1,ii],fvv+vv[1,ii]-vv[0,ii],fbb+bb[1,ii]-bb[0,ii],currentbar);
            handlB = TL_New(dd[1,ii],tt[1,ii],vv[1,ii],date,time,pvv);
            TL_SetExtRight(handlB,TRUE);
		TL_SetColor(handlB, MyColor[ii]);
		TL_SetSize(handlB, TL_Thick);

            pvv =
TLValue(vv[0,ii]-(fvv-vv[2,ii]),bb[0,ii]+(bb[2,ii]-fbb),vv[2,ii],bb[2,ii],bb[1,ii]);
            handlC = TL_New(dd[1,ii],tt[1,ii],pvv,date,time,vv[2,ii]);
            TL_SetExtRight(handlC,TRUE);
		TL_SetColor(handlC, MyColor[ii]);
		TL_SetSize(handlC, TL_Thick);
         end;
      end;
   end;
end;