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

Re: There's Something for Everyone Here!



PureBytes Links

Trading Reference Links


> >JACKPOT!   I must test this out, but it appears that the code
> >posted by Hans for the regression channels contains a way to mark
> >text on the chart, then have these points passed on into variables
> >for calculations.

I received the following privately:

> I didn't get your original e-mail...even checked trash (mostly
> greene...). Could you send it?  

NO - wasnt me <g> <g> <g>, mightbe be in the THE CODE xmas-packages 
we all received premature...

> Thanks!
> 
> Humbly in your debt <g>

whats new ?

I have 220++ UNread Omeaga messages at the moment as everbody trying 
to do some serious work cant keep up with reading this volume, not 
to mention trying to comment on every burp which is been posted, so 
didnt see the message you copied above........ just checked it now

There is a automatic LIN REG I know, which is fantastic and its done 
by GREG WOOD, he has done also other great work for labeling 
screens, but I have no idea whether that can do what is suggested 
here,,,,,,,,,,,it might

I did a text search for part of the code and I found its really from 
GREG and I copied the original code to the bottom - hope that helps

.....well at least Im the one and only HANS here so you know whom to 
ask, if they would have said JOHN, you would have been in 
trouble....hehe

rgds hans

~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------------------
input:  price(c), labTL("R"), colorTL(tool_GREEN), thickTL(0);

{ ======================================
This is my implementation of Linear Regression Channels. 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

01/26/97 v1.0 - Initial distribution
========================================}

{ 
USAGE

Use the text tool to indicate the beginning and end of the channel(s)
you want.  The default uses "R"s (upper case, no quotes). Then to show
the channel(s), go to Format Analysis Techniques, select this
indicator, and press the "Status" button two times (this is not a
double-click, really press it two times).

The channel is based on Price, which defaults to Close, but you can
change it to High or Low.

You can set the color and thickness of the channels.

You can show a series of channels by putting more "R"s on the chart. 
Each pair of "R"s will get its own channel.

If you want separate channels or different colors, you can add the
indicator multiple times. Be sure to give each one a different labTL
value.

}

array: dd[20](0),tt[20](0),vv[20](0),bb[20](0);
var: iMax(20), ix(0), hh(0), ll(0), hhbb(0), llbb(0);
var: pvv1(0), pbb1(0), pvv2(0), pbb2(0), x1(0), x2(0), y1(0), y2(0);
var: ii(0), jj(0), kk(0), hval(0), lval(0); var: handl(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
      if text_getstring(handl) = labTL then begin { save the item's
      date, time, value and handle }
            if ix < iMax - 1 then begin

      tt[ix] = text_gettime(handl);
                dd[ix] = text_getdate(handl);
                vv[ix] = text_getvalue(handl);
                ix = ix + 1;
           end;
      end;
      handl = text_getnext(handl,2); { IMPORTANT -- infinite loop if
      this is
missing!  }
   end;
end;

for ii = 0 to ix - 1 begin { check each point }
   if time = tt[ii] and date = dd[ii] then begin { we've found a
   selected
point }
      bb[ii] = currentbar; { remember where we found it }
      plot1(price,""); { show the user which point we used for the
calculations }
      if ii > 0 then begin { need at least 1 point }
         { The regression line passes through (x1,y1) and (x2,y2) } x1
         = bb[ii]; x2 = bb[ii-1]; y1 = LinearRegValue(price, x1-x2
         ,0); y2 = LinearRegValue(price, x1-x2, x1-x2);

         { Draw the regression line }
         handl = TL_New(date[currentbar-x2],time[currentbar-x2],y2,
date[currentbar-x1],time[currentbar-x1],y1 );
         TL_SetExtRight(handl, true);
         TL_SetExtLeft(handl, false);
         TL_SetSize(handl, thickTL);
         TL_SetColor(handl, colorTL);

         { find the max excursion on each side of the line }
         hval = 0;
         lval = 0;
         for kk = x2 to x1 begin
             value1 = pnt2line(x1,y1,x2,y2, barnumber[currentbar-kk],
high[currentbar-kk]);
             if value1 > 0 and hval < value1 then begin
                hval = value1;
                hh = h[currentbar-kk];
                hhbb = kk;
             end;
             value2 = pnt2line(x1,y1,x2,y2, barnumber[currentbar-kk],
low[currentbar-kk]);
             if value2 < 0 and lval > value2 then begin
                lval = value2;
                ll = l[currentbar-kk];
                llbb = kk;
             end;
         end;

         { Now draw the channel lines }
         plot2[currentbar-hhbb](hh,"");
         pvv1 = TLValue(ll,llbb, ll-(y2-y1), llbb-(x2-x1), x1);
         pvv2 = TLValue(ll,llbb, ll-(y2-y1), llbb-(x2-x1), x2);
         handl = TL_New(date[currentbar-x2],time[currentbar-x2],pvv2,
date[currentbar-x1], time[currentbar-x1],pvv1);
         TL_SetExtRight(handl, true);
         TL_SetExtLeft(handl, false);
         TL_SetSize(handl, thickTL);
         TL_SetColor(handl, colorTL);

         plot3[currentbar-llbb](ll,"");
         pvv1 = TLValue(hh,hhbb, hh-(y2-y1), hhbb-(x2-x1), x1);
         pvv2 = TLValue(hh,hhbb, hh-(y2-y1), hhbb-(x2-x1), x2);
         handl = TL_New(date[currentbar-x2],time[currentbar-x2],pvv2,
date[currentbar-x1], time[currentbar-x1],pvv1);
         TL_SetExtRight(handl, true);
         TL_SetExtLeft(handl, false);
         TL_SetSize(handl, thickTL);
         TL_SetColor(handl, colorTL);

      end;
   end;
end;

~~~~~
......I wanted to do this ever since I laid eyes on you !