Job finished
Specification
Hello and thanks already for your interest into this project !
I use a grid EA - referred hreafter as "original EA", which is quite successful but has some drawdown ad has a tendancy to trade against the trend. The EA requested for development will be used on a case by case basis when I fell the trend on a pair is too strong and hence, that it would be beneficial to counter the original EA (to reduce drawdown and in an attempt to generate some profits).
I would like to order an EA that opens an opposite trade when the original EA places a trade. I will name this EA (requested for development) as the "reversing EA".
The reversing EA has nothing more to do than copying the trades each time the initial EA places a market order (it does not place pending orders). It hsould be working on VPS offered by MQL.
The reversing EA will be attached to the chart of the pair it can trades, on the same terminal as the original EA (no need to copy accross mulitple terminal).
The original EA manages only the pair of the chart it is attached. Each pair has its own magic. So we get one grid per pair, with one magic. For 2 grids, we will have 2 pairs, 2 charts, 2 magics etc.
The first trade of the grid of the original EA has a specific comment (initial position) and the successive grid orders from the original EA have each the same comment (grid Position), which differs from the comment of the first trade . The reversing EA should be able to reverse-copy either of the initial trade order and the trades from the grid made by the initial EA, based on the searching of the comment specific to the 1st order ("initial position") or on subsequent orders ("grid position").
The original EA may be long and short at the same time on the same pair, with same magic. The original EA cannot open more than 2 grids with the same magic on the same pair (one long, one short).
ATTENTION
In the case the original EA is already long and short, the reversing EA should not copy trade. The reversing EA should check that it does not copy trade as long it finds already 2 orders on the opposite side (one long and one short per pair). The reversing EA shall incorporate this parameter to prevent the risk of having 2 grids running on the same side - or to prevent the risk of creating a loop, where the reversing EA would open opposite orders to its own trades.
Input parameters:
Permitted Reversed Copy Sides : None / Both Sides / Long / Short - the side of orders that the reversing EA is authorised to place. If set to Long, then reversing EA can only enter into long deals - which would then mean that the original EA is short.
fixed lot : TRUE/FALSE - if FALSE, then input "Lot ratio" applies
FIxed lot: fixed lot size of trades made by the reversing EA. Applies only if "FIxed Lot" set to TRUE.
Lot ratio : number - Applies only if "FIxed Lot" set to FALSE. it is calculated from the lot size of the original EA, the ratio is used as multiplier. For a lot size of 1 lot placed by the original EA and a lot ratio of 0.01 then the reversing EA should place a trade for 0.01 lot and - if input is 10, then the reversing EA should open a 10 lot order). The lot size are not to be rounded.
Comment from original to Copy - will select trades to be copied from original EA (per comment), so that only the initial trade is copied when the input "initial Position" is made - or any of the grid order from the original EA if "Grid Position" is input.
Magic from original EA to copy: Magic from the initial EA that the reversing EA should be looking for in open orders to reverse copy. ALthough the reversing EA should only be able to place trades on pair it is attached, I would like this input as additional protection to prevent manipulation errors
Comment to be copied: Comment that the reversing EA should put in orders it opens.
Magic to be copied: Magic of the trade opened by the reversing EA -may differ from the Magic of the Initial EA.
Take Profit: when reversing EA instructs a market order, the order should have an initial TP - set as pips distance from the obtained market price.
Pause: expressed in milliseconds - to reduce the overload of the VPS, the EA should check orders every X milliseconds - 500 milliseconds by default.