Build Me A Simple Hedging Strategy

Job finished

Execution time 2 days
Feedback from customer
Did good quality work and on time. The EA and source code looks well done.
Feedback from employee
the customer treats you like real humen he is so understanding ,kind,and fun to work with .will work love with him again next time

Specification

Me and my friend had a bet that a strategy he heard about does not not work. I have code logic for my EA in Python and It does not work. But my friend claim I code it wrong said it should be built in MT4 because they is the FX standards. 

I can provide the source code in Python.  The EA is quite simple.  In each tick it check each currency and decides check if the current order is filled if the order is filled the EA submits a new Stop Order for the currency.     

I would like the source code of the final product for me to compile and execute

Here is the logic of the EA.  There are no indicators.  The logic is a bit complex, but the math is very simple.  Basically it enters a trade.  If the trade goes again you it enters a short position. Keeps entering addtional long and short positions until the trade either hits the stop loss or profit target.  The stop loss for the buy trade is the profit target for the sell trade. Also the stop loss for the sell trade is the profit target for the buy trade. So this means when a stop loss or profit target is hit all the trades close together.

What make it a bit more complex is he wants to test the stratgy with a bullish and bearish strategies and want to test for multiple currencies at one.

   

The solution will need the following inputs.

Tickers: 

  • This is a list of tickers to execute the strategy on.  Each ticker should be separated by as space.

Pip Units:

  • this is number of pips the profit target and stop loss. This is a space separated list as each ticker will have a different profit target and stop loss value.

Lot Units:

  • this is the number of lots the to be used by the ticker. This is a space separated list as each ticker will have a different lot size value.

Directions:

  • this will specify if the the ticker is to be trade Bullish, Bearish or Both. This is a space separated list as each ticker could be traded Bullish, Bearish or Both.

Bullish Magic Numbers:

  • This is the magic number used by the ticker when trading the Bullish Strategy.  This is a list because each ticker will have its own magic number.

Bearish Magic Numbers:

  • This is the magic number used by the ticker when trading the Bearish Strategy.  This is a list because each ticker will have its own magic number.

Trade Units:

  • This is the scaling table used to know how big position to open based on the trading rules.  Again this is a space separated list of floating point numbers.

Take Profit Ratio

  • This is the take profit relative to the pip units.  This is a space separated list as each ticker will have it's own ratio.

Stop Loss Ratio

  • This is the stop loss relative to the pip units.  This is a space separated list as each ticker will have it's own ratio.



During the initialization these inputs will need to be converted in to arrays.


There will need to be a loop on the OnTick event where it loops through each ticker.  With in the loop it will do the following

Get the Bullish strategy Magic Number for the current Ticker in the loop from the array

If Has Open Positions

  • Count the number of Open Positions for the Magic Number 
  • While counting the open positions for the magic number. Get the Profit Target, Stop Loss of the first Open Position
  • Set the max of returned Profit Target and Stop Loss as Profit Target
  • Set the min of returned Profit Target and Stop Loss as Stop Loss
  • Set the entry price as the stop loss + (pip units * (stop loss ratio + 1))
  • Set the hedge price as the stop loss + (pip units * (stop loss ratio))

If No Open Positions and Has Unfilled Orders

  • Count the number of Unfilled Orders for the Magic Number \
  • While counting the unfilled positions for the magic number. Get the Stop Price, Profit Target of the first unfilled Order
  • Set the max of returned Profit Target and Stop Loss as Profit Target
  • Set the min of returned Profit Target and Stop Loss as Stop Loss
  • Set the entry price as the stop loss + (pip units * (stop loss ratio + 1))
  • Set the hedge price as the stop loss + (pip units * (stop loss ratio))

If there are no open positions and has unfilled order

  • should check the Stop Price is no more than 1 pip away from current price.  
  • If the current price is more than one pip away from the stop price should cancel the unfilled order.  The unfilled order count should be reduced by one.

 If there are no open positions and no unfilled orders.

  • The Entry Price should be calculated point above the current price.
  • It will calculate the Take Profit as Entry Price + (pip units * take profit ratio). 
  • It will calculate the Hedge Price as Entry Price - pip units
  • It will calculate the Stop Loss as Entry Price - (pip units * stop loss ratio)

If there are no unfilled orders will 

  • This ensures there is never more than one unfilled order per magic number

calculate the lots multiplier as the trade units[open positions + 1]
        calculate the opening units as lot units times lots multiplier


  • The trade quantity should be calculated as the lot units * trade unnts 

  • If the number of current open position is positive will open a buy stop order
  • If the number of current open position is negative will open a sell stop order

Each Order that is executed will be a Stop Order with a Ticker, Stop Price, Quantity, Take Profit, Stop Loss, Magic Number.

where 

  • Quantity is the  the opening units and the is times minus 1 for sell stop 
  • Stop Price is the Entry Price for Buy Stop and Hedge Price for Sell Stop
  • The Take Profit and Stop Loss are swapped around for Sell Stop trades 


The logic above is for a bullish strategy and want to repeat for a bearish strategy but in reverse.


