Please tell me which code should be written in the EA to make the EA trade only once an hour
For example, the EA has triggered, an order is opened (not interested in further), I would like the order not to open on the current bar on an hour timeframe
it all looks alike:
int hh; int CurrentHour; CurrentHour=TimeHour(TimeCurrent()); if (CurrentHour!=hh) { OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-3*Point,Bid+3*Point); hh=TimeHour(TimeCurrent()); }
Guys, help me find an EA for manual trading in the tester on history. There are several in the codebase, I need one that was controlled by dragging the caption in the lower left corner of the nrafik. Very simple, can't find one. HistTraining and Visualisation Testing. Manual trading is not it. Very easy advisor, you could also set levels where testing stopped.
I am specifically interested in what kind of timeout it is.
https://www.mql5.com/ru/forum/112612 This is an expired server response --- whether the deal opened or not. And there is no guarantee that the trade did not open.
So, I have to check if order is opened in a minute and then continue trading.
int hh = 0; int init() { return(0); } int start() { //------------------------------------------------- int countorder; countorder=OrdersTotal(); if (countorder==0) { Alert ("no open orders"); }else { Alert ("have open orders"); } int hh; int CurrentHour; CurrentHour=TimeHour(TimeCurrent()); if ((CurrentHour!=h)&&(countorder==0)) { OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-3*Point,Bid+3*Point); hh=TimeHour(TimeCurrent()); } //------------------------------------------------- return(0); }
int deinit() { return(0); }
I did as you said, no effect, added count of open orders, now opens orders right after close
I worked around it via OrderCloseTime() - it seems to work now
int countorder; countorder=OrdersTotal(); if (countorder==0) { Alert ("no open orders"); }else { Alert ("have open orders"); } int hh; int CurrentHour; int LastOrderCloseTime; CurrentHour=TimeHour(TimeCurrent());
https://www.mql5.com/ru/forum/112612 This is the waiting period for the server to respond --- whether a trade has opened or not. And there is no guarantee that the deal has not opened.
Therefore, as recommended by the developers, check after one minute whether an order has opened and only then proceed.
iBarShift() works fine to get the bar number from the history, but how would you get the bar number for this code if you move the line to the right - beyond the zero bar?
iBarShift() works fine for getting the bar number from the history, but how can I get the bar number for this code if I shift the line to the right - beyond the zero bar?
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.
demlin:
Еще вопрос: какой функцией можно вытащить стоимость одного пункта инструмента?
https://docs.mql4.com/ru/constants/marketinfo
MarketInfo(Symbol(), MODE_TICKVALUE);Please tell me which code should be written in the EA to make the EA trade only once an hour
For example, the EA has triggered, an order is opened (not interested in further), I would like the order not to open on the current bar on an hour timeframe
it all looks alike:
int hh;
int CurrentHour;
CurrentHour=TimeHour(TimeCurrent());
if (CurrentHour!=hh)
{
OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-3*Point,Bid+3*Point);
hh=TimeHour(TimeCurrent());
}
but I have countless orders open
Hello all!
Please tell me what this means:
Order buy ...... failed [Trade timeout]
I am specifically interested in what kind of timeout it is.
https://www.mql5.com/ru/forum/112612
This is an expired server response --- whether the deal opened or not. And there is no guarantee that the trade did not open.
So, I have to check if order is opened in a minute and then continue trading.
rlx:
needs to be set before start() and init()
int hh = 0;
int init()
{
return(0);
}
int start()
{
//-------------------------------------------------
int countorder;
countorder=OrdersTotal();
if (countorder==0)
{
Alert ("no open orders");
}else
{
Alert ("have open orders");
}
int hh;
int CurrentHour;
CurrentHour=TimeHour(TimeCurrent());
if ((CurrentHour!=h)&&(countorder==0))
{
OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-3*Point,Bid+3*Point);
hh=TimeHour(TimeCurrent());
}
//-------------------------------------------------
return(0);
}
int deinit()
{
return(0);
}
I did as you said, no effect, added count of open orders, now opens orders right after close
I worked around it via OrderCloseTime() - it seems to work now
int countorder;
countorder=OrdersTotal();
if (countorder==0)
{
Alert ("no open orders");
}else
{
Alert ("have open orders");
}
int hh;
int CurrentHour;
int LastOrderCloseTime;
CurrentHour=TimeHour(TimeCurrent());
OrderSelect(HistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY);
hh=TimeHour(OrderCloseTime());
if ((CurrentHour!=hh)&&(countorder==0))
{
OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-3*Point,Bid+3*Point);
}
https://www.mql5.com/ru/forum/112612
This is the waiting period for the server to respond --- whether a trade has opened or not. And there is no guarantee that the deal has not opened.
Therefore, as recommended by the developers, check after one minute whether an order has opened and only then proceed.
I don't want to be a pain in the ass, however.
Explain to me how an order will open if OrderTotal() is zero.
Thank you.
Below is the figure with brackets limiting the block of code that is executed under the condition
OrderSend() operations are not affected by this condition.
how to get a bar number, in the "future" :)
iBarShift() works fine to get the bar number from the history, but how would you get the bar number for this code if you move the line to the right - beyond the zero bar?
how to get a bar number, in the "future" :)
iBarShift() works fine for getting the bar number from the history, but how can I get the bar number for this code if I shift the line to the right - beyond the zero bar?
You can get an offset relative to Time[0]
You can get an offset relative to Time[0]
Thank you! Everything is OK now!