Simple Fix involving TimeMinute (TimeCurrent())??

 

I made a trading application in VC++ and couldnt figure out how to send trade signals to MT4 so im stuck trying to make an expert advisor. So I wanted to start out with something simple and to get a feel for MT4 so I came up with this, forsome reason it doesnt work and I have no idea why. I think it might be something with getting the current time, or even the buy/sell comands might be wrong. PLEASE HELP!, and remember this EA wasent suppost to make money just test run the time and buy/sell functions...

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);
}

Thanks John,

 
you are comparing time to price
 
Russell wrote >>
you are comparing time to price

Yeah, I just wanted to get a feel for how the time function works. The time is a relationship and always less than one, so eather way it will sell or buy and for some reason its not working

 

ok when you run this on eurusd the buy direct command always will be used... since eurusd > 1


the buy direct command is using Ask as price. Which should be Bid. So it will always return an error.


hth

 
Russell wrote >>

ok when you run this on eurusd the buy direct command always will be used... since eurusd > 1

the buy direct command is using Ask as price. Which should be Bid. So it will always return an error.

hth

OK, so I changed what I thought you were talking about with the bid instead of the ask price but I still keep getting the OrderSend error 130 message in the journal when I test it. And it doesnt make any trades. What function shoud I use if I I want to sell/buy everything? and btw thanks for the help

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 = Bid;


if (currentvalue > currenttimeN){
OrderSend(Symbol(),OP_SELL,1,Bid,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);


}

/* BUY COMMAND */
else if (currentvalue < currenttimeN){
OrderSend(Symbol(),OP_BUY,1,Bid,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);

}
//----
return(0);
}