Bonjour à tous

Hello to all

Did post a similar post, but not resolved yet

memberlist.php?mode=viewprofile&u=11966

My day start @ 5pm and closed the following day @ 4:59:59. I'm looking to get the high and low for this period.

Highd: Does get the highest price of the last calendar day

DailyHigh witch is suppose to return the high of the last day session is not working

Any help appreciate

Martin

# How can I get the high and low of the previous day session

- TJ
**Posts:**7146**Joined:**29 Aug 2006**Location:**Global Citizen**Has thanked:**987 times**Been thanked:**2040 times

### Re: How can I get the high and low of the previous day sessi

arjfca wrote:Bonjour à tous

Hello to all

Did post a similar post, but not resolved yet

memberlist.php?mode=viewprofile&u=11966

My day start @ 5pm and closed the following day @ 4:59:59. I'm looking to get the high and low for this period.

Highd: Does get the highest price of the last calendar day

DailyHigh witch is suppose to return the high of the last day session is not working

Any help appreciate

Martin

Set your chart to exchange time, so that the begin and end time of the session are on the same day.

### Re: How can I get the high and low of the previous day sessi

Set your chart to exchange time, so that the begin and end time of the session are on the same day.

That could be a solution, but not the one that I want to use.

My view: Forex market do close @ 4:59:59 New-York time so trend and market participants do look at the high and low of the previous session. Maybe same reaction could be seen for session starting @00:00:00 and close at 23:59:59. I did not test it

Any one interested to see what is a short term effect on price when the high or the low of the previous day session is crossed, see this video from my mentor

http://www.youtube.com/watch?v=RgOofu7A ... 26lrLwLF8=

I will work on a function to get the high and low of the previous day session value and publish the code later.

Happy trading week to all

Martin

- TJ
**Posts:**7146**Joined:**29 Aug 2006**Location:**Global Citizen**Has thanked:**987 times**Been thanked:**2040 times

### Re: How can I get the high and low of the previous day sessi

arjfca wrote:Bonjour à tous

Hello to all

Did post a similar post, but not resolved yet

memberlist.php?mode=viewprofile&u=11966

My day start @ 5pm and closed the following day @ 4:59:59. I'm looking to get the high and low for this period.

Highd: Does get the highest price of the last calendar day

DailyHigh witch is suppose to return the high of the last day session is not working

Any help appreciate

Martin

I don't understand why you need to ask...

are you running a 24 hr chart?

what instrument you are tracking?

where is the exchange?

what is the chart resolution?

Code: Select all

`var:`

day.high(0),

day.low(0);

if t = 1700 then

begin

day.high = high;

day.low = low;

end

else

begin

if day.high < high then

day.high = high;

if day.low > low then

day.low = low;

end;

### Re: How can I get the high and low of the previous day sessi

Hello TJ

24Hr chart start end end with New-York time session

Exchange is in New-York

Instrument: Eur.Usd

Scale, chart resolution: 175 sec.

Just came back from a walk with the dog and I was thinking of a similar solution as yours. Will nee to add a condition that will switch from > 1700 to < 1700 after midnight

Martin

24Hr chart start end end with New-York time session

Exchange is in New-York

Instrument: Eur.Usd

Scale, chart resolution: 175 sec.

Just came back from a walk with the dog and I was thinking of a similar solution as yours. Will nee to add a condition that will switch from > 1700 to < 1700 after midnight

Martin

### Re: How can I get the high and low of the previous day sessi

Here is my solution

1' count the number of bars that compose the day

When done, then each time a day finished, look for the lowest and the highest price for the last number of bars that compose the day

Et voilà!

Martin

1' count the number of bars that compose the day

When done, then each time a day finished, look for the lowest and the highest price for the last number of bars that compose the day

Et voilà!

Martin

Code: Select all

`// return the high and low of the previous session day`

Var:

Intrabarpersist Barcount (0),

Intrabarpersist CountStart (false),

intrabarpersist Counting (true),

Intrabarpersist BarNum (0),

Intrabarpersist Dayhigh (0),

Intrabarpersist Daylow (0);

// count the numbers of bars during a day

If counting = true then begin

if time = 1700 and countstart = false then begin

Barcount = 0;

countstart = True;

BarNum = Barnumber;

end;

If countstart = True and barnum <> Barnumber then begin

Barcount = barcount +1;

