externint iOpenHour = 6;
int start()
{
int b, scannedhour;
datetime bartime;
double dibsclose, dibsopen, prevdayrange[4]; // prevdayrange Array Categorys ( 1 EURUSD, 2 GBPUSD, 3 USDCHF, 4 USDJPY )//----------------------------------------------------------------------------------------------// EURUSD PREV DAY RANGE CALCfor(b=0; b<=24; b++) // scans the last 24 bars on eurusd
{
bartime = iTime("EURUSD", 60, b); // checks the open time of each bar
scannedhour = TimeHour(bartime); // extracts the hour of that barif ( scannedhour == iOpenHour ) // Check to see if scanned hour = Dibs hour
{
dibsclose = iOpen("EURUSD", 60, b); // Get the open value of that bar (Close of 6gmt day)
dibsopen = iOpen("EURUSD", 60, b+24); // Get the value of the bar 24 bars before the Dibs bar (Open of 6gmt day)
prevdayrange[1] = (dibsclose-dibsopen); // Calculate the range of the Dibs day
} // End of if statement
} // End of for statement//----------------------------------------------------------------------------------------------// GBPUSD PREV DAY RANGE CALCfor(b=0; b<=24; b++) // scans the last 24 bars on eurusd
{
bartime = iTime("GBPUSD", 60, b); // checks the open time of each bar
scannedhour = TimeHour(bartime); // extracts the hour of that barif ( scannedhour == iOpenHour ) // Check to see if scanned hour = Dibs hour
{
dibsclose = iOpen("GBPUSD", 60, b); // Get the open value of that bar (Close of 6gmt day)
dibsopen = iOpen("GBPUSD", 60, b+24); // Get the value of the bar 24 bars before the Dibs bar (Open of 6gmt day)
prevdayrange[2] = (dibsclose-dibsopen); // Calculate the range of the Dibs day
} // End of if statement
} // End of for statement//----------------------------------------------------------------------------------------------// USDCHF PREV DAY RANGE CALCfor(b=0; b<=24; b++) // scans the last 24 bars on eurusd
{
bartime = iTime("EURUSD", 60, b); // checks the open time of each bar
scannedhour = TimeHour(bartime); // extracts the hour of that barif ( scannedhour == iOpenHour ) // Check to see if scanned hour = Dibs hour
{
dibsclose = iOpen("USDCHF", 60, b); // Get the open value of that bar (Close of 6gmt day)
dibsopen = iOpen("USDCHF", 60, b+24); // Get the value of the bar 24 bars before the Dibs bar (Open of 6gmt day)
prevdayrange[3] = (dibsclose-dibsopen); // Calculate the range of the Dibs day
} // End of if statement
} // End of for statement//----------------------------------------------------------------------------------------------// USDJPY PREV DAY RANGE CALCfor(b=0; b<=24; b++) // scans the last 24 bars on eurusd
{
bartime = iTime("USDJPY", 60, b); // checks the open time of each bar
scannedhour = TimeHour(bartime); // extracts the hour of that barif ( scannedhour == iOpenHour ) // Check to see if scanned hour = Dibs hour
{
dibsclose = iOpen("USDJPY", 60, b); // Get the open value of that bar (Close of 6gmt day)
dibsopen = iOpen("USDJPY", 60, b+24); // Get the value of the bar 24 bars before the Dibs bar (Open of 6gmt day)
prevdayrange[4] = (dibsclose-dibsopen); // Calculate the range of the Dibs day
} // End of if statement
} // End of for statement//----------------------------------------------------------------------------------------------Comment("EURUSD RANGE=", prevdayrange[1], //Display Ranges of each pair"GBPUSD RANGE=", prevdayrange[2],
"USDCHF RANGE=", prevdayrange[3],
"USDJPY RANGE=", prevdayrange[4]);
return(0);
}
Ok so I fixed it up so the prevdayrange is the only array. Now for some reason the USDJPY section of the code isn't working. It is the same as the other 4 statements with the pair changed in iopen's and the correct array value...
Ok so I fixed it up so the prevdayrange is the only array. Now for some reason the USDJPY section of the code isn't working. It is the same as the other 4 statements with the pair changed in iopen's and the correct array value...
Alright this code is pretty much doing what it is meant to except when a new 6:00 candle opens It doesn't update the information. If the current candle is a 6:00 candle I want it to scan that bars open and go back 24 bars and scan that bars open and do all the calcs and if the current bar is not a 6:00 bar then keep stepping back a bar until it finds the last 6:00 candle. It seems to be stepping back ok but doesn't seem to like if the current candle is the 6:00. Can't work it out. Can the legends spot the problem?
The code is getting too extensive to post on here so I had to upload the source code
I'll test your code at the next hour change because I can't see anything obvious . . . are you sure you were checking at 6am Server time ? local PC time is not necessarily the same time as Server time, server time is what is used in your code and on your charts.
Ok so I fixed it up so the prevdayrange is the only array. Now for some reason the USDJPY section of the code isn't working. It is the same as the other 4 statements with the pair changed in iopen's and the correct array value...
Here is what it does ---> http://clip2net.com/s/13WDY
How do you put spaces in the comment function and can you get it to print to the next line?
Ok so I fixed it up so the prevdayrange is the only array. Now for some reason the USDJPY section of the code isn't working. It is the same as the other 4 statements with the pair changed in iopen's and the correct array value...
Here is what it does ---> http://clip2net.com/s/13WDY
How do you put spaces in the comment function and can you get it to print to the next line?
The first element in an array is 0, if an array has 4 elements the last will be 3 not 4 ;-) https://docs.mql4.com/basis/variables
Comment()
Alright this code is pretty much doing what it is meant to except when a new 6:00 candle opens It doesn't update the information. If the current candle is a 6:00 candle I want it to scan that bars open and go back 24 bars and scan that bars open and do all the calcs and if the current bar is not a 6:00 bar then keep stepping back a bar until it finds the last 6:00 candle. It seems to be stepping back ok but doesn't seem to like if the current candle is the 6:00. Can't work it out. Can the legends spot the problem?
The code is getting too extensive to post on here so I had to upload the source code
It seems to be stepping back ok but doesn't seem to like if the current candle is the 6:00. Can't work it out. Can the legends spot the problem?
Is this using the Strategy Tester ? if it was . . .
Nope Raptor this was on a live chart., Should I change
Just thinking out aloud there not sure if that would fix anythingNope Raptor this was on a live chart., Should I change
Just thinking out aloud there not sure if that would fix anythingEverything seems to work fine but it won't pick up the 6:00 bar unless it is behind the current bar if that makes sense.
Thanks for your time Raptor
Everything seems to work fine but it won't pick up the 6:00 bar unless it is behind the current bar if that makes sense.
Thanks for your time Raptor
Yes I think I understand what you are saying, it doesn't update when the time changes from 05:59 to 06:00 . . .
I'm using MBT for testing and it's Server time for the current H1 bar is 04:00 so I have set iOpenHour to 5, lets see what happens in 20 mins.
OK, I have the same issue, no update when the current candle opened at 05:00 . . . . interesting.