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.
{
for (int i=0;i<=23;i++) {
if(Hour()==i )
{
for (int j=0;j<=59;i++) {
if( Minute()==j )
{
for (int k=20;k<=1439;k=k+60) {
if( Seconds()==k )
{ ticket=-1;
do {
ticket =OrderSend(Symbol(),OP_BUY,Lots,Ask,1,0,Ask+(TP*Point),comment,magic,0,0);
}
while (ticket==-1 );
}
}
}
}
}
}
}
and i tried this to but both , not work!
#define HOUR 3600
#define MINUTE 60
#define SECOND 1
input double Lots = 0.1;
input int TP = 200;
input int SL = 200;
input string comment = "MyOrder";
input int magic = 1234;
input int StartHour = 14;
input int StartMinute = 15;
input int StartSecond = 16;
datetime NextTrade = StartSecond*SECOND + 60 ;
//+--------------------------------------------------------------------------------------+
//| OnInit() |
//+--------------------------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+--------------------------------------------------------------------------------------+
//| OnDeinit() |
//+--------------------------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+--------------------------------------------------------------------------------------+
//| OnTick() |
//+--------------------------------------------------------------------------------------+
void OnTick()
{
datetime now = TimeCurrent();
if(now/(86400+3600+60) >= NextTrade)
{
if(OrderSend(Symbol(),OP_BUY,Lots,Ask,1,0,Ask+(TP*Point),comment,magic,0,0) < 0)
{
printf("OrderSend() failed. Error code: %i", GetLastError());
}
else
{
NextTrade = StartSecond*SECOND + 60 ;
printf("Next Trade scheduled for %s", TimeToString(NextTrade));
}
}
}