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

Re: Click Debugger



PureBytes Links

Trading Reference Links

> As my code gets ever more complex, with functions calling functions
> and virtual bars and array values and on and on... I'm trying to use
> an "input" of some kind to "pause" the execution wherever I want, so
> I can better isolate sub-loops etc. within the execution of a
> particular bar or set of bars. 

As Bob said, you're asking for the unreasonable:  for TS to 
include debugging capabilities that have been taken for granted 
in most coding environments for at least 20 years.

> I had merely recalled a question raised by someone who wanted to
> input values by clicking on particular bars on a chart. And I thought
> that with this method of inputting, if it could perhaps "mark" a bar
> or something similar, could better isolate the sections I want to
> examine. 

There's no way for your clicks to get fed into your indicator.  
EL has no concept of interrupt- or event-driven code to handle an 
interactive model like that.

You need to use something that EL can do as it's scanning through 
the chart.  The most common way I've seen to do this is to mark a 
bar with a text string, then use the text functions to locate 
that string and determine what bar it's closest to.  

Gregory Woods used this technique in his Andrews Pitchfork 
indicator.  The Purebytes archive seems to be messed up now so I 
can't point you to a copy of it, so here's his code.  There's a 
lot more here than just grabbing text markers, but look for the 
text_getfirst(2) call and you should be able to dig out what you 
need.

Gary

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

input: TL_Thick(0);
{ ======================================
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] = "r";
      abc[1
] = "t";
      abc[2] = "y";
   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],curr
en tbar);
            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;