Download MetaTrader 5
Watch how to order a trading robot
Read the Rules before you post an order or execute it
How to order a trading robot and get the desired result
Develop a robot in no time
Write trade operations easily
48
Customer 2016.11.07 13:50 10 - 50 USD   from 1 to 3 day(s)

Dear all,

I'm new to, but learning, MQL4 coding. I've created a very simple EA that I'm quite happy with. But I'd like to pay for some help with a few more complicated (at least for me) functions. I really want to improve my coding skills so I'd appreciate well-commented code. That way I can learn.

Please note that this EA is only aimed at short positions

What I'm looking for is to extend my EA with the following:

1 - Hedging short positions

  • I wish to prevent margin calls and negative liquidity/ equity fluctuations if a short position temporarily moves against me. 
  • I'd like to profit from the hedge position if my short position gets stopped out and the price keeps moving up. 

Specifically: 

  1. I'd like to have an input variable called something like "input double HedgeCost=10.0;"
  2. Every time my EA opens a short position, I'd like a buystop order to be placed at a level of the OpenSell price + HedgeCost. In this example, the buystop order would be triggered when the bid price reaches 10.0 PIP's above the OpenSell price).
  3. When the price moves down, I'd like the hedge position to be closed at OpenSell price - HedgeCost. And again, another BuyStop order should be placed, at OpenSell price + HedgeCost. So if the price moves up again, my short position will be hedged again.
  4. When my short position is closed by Take Profit or any reason except Stop Loss, I want the BuyStop order to be canceled.
  5. If my short position is closed due to a stop loss, the hedge position should be modified and a trailing stop should be placed at the exact level of where my short position got stopped out.

I also would like this hedge function to really attach to the ticket number. Because in the future, my EA may open several positions, and all of these need to be hedged. So it won't work if the hedge order is triggered by looking at the total open orders, it has to really check any open short position that hasn't got a hedge Buystop attached to it. And then hedge those that don't. 

 

2 - Trailing stop when TP is reached

I think this is relatively simple. Again I'd like to learn how to do this, based on your code.

  1. I'd like an input variable called something like "input int TrailingRange=3"
  2. When my short position almost reaches it's TP level, I'd like an OrderModify to happen so that the TP is removed and a trailing stop loss is put into place at the TP - TrailingRange level.
Thank you in advance and I look forward to your offer/ reply.

Best regards,

Oscar. 

Experts, MQL4
Job completed in 4 days. Budget: 40.00 USD
2016.12.21
: My first time working with a freelancer here, Billy was a pleasure to work with. Very fast and highly skilled. My EA is greatly improved. Will work with him again and I can highly recommend him.
2016.12.21
: Happy to work with you Oscar, hope we can do it again next time.

Developer 2016.11.07 13:51
Published 10 codes in Library
Jobs: 133 (66% personal)
Arbitration: 35 (completed in favor of the developer 22%, canceled in favor of the customer 57%)
Overdue: 34 (25%)

Developer 2016.11.07 14:06
Jobs: 217 (27% personal)
Arbitration: 40 (completed in favor of the developer 15%, canceled in favor of the customer 50%)
Overdue: 97 (44%)

Developer 2016.11.07 17:29
Published 5 codes in Library
Jobs: 125 (42% personal)
Arbitration: 9 (completed in favor of the developer 22%, canceled in favor of the customer 77%)
Overdue: 49 (39%)
Files:
email.txt 1 kb

Developer 2016.11.07 14:24
Jobs: 149 (35% personal)
Arbitration: 29 (completed in favor of the developer 3%, canceled in favor of the customer 55%)
Overdue: 70 (46%)

Developer 2016.11.07 19:06
Jobs: 137 (24% personal)
Arbitration: 35 (completed in favor of the developer 8%, canceled in favor of the customer 40%)
Overdue: 77 (56%)

Developer 2016.11.07 15:59
Jobs: 121 (24% personal)
Arbitration: 5 (completed in favor of the developer 20%, canceled in favor of the customer 60%)
Overdue: 38 (31%)

Developer 2016.11.07 13:51
Jobs: 49 (24% personal)
Arbitration: 19 (completed in favor of the developer 0%, canceled in favor of the customer 63%)
Overdue: 27 (55%)

Developer 2016.11.07 14:05
Jobs: 2 (0% personal)
Arbitration: 1 (completed in favor of the developer 0%, canceled in favor of the customer 100%)
Overdue: 1 (50%)
To add comments, please log in or register