Also would like on the chart white circle and squares for buy and sell for open bullish strategy positions with blue lines connecting to the close point.  Fore the bearish strategy would like red line connecting to the target. But what ever you think looks good. 

The strategy should be quite simple there is not complex math.  However the Inputs have to be loaded into arrays and the arrays need to be accessed to get the values.  But that is about it.


  

Responded

1
Developer 1
Rating
(6)
Projects
12
8%
Arbitration
1
0% / 100%
Overdue
4
33%
Free
2
Developer 2
Rating
(45)
Projects
74
49%
Arbitration
1
0% / 0%
Overdue
1
1%
Free
3
Developer 3
Rating
(97)
Projects
135
52%
Arbitration
4
50% / 50%
Overdue
0
Working
4
Developer 4
Rating
(56)
Projects
166
69%
Arbitration
4
100% / 0%
Overdue
1
1%
Free
5
Developer 5
Rating
(41)
Projects
88
14%
Arbitration
29
31% / 48%
Overdue
36
41%
Loaded
6
Developer 6
Rating
(57)
Projects
72
22%
Arbitration
13
46% / 15%
Overdue
5
7%
Free
7
Developer 7
Rating
(74)
Projects
121
43%
Arbitration
12
33% / 50%
Overdue
17
14%
Free
8
Developer 8
Rating
(10)
Projects
15
27%
Arbitration
3
67% / 33%
Overdue
0
Free
9
Developer 9
Rating
(45)
Projects
67
45%
Arbitration
3
0% / 100%
Overdue
0
Free
10
Developer 10
Rating
(567)
Projects
641
41%
Arbitration
21
57% / 29%
Overdue
47
7%
Working
11
Developer 11
Rating
(233)
Projects
413
34%
Arbitration
52
37% / 40%
Overdue
152
37%
Loaded
12
Developer 12
Rating
(252)
Projects
403
38%
Arbitration
83
41% / 19%
Overdue
70
17%
Busy
13
Developer 13
Rating
(66)
Projects
143
34%
Arbitration
11
9% / 55%
Overdue
26
18%
Working
14
Developer 14
Rating
(1)
Projects
2
0%
Arbitration
1
100% / 0%
Overdue
0
Free
Similar orders
Hi I need a software like Mirror trade copier ( https://www.antonnel.net/mirror/ ) which directly connect to the Accounts over api with out MT4 terminal and copies trades from mater to client. I want the same and possible improvement like can be accessed over a url and dashboard for some basic metrics (optional)
Hello there, I need a mql4 EA based on pine script custom indicator. You need to do pine script indicator convert into mt4 advisor. If you are able to do please contact. Thanks
I need a AI signal generating bot for forex trading. The bot should operate such that when i put it in a chart it will analyse the market, after several minutes it will display whether the trade is buying or selling. It should display the one minute, five minute,15minute, 30 minute, one hour, 4 hours and daily time frame whether they are buying or selling. If it is buying the arrow should be green and if it is
Using Bollinger Band only. When price closes above upper BB, open Buy. If the length of the candle body that closed above the upper BB is more than Y pips, then do not Buy and remove the EA. Otherwise, continue to open Buy if crosses and close above upper BB and the number of positions is not more than Max No of Positions. The user will choose either Buy or Sell only. When price closes below the lower BB, close all
Hello freelancers here, I need an expert to help me with coding my script which is already working in pinescript, Moreover, i want a system whereby i can sell my trading bot and can give access with a license, I need an expert that can help me with this
I need an EA which only trades the news data. The EA has to analyze the news-data and needs to classify them into categories. The Strategy includes the following points and this features needs to be included : 1. Filter for news Data : Pairs : USD ● EUR ● AUD ● GBP News Events : GDP Unemployment rate (initial claims) CB Consumer Confidence (US) Retail sales Consumer Price Index (CPI) Purchasing Managers' Index (PMI)
hello great developer Can you make a high/low ticker tape on a table for 100 stock symbols? As a symbol makes a high or low throughout the day, it will appear on the table. i will be expecting great developer to bid for this project
Hello freelancers here, I need an expert to help me with coding my script which is already working in pinescript, Moreover, i want a system whereby i can sell my trading bot and can give access with a license, I need an expert that can help me with this, and my budget is $20, Thank you
Hello freelancers here, I need an expert freelancer to help me convert an expert advisor from MT4 to MT5. I have the MT4 source code, As for now i only got $15 for this project i don't have much on me at the moment, So i need someone who can work long terms cause i still have other projects i need him to work on for me
An EA based on Fibonacci 100 - 750 USD
I am in need of 3 EA based on Fibonacci re-tracement after a high or low is made,each EA will have a hedge trade on it.the hedge trade will be at the 50 percent of the Fibonacci..this will be present on all 3 EA, all three EA will have different levels of re-tracement, while the hedge trade will be a continuation (buy/sell stop), while the re-tracement trades will be (buy/sell limit)This EA must work on timeframe

Project information

Budget
150+ USD
For the developer
135 USD