BarNum = Barnumber;

If time = 1700 then begin

Counting = false;

Print (Barcount:0:0);

end;

end;

end;

//counting as been done and I know how many bars compose my day

// Now, found the highest and the lowest price for the previous barcount bars.

// This operation is done only when the day as been terminated

If counting = false and time = 1700 then begin

Dayhigh = highest(high,Barcount);

DayLow = lowest(low, barcount);

Print ( dayhigh:5:5, " " , daylow:5:5);

end;

### Re: How can I get the high and low of the previous day sessi

arjfca wrote:Here is my solution

1' count the number of bars that compose the day

When done, then each time a day finished, look for the lowest and the highest price for the last number of bars that compose the day

Et voilà!

MartinCode: Select all

`// return the high and low of the previous session day`

Var:

Intrabarpersist Barcount (0),

Intrabarpersist CountStart (false),

intrabarpersist Counting (true),

Intrabarpersist BarNum (0),

Intrabarpersist Dayhigh (0),

Intrabarpersist Daylow (0);

// count the numbers of bars during a day

If counting = true then begin

if time = 1700 and countstart = false then begin

Barcount = 0;

countstart = True;

BarNum = Barnumber;

end;

If countstart = True and barnum <> Barnumber then begin

Barcount = barcount +1;

BarNum = Barnumber;

If time = 1700 then begin

Counting = false;

Print (Barcount:0:0);

end;

end;

end;

//counting as been done and I know how many bars compose my day

// Now, found the highest and the lowest price for the previous barcount bars.

// This operation is done only when the day as been terminated

If counting = false and time = 1700 then begin

Dayhigh = highest(high,Barcount);

DayLow = lowest(low, barcount);

Print ( dayhigh:5:5, " " , daylow:5:5);

end;

Hello Martin,

I know this is an old post but your code works perfectly.

I'm only struggling to find a way to know wich is the most RECENT between the DayHigh and DayLow of the previous day.

I need tha latest max or min of the previous day to calculate some levels in the morning at the session open.

I thought that by using your Barcount and save it when the min or the max condition is met could be a solution . This is how I modified you final if:

Code: Select all

`If counting = false and time = 2200 then begin `

Dayhigh = highest(high,Barcount);

DayLow = lowest(low, barcount);

Print ( dayhigh:5:5, " " , daylow:5:5);

for ii = 1 to Barcount begin

if highest(high,ii) > todayMax then begin

todayMax = highest(high,ii);

barYMax = Barcount ;

end;

if lowest(low, ii) < todayMin then begin

todaymin = lowest(low, ii);

barYMin = Barcount ;

end;

end;

print(NewLine," ----------Max e Min DATE: ", FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," -- Time ",NumToStr(time,0), " ------ ");

print(NewLine," barYMax = ", NumToStr(barymax,0));

print(" barYMin = ", NumToStr(barymin,0));

end;

So simply by making a comparison between the barYMax and barYMin I should be able to know the most recent value.

Is there anything wrong?

Thanks,

Regards,

David

### Re: How can I get the high and low of the previous day session

arjfca wrote:Hello David

I did not try your code, but the logic is good

The oldest bar event( day_High or Day_Low) will be represent by the smallest bar number

BarMin_BarMax.png

Hello arjfca and thanks for you reply,

Ok so if you say that the code is good then there must be some other problem because I always get the barYMax with a value and barYMin zero.. always and sometime the barYMax has the same value for 3 or 4 days.. and that's not possible fo sure.

I used this to reset the values

Code: Select all

`if time = 115 then begin`

barYMax = 0;

barYMin = 0;

todayMax = 0;

todayMin = 30000;

end;

but it does not work.

I simply cannot find what the problem is....

Regards,

David

- TJ
**Posts:**7146**Joined:**29 Aug 2006**Location:**Global Citizen**Has thanked:**987 times**Been thanked:**2040 times

### Re: How can I get the high and low of the previous day session

dvdkite wrote: . . .

but it does not work.

I simply cannot find what the problem is....

Regards,

David

Please post a screen shot of your chart.

Please draw on the chart what you are looking for.

### Re: How can I get the high and low of the previous day session

TJ wrote:dvdkite wrote: . . .

but it does not work.

I simply cannot find what the problem is....

Regards,

David

Please post a screen shot of your chart.

Please draw on the chart what you are looking for.

Hello Tj,

