Skip to content

Instantly share code, notes, and snippets.

@currencysecrets
Last active June 25, 2017 13:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save currencysecrets/6543381 to your computer and use it in GitHub Desktop.
Save currencysecrets/6543381 to your computer and use it in GitHub Desktop.
Automated Trading - Framework. I'm finding through continued automated MetaTrader 4 system programming that my expert advisors are taking the same form and shape.
INIT
----
|
|_ remove pending orders
| |
| |_ error alert
|
|_ reset charts
|_ reset global variables
START
-----
| |
| |_ process every tick
| |
| |_ check open trades
| |
| |_ manage trailing stops
| |
| |_ error alert
|
|
|_ process every nth-bar (period)
|
|_ check entry gates
| |
| |_ pre-trade
| | |
| | |_ check existing trades
| | |_ check existing orders
| | |_ check portfolio drawdown
| |
| |_ money management
| | |
| | |_ calculate initial stop loss
| | |_ calculate expiry time
| | |_ calculate position size
| | |
| | |_ check margin / cash available
| |
| |_ pre-order
| | |
| | |_ check order distance from market (for stop entry orders)
| | | |
| | | |_ if too close, change order to an "at market" order
| | |
| | |_ check global switch (has previous tick been here?)
| | |_ check if trade context is free
| |
| |_ order placement
| |
| |_ error alert
|
|_ reporting (email)
|
|_ open trades
|_ closed trades
DEINIT
------
|
|_ error alert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment