Mastering Time-Based Position Closure with MetaTrader 5

Mike 2017.05.29 22:48 18 0 0
Attachments

Hey there, fellow traders! If you’re using MetaTrader 5, you might want to check out the Exp_ClosePositionsByTime Expert Advisor. This handy tool automatically closes all open positions for a specific symbol once the server time exceeds the limit you’ve set. It’s like having a reliable assistant that helps you stick to your trading plan without second-guessing!

Customizing Your Expert Advisor

Here’s how you can set it up:

  • StopTime: This parameter lets you specify when to close your positions. For instance, you can set it to a future date and time, like this: D'2030.01.01 23:59'.
  • Deviation_: This defines the maximum price deviation in points that you're willing to tolerate. Setting this to a value like 20 can help ensure your trades are closed at a price close to your intended target.

Code Snippet

//+----------------------------------------------+
//| Expert Advisor input parameters              |
//+----------------------------------------------+
input datetime StopTime=D'2030.01.01 23:59';   //Position closing time
input uint    Deviation_=20;                   //max price deviation in points

So, whether you're trading forex, stocks, or commodities, having this EA in your toolkit can save you a lot of hassle. It ensures you’re not left holding the bag past your planned exit time. Make sure to give it a whirl and let it help you manage your trading positions like a pro!

List
Comments 0