62 lines
2.1 KiB
Markdown
62 lines
2.1 KiB
Markdown
|
|
[← MQLArticles](../README.md)
|
||
|
|
|
||
|
|
# Strategy
|
||
|
|
|
||
|
|
Framework for building EAs by composition: a base strategy template plus chainable entry/exit filters and a text-based logic engine to combine them.
|
||
|
|
|
||
|
|
## Main features
|
||
|
|
- Base strategy template with TP/SL by ATR or fixed points, lot sizing modes and buy/sell control (`CStrategyBaseTemplate<TPadre>`).
|
||
|
|
- Chainable technical filters (RSI, Stochastic, Bollinger Bands, SuperTrend, FVG, AD, liquidity...).
|
||
|
|
- A small logic-rule engine that combines filters using a text expression (`and`/`or`, groups, indices) instead of hardcoded if-chains (`CStrategyFilterParserClasific`).
|
||
|
|
- Time filters: by day of week and by year (`Strategy/Utils`).
|
||
|
|
|
||
|
|
## Basic usage
|
||
|
|
|
||
|
|
### Basic configuration
|
||
|
|
```mql5
|
||
|
|
CAtrUltraOptimized* atr_ultra = new CAtrUltraOptimized();
|
||
|
|
atr_ultra.SetVariables(PERIOD_CURRENT, _Symbol, 0, 14);
|
||
|
|
atr_ultra.SetInternalPointer();
|
||
|
|
strategy.AddLogFlags(InpStrategyLogLevel);
|
||
|
|
strategy.SetAtrTP_SL(atr_ultra, INP_STRATEGY_ATR_MULTIPLIER_TP, INP_STRATEGY_ATR_MULTIPLIER_SL); // TP/SL by ATR
|
||
|
|
strategy.SetOperateMode(TR_BUY_SELL, INP_STRATEGY_TYPE_TPSL);
|
||
|
|
strategy.SetTP_SL(INP_STRATEGY_SL_POINT, INP_STRATEGY_TP_POINT); // TP/SL by points
|
||
|
|
if(InpRmLoteType == Fijo)
|
||
|
|
strategy.FixedLotSize(InpRmLote);
|
||
|
|
```
|
||
|
|
|
||
|
|
### Filters
|
||
|
|
```mql5
|
||
|
|
// RSI filter
|
||
|
|
if(INP_FILTER_RSI_ENABLE)
|
||
|
|
{
|
||
|
|
CSFilterRsi* f = new CSFilterRsi();
|
||
|
|
strategy.AddFilter(f);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Stochastic filter
|
||
|
|
if(INP_FILTER_STOCH_ENABLE)
|
||
|
|
{
|
||
|
|
CSFilterStochastic* f = new CSFilterStochastic();
|
||
|
|
strategy.AddFilter(f);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Bollinger Bands filter
|
||
|
|
if(INP_FILTER_BANDS_ENABLE)
|
||
|
|
{
|
||
|
|
CSFilterBands* f = new CSFilterBands();
|
||
|
|
strategy.AddFilter(f);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Logic combining filters as text
|
||
|
|
strategy.CodeCompra<CStrategyFilterEmptyFuncFac>(StringFormat(
|
||
|
|
"#group oAnd (%s,%s,%s,%s,%s,%s,%s) == 0 oAnd ([%s] == 0 oOr [%s] == 2)",
|
||
|
|
CSFIlterAD_NAME, CSFilterSuperTrend_NAME, CSFilterFvg_NAME, CSFilterBands_NAME,
|
||
|
|
CSFilterRsi_NAME, CSFilterStochastic_NAME, CSFilterLiqEstimed_NAME,
|
||
|
|
CMediationsByZoneFilterName, CMediationsByZoneFilterName), 5);
|
||
|
|
|
||
|
|
// Summary of registered filters
|
||
|
|
strategy.PrintFilters();
|
||
|
|
```
|
||
|
|
|
||
|
|
> Only the most representative classes are shown here.
|