The Expert Advisor sets an order depending on Moving Average.
If the symbol approaches to the distance less than or equal to TP_THRESHOLD, the EA moves take profit by STEP_TP to profit. While doing so, it tries to set a new stop loss with STEP_SL step from the current symbol price if the minimum breakeven PROFIT_DELTA value is satisfied.
- a new order of the same type is opened if the symbol price approaches for the value less than or equal to TP_THRESHOLD;
- the current order or a new one of another type is closed if the symbol price is very close to stop loss (less than 20%) when an order is in a loss.
- upon expiration of EXTRA_HOURS_SPENT, the EA opens an additional order if the total amount of orders is less or equal to the half of the possible number (MAX_ORDERS).
- TP_THRESHOLD - threshold value before the set TP, at which the EA sets new SL and TP (in points);
- STEP_TP - step for setting a take profit from the already placed one (in points);
- STEP_SL - step for setting a stop loss from the current symbol price (in points);
- PROFIT_DELTA - step in profit from the order price, below which it is impossible to place SL (in points);
- SL - stop loss (points);
- TP - take profit (points);
- LOT_VOLUME - volume of orders being opened;
- MAX_ORDERS - maximum number of orders;
- MIN_FREE_MARGIN - minimum free margin value, at which new orders can be opened (in deposit currency);
- EXTRA_HOURS_SPENT - open an additional order upon expiration of the specified number of hours after opening the last active order if the total number of orders is less or equal to the half of the maximum number (0 - not used);
- NEW_ORDER_OPEN_PRICE_DELTA - offset from the previous order Open price (in points), within which you cannot open a new order of the same type (0 - not used);
- MAX_SPREAD - maximum spread of a pair, at which a new order (in points) can be opened;
- SLIPPAGE - maximum permissible slippage (points);
- MAGIC_NUMBER - EA magic number;
- LOGGING - show messages in the journal (flag).
- No profits are guaranteed. Be sure to test the EA work.
- When testing the EA, modify the LOT_VOLUME, MAX_ORDERS, MIN_FREE_MARGIN and MAX_SPREAD settings depending on your currency pair and deposit size.
2. Default parameter value for TP changed from 50 to 60 pips.
3. Bug fixes.