指定
📌 Project: Converting a TradingView Indicator (Pine Script) to MQL5
🎯 Project Objective
The goal of this project is to convert a TradingView Pine Script indicator to MQL5 for use on MetaTrader 5 (MT5). The indicator to be converted is UT Bot Alerts by QuantNomad, which is based on an ATR-based trailing stop and generates buy and sell signals in the form of arrows.
Additionally, the ATR calculation method should be flexible, allowing the user to switch between an Exponential ATR (default) and an SMA-based ATR. The SMA-based ATR should produce results identical to the TradingView SuperTrend indicator by KivancOzbilgic.
✅ Required Features
1️⃣ Trailing Stop Calculation
- The trailing stop should be based on the ATR (Average True Range).
- It should adjust dynamically to market movements with the following behavior:
- If the price is above the stop, it follows upward movements but never decreases.
- If the price is below the stop, it follows downward movements but never increases.
- The stop’s sensitivity should be adjustable via an input parameter:
- 🔹 KeyValue – Multiplier for ATR to define trailing stop sensitivity.
2️⃣ ATR Calculation Method (User-Selectable)
- The ATR calculation method should be user-selectable between:
- Exponential ATR (default, like UT Bot Alerts)
- SMA-based ATR (matching KivancOzbilgic’s SuperTrend indicator on TradingView)
- This should be controlled by an input parameter:
- 🔹 ChangeATRMethod – Boolean input ( true = Exponential ATR, false = SMA-based ATR)
3️⃣ Signal Generation
- A buy signal should be generated when the price breaks above the trailing stop.
- A sell signal should be generated when the price breaks below the trailing stop.
- These signals should be displayed as colored arrows:
- Green for a buy signal
- Red for a sell signal
4️⃣ Candle Coloring (Customizable)
- Candles should be colored based on their position relative to the trailing stop:
- Bullish candle: If the price is above the stop.
- Bearish candle: If the price is below the stop.
- Users should be able to customize the candle colors via input parameters:
- 🔹 BullishCandleColor – Color for bullish candles.
- 🔹 BearishCandleColor – Color for bearish candles.
5️⃣ ATR Visibility Toggle
- The user should have the option to display or hide the ATR line on the chart.
- This should be controlled by an input parameter:
- 🔹 ShowATR – Boolean input ( true/false ) to enable or disable ATR visibility.
6️⃣ Compatibility with an Expert Advisor
- The indicator must be readable by an Expert Advisor (EA).
- Buy/sell signals should be accessible via output buffers so that an EA can read them.
7️⃣ Alert System
- A MT5 alert should be triggered whenever a new buy or sell signal is detected.
- The user should have the option to enable or disable alerts via an input parameter:
- 🔹 EnableAlerts – Boolean input ( true/false ) to toggle alerts ON/OFF.
🔧 Input Parameters
Parameter | Description |
---|---|
KeyValue | Sensitivity factor for the trailing stop (multiplied by ATR) |
ATRPeriod | Number of periods used for ATR calculation |
ChangeATRMethod | Boolean ( true = Exponential ATR , false = SMA ATR ) |
ShowATR | Boolean ( true/false ) to enable or disable ATR display |
EnableAlerts | Boolean ( true/false ) to enable or disable alerts |
BullishCandleColor | Customizable color for bullish candles |
BearishCandleColor | Customizable color for bearish candles |
🔄 Conversion Requirements in MQL5
The MQL5 code should adhere to the following principles:
✔ Ensure fast and smooth execution, especially during backtesting and optimization.
✔ Ensure signals are usable by an Expert Advisor (output buffers).
✔ Trigger alerts upon buy/sell signals (if EnableAlerts is true ).
✔ Allow users to customize candle colors dynamically via input parameters.
✔ Allow users to toggle ATR visibility via the ShowATR parameter.
✔ Ensure the SMA-based ATR mode produces identical results to KivancOzbilgic’s TradingView SuperTrend indicator.
🎯 Expected Deliverables
The developer should provide:
✅ A fully functional .mq5 indicator file
📌 Validation Criteria
The indicator will be considered approved if it meets all of the following criteria:
✅ It correctly displays the trailing stop on MT5.
✅ It correctly generates buy/sell signals with arrows.
✅ Candles are colored based on trend direction, with user-defined colors.
✅ The ATR can be toggled on or off via the ShowATR input.
✅ ATR calculation method (Exponential or SMA) works as expected.
✅ The SMA ATR mode produces identical results to KivancOzbilgic’s SuperTrend indicator.
✅ It does not significantly slow down MT5.
✅ It is readable by an Expert Advisor.
✅ It triggers alerts when signals occur (if EnableAlerts is enabled).
🕒 Expected Delivery Time
📅 1 day after contract acceptance
📌 Summary
This conversion should result in a fast and precise MQL5 indicator, with:
✔ Efficient performance
✔ Customizable visuals (candle colors, ATR visibility)
✔ Compatibility with an Expert Advisor
✔ Accurate buy/sell signals matching the UT Bot Alerts indicator on TradingView
✔ An ATR calculation method that can match KivancOzbilgic’s SuperTrend indicator
💬 Next Steps
Please confirm if you have any questions or if additional details are needed before starting. Looking forward to your response. 🚀