Dawno mnie tu nie było.
Od miesięcy używam różnych AI do celów przede wszystkim rozrywkowych.
Rynkami interesuję się raczej okazjonalnie i z dala od wchodzenia w niego.
Dzisiaj postanowiłem przetestować DeepSeek, do napisania innowacyjnego wskaźnika dla MT5 w języku tylko mql5. Mógł użyć do tego każdego innego wskaźnika, danych ohlc i wolumenów.
Oto co wypluł po długich poprawkach.
Wskaźnik działa. Sygnał jest w osobnym oknie pod wykresem, ale niezbyt czytelny. generuje jakieś tam sygnały. Pod kodem wkleję opis jak czytać sygnały.
Zapraszam do dyskusji i własnych testów.
Może jakieś poprawki by sie przydały.
Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| QuantumTrendNexus_DeepSeek.mq5 |
//| Copyright 2023, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, Quantum Trading Innovations"
#property version "1.00"
#property description "Advanced Predictive Trend Indicator"
#property indicator_separate_window
#property indicator_buffers 8
#property indicator_plots 4
#property indicator_label1 "QuantumOscillator"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDodgerBlue
#property indicator_label2 "TrendWave"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrDarkOrange
#property indicator_label3 "BullishDivergence"
#property indicator_type3 DRAW_ARROW
#property indicator_color3 clrLimeGreen
#property indicator_label4 "BearishDivergence"
#property indicator_type4 DRAW_ARROW
#property indicator_color4 clrRed
//+------------------------------------------------------------------+
//| Input Parameters |
//+------------------------------------------------------------------+
input ENUM_TIMEFRAMES WaveletTF = PERIOD_H4; // Wavelet timeframe
input int CorePeriod = 34; // Core period
input double VolumeWeight = 1.8; // Volume weight
input int TickSensitivity = 3; // Tick sensitivity
input bool EnableAI = true; // Neural filter
input int PredictionBars = 3; // Prediction bars
input double BullThreshold = 0.68; // Bull threshold
input double BearThreshold = -0.68; // Bear threshold
input int DivergenceDepth = 5; // Divergence depth
//+------------------------------------------------------------------+
//| Global Variables |
//+------------------------------------------------------------------+
int maHandle;
double maBuffer[];
//+------------------------------------------------------------------+
//| Indicator Buffers |
//+------------------------------------------------------------------+
double QuantumBuffer[];
double TrendWaveBuffer[];
double BullishDivergenceBuffer[];
double BearishDivergenceBuffer[];
double TempVolumeBuffer[];
double TickAccelBuffer[];
double PriceMomentumBuffer[];
double NeuralFilterBuffer[];
//+------------------------------------------------------------------+
//| Custom Functions |
//+------------------------------------------------------------------+
double CalculateQuantumEnergy(int index, const long &volume[], const long &tick_volume[]) {
double energy = 0.0;
double volumeFactor = MathLog((double)volume[index]+1) * VolumeWeight;
double tickAccel = ((double)tick_volume[index] - (double)tick_volume[index+1]) * TickSensitivity;
double wavelet = 0;
for(int i = 0; i < 5; i++) {
wavelet += (iClose(NULL,WaveletTF,index+i) - iClose(NULL,WaveletTF,index+i+2))
* (1 - (i%2)*2);
}
double closePrice = iClose(NULL,0,index);
double maValue;
CopyBuffer(maHandle, 0, index, 1, maBuffer);
maValue = maBuffer[0];
double momentum = (closePrice - maValue) / _Point;
return (momentum + wavelet + volumeFactor + tickAccel) * 0.25;
}
//+------------------------------------------------------------------+
//| Neural Network Filter |
//+------------------------------------------------------------------+
double ApplyNeuralFilter(double x) {
static double memoryCell = 0;
double gate = MathTanh(x * 0.5 + memoryCell * 0.3);
memoryCell = memoryCell * 0.8 + x * gate;
return MathTanh(memoryCell * 0.6);
}
//+------------------------------------------------------------------+
//| Divergence Detection |
//+------------------------------------------------------------------+
bool CheckDivergence(int mode, int index) {
if(index >= ArraySize(QuantumBuffer)-DivergenceDepth-1) return false;
int pricePeak = ArrayMaximum(QuantumBuffer, index, DivergenceDepth);
int priceValley = ArrayMinimum(QuantumBuffer, index, DivergenceDepth);
if(pricePeak == -1 || priceValley == -1) return false;
double priceHigh = iHigh(NULL,0,pricePeak);
double priceLow = iLow(NULL,0,priceValley);
if(mode == 1) {
return (priceLow > iLow(NULL,0,priceValley+1) &&
QuantumBuffer[priceValley] < QuantumBuffer[priceValley+1]);
}
else if(mode == -1) {
return (priceHigh < iHigh(NULL,0,pricePeak+1) &&
QuantumBuffer[pricePeak] > QuantumBuffer[pricePeak+1]);
}
return false;
}
//+------------------------------------------------------------------+
//| Initialization |
//+------------------------------------------------------------------+
int OnInit() {
maHandle = iMA(NULL, 0, CorePeriod, 0, MODE_EMA, PRICE_CLOSE);
SetIndexBuffer(0, QuantumBuffer, INDICATOR_DATA);
SetIndexBuffer(1, TrendWaveBuffer, INDICATOR_DATA);
SetIndexBuffer(2, BullishDivergenceBuffer, INDICATOR_DATA);
SetIndexBuffer(3, BearishDivergenceBuffer, INDICATOR_DATA);
SetIndexBuffer(4, TempVolumeBuffer, INDICATOR_CALCULATIONS);
SetIndexBuffer(5, TickAccelBuffer, INDICATOR_CALCULATIONS);
SetIndexBuffer(6, PriceMomentumBuffer, INDICATOR_CALCULATIONS);
SetIndexBuffer(7, NeuralFilterBuffer, INDICATOR_CALCULATIONS);
PlotIndexSetInteger(2, PLOT_ARROW, 233);
PlotIndexSetInteger(3, PLOT_ARROW, 234);
IndicatorSetInteger(INDICATOR_DIGITS, 2);
IndicatorSetString(INDICATOR_SHORTNAME, "QT Nexus");
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Main Calculation |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[]) {
int limit = rates_total - prev_calculated;
if(prev_calculated > 0) limit++;
CopyBuffer(maHandle, 0, 0, rates_total, maBuffer);
for(int i = limit-1; i >= 0; i--) {
if(i > rates_total - PredictionBars - 5) continue;
QuantumBuffer[i] = CalculateQuantumEnergy(i, volume, tick_volume);
double sum = 0;
int count = 0;
for(int j = 0; j < CorePeriod/2 && (i+j) < rates_total; j++) {
sum += QuantumBuffer[i+j];
count++;
}
if(count > 0) TrendWaveBuffer[i] = sum/count;
if(EnableAI) {
QuantumBuffer[i] = ApplyNeuralFilter(QuantumBuffer[i]);
TrendWaveBuffer[i] = ApplyNeuralFilter(TrendWaveBuffer[i]);
}
if(CheckDivergence(1, i)) BullishDivergenceBuffer[i] = QuantumBuffer[i] - 0.0005;
if(CheckDivergence(-1, i)) BearishDivergenceBuffer[i] = QuantumBuffer[i] + 0.0005;
}
return(rates_total);
}
Oto kompleksowy przewodnik interpretacji wskaźnika Quantum Trend Nexus:
### 1. **Główne Komponenty Wskaźnika**
| Element | Kolor | Opis |
|-----------------------|----------------|---------------------------------------------------------------------|
| QuantumOscillator | Niebieski | Główny oscylator trendu (łączy momentum, wolumen i analizę falkową) |
| TrendWave | Pomarańczowy | Wygładzona średnia ruchoma sygnału kwantowego |
| BullishDivergence | Zielona strzałka| Sygnał dywergencji byczej (🡅) |
| BearishDivergence | Czerwona strzałka| Sygnał dywergencji niedźwiedziej (🡇) |
### 2. **Interpretacja Sygnałów**
#### A. **Poziomy Progowe**
- **BullThreshold (0.68)** - strefa wykupienia:
```mql5
if(QuantumOscillator > 0.68)

```
- **BearThreshold (-0.68)** - strefa wyprzedania:
```mql5
if(QuantumOscillator < -0.68)

```
#### B. **Interakcja Oscylatora i TrendWave**
- **Trend wzrostowy**:
```
QuantumOscillator > TrendWave
&& Obie linie rosnące
```
- **Trend spadkowy**:
```
QuantumOscillator < TrendWave
&& Obie linie malejące
```
- **Zmiana trendu**:
```mql5
Przecięcie QuantumOscillator przez TrendWave od dołu

Przecięcie QuantumOscillator przez TrendWave od góry

```
### 3. **Dywergencje (Najsilniejsze Sygnały)**
#### Przykład praktyczny:
```pine
// Dywergencja Bycza
Cena: Lower Low (LL)
Oscylator: Higher Low (HL)

// Dywergencja Niedźwiedzia
Cena: Higher High (HH)
Oscylator: Lower High (LH)

```
### 4. **Filtr Neuronowy**
- **Efekt Wizualny**:
- Włączony (`EnableAI=true`): Gładsze linie, mniej fałszywych sygnałów
- Wyłączony: Bardziej dynamiczna, wrażliwsza reakcja na zmiany
### 5. **Strategie Tradingowe**
#### A. **Kombinacja Sygnałów**
```python
if BullishDivergence and QuantumOscillator < -0.68:
Sygnał kupna
elif BearishDivergence and QuantumOscillator > 0.68:
Sygnał sprzedaży
```
#### B. **Potwierdzenie Trendu**
```
Entry Long gdy:
1. QuantumOscillator przekroczy TrendWave od dołu
2. VolumeWeight > 1.5 (silne wsparcie wolumenowe)
3. TickSensitivity > 2 (reakcja na płynność)
```
### 6. **Optymalizacja Parametrów**
| Rynek | Sugerowane Ustawienia |
|-------------|-----------------------------------------------|
| Forex | `CorePeriod=34`, `VolumeWeight=1.0` |
| Kryptowaluty| `CorePeriod=55`, `TickSensitivity=4` |
| Akcje | `DivergenceDepth=7`, `PredictionBars=2` |
### 7. **Wskazówki Praktyczne**
1. Na mniejszych interwałach (M1-M15) zwiększ TickSensitivity do 4-5
2. W okresach wysokiej zmienności zmniejsz VolumeWeight o 30%
3. Do analizy długoterminowej używaj WaveletTF=PERIOD_D1
### Wizualizacja Działań:
```diff
+ Sygnał KUPNA:
Zielona strzałka + QuantumOscillator przecina TrendWave od dołu
w strefie wyprzedania (-0.68)
- Sygnał SPRZEDAŻY:
Czerwona strzałka + QuantumOscillator przecina TrendWave od góry
w strefie wykupienia (+0.68)
```
Wskaźnik najlepiej sprawdza się w połączeniu z analizą struktury rynku (poziomy support/opór) oraz wskaźnikami wolumenowymi.