Time of yesterday's high

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
Joogen
Posts: 9
Joined: 27 May 2009

Time of yesterday's high

Postby Joogen » 08 Jun 2010

Hi,

how could I get the time of yesterday's high for use in a strategy based on intraday data?
Thank you.

User avatar
Anastassia
Posts: 179
Joined: 18 Jan 2010
Been thanked: 4 times

Postby Anastassia » 08 Jun 2010

Hi Joogen,

Please try to get the time of yesterday's high in the strategy based on intraday data using the code below:

Code: Select all

variables:
   varPrevHigh( 0 ),
   varCurrHigh( 0 );
   
if Date <> Date[1] then
   begin
   varPrevHigh = varCurrHigh ;
   varCurrHigh = High ;
   end
else
   begin
   if High > varCurrHigh then
      varCurrHigh = High ;
   end ;


Thank you

Joogen
Posts: 9
Joined: 27 May 2009

Postby Joogen » 08 Jun 2010

Hi Anastaccia,

Thank you.
And how do I get the time stamp, when the day high of yesterday occured?

User avatar
Anastassia
Posts: 179
Joined: 18 Jan 2010
Been thanked: 4 times

Postby Anastassia » 08 Jun 2010

Hi again,

VarPrevTime is the time stamp, when the day high of yesterday occurs.

Code: Select all

variables:
   varPrevHigh( 0 ),   varPrevTime( 0 ),
   varCurrHigh( 0 );
   
if Date <> Date[1] then
   begin
   varPrevHigh = varCurrHigh ;
   varPrevTime = time;
   varCurrHigh = High ;
   end
else
   begin
   if High > varCurrHigh then
      varCurrHigh = High ;
   end ;

Joogen
Posts: 9
Joined: 27 May 2009

Postby Joogen » 08 Jun 2010

Really? It seems to be the time of the first bar of the day...

User avatar
Anastassia
Posts: 179
Joined: 18 Jan 2010
Been thanked: 4 times

Postby Anastassia » 08 Jun 2010

please try this

Code: Select all

variables:
   varPrevHigh( 0 ),
   varPrevTime( 0 ),
   varCurrHigh( 0 ),
   varCurrTime( 0 );
   
if Date <> Date[1] then
   begin
   varPrevHigh = varCurrHigh;
   varPrevTime = varCurrTime;
   varCurrTime = Time;
   varCurrHigh = High;
   end
else
   begin
   if High > varCurrHigh then
      varCurrTime = Time;
      varCurrHigh = High;
   end ;

Joogen
Posts: 9
Joined: 27 May 2009

Postby Joogen » 08 Jun 2010

Unfortunately it doesn't work. Time ist time of previous' days last bar...

Joogen
Posts: 9
Joined: 27 May 2009

Postby Joogen » 09 Jun 2010

I think I have a solution now. You only have to define or calculate Length input dependent on data resolution.

Code: Select all

Input: Length(840);
vars:timeofbarsago(0), counter(0);


If Date<>Date[1] Then begin
For counter = 1 to Length
   begin
   if H[counter] = HighD(1) then timeofbarsago = time[counter];
   end;
end;
Plot1(timeofbarsago,"xxx");
[/code]


Return to “User Contributed Studies and Indicator Library”