TeeChart 8.02 Darvas Boxes

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Nina
Newbie
Newbie
Posts: 4
Joined: Wed Jun 01, 2005 4:00 am

TeeChart 8.02 Darvas Boxes

Post by Nina » Thu Mar 20, 2008 5:17 pm

How do I find the top and bottom of a darvas box? That is, I want to develop additional logic based on whether a new value will be within or outside a particular Darvas box.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 25, 2008 9:33 am

Hi Nina,

You can do something like this:

Code: Select all

  for i:=0 to Series1.Count - 1 do
  begin
    tmpL:=Series1.Boxes[i].Left;
    tmpR:=Series1.Boxes[i].Right;
    tmpT:=Series1.Boxes[i].Top;
    tmpB:=Series1.Boxes[i].Bottom;
  end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Nina
Newbie
Newbie
Posts: 4
Joined: Wed Jun 01, 2005 4:00 am

More on Darvas Boxes

Post by Nina » Mon Apr 28, 2008 10:52 pm

After trying the suggestion several times I am still unable to get the values for the hinges of the darvas boxes. What am I doing wrong?

I have defined the Darvas Series as:

Code: Select all

DarvasSeries1: TDarvasSeries;
I am adding data into the Darvas Series using:

Code: Select all

DarvasSeries1.AddOHLC(ADate,AOpen,AHigh,ALow,AClose);
Some of the sample data is:
Date,Open,High,Low,Close,Volume,Adj Close
080416,29.34,30.60,29.34,30.40,2882600,30.40
080417,30.51,30.69,29.88,30.09,1966100,30.09
080418,30.63,31.30,30.54,30.97,2172800,30.97
080421,30.72,30.99,30.38,30.66,1798900,30.66
080422,30.48,30.61,29.96,30.15,1512000,30.15
080423,30.14,31.19,30.13,31.04,2317800,31.04
080424,31.03,31.75,30.85,31.44,2384000,31.44
080425,31.54,31.79,30.95,31.53,2077600,31.53

The generated graph is at: http://winors.tzo.com/cgi-bin/darvas/a.jpg

When I used the suggested code (shown below) to access the last darvas boxes’ hinge, the values I get for Left, Right, Top, and Bottom are: 20905284.00, 0.00, 280.00, 16973824.00,

Code: Select all

      With DarvasSeries1 Do
      begin
        tmpL:=(Boxes[count-1].Left);
        tmpR:=(Boxes[count-1].Right);
        tmpT:=(Boxes[count-1].Top);
        tmpB:=(Boxes[count-1].Bottom);
      end;
I am obviously doing something wrong. Please help.


Thanks,
Nina[/img]

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Apr 29, 2008 9:48 am

Hi Nina,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue May 13, 2008 10:15 am

Hi Nina,

Thanks for the example project. You get an Access Violation because you are trying to retrieve Darvas boxes when they haven't been calculated because the chart hasn't being painted yet. A solution to this is making a call to TChart's Draw method before as shown in the code snippet below.

Code: Select all

      (* HERE IS WHERE I GET AN ACCESS VIOLATION *)
      AssignFile(Dfl,'DarvasHinges.txt');
      Rewrite(Dfl);
      showmessage(floattostr(darvasseries1.count))      ;

      Chart1.Draw;
      With DarvasSeries1 Do
      for ii := 0 to Count-1 Do
      begin
        tmpL:=(Boxes[ii].Left);
        tmpR:=(Boxes[ii].Right);
        tmpT:=(Boxes[ii].Top);
        tmpB:=(Boxes[ii].Bottom);
        Writeln(Dfl,TickerSS+' ',tmpR,' ',tmpR,' ',tmpT,' ',tmpB);
      end;
      CloseFile(Dfl);
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Nina
Newbie
Newbie
Posts: 4
Joined: Wed Jun 01, 2005 4:00 am

Darvas Hinges

Post by Nina » Wed May 21, 2008 3:15 pm

Hi,

The Chart1.Draw did solve the access violation. However, the numbers for the darvas hinges are still out of range -- that is they do not represent anything that i see on the screen.

