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

Re: Daily DMI on 5 min. bars



PureBytes Links

Trading Reference Links

On Nov 26, 12:46pm, NM wrote:
> I am trying to plot DMI indicator on 5 min chart based on daily activity.
> (Not by ploting the indicator based on data2)
> Does anyone know the code?

Are you saying you want to know the value of DMI as if it were
calculated on daily data?  I think you'll probably have to
roll your own.  The basic idea is, you'll need to keep separate
arrays that track the daily open/high/low/close data, and then
pass those values to DMI_Custom.  Something like the following,
which is modeled after Omega's HighD function.  I haven't
tried verifying this, but it may serve as a start.

{
   Function: DMI_Daily - calculate Daily DMI using intraday data.

   requires intraday data 

   If there are M bars in a day, and N days used in the calculation of DMI,
   then this function will require ((N+1)*M+Maxbarsback) bars
   before it can return the first DMI_Daily value.  To calulate
   DMI for 14 days on 5 min. data with MAXBARSBACK set to 50,
   then 1400 bars are required before the first value will be
   returned.

   author: Gary Funck <gary@xxxxxxxxxxxx>,  Nov. 26, 1999

}
inputs: Length(numeric);
var: Daysdone(0);
array: Opena[50](-1), Closea[50](-1), Lowa[50](-1), Higha[50](-1);
if Datacompression < 2 and Length <= 50 then begin
    if Date > Date[1]  then begin
        Daysdone = Daysdone + 1;
        for Value1 = Length downto 1 begin
            Opena[Value1] = Opena[Value1 - 1];
            Higha[Value1] = Higha[Value1 - 1];
            Lowa[Value1] = Lowa[Value1 - 1];
            Closea[Value1] = Closea[Value1 - 1];
        end;
        Opena[0] = Open;
        Higha[0] = High;
        Lowa[0] = Low;
    end;
    Closea[0] = Close;
    if Daysdone > 0 then begin
        if High > Higha[0] then Higha[0] = High;
        if Low  < Lowa[0]  then Lowa[0]  = Low;
    end;
    if Daysdone >= Length then begin
	DMI_Daily = DMI_Custom(Higha, Lowa, Closea, Length);
    end;
end;