Demand And Supply Diagram MT5 EA
This Expert Advisor analyzes the volume scale, divides the volumes into components (supply and demand), plots a diagram of supply and demand, and trades according to this diagram.
Application of the supply and demand diagram as the main part of the trading strategy claims to be universal. However, not all trading instruments are fully subject to it. Nevertheless, the EA features a set of optional modes and contains several calibration variables, which can be used to achieve the most acceptable result.
The EA does not use pending orders and open positions using market orders only. Along with opening a position, the EA sets the stop loss and switches to position management - it performs the stop loss trailing and partial closure.
The description of the input variables mostly matches those of the indicator. Therefore, only the variables related to trading, optional modes and calibration are listed below.
- EntryLot - trade volume; if set to zero, the trade volume is assigned automatically depending on the DepositPart value.
- DepositPart - percentage of the deposit available for the EA to trade; a value of EntryLot set too high will also be adjusted automatically.
- PartialClosePart - percentage of the open position volume for partial closure.
- Average - diagram's midpoint: moving average or weighted average based on volume.
- Deviation - diagram's amplitude: the maximum or standard deviation, or Hurst coefficient based deviation.
- Signal - data set (supply and demand and/or total volume) to be used for generation of the trade signal.
- Correlation - enable/disable the mode of checking the correlation between the trade signals of the current and the higher timeframes.
- ExcessValidate - select the mode of tracking subsequent chains of signals, as a direction filter - by trend and/or against the trend;
- ElasticityValidate - check the elasticity of supply/demand to the price, with selection of the position opening type - "limit" and/or "stop";
- Hedging - enable/disable the mode of holding two opposite positions, if allowed by broker.
- Trailing - trailing mode: bi-directional (floating), unidirectional (only in profit), or fixed.
- LowLevelValue - below this value the volume will be considered as low, in percent. Recommended calibration range is from 10 to 30, with step 1.
- LowestLevelValue - below this value the volume will be considered as very low, in percent. Recommended calibration range is from 10 to LowLevelValue, with step 1. If set to zero, the variable is automatically set to LowLevelValue/2.
- HighLevelValue - above this value the volume will be considered as high, in percent. If set to zero, the variable is automatically set to a "mirrored" value, which is equal to 100-LowLevelValue. In this case, it does not require calibration.
- HighestLevelValue - above this value the volume will be considered as very high, in percent. If set to zero, the variable is automatically set to a "mirrored" value, which is equal to 100-LowestLevelValue. In this case, it does not require calibration.
- DurationParts - the number of the diagram sectors along the time scale. This variable can be used for calibration. Recommended calibration range is from 0.5 to 2.5, with step 0.1.
- StandardDeviations - multiplier for the standard deviation mode. Recommended calibration range is from 1.5 to 2.5, with step 0.1.
- HurstExponent - the exponent for the Hurst coefficient based deviation. Recommended calibration range is from 0.4 to 0.6, with a step of 0.01.
- PositionEntryAreaTicks - width of the position opening zone in ticks. Optimal value - not more than 2.
The diagram plotting algorithm implies a reduction in dependence on the quality of volume scale, but such dependence still remains - before buying, make sure you evaluate the efficiency of the EA on your broker's quotes.
The strategy is intended for medium-term trading - the optimal timeframe is H1 or higher.
The ED and ES signals are now accompanied by the messages «Close sell position» and «Close buy position» as an additional indication when closing the corresponding position partially or completely.
Added algorithm for checking volatility to avoid signals in too narrow flat periods of the market.
The functions ExcessValidate and Direction have been merged into ExcessValidate.
Fixed the error in calculation of the daily chart length for symbols with additional shortened trading day.