Conversion and adjustment of a TradingView Strategy to MQL5

MQL5 Uzman Danışmanlar

İş Gereklilikleri

This is the tradingview strategy: 


I made a few adjustments in the TV Code, also willing to provide this to the developer. 

The adjusted code has the following additional attributes: 

- no repaint of the signals

- (T)SL and (T)TP Settings based on ATR




Additionally i would like to include the following: 


- Option for trade execution in the input: 

Option1: Long Entry Signal = Short Close Signal (Netting)

Option2: Trade with fixed ATR, SL and TP are multiplier of the ATR. By default this option is enabled and the value for ATR is 14, SL Multiplier is 3 and TP Multiplier is 6. There should be an option to enable "Move SL to BE after 1R"

Option3: The ATR is gathered from the current market environment.  With this setting use SL Multiplier = 3  and TP Multiplier = 6 as default. 

Option4. Trade with fixed ATR, SL and TP are multiplier of the ATR. The take profit is moved "upwards" until the signal in the opposite direction appears. SL is also moved "downwards" until the signal of the opposite direction occurs. 

  

// ATR für Stop-Loss und Take-Profit
atr = atr(atr_length)
long_stop = low - atr * atr_multiplier_sl  // Stop-Loss für Long-Trades
long_target = high + atr * atr_multiplier_tp  // Take-Profit für Long-Trades
short_stop = high + atr * atr_multiplier_sl  // Stop-Loss für Short-Trades
short_target = low - atr * atr_multiplier_tp  // Take-Profit für Short-Trades

// Trailing Stop für Long- und Short-Trades
long_trailing = high - atr * atr_multiplier_sl

short_trailing = low + atr * atr_multiplier_sl



1. Strategy Fundamentals

  • The strategy uses the Kaufman Adaptive Moving Average (KAMA) to identify trends and pairs it with Heikin-Ashi candles.
  • Two moving averages are calculated:
    • Black moving average (bfma): Based on Heikin-Ashi logic with adjustments.
    • Red moving average (bsma): A slower exponential moving average (SMA) over a longer period.


2. Signals

  • Long Entry: When the black moving average (bfma) crosses above the red moving average (bsma).
  • Short Entry: When the black moving average crosses below the red moving average.

3. Entry and Exit Logic

  • Entry: A Long or Short position is opened based on the crossover signals:
    • Long Trade: Black MA crosses above Red MA.
    • Short Trade: Black MA crosses below Red MA.
  • Exit: Positions are closed when:
    • The Stop-Loss level is hit.
    • The Take-Profit level is hit.
    • The Trailing Stop is triggered.

4. SL and TP:

- as described above. 

5. Visualization

  • The strategy plots the following on the chart:
    • Black line: Fast moving average (bfma).
    • Red line: Slow moving average (bsma).
    • Stop-Loss and Take-Profit levels for both Long and Short trades.

- Display SL and TP as short lines on the chart

- Display the SL and TP Values in a small table to the bottom left corner of the chart (box size and font size adjustable)

- There should be an overview of which signal would currently be active on which timeframe: This could look like this: 

Timeframe Current trade direction 
1min buy
5min buy
15min buy
30min buy
1h short
2h short
4h  short
1d  short










Yanıtlandı

1
Geliştirici 1
Derecelendirme
(498)
Projeler
569
33%
Arabuluculuk
29
41% / 45%
Süresi dolmuş
9
2%
Yüklendi
2
Geliştirici 2
Derecelendirme
(362)
Projeler
503
52%
Arabuluculuk
24
54% / 25%
Süresi dolmuş
5
1%
Meşgul
3
Geliştirici 3
Derecelendirme
(264)
Projeler
434
38%
Arabuluculuk
88
43% / 18%
Süresi dolmuş
72
17%
Meşgul
4
Geliştirici 4
Derecelendirme
(13)
Projeler
13
100%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
5
Geliştirici 5
Derecelendirme
(37)
Projeler
45
38%
Arabuluculuk
0
Süresi dolmuş
3
7%
Serbest

Proje bilgisi

Bütçe
100+ USD
KDV (19%): 19 USD
Toplam: 119 USD
Geliştirici için
90 USD

Müşteri

(1)
Verilmiş siparişler5
Arabuluculuk sayısı0