주시
1
0
포크
이미 MQLArticles을(를) 포크했습니다
0
원본 프로젝트 nique_372/MQLArticles
MQLArticles/Strategy/README.md
Nique_372 Nique_372 0c48ad792e
2026-10-25 11:50:52 -05:00
60 라인
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
CAtrOptimized* atr_ultra = CAtrEmbCreator::Create(PERIOD_CURRENT, _Symbol, 0, 14); // timeframe, symbol, bar index, period
strategy.AddLogFlags(InpStrategyLogLevel);
strategy.SetAtrTP_SL(atr_ultra, INP_STRATEGY_ATR_MULTIPLIER_TP, INP_STRATEGY_ATR_MULTIPLIER_SL); // TP/SL by ATR (the strategy takes ownership of the pointer)
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.