Waiting Time since Last Trade Close - page 2

 
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.
 

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 ??

 
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"

 
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 . . .
 
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