This is an EA that has to open and solve one lock of two opposite positions, wile one protects the other. This EA, will control a source position with only one order and open and close only one order for each side. It must have two indicators to supply a signal to lock and unlock the positions, shorten the GAP. (I have some more information, I accept ideas and improvements).
The EA must see and calc the source position and automatically protect/cover that position with an opposite pending order with the settings stated.
To solve the GAP:
The EA must trade one of the positions by an indicator, the best side with the best condition, as often as necessary (lock & unlock) to shorten the GAP, till no GAP.
-----------------INPUTS------------------
SCREEN:
GAP Distance points: "X" (distance to open the lock)
Gap value $ "X$" (loss)
Orders value $: Sell:"X" Buy:"X" Total: "X"
Manual mode:
Button close BUY
Button close SELL
Button close ALL
Button open BUY
Button open SELL
One line representing the GAP that is together with the price (description: "GAP", "cost", "Distance")
Note: This representation is the accountability of all closed orders and open that contribute for the actual GAP.
-----------------SETTINGS---------------
BASIC SETTINGS
- Pairs to control (filter): "XXXXXX,XXXXXX,XXXXXX"... till 21 (multi pair EA);
- Magic number internal orders: "XXXXX,XXXXX,XXXXX,XXXXX,...";
- Distance cross to close all orders > X points: "X" (When sell above buy or buy below sell / No gap = > X);
- Option mode: "Manual" or "Indicator".
SOURCE POSITION
- Magic for source position (filter);
- or/and Comment for source position (filter);
- Open Take profit for source position ON/OFF: "true/false";
- Take Profit distance points: "X";
- When locked, clear TP: true/false.
- When locked, clear SL: true/false.
GAP
- Lock position size %: "X" (% of position to cover/lock);
- GAP distance points to open the pending order for position lock: "500";
- Offset SW ON/OF: true/false
- Offset distance > X points:"X".
OPEN AND MOVE PENDING ORDERS
Virtual Take Profit moving a pending order (above the price);
- Switch ON/OFF: "true/false";
- Distance points: "X";
- Step points: "10";
- Speed step points multiplier: "1X" (when the price move one pip, how many points it has to move the pending order).
Virtual Trailing Stop Loss moving a pending order (below the price)
- Switch ON/OFF: "true/false";
- Distance trigger points: "X";
- Distance start points: "X";
- Step points: "10";
- Speed step points multiplier: "1X" (when the price move one pip, how many points it has to move the pending order)
Fixed Stop Loss with pending orders
- Virtual fixed stop loss;
- Distance points (to open the pending order).
INDICATORS (sequential)
- Distance indicator;
- Signal indicator for direction and open the position.
Note: when the two indicators are in condition, close the favorable balance order.
First the distance condition and after the direction signal.
INTEGRITY FOR THE GAP CALC
CSV to register all trading IDs to calc the GAP after an application restart.
***** IMPORTANT *****
100% Full Ownership of the Intelectual piece, Full distribution Right and Unlimited License for all effects - All rights and ownership are exclusive and the source code has to be supplied to me as my own and total property. The source code has to be supplied fully compliant with the rules of the MQL5 market for the Metatrader 4