|
How to use Time in calculations
I am new to MQL4 and was just trying to see if I could make a simple EA that would use some basic functions. I know C++ well but must be awful at MQL4 because I something is worng with this code and I think it has to do with the time functions or possibably the buy/sell functions, heres the code: ...and by the way this wasnt designed to make money just test the functions Thanks!
int start()
{
//----
double currenttimeN, currentvalue;
double timeM = TimeMinute (TimeCurrent());
double timeH = TimeHour(TimeCurrent());
currenttimeN = (timeH / 24) + (timeM / 1440);//gives the time of day as a percent or 1 (1 = one complete day) so always less than 1
currentvalue = Ask;
if (currentvalue > currenttimeN){
OrderSend(Symbol(),OP_SELL,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
}
/* BUY COMMAND */
else if (currentvalue < currenttimeN){
OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
}
//----
return(0);
}
|