Conversion and adjustment of a TradingView Strategy to MQL5

MQL5 Эксперты

Техническое задание

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










Откликнулись

1
Разработчик 1
Оценка
(498)
Проекты
569
33%
Арбитраж
29
41% / 45%
Просрочено
9
2%
Загружен
2
Разработчик 2
Оценка
(362)
Проекты
503
52%
Арбитраж
24
54% / 25%
Просрочено
5
1%
Занят
3
Разработчик 3
Оценка
(264)
Проекты
434
38%
Арбитраж
88
43% / 18%
Просрочено
72
17%
Занят
4
Разработчик 4
Оценка
(13)
Проекты
13
100%
Арбитраж
0
Просрочено
0
Свободен
5
Разработчик 5
Оценка
(37)
Проекты
45
38%
Арбитраж
0
Просрочено
3
7%
Свободен

Информация о проекте

Бюджет
100+ USD
VAT (19%): 19 USD
Итого: 119 USD
Исполнителю
90 USD

Заказчик

(1)
Размещено заказов5
Количество арбитражей0