Conversion and adjustment of a TradingView Strategy to MQL5

MQL5 Experten

Spezifikation

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










Bewerbungen

1
Entwickler 1
Bewertung
(498)
Projekte
569
33%
Schlichtung
29
41% / 45%
Frist nicht eingehalten
9
2%
Beschäftigt
2
Entwickler 2
Bewertung
(362)
Projekte
503
52%
Schlichtung
24
54% / 25%
Frist nicht eingehalten
5
1%
Überlastet
3
Entwickler 3
Bewertung
(264)
Projekte
434
38%
Schlichtung
88
43% / 18%
Frist nicht eingehalten
72
17%
Überlastet
4
Entwickler 4
Bewertung
(13)
Projekte
13
100%
Schlichtung
0
Frist nicht eingehalten
0
Frei
5
Entwickler 5
Bewertung
(37)
Projekte
45
38%
Schlichtung
0
Frist nicht eingehalten
3
7%
Frei

Projektdetails

Budget
100+ USD
MwSt (19%): 19 USD
Insgesamt: 119 USD
Für die Entwickler
90 USD

Kunde

(1)
Veröffentlichte Aufträge5
Anzahl der Schlichtungen0