İş Gereklilikleri
Current workings:
I have an MQL5 Expert Advisor for MT5 platform that triggers a market buy order when I press Shift b and triggers a market sell order when I press Shift s. The trade size is taken from the settings, and there can be a maximum of 10 trades given in the settings section.
After the order is triggered, it looks at the entry price, adds 50 points as take profit and feeds it into the order.
It does not use stop loss and has martingale style trades instead.
The first active order is a Main Trade (MT) and any second active order is called a Counter Trade (CT)
Option 1 - CT order hits take profit and makes $100 in profit. IF the MT order is in a loss of less than $100, EA closes the MT trade completely.
Option 2 - CT order hits take profit and makes $100 in profit. IF the MT order is in a loss of more than $100, EA closes some lots of the MT order up to $100 but never more.
EA can also select which active loss making order to adjust from the settings.
ALL THIS is working fine.
=============================
I need you to add an option that makes the EA AutoCalculate the correct CT trade size, instead of me manually guessing it every time.
Settings Will Have:
Input AutoCalculate CT Size = True/False; (If True then…)
Input AutoCalculate CT TP = 50; (Take Profit Points To Be Entered)
Input AutoCalculate CT Minimum Margin = 10.00; (Minimum Dollar Margin)
IF MT order is BUY & CT is SELL Order - AutoCalculate CT Size =
IF MT is BUY && CT is SELL | |||
MT Buy Entry Price | 3,525.00 | CT Sell Entry Price | 3,519.00 |
MT TP | 50 | CT TP | 50 |
MT Buy Exit Price | 3,525.50 | CT Sell Exit Price | 3,518.50 |
CT Minimum Margin | 10.00 |
(CT Margin - ((ENTRY price of Trade to Adjust-EXIT price of CT)*(0.10*100)))/ CT Take Profit
For example:
10+((3525.00-3518.50)*0.10*100)/50
(10 + (+65)) / 50
(10 + 65) / 50
75 / 50
= 1.50 lots
IF MT order is BUY & CT is BUY Order - AutoCalculate CT Size =
MT Buy Entry Price | 3,525.00 | CT Buy Entry Price | 3,519.00 |
MT TP | 50 | CT TP | 50 |
MT Buy Exit Price | 3,525.50 | CT Buy Exit Price | 3,519.50 |
CT Minimum Margin | 10.00 |
(CT Margin - ((ENTRY price of Trade to Adjust-EXIT price of CT)*(0.10*100)))/ CT Take Profit
For example:
10+((3525.00-3519.50)*0.10*100)/50
(10 + (+55)) / 50
(10 + 55) / 50
65 / 50
= 1.30 lots
IF MT order is SELL & CT is BUY Order - AutoCalculate CT Size =
MT Sell Entry Price | 3,511.00 | CT Buy Entry Price | 3,515.00 |
MT TP | 50 | CT TP | 50 |
MT Sell Exit Price | 3,510.50 | CT Buy Exit Price | 3,515.50 |
CT Minimum Margin | 10.00 |
(CT Margin - ((EXIT price of CT - ENTRY price of Trade to Adjust)*(0.10*100)))/ CT Take Profit
For example:
(10+((3515.50-3511.00)*0.10*100))/50
(10 + (+45)) / 50
(10 + 45) / 50
55 / 50
= 1.10 lots
IF MT order is SELL & CT is SELL Order - AutoCalculate CT Size =
MT Sell Entry Price | 3,511.00 | CT Sell Entry Price | 3,515.00 |
MT TP | 50 | CT TP | 50 |
MT Sell Exit Price | 3,510.50 | CT Sell Exit Price | 3,514.50 |
CT Minimum Margin | 10.00 |
(CT Margin - ((EXIT price of CT - ENTRY price of Trade to Adjust)*(0.10*100)))/ CT Take Profit
For example:
(10+((3514.50-3511.00)*0.10*100))/50
(10 + (+35)) / 50
(10 + 35) / 50
45 / 50
= 0.90 lots
Important Notes
EA Must Compile correctly at my End. Any Trade folder files must also be submitted.
EA Trade Adjustment on AutoCalculate CT Size = True should be the same as when False
EA Must retain the same magic number and COMMENT after a trade has been adjusted.