~ nina

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 22, 2008 9:57 am

Hi Nina,

Using code below, in DarvasHinges.txt you get the candle's point indexes for the boxes in tmpL, tmpR, tmpT and tmpB.

Code: Select all

      (* HERE IS WHERE I GET AN ACCESS VIOLATION *)
      AssignFile(Dfl,'DarvasHinges.txt');
      Rewrite(Dfl);
      //showmessage(floattostr(darvasseries1.count))      ;
      Chart1.Draw;
      With DarvasSeries1 Do
      //for ii := 0 to Count-1 Do
      for ii := 0 to Length(Boxes) Do
      begin
        tmpL:=(Boxes[ii].Left);
        tmpR:=(Boxes[ii].Right);
        tmpT:=(Boxes[ii].Top);
        tmpB:=(Boxes[ii].Bottom);
        Writeln(Dfl,TickerSS+' ',tmpL,' ',tmpR,' ',tmpT,' ',tmpB);
      end;
      CloseFile(Dfl);
If you want to get the screen coordinates of the boxes you need to change the for loop like this:

Code: Select all

      for ii := 0 to Length(Boxes) Do
      begin
        tmpL:=CalcXPos(Boxes[ii].Left);
        tmpR:=GetVertAxis.CalcYPosValue(HighValues.Value[Boxes[ii].Right]);
        tmpT:=CalcXPos(Boxes[ii].Top);
        tmpB:=GetVertAxis.CalcYPosValue(LowValues.Value[Boxes[ii].Bottom]);

        Writeln(Dfl,TickerSS+' ',tmpL,' ',tmpR,' ',tmpT,' ',tmpB);
      end;
And if you want to retrieve series values corresponding to the boxes:

Code: Select all

      for ii := 0 to Length(Boxes) Do
      begin
        tmpL:=XValue[Boxes[ii].Left];
        tmpR:=HighValues.Value[Boxes[ii].Right];
        tmpT:=XValue[Boxes[ii].Top];
        tmpB:=LowValues.Value[Boxes[ii].Bottom];

        Writeln(Dfl,TickerSS+' ',tmpL,' ',tmpR,' ',tmpT,' ',tmpB);
      end;
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 22, 2008 10:09 am

Hi Nina,

Sorry but there's an error with my last 2 examples, tmpL, tmpR, tmpT and tmpB should be like this:

Code: Select all

        tmpL:=CalcXPos(Boxes[ii].Left);
        tmpT:=GetVertAxis.CalcYPosValue(HighValues.Value[Boxes[ii].Top]);
        tmpR:=CalcXPos(Boxes[ii].Right);
        tmpB:=GetVertAxis.CalcYPosValue(LowValues.Value[Boxes[ii].Bottom]);

Code: Select all

        tmpL:=XValue[Boxes[ii].Left];
        tmpT:=HighValues.Value[Boxes[ii].Top];
        tmpR:=XValue[Boxes[ii].Right];
        tmpB:=LowValues.Value[Boxes[ii].Bottom];
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Nina
Newbie
Newbie
Posts: 4
Joined: Wed Jun 01, 2005 4:00 am

Post by Nina » Thu May 22, 2008 3:46 pm

Hi Narcis,

Thanks so MUCH for your help. I finally can get to the hinges. Now the fun begins! As always, I am much impressed with the work being done at Steema and their customer support.

By the way, if someone is reading this thread -- the for loop should be 1 less than the length(boxes).

~ nina

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri May 23, 2008 7:09 am

Hi Nina,

You're welcome. I'm glad to hear that helped.

Yes, sorry, my fault, it should be like this:

Code: Select all

      for ii := 0 to Length(Boxes)-1 Do
      begin
        tmpL:=XValue[Boxes[ii].Left];
        tmpR:=HighValues.Value[Boxes[ii].Right];
        tmpT:=XValue[Boxes[ii].Top];
        tmpB:=LowValues.Value[Boxes[ii].Bottom];

        Writeln(Dfl,TickerSS+' ',tmpL,' ',tmpR,' ',tmpT,' ',tmpB);
      end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply