Download MetaTrader 5

Waiting Time since Last Trade Close - page 2

To add comments, please log in or register
Search in documentation is available via MetaTrader 5. Search and learn!
Simon Gniadkowski
Moderator
17998
Simon Gniadkowski 2013.02.21 12:24  
FamWue:

Oh my god. So stupid.


Ok. Now i how can i compare the current time to the OrderCloseTime() in case of different Timeframes.

Since the close there should be minimum 5 Bars of the current timeframe.

Use iBarShift()  with the time to get the bar number of the close.
Mohd Supandi
7
Mohd Supandi 2014.02.26 07:57  

Hi guys,

if a trade was closed i want my EA wait for opening a next trade till 5 bars were finished.

How can i do this?

How do i get the time of the close of the last trade and how can i compare it with the bars?


Thanks guys

Mohd Supandi
7
Mohd Supandi 2014.02.26 07:58  

Dear FamWue

Have u got the solution ??

Mohd Supandi
7
Mohd Supandi 2014.02.26 08:04  
FamWue:

Hi guys,

if a trade was closed i want my EA wait for opening a next trade till 5 bars were finished.

How can i do this?

How do i get the time of the close of the last trade and how can i compare it with the bars?

Thanks guys

Dear FamWue,

Have u got the solution for the above problem?

Please share with me because I m having the same problem "trying to identify the time of last trade closed"

Simon Gniadkowski
Moderator
17998
Simon Gniadkowski 2014.02.26 08:25  
EdiBasar:

Dear FamWue,

Have u got the solution for the above problem?

Please share with me because I m having the same problem "trying to identify the time of last trade closed"


RaptorUK:
Use iBarShift() with the time to get the bar number of the close.


What are you struggling with ? please show your code . . .
whroeder1
14470
whroeder1 2014.02.26 13:54  
EdiBasar: Please share with me because I m having the same problem "trying to identify the time of last trade closed"
This doesn't get the time of the "last trade closed" it gets the time of the trade with the highest position.
datetime Last;
int TotalNumberOfOrders = OrdersHistoryTotal(); //
for(int i = 0; i <=TotalNumberOfOrders - 1 ; i++) //
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) continue; // falls Zeile leer
{
if(OrderType()==OP_BUY && OrderType()==OP_SELL ) {Last=OrderCloseTime(); Alert(OrderCloseTime());}
i <= TotalNumberOfOrders - 1 is the same as i < TotalNumberOfOrders Simplified - less operations
Get in the habit of counting down - Loops and Closing or Deleting Orders - MQL4 forum
You would never write if( ( (2+2) == 4 ) == true ) would you? So don't write if(bool == true). if(bool) or if(!bool) is sufficient.
The && was previously mentioned.
Find the trade with the newest close time.
datetime Last=0; // None found yet.
for(int i = OrdersHistoryTotal(); i >= 0 ; i--) if(
   OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)
&& (OrderType()==OP_BUY || OrderType()==OP_SELL )
&& Last <= OrderCloseTime()
   ) {Last=OrderCloseTime(); Alert(OrderCloseTime());} 
if(Last == 0) Alert("No orders in history");
No magic number make this incompatible with every other EA including itself on other charts and manual trading. Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
12
To add comments, please log in or register