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

Date PaintBar Routine



PureBytes Links

Trading Reference Links

Stephen Whiteside asked about how to do a paintbar study such that
a given bar (defined by date and time) would be painted.

Well, the task seems simple BUT if you want to be explicitly correct
in this application then care needs to be exercised.

The following (.ela attached) is a GENERAL solution to the problem
and you may find it useful.  It is really an overkill but does show
some programming concepts that the less experienced might find
useful in this or other applications.

Clyde



{PaintBar:   Whiteside_PaintDate

 Purpose:    paint the bar(s) of an entered date and time or
             if entered time is zero then paint ALL bars on
       the entered date.  Date and time matches MUST
       be found to accomplish this.

}



Input:  Date1(1020412),Time1(0),
        Date2(1020414),Time2(0),
        Date3(1020514),Time3(0),
        Date4(1020517),Time4(0),
        Date5(1020616),Time5(0),
        Date6(1020618),Time6(0);


Array:  InDate[6](0), InTime[6](0);
Vars:   DoInit(true), DateKnt(0);

If DoInit then begin
 DoInit=False;

 If Date1<>0 then begin
  DateKnt=DateKnt+1;
  Indate[DateKnt]=Date1;
  Intime[DateKnt]=Time1;
 end;
 If Date2<>0 then begin
  DateKnt=DateKnt+1;
  Indate[DateKnt]=Date2;
  Intime[DateKnt]=Time2;
 end;
 If Date3<>0 then begin
  DateKnt=DateKnt+1;
  Indate[DateKnt]=Date3;
  Intime[DateKnt]=Time3;
 end;
 if Date4<>0 then begin
  DateKnt=DateKnt+1;
  Indate[DateKnt]=Date4;
  Intime[DateKnt]=Time4;
 end;
  if Date5<>0 then begin
  DateKnt=DateKnt+1;
  Indate[DateKnt]=Date5;
  Intime[DateKnt]=Time5;
 end;
  If Date6<>0 then begin
  DateKnt=DateKnt+1;
  Indate[DateKnt]=Date6;
  Intime[DateKnt]=Time6;
 end;

{The following sort really is not needed if you scan all entries each date
as is done below}

  If DateKnt>1 then begin
  For Value1=1 to DateKnt-1 begin
   For Value2=Value1+1 to DateKnt begin
    If (InDate[Value2]<InDate[Value1]) or
      (InDate[Value2]=InDate[Value1]  and InTime[Value2]<InTime[Value1])
then begin

Value4=InDate[Value2];InDate[Value2]=InDate[Value1];InDate[Value1]=Value4;

Value4=InTime[Value2];InTime[Value2]=InTime[Value1];InTime[Value1]=Value4;
    End;
   End;
  End;
  End;
End;


{you could increment EndKnt and only 1 bar would be painted for any given
date}

Vars:  EndKnt(1);

For EndKnt=1 to DateKnt begin
 If InDate[EndKnt]=Date and (InTime[EndKnt]=Time or InTime[EndKnt]=0) then
begin
  PlotPaintBar(High, Low, "WDate");
 End;
End;



- - - - - - - - - - - - - - - - - - - - -  - - - - - - -
Clyde Lee   Chairman/CEO          (Home of SwingMachine)
SYTECH Corporation          email: clydelee@xxxxxxxxxxxx
7910 Westglen, Suite 105       Office:    (713) 783-9540
Houston,  TX  77063               Fax:    (713) 783-1092
Details at:                      www.theswingmachine.com
- - - - - - - - - - - - - - - - - - - -  - - - - - - - -



Attachment: Description: "WHITDATE.ELA"