So I should be able to create my own function for trading within a time range by using the date and time functions and using bool of some type ? This is going to make my eyes blurry. Back to the drawing board again. I'll post me code of my own invention to get some feedback and/or advise on it once completed.
I have some code that sets a bool depending on time of day allowed to trade . . . the tricky bit it to get it right if the start time is greater than the finish time, e.g. allow trading from 10pm to 8am.
RaptorUK:
I have some code that sets a bool depending on time of day allowed to trade . . . the tricky bit it to get it right if the start time is greater than the finish time, e.g. allow trading from 10pm to 8am.
The comments are there for a specific reason . . .
//extern double TradeHr.UTC.Start = 7.3; // London-1//extern double TradeHr.UTC.End = 12.9; // NY open
add these externs and this is where you set your start time (TradeHr.UTC.Start) and finish time (TradeHr.UTC.End)
TradeHr.UTC.End is a variable name . . .
There is no conditional statement to allow trading . . . you need to add it, if the code runs to the end then it's OK to trade as it is within the allowed hours . . otherwise the two returns exit the code early. You could build this into a function, change the returns to return(false); and add a return(true); at the very end . . .
Also you are going to have to look through WHRoeder's other code in the same thread to find the function for TimeGMT()
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
So I should be able to create my own function for trading within a time range by using the date and time functions and using bool of some type ?
This is going to make my eyes blurry. Back to the drawing board again.
I'll post me code of my own invention to get some feedback and/or advise on it once completed.
Thanks all
I have some code that sets a bool depending on time of day allowed to trade . . . the tricky bit it to get it right if the start time is greater than the finish time, e.g. allow trading from 10pm to 8am.
Hi with WHRoeder point 3 code.
int secStart = 14400*TradeHr.UTC.Start, // is this where you set the 4hr time
secEnd = 43200*TradeHr.UTC.End, // is this where for 12hr time
please explain .UTC.Start,
.UTC.End,
Also I don't see where is the
if conditional statement to allow trading.
Thanks
The comments are there for a specific reason . . .
add these externs and this is where you set your start time (TradeHr.UTC.Start) and finish time (TradeHr.UTC.End)
TradeHr.UTC.End is a variable name . . .
There is no conditional statement to allow trading . . . you need to add it, if the code runs to the end then it's OK to trade as it is within the allowed hours . . otherwise the two returns exit the code early. You could build this into a function, change the returns to return(false); and add a return(true); at the very end . . .
Also you are going to have to look through WHRoeder's other code in the same thread to find the function for TimeGMT()