Termos de Referência
Safe Haven EA
1) PLACING ORDERS
EA opens Buy stop and Sell Stop at a set distance ‘d’ from below options depending on what is chosen.
Create EA to have below as options
1A) Open of a candle
1B) Current market position
1C) Set price
Example I
If d = 100, option 1A) is chosen, Daily candle is chosen and openprice of US 30 daily candle is 46600.0 for a chosen lot “ L” = 0.01,
i) A buy stop order 0.01 will be placed at 46610.0
ii) A sell stop order order will be p
laced at 46590.0
Example II
If d = 200, option 1B) is chosen, and current of US 30 is 46500.0 for a chosen lot “ L” = 0.01,
i) A buy stop order 0.01 will be placed at 46520.0
ii) A sell stop order 0.01 will be placed at 46480.0
Example III
If d = 300, option 1C) is chosen, and price of US 30 is set at 46100.0 for a chosen lot “ L” = 0.01,
i) A buy stop order 0.01 will be placed at 46130.0 when current price get to the set price of 46100
ii) A sell stop order 0.01 will be placed at 46070.0 when current price get to the set price of 46100
2) SETTING TAKE PROFIT AND STOP LOSS
2A) For all three options 1A, 1B, 1C, there should be an option to set Take profit and Stop Loss.
2B) There should an option to set trailing Stop
3) ORDER TRIGGER
A) When a stop order is triggered, the opposite stop order is cancelled and a stop with lot XL is placed at the reference price that led to the order trigger. NB X ≥ 4 ie 4, 5, 6 etc. Create and option so the value of X can be decided.
Lets assume x= 5 is chosen,
Consider Example I in 1 above.
For Take profit = 46820, Trailing Stop trigger = 400 and trailing stop distance set to 10
If buystop (order1) 0.01 at 46610.0 is triggered, sell stop 46590.0 (order 2) will be cancelled and another sell stop order (order 3) 0.01* 5(because x=5 was chosen for this example) will be placed at price 46600.0
Let us assume
Scenario 1
Price moves to 46820.0
In this scenario take profit will be taken and all orders close
Scenario 2
Price does not get to take profit 46820.0 but gets to 46720 and begins to drop.
In this scenario because price went past 46650.0, Trailing stop would have been triggered at 46650.0 using a following distance of 10 and take profit closed at a price either at 46650.0 or higher.
All orders that was not triggered will be automatically closed because trailing stop was closed at a profit
Scenario 3
Price does not get to chosen take profit or above trailing stop price trigger, but reverses.
In this scenario if price gets to reference price (let this apply apply to 1B and 1C if they were the options chosen ) automatic pending order with X Lot will be triggered.
Considering our reference example I
When price gets to 46600.0, sell stop 0.05(order 3) will be triggered, the take profit for this order 'SK' will be set at SK= triggered price(TK1) - d/2, triggered price(TK1) - 3/5d , triggered price (TK1) - 2/3d, triggered price – 3/4d depending. Create EA in a way any of these options can be chosen. Triggered price here stands for automatic multiple lot order price placed by ea which got opened because take profit was not reached. We can denote the first as TK1, second TK2 third TK3 etc.
Assuming we chose SK=triggered price(TK1) - d/2
The take profit will be set to 46600.0 – 50points = 46595.0
The stop loss of the buy order (order 1) will also be set to 46595.0 automatically i.e.(46610.0 - (d+d/2 ))=46610.0 -150 points = 46595.0 which is also = SK
A buy stop order of 0.24 i.e ( 5*(5*L)-L) will be placed at 466610.0 with take profit =BK= triggered price(TK2) + d/2, = 46610.0 + 50 points = 46615.0
The stop loss of the 0.05 sell order(order 3) will automatically set to BK(46615.0).
The Buy stop order of 0.01 will also have its take profit changed to BK= 46615.0
If order 3 reaches take profit, all pending orders will be closed. If it does not the cycle continues.
3B) Same Patterns should be in place for Example II and III
4) Reccuring orders.
4a) There should be an option to repeat a cycle once price gets back to the very price that started the cycle if initial cycle is already closed in profit.
Consider Scenario 3 in 3 above.
Assuming price reaches 46595.0 and all orders got closed. EA should place a buystop of 0.01 and
sell stop of 0.01 at 46610.0 and 46590.0 if price gets back to open market price which was 46600.
4b) Put an option to determine how many times cycle should be repeated when conditions are met
4c)Ensure “4b)’ applies to all three ways to start cycle which is 1A), 1B), 1C)
4d) If current market price(option 1B) is what was chosen, cycle should restart at time T after which all orders were closed. If T is set = 0, once orders are closed, cycle should resume immediately at the next available current price.
4e) For 1 C) Order cycle should only resume when price returns to set price
4f) If a new candle opens while a cycle on a particular candle is not closed for 1A) option. EA should not start a new cycle. A new cycle only starts once a particular cycle is closed. Set this as true or false.
If false option is chosen EA can start a new cycle while another cycle is in place
5) EA to work on all Candles, at Current market price or Set price depending on what is chosen
Ensure EA works with all candles 1 miniute 5 minute, 15 minutes, 30 minutes, 1 hr, 4 hrs, daily, weekly and Monthly candles
6) Option for EA to work according to a particular set time should be in place.
For example EA can be set to work from 4:00am to 9:00pm GMT, 00:00hh – 23:00 etc
7) EA should have a variable lot option where initial lot placed will be function of equity so as equity increases, initial lot can increase
8) EA should have a magic number and should not get confused if it is used on different time frames at the same time or used on different symbols at one time
9) EA should be set in a way it knows public holidays and does not trade on holidays
10) EA should have a gap protection option.
EA will trigger an opposite order to hedge market if all orders are not closed at Time To close of market.
This should be a true or false option. Time should be set in seconds.
The EA should close the hedge order at a certain time set once market reopens. Let that time be in seconds.
Create EA to have this option as true or false
11) EA should have and option were instead of placing higher lot sizes in the entire cycle it rather places multiple small lot sizes
Taking Scenario 3 in 3 above, order three whose lot is (0.05) can instead be five of 0.01 lots. This means five 0.01 sell stop orders will have been placed and triggered instead of a single 0.05 sell stop order placed and triggered