Работа завершена
Техническое задание
Develop MT5 EA - entry based on previous bar and when direction is wrong, place Martingale Trades. (Source Code in MT5 must be provided as part of acceptance)
I have a trading strategy that I would like to be coded into a MT5 EA. The worker will take the requirements and translate them into the language of the MT5 and test it.
Extensive Experience with coding for MT5 EA (involving Martingale, Trailing stop loss, Checking Free Margin and Margin Used etc) is required. Please post previous experience with mql5.
=============================
Set File Paramters List
1. EA_ShortName (alphanumeric 7 characters) – Default “WFCZ”
2. MagicNo (Numeric 6 digits) – default “3467”
3. MaxSpread in points (2 digits) – default 20
4. MaxSlippage in points (2 digits) – default 5
5. StopNewInitialTrade = Yes/No (Boolean) – default NO
6. BarWait = 0, 1, 2, … (integer – 1 digit) – Default 3
7. PriceNotToLong / PriceNotToShort (numeric – 999999.99999)
8. AsianSessionTP / LondonSessionTP / USSessionTP in points (4 digits - 9999)
a. ATR(UserATRPeriod integer 2 digits) x ATRFactor (99.9999)
9. InitTradeTrailingStopMode – (Boolean) Can be On or Off to decide whether to use Trailing Stop for initial trade
10. InitTradeTrailingDistancePnts; InitTradeTrailingStepPnts (5 digits – 99999 (i.e. up to thousand pips))
11. MartgTradeTrailingStopMode - Can be On or Off to decide whether to use Trailing Stop for Martingale trade
12. MartgTrailingDistancePnts; MartgTrailingStepPnts (5 digits – 99999 (i.e. up to thousand pips))
13. MartgLotSize1 (99.99 lots) , PipsFromPrevTrade1 (5 digits 99999), MartgTP1 (4 digits - 9999),
14. MartgLotSize2, PipsFromPrevTrade2, MartgTP2 …
15. …, MartgLotSize10, PipsFromPrevTrade10, MartgTP10
16. MartgMaxLevel (integer – 1 digit) = 0 (disable Martingale), 1, 2, 3, … 10
17. MinFreeMargin / MaxMarginUsed – (8 digits - 999,999.99)
Initialization / Start:
1. Check the previous trades / recognize where EA left off (What Martingale level next) because the system could be stopped by user, scheduled maintenance, or system crashed etc. – store the NxtMartgLvl in variables and to check/compare against these just before placing new orders later
2. Check all of EA’s own trades have TP properly set (i.e. sometimes server is busy or disconnected before TP is modified or user/trader changed set file TP) – if TP is different from set file – modify the tp depending on whether it’s initial trade or martingale trade
3. Check all of EA’s own trades have TrailingStop properly set
4. Calculate MarginLoadOfSymbol (see money management)
Requirements
1. Control by MagicNo + Symbol() (i.e. diff. chart symbols can have same magic number)
a. but diff timeframe of same chart symbol must use/set diff. magic number) because EA doesn’t store/check timeframe
2. MaxSpread & MaxSlippage
a. MaxSpread can be a fixed points or as percentage of quote
b. MaxSlippage - not to trade only if adverse slippage, continue to trade if favorable slippage
3. After trade, get the actual price executed from broker server to calculate TP (because executed price may be different for the ordersend price due to slippage, etc.)
4. After modifying TP, read from server and compare to make sure the TP is modified (sometimes server is busy / disconnected and loss the TP)
5. After trade, populate Comment field: EA_ShortName+”/”+MagicNo+”/”+YMDD+”/”+HHMMSS + InitTrade (0 is initial trade) or Martingale Level (1, 2, 3, etc.)
a. Y is last digit of year (e.g. “8” for 2018)
b. M is 1-9, A (Oct), B (Nov), C (Dec)
6. InitTradeTrailingStopMode – Can be On or Off to decide whether to use Trailing Stop for initial trade
7. MartgTradeTrailingStopMode – Can be on or off to decide whether to use Trailing Stop for Martingale Trades
Entry of Initial Trade (i.e. NOT martingale trade) –
1. If NOT StopNewInitialTrade then execute the below code
2. Check if within EA Operating hours – 2 time bands (see below)
3. BarWait – number of bars to wait before initial trade entry (0 bar and up; 0 means don’t wait) – barwait is only for initial trade and is not applicable to martingale trades
a. After exit, wait for barwait no. of bars and if immediate bar is positive/bullish then initialtrade is buy; if immediate bar is negative/bearish then initial trade is sell
4. Place Long Order (OrderSend) only if Current Price is < PriceNotToLong and Place short order only if Current Price is > PriceNotToShort
5. Check if satisfies Max Spread & Max Slippage
6. If TrailingStopInitTradeMode is Off then use TP as follows
7. AsianSessionTP ; LondonSessionTP; USSessionTP each can be set as fixed points for TP or as percent of ATR(UserATRPeriod) x ATRFactor
8. If InitTradeTrailingStopMode is on – InitTradeTrailingDistancePnts; InitTradeTrailingStepPnts
9. Trailing Stop for Initial Trade Only takes effect after the moving above entry price (i.e. trailingstop will only kick in to take profit when price retrace); for loss below entry price, using martingale
Martingale trades
1. Martingale – For each Martingale levels user can define/input MartgLotSize, PipsFromPrevTrade, MartgTP
2. If MartgMaxLevel > 0 and Current Martg Count <10 and Abs (Current Price – Last Order Executed) > PipsFromPrevTrade then place new martg order
3. MartgTrailingStopMode – Can be On or Off to decide whether to use Trailing Stop for Martingale trade
4. Trailing Stop – MartgTrailingDistancePnts; MartgTrailingStepPnts
EA Operating Hours (Op. Hr. Start / End for Monday to Friday; 2 sections per day; format of 00:00 to 24:00)
1. Start Hours and Ending Hours (for Monday to Friday) – no trade if not within trading hours (00:00 to 24:00)
1. MonOpHrStart1 ; MonOpHrEnd1 ; MonOpHrStart2 ; MonOpHrEnd2
2. TueOpHrStart1 ; TueOpHrEnd1 ; TueOpHrStart2 ; TueOpHrEnd2
3. WedOpHrStart1 ; WedOpHrEnd1 ; WedOpHrStart2 ; WedOpHrEnd2
4. ThuOpHrStart1 …
5. FriOpHrStart1 …
6. Only trade if CurrentTime is within EA Operating hours– that is:
a. If DayOfWeek is Monday and CurrentTime Is within (MonOpHrStart1 and MonOpHrEnd1) or (MonOpHrStart1 and MonOpHrEnd2) then execute trade
b. If DayOfWeek is Tuesday and CurrentTime is within (TueOpStart1 …
Money Management
1. Before placing the order (OrderSend) check what would be the Free Margin had the trade taken place, if it’s less than the user parameter (MinFreeMargin) then don’t place order
2. Before placing the order, check what would be the “margin used” had the trade taken place, if margin used is more than user parameter (MaxMarginUsed) then don’t pace order
a. Because MaxMarginUsed is a proxy of positions open and level of risk in the event of highly volatile market
3. MaxMarginUsed is affected by MarginLoadOfSymbol – MarginLoadOfSymbol is calculated by EA – to calculate, simply adding initial trade Lot, plus M1 Lot, M2 Lot, M3 Lot (from set file) upto MaxLevel – this calculation is done at EA Initialization/start Stage