EA Close a position after 4 hours

To add comments, please log in or register
Jonathan Moncini
160
Jonathan Moncini  

Hi everybody, some days ago i download an MT4 EA that seems to do this job : close the open position after a determinate number of seconds.

I need this EA for my MT5 Account but i am not a programmer and i don't want to spend money because this is not a real EA, just a test that i would try to do.

Here i have the MT4 code (downloaded for free from this forum), someone could help me to make it work on MT5? Thank you


///+---------------------------------------------------------------------+

//|                                                       TIMEKEEPER.mq4 |

//|                                                                      |

///+---------------------------------------------------------------------+

//+------------------------------------------------------------------+

//| expert initialization function                                   |

//+------------------------------------------------------------------+

int init()

  {

//----

//----

   return(0);

  }

//====================================================================

//====================================================================

//+------------------------------------------------------------------+

//| expert deinitialization function                                 |

//+------------------------------------------------------------------+

int deinit()

  {

//----

//----

   return(0);

  }

//====

//+------------------------------------------------------------------+

//| |EXPERT

//+------------------------------------------------------------------+

int start()

   {

int maxDuration = 240 * 60; 

for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (

    OrderSelect(pos, SELECT_BY_POS)            // Only my orders w/

&&  OrderSymbol()== "EURUSD"){               // and period and symbol

    int duration = TimeCurrent() - OrderOpenTime();

    if (duration >= maxDuration)

         OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(),

                     3*Point);

}      return(0);

      }



//+------------------------------------------------------------------+

///+---------------------------------------------------------------------+

//|                                                       TIMEKEEPER.mq4 |

//|                                            Thanks to the MQL Forum ! |

///+---------------------------------------------------------------------+
Sergey Golubev
Moderator
106075
Sergey Golubev  

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button

Thank you.


ForexWinner81
9
ForexWinner81  
A lot of coders here.....I feel dumb lol
To add comments, please log in or register