New EA and Indi
This commit is contained in:
148
EMA Indi/README.md
Normal file
148
EMA Indi/README.md
Normal file
@@ -0,0 +1,148 @@
|
||||
# Base-EMA Multi-Stage Reversal Signal Indicator
|
||||
|
||||
## Overview
|
||||
|
||||
The Base-EMA Reversal Indicator is a sophisticated trading tool that identifies potential reversal opportunities using a multi-stage state machine approach with EMA confluence. The indicator tracks both buy and sell opportunities through a systematic process of base formation, EMA confirmation, and pullback detection.
|
||||
|
||||
## Features
|
||||
|
||||
### 8 Indicator Buffers
|
||||
1. **BUY_SIGNAL** (Buffer 0): Price level for buy entry (up arrow)
|
||||
2. **SELL_SIGNAL** (Buffer 1): Price level for sell entry (down arrow)
|
||||
3. **BUY_SL** (Buffer 2): Stop Loss level for buy positions (from base low)
|
||||
4. **SELL_SL** (Buffer 3): Stop Loss level for sell positions (from base high)
|
||||
5. **BUY_TP** (Buffer 4): Take Profit level for buy positions (EMA 600)
|
||||
6. **SELL_TP** (Buffer 5): Take Profit level for sell positions (EMA 600)
|
||||
7. **BUY_STATE** (Buffer 6): Current buy state (0-3) for EA consumption
|
||||
8. **SELL_STATE** (Buffer 7): Current sell state (0-3) for EA consumption
|
||||
|
||||
### Input Parameters
|
||||
|
||||
#### EMA Settings
|
||||
- **EMA 50 Period**: Fast EMA period (default: 50)
|
||||
- **EMA 100 Period**: Medium-fast EMA period (default: 100)
|
||||
- **EMA 200 Period**: Medium EMA period (default: 200)
|
||||
- **EMA 300 Period**: Medium-slow EMA period (default: 300)
|
||||
- **EMA 400 Period**: Slow EMA period (default: 400)
|
||||
- **EMA 500 Period**: Very slow EMA period (default: 500)
|
||||
- **EMA 600 Period**: Target EMA for TP (default: 600)
|
||||
|
||||
#### Setup Settings
|
||||
- **Lookback Period**: Bars to look back for base detection (default: 20)
|
||||
- **Base Threshold**: Points tolerance for pullback to base (default: 50)
|
||||
- **State Reset Period**: Bars before resetting state if no signal (default: 50)
|
||||
|
||||
#### Display Settings
|
||||
- **Show Dashboard**: Toggle dashboard display (default: true)
|
||||
- **Show Stage Labels**: Toggle stage label display (default: true)
|
||||
- **Show EMA Lines**: Toggle EMA lines display (default: true)
|
||||
|
||||
## Logic Workflow
|
||||
|
||||
### Buy Side State Machine (Looking for reversal up to EMA 600)
|
||||
|
||||
#### State 0: Idle/Reset
|
||||
- Waiting for new low formation
|
||||
|
||||
#### State 1: Find Base
|
||||
- Price makes new low in `InpLookback` bars (at frist install then use last signal as a start of lookback)
|
||||
- Store `BaseLow = Low[i]`
|
||||
- Transition to State 2
|
||||
|
||||
#### State 2: Confirm Test
|
||||
- Price touches or crosses EMA 50, 100, or 200 from below
|
||||
- Wait for pullback opportunity
|
||||
- Transition to State 3
|
||||
|
||||
#### State 3: Wait Pullback
|
||||
- Price pulls back to `BaseLow` within `InpBaseThreshold` points
|
||||
- Generate buy signal at current close
|
||||
- Set SL at `BaseLow`
|
||||
- Set TP at EMA 600
|
||||
- Reset to State 0
|
||||
|
||||
### Sell Side State Machine (Looking for reversal down to EMA 600)
|
||||
|
||||
#### State 0: Idle/Reset
|
||||
- Waiting for new high formation
|
||||
|
||||
#### State 1: Find Base
|
||||
- Price makes new high in `InpLookback` bars (at frist install then use last signal as a start of lookback)
|
||||
- Store `BaseHigh = High[i]`
|
||||
- Transition to State 2
|
||||
|
||||
#### State 2: Confirm Test
|
||||
- Price touches or crosses EMA 50, 100, or 200 from above
|
||||
- Wait for bounce back opportunity
|
||||
- Transition to State 3
|
||||
|
||||
#### State 3: Wait Pullback
|
||||
- Price bounces back to `BaseHigh` within `InpBaseThreshold` points
|
||||
- Generate sell signal at current close
|
||||
- Set SL at `BaseHigh`
|
||||
- Set TP at EMA 600
|
||||
- Reset to State 0
|
||||
|
||||
## Visual Elements
|
||||
|
||||
### Color Scheme
|
||||
- **EMA 50**: Red
|
||||
- **EMA 100**: Orange
|
||||
- **EMA 200**: Yellow
|
||||
- **EMA 300**: Green
|
||||
- **EMA 400**: Blue
|
||||
- **EMA 500**: Purple
|
||||
- **EMA 600**: Magenta
|
||||
- **Buy Signals**: Lime green arrows (↑)
|
||||
- **Sell Signals**: Red arrows (↓)
|
||||
- **SL Lines**: Gray dashed lines
|
||||
- **TP Lines**: Blue dotted lines
|
||||
- **Stage Labels**: Color-coded by state
|
||||
|
||||
### Stage Labels
|
||||
Located in top-right corner, shows:
|
||||
- Current buy stage with colored background
|
||||
- Current sell stage with colored background
|
||||
- State descriptions for active states
|
||||
|
||||
## State Descriptions
|
||||
|
||||
| State | Value | Description | Color |
|
||||
|-------|-------|-------------|-------|
|
||||
| Idle/Reset | 0 | Waiting for setup | Gray |
|
||||
| Finding Base | 1 | Looking for new high/low | Blue |
|
||||
| Confirm Test | 2 | EMA touch/cross detected | Orange |
|
||||
| Wait Pullback | 3 | Waiting for pullback to base | Green |
|
||||
|
||||
|
||||
### For EA Developers
|
||||
The indicator provides two key buffers for automated trading systems:
|
||||
- `BUY_STATE_BUFFER` (6): Current buy state (0-3)
|
||||
- `SELL_STATE_BUFFER` (7): Current sell state (0-3)
|
||||
|
||||
These buffers can be accessed programmatically to:
|
||||
- Monitor setup progression
|
||||
- Trigger automated entries at State 3
|
||||
- Implement custom risk management
|
||||
- Build multi-timeframe strategies
|
||||
|
||||
## Technical Details
|
||||
|
||||
### Buffer Configuration
|
||||
```mql5
|
||||
#property indicator_buffers 8
|
||||
#property indicator_plots 6
|
||||
```
|
||||
|
||||
### Performance Considerations
|
||||
- Uses iMA() handles for efficient EMA calculation
|
||||
- Implements series arrays for optimal memory usage
|
||||
- Minimal repainting - signals generated on bar close
|
||||
- Efficient object management for dashboard and labels
|
||||
|
||||
### Error Handling
|
||||
- Validates EMA handle creation
|
||||
- Checks array bounds before access
|
||||
- Graceful cleanup on deinitialization
|
||||
- Proper series array management
|
||||
|
||||
Reference in New Issue
Block a user