仕事が完了した
指定
I need a MetaTrader5 EA that will call a URL (WebRequest) every N seconds, and based on the JSON data it sees in the response, it should open a new order in MetaTrader.
(When doing the WebRequest, the url being connected to requires a key/value to be passed in the header of the WebRequest to successfully connect. The URL and key/value will be hardcoded in the code and won't be a setting.)
It will then follow a very simple set of rules of when to close the order. Those rules are pre-set in the settings of the EA along with 2 other global settings.
*************** EA Settings ***************
Pair: EURUSD
Lot Size (%): 5
Candle Period: H1
Close Rule: 3
Algorithm: 100258
_________________________
Pair: XAUUSD
Lot Size (%): 20
Candle Period: M30
Close Rule: 1
Algorithm: 504703
_________________________
Pair: XAUUSD
Lot Size (%): 10
Candle Period: M15
Close Rule: 2
Algorithm: 401062
_________________________
etc... there are 50+ entries that will be added here.
************ EA Global Settings *********
Don't open an order if older than (seconds): 25
WebRequest (seconds): 3
********************************************
"Lot Size" Definition:
Represents the order size as a percentage of the free margin available in the account.
For example, if the free margin in the account is $1000, and the "LotSize" of a pair is set to 20%, the order size for that pair should not be more than $200. (The "free margin" calculation must be done every time prior to opening a new order)
"Close Rule" Definition:
1 = Close order 3 seconds BEFORE the current candle period ends.
2 = Close order 3 seconds BEFORE the second candle period ends.
3 = Close order 3 seconds BEFORE the current candle period ends IF order profit is greater than $0.01. ELSE, close order 3 seconds BEFORE the second candle period ends regardless of profit.
4 = Close order 3 seconds BEFORE the third candle period ends.
5 = Close order 3 seconds BEFORE the current candle period ends IF order profit is greater than $0.01. ELSE, close order 3 seconds BEFORE the third candle period ends regardless of profit.
Global Settings Definition:
- For the "Don't open an order if older than" setting, in the JSON of an order there's a field called "HoldingPeriod". Before opening a new order, check that field and make sure it's "less than the amount of seconds" set in the settings. If the "HoldingPeriod" of the order is greater than the value in the settings, do NOT open the order.
- For the "WebRequest" setting, that's how often the EA should do a WebRequest to check and see if there are new orders to open.
You'll see a lot of entries/orders (see attachment) in the JSON response. Each entry is a separate order.
(The ONLY fields that you need to take into consideration from an entry/order in the JSON are: ActionType, CurrencyPair, HoldingPeriod, Algorithm --- You'll match the " Algorithm" and " CurrencyPair" of an order to what is found in the settings of the EA, and based on the setting that it got matched to, you then know what timeframe that order is using.)
Note: The JSON will NEVER display orders for the same pair in 'opposite' directions. Meaning, you'll never see an order for a BUY/long and another order for a SELL/short at the same time for the same pair!
All source code is required. (I do not test or accept compiled EA's).