Page 1 of 1
Time of yesterday's high
Posted: 08 Jun 2010
by Joogen
Hi,
how could I get the time of yesterday's high for use in a strategy based on intraday data?
Thank you.
Posted: 08 Jun 2010
by Anastassia
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
Posted: 08 Jun 2010
by Joogen
Hi Anastaccia,
Thank you.
And how do I get the time stamp, when the day high of yesterday occured?
Posted: 08 Jun 2010
by Anastassia
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 ;
Posted: 08 Jun 2010
by Joogen
Really? It seems to be the time of the first bar of the day...
Posted: 08 Jun 2010
by Anastassia
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 ;
Posted: 08 Jun 2010
by Joogen
Unfortunately it doesn't work. Time ist time of previous' days last bar...
Posted: 09 Jun 2010
by Joogen
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]