As you wish here is the chart:

As I said I need to know at the session open in the morning ( so at 1:15 for the DAX for example) wich of the Yesterday High and Low are THE MOST RECENT. In the photo example the minimum was at the open (YMIN) and the maximum price was at 11:20 (YMAX) ... so the most recent is the YMAX and I need to know that at the session open in order to calculate some Gann levels.

As you seen above I've tryied to create a code that at the end of the session (22:00) performs a cicle throw all the bars of the day to find the day high and low and save the related bar number.... so at the session open I should simply be able to compare the Barnumber of the Ymax and YMin and assume that the bigger one is the most recent... but it doesn't work.

This is the output in powerlanguage MC editor:

Code: Select all

`----------Max e Min DATE: 28-03-2019 -- Time 2200 ------ `

barYMax = 247

barYMin = 0

11570.00000 11456.50000

----------Max e Min DATE: 29-03-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

11733.50000 11555.50000

----------Max e Min DATE: 01-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

11829.50000 11675.00000

----------Max e Min DATE: 02-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

11997.50000 11784.00000

----------Max e Min DATE: 03-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12053.00000 11931.00000

----------Max e Min DATE: 04-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12047.00000 11989.50000

----------Max e Min DATE: 05-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12028.50000 11962.00000

----------Max e Min DATE: 08-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12014.50000 11866.50000

----------Max e Min DATE: 09-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

11972.00000 11866.50000

----------Max e Min DATE: 10-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

11992.00000 11871.00000

----------Max e Min DATE: 11-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12059.00000 11916.00000

----------Max e Min DATE: 12-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12061.50000 12006.00000

----------Max e Min DATE: 15-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12143.00000 12035.50000

----------Max e Min DATE: 16-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12221.00000 12111.00000

----------Max e Min DATE: 17-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12292.00000 12124.00000

----------Max e Min DATE: 18-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12292.00000 12206.00000

----------Max e Min DATE: 23-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12379.00000 12216.50000

----------Max e Min DATE: 24-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12358.00000 12261.00000

----------Max e Min DATE: 25-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12349.50000 12275.00000

----------Max e Min DATE: 26-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12396.50000 12283.50000

----------Max e Min DATE: 29-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12395.00000 12295.00000

----------Max e Min DATE: 30-04-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

12420.50000 12276.50000

----------Max e Min DATE: 02-05-2019 -- Time 2200 ------

barYMax = 247

barYMin = 0

Clearly there's something wrong as you can see the in the output and I have several days with the same barYmax and that's almost impossible (it really uncommon that you have the max of the day at the same barnumber for three days in row). Also I always find a barYMin value equal to ZERO and that's wrong too.

Any ideas?

Just for reference this is the code used

Code: Select all

`// return the high and low of the previous session day`

Var:

Intrabarpersist Barcount (0),

Intrabarpersist CountStart (false),

intrabarpersist Counting (true),

Intrabarpersist BarNum (0),

Intrabarpersist Dayhigh (0),

Intrabarpersist Daylow (0);

// count the numbers of bars during a day

If counting = true then begin

if time = 1700 and countstart = false then begin

Barcount = 0;

countstart = True;

BarNum = Barnumber;

end;

If countstart = True and barnum <> Barnumber then begin

Barcount = barcount +1;

BarNum = Barnumber;

If time = 1700 then begin

Counting = false;

Print (Barcount:0:0);

end;

end;

end;

//counting as been done and I know how many bars compose my day

// Now, found the highest and the lowest price for the previous barcount bars.

// This operation is done only when the day as been terminated

If counting = false and time = 2200 then begin

Dayhigh = highest(high,Barcount);

DayLow = lowest(low, barcount);

Print ( dayhigh:5:5, " " , daylow:5:5);

// ---------------- FROM HERE THIS IS THE CODE I ADDED --------------------------

for ii = 1 to Barcount begin

if highest(high,ii) > todayMax then begin

todayMax = highest(high,ii);

barYMax = Barcount ;

end;

if lowest(low, ii) < todayMin then begin

todaymin = lowest(low, ii);

barYMin = Barcount ;

end;

end;

print(NewLine," ----------Max e Min DATE: ", FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," -- Time ",NumToStr(time,0), " ------ ");

print(NewLine," barYMax = ", NumToStr(barymax,0));

print(" barYMin = ", NumToStr(barymin,0));

end;