Page 119 of 147

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Tue Nov 04, 2025 9:04 am
by Vetis
SEMA logic explained by Claude AI

# XU SEMA v2.13 - Logic Explanation

This is a **multi-timeframe ZigZag indicator** with a ternary logic system and VWAP continuity tracking. Let me break down its core components:

## 🎯 Core Purpose

The indicator identifies swing highs/lows across 4 different periods (SEMA1-4) and tracks their directional bias using ternary logic, displaying them as symbols on the chart.

## 🔢 Ternary Logic System

Instead of binary (true/false), it uses **three states**:
- **TRIT_T (-1)**: Trend DOWN
- **TRIT_0 (0)**: NEUTRAL
- **TRIT_1 (1)**: Trend UP

This allows for more nuanced market state representation beyond simple bullish/bearish.

## 📊 Four SEMA Layers

Each SEMA is a ZigZag calculation with different parameters:

1. **SEMA1** (Period: 11) - Small dots, fastest signals
2. **SEMA2** (Period: 43) - Big dots, intermediate swings
3. **SEMA3** (Period: 175) - Arrows, major swings
4. **SEMA4** (Period: 703) - Squares, highest timeframe structure

Each uses:
- **Depth**: Lookback period for finding extremes
- **Deviation**: Minimum price movement threshold (in points)
- **Backstep**: Prevention of overlapping signals

## 🔄 ZigZag Calculation Logic

The `ZigZag_Calc()` function:

1. **Finds local extremes** within the depth period
2. **Validates them** against deviation threshold
3. **Prevents repainting** by checking backstep distance
4. **Alternates high/low** - removes invalidated points when a new extreme exceeds the previous

Example flow:
```
- Find highest high in last 11 bars
- Check if current bar is within deviation tolerance
- Remove any closer highs within backstep range
- Mark valid high in buffer
- Repeat for lows
```

## 🎨 Visual Display

Each SEMA level displays as Wingdings font characters:
- **Size increases** with timeframe (S1: 20 → S4: 78)
- **Colors configurable** for up/down (default: Orchid/Green)
- **Symbol codes** (S1kod-S6kod) determine character appearance

## 📈 VWAP Continuity System

The key innovation - maintains directional bias between zigzag points:

```cpp
GetBiasDirectionWithContinuity()
```

**Logic:**
1. Scans last 5000 bars for most recent high/low signals
2. Compares which occurred more recently
3. Maintains this direction until next valid zigzag point appears
4. Stores state in `currentSemaXSet` variables

**Without continuity**: Would show NEUTRAL between zigzag points
**With continuity**: Maintains last known direction (UP/DOWN)

## 🎛️ Bias Boxes

Three button displays at chart bottom showing current bias:

- **Square Box** → SEMA4 direction (highest timeframe)
- **Arrow Box** → SEMA3 direction
- **BigDot Box** → SEMA2 direction

Colors change: Green (uptrend) / Red (downtrend) / Gray (neutral)

## 🔍 Key Functions

### `GetBiasDirection()`
Determines trend by finding most recent high vs low zigzag point:
```
If latest_high_bar < latest_low_bar → TREND_DOWN
If latest_low_bar < latest_high_bar → TREND_UP
```

### `UpdateBiasBoxes()`
Updates button labels and colors based on `currentSemaXSet` ternary values

### `OnCalculate()`
Main execution loop:
1. Calculates all 4 zigzags on new bars
2. Updates white dot buffers (SEMA3)
3. Determines bias directions with continuity
4. Creates/updates chart objects (symbols)
5. Refreshes bias boxes

## 🛡️ Protection Features

- **Name verification** - prevents unauthorized modification
- **DPI scaling** - adjusts symbol sizes for different screen resolutions
- **Array resizing** - handles growing bar counts dynamically
- **Error handling** - checks array bounds before access

## 💡 Trading Application

The indicator helps identify:
- **Nested structures**: Higher timeframe trends containing lower timeframe swings
- **Trend alignment**: When all 4 SEMAs point same direction = strong trend
- **Divergences**: When lower timeframes reverse before higher ones
- **Entry timing**: Use faster SEMAs for entries within slower SEMA trends

The ternary logic allows for **three-way decision making** rather than binary yes/no, which better represents market uncertainty and transitional states.

XARD: What the documentation doesn't mention is that I've reconfigured the SEMA logic from a 5x to a 4x multiplier and now use timeframes that are 4x apart to capture fractal resonance -- Trade exclusively in the direction of [VWAP + EMA] when their colors synchronize - and exit immediately when those colors fall out of alignment.

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Tue Nov 04, 2025 8:18 pm
by SOLESHOE
Vetis wrote: Tue Nov 04, 2025 9:04 am
XARD: What the documentation doesn't mention is that I've reconfigured the SEMA logic from a 5x to a 4x multiplier and now use timeframes that are 4x apart to capture fractal resonance -- Trade exclusively in the direction of [VWAP + EMA] when their colors synchronize - and exit immediately when those colors fall out of alignment.
" Trade exclusively in the direction of [VWAP + EMA] when their colors synchronize - and exit immediately when those colors fall out of alignment."

THANK YOU For this clarification !
(this also explain why smaller TF implies shorter trades)

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Wed Nov 05, 2025 12:38 am
by jackboton
The pre-market volatility lost some points, and today's target was not achieved. Let's work harder tomorrow.

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Wed Nov 05, 2025 7:27 pm
by Lenovo
Hi, could we have a channel on MT5 that tells us where the arrow will be on MT4, even if it wasn't precise, I was following channel xu54, is there something similar with the new parameters for MT5?

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Thu Nov 06, 2025 1:31 am
by jackboton
I was busy with work during the day and didn't make any trades. In the evening, I completed two trades, achieving a profit of nearly 5%. Keep up the good work!

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Thu Nov 06, 2025 2:17 am
by XYM
Today Pancha dinners LOL

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Thu Nov 06, 2025 8:05 pm
by Tomson
Perhaps the most useful things included on posted trade snapshots are the trade levels and / or trade history.

Without these, may as well just post an image of the PnL box.

It is such an easy, obvious and constructive thing to do, why would they be omitted?

The only reason I can charitably think of is that the trades are actually placed on another platform. (Edit: how then is the PnL showing?)

Or am I'm missing something?

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Thu Nov 06, 2025 8:22 pm
by andrei-1
Tomson wrote: Thu Nov 06, 2025 8:05 pm
It is ok. There are 30 MT4 terminals + 10 positions, and the computer freezes (very high traffic). We need another account.

Crypto exchanges, I would prefer to spread assets across several exchanges.

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Thu Nov 06, 2025 8:55 pm
by Asur
Tomson wrote: Thu Nov 06, 2025 8:05 pm Edit: how then is the PnL showing?
Or am I'm missing something?
That's the mystery. I'm not suggesting anyone is, but with our open-source tools, it's technically possible for the PnL to be as customizable as the indicators themselves.

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Posted: Thu Nov 06, 2025 9:05 pm
by Tomson
Asur wrote: Thu Nov 06, 2025 8:55 pm That's the mystery. I'm not suggesting anyone is, but with our open-source tools, it's technically possible for the PnL to be as customizable as the indicators themselves.
Yep. But why?