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

Re: paint bar code help



PureBytes Links

Trading Reference Links

Good description - easy to understand.

The case of marking trading days is easier since you just have to
count them. This is the "if IMode = 1" section of the code below. You
may need to modify the statement:

    if Mod(Count, Days) = 0

from zero to some other number since it wasn't clear when you wanted
to start plotting.

The case of marking calendar days is more complicated. You need to
convert dates to Julian dates and increment to the next date even
when the target date falls on a non-trading day. The "if IMode = 2"
section of the code below should be close.

Bob Fulks

---



Inputs: StrtDate(1010115), Days(5), IMode(1);

Vars: Count(0), JDateNxt(DateToJulian(StrtDate));   {Inialize variables}
  
if IMode = 1 and Date >= StrtDate then begin
   Count = Count +1;                                {Count trading days}
   if Mod(Count, Days) = 0 then                     {Plot every "Days" days}
      PlotPaintBar(High, Low, "PB1");
end;

{Plot if Julian dates match}
if IMode = 2 and DateToJulian(Date) = JDateNxt then begin
   PlotPaintBar(High, Low, "PB1");                 
end;

{Update to next Julian date on next trading day}
if DateToJulian(Date) >= JDateNxt then begin
   JDateNxt = JDateNxt + Days;
end;



>Trying to program a Paint Bar study in 2000i.
>
>It is very simple but I do not know how to do it. If
>anyone is willing to take a stab at it, I would be
>greatful.
>
>I would like to *manually* input a specific start
>date.
>
>Then, going forward from the start date, paint each
>bar that corresponds to a specific number of calendar
>days in a number series.
>
>For example, manually input start date: January 15,
>2002.
>
>Paint each bar that corresponds to the following
>number series, based on calendar days.
>
>5
>10
>15
>..etc  up to, say, 30
>
>So first bar Painted would be Jan 19th, etc.
>
>Ideally I would like this Paint Bar based on both
>calendar days, and trading days (either two seperate
>Paint Bar studies, or, have ability to toggle within
>one study).
>
>In advance, thanks.
>
>-RNM