Посты канала Next Pip Community™️
- Current MA20 value. - Current MA50 value. - Current trend: BULLISH, BEARISH, or NEUTRAL. - Most recent confirmed crossover: BUY or SELL. - Date and time of the most recent crossover. - Number of bars since the last crossover. - Whether the MA20 is currently above or below the MA50. - Whether both moving averages are rising, falling, or mixed. Use green for bullish information, red for bearish information, and gray for neutral information. The panel must distinguish between: 1. The latest confirmed crossover signal. 2. The current trend. 3. Whether the crossover is recent or old. Do not display an old BUY or SELL crossover as if it were a new signal. ## 8. ALERT SYSTEM When a new BUY or SELL crossover is confirmed, allow the indicator to: - Display an MT5 alert. - Play a sound. - Send a push notification if enabled. - Include the symbol, timeframe, signal type, and closing price in the alert. Prevent duplicate alerts for the same crossover candle. Do not trigger alerts repeatedly on every incoming tick after the signal has been confirmed. ## 9. NON-REPAINTING REQUIREMENTS This is essential. - Generate confirmed crossover signals only after candle closure. - Never use future candle data. - Do not move or delete historical crossover arrows because of later price movement. - Do not generate a confirmed signal from the currently forming candle. - Recalculate historical values correctly when the chart is refreshed or the timeframe changes. - Avoid duplicate signals and alerts. - Use correct MQL5 indicator handles, CopyBuffer(), OnInit(), OnCalculate(), and OnDeinit() implementation where appropriate. - Handle insufficient historical bars and indicator initialization safely. Explain any unavoidable limitations clearly. The indicator should not promise profitable signals or claim that non-repainting signals predict future price movements. ## 10. OPTIONAL HIGHER-TIMEFRAME CONFIRMATION Provide an optional higher-timeframe filter, disabled by default. For example, when trading on M15, the user may choose H1 as the trend-confirmation timeframe. If enabled: - BUY signals are allowed only when the higher-timeframe MA20 is above its MA50. - SELL signals are allowed only when the higher-timeframe MA20 is below its MA50. - Use only completed higher-timeframe candles for confirmation. Make the higher timeframe configurable and handle missing data safely. ## 11. CODE QUALITY REQUIREMENTS Deliver the following: 1. The complete MQL5 source code in one file named MA20_MA50_Crossover.mq5. 2. No pseudocode, omitted functions, placeholders, or unexplained external dependencies. 3. Correct MT5 indicator buffer and plotting configuration. 4. Clear comments explaining the signal logic. 5. Safe memory and indicator-handle management. 6. No compilation errors or warnings where reasonably avoidable. 7. Correct handling of historical chart data and new-bar detection. 8. Efficient recalculation without unnecessary processing on every tick. 9. No trading execution or automatic order placement. This is an indicator only. ## 12. TESTING AND DELIVERY Before presenting the final code: - Review the crossover conditions for off-by-one errors. - Verify the BUY and SELL crossover logic. - Check the closed-candle indexing. - Check that historical arrows are plotted on the correct candles. - Check that alerts trigger only once per confirmed signal. - Check that optional filters work independently. - Check that all configurable inputs have sensible defaults. - Review the code for MQL5-specific syntax and API compatibility. If you cannot actually compile or execute the code in MetaTrader 5, state that clearly instead of claiming it has been compiled or tested. Finally, provide step-by-step instructions for installing the indicator in MT5, compiling it in MetaEditor, attaching it to a chart, and configuring its inputs. Return the complete source code first, followed by installation instructions, a clear explanation of the strategy, and a testing checklist.
Открыть в Telegram# TASK: Build a Complete MT5 Indicator Using MA20 and MA50 Crossover Strategy Act as an expert MQL5 developer and professional technical analysis trader. Create a complete, compile-ready MetaTrader 5 (MT5) custom indicator using the 20-period Moving Average (MA20) and 50-period Moving Average (MA50). The indicator must be reliable, easy to understand, visually clear, and suitable for beginners. Write the code in native MQL5, not MQL4. ## 1. INDICATOR SETTINGS Create configurable inputs for: - Fast Moving Average Period: 20 - Slow Moving Average Period: 50 - Moving Average Method: Simple Moving Average (SMA) by default, with an option to select EMA - Applied Price: Close - Signal Confirmation: Wait for the candle to close - Enable BUY signals: true - Enable SELL signals: true - Enable Alerts: true - Enable Sound Alerts: true - Enable Push Notifications: false by default - Show Moving Averages: true - Show Signal Arrows: true - Show Status Panel: true All settings must be adjustable through the MT5 indicator properties. ## 2. BUY SIGNAL LOGIC Generate a potential BUY signal when: 1. The MA20 crosses from below the MA50 to above the MA50. 2. The crossover is confirmed on a fully closed candle. 3. The indicator compares the current closed candle with the previous closed candle to confirm that a genuine crossover occurred. Mathematical conditions: - Previous closed candle: MA20 is less than or equal to MA50. - Latest closed candle: MA20 is greater than MA50. When these conditions are met, display a green upward arrow below the signal candle. Label the signal "BUY". ## 3. SELL SIGNAL LOGIC Generate a potential SELL signal when: 1. The MA20 crosses from above the MA50 to below the MA50. 2. The crossover is confirmed on a fully closed candle. 3. The indicator verifies that a genuine crossover occurred between the two closed candles. Mathematical conditions: - Previous closed candle: MA20 is greater than or equal to MA50. - Latest closed candle: MA20 is less than MA50. When these conditions are met, display a red downward arrow above the signal candle. Label the signal "SELL". ## 4. TREND DIRECTION FILTER Add an optional trend filter that is enabled or disabled through the settings. When enabled: - Bullish trend: MA20 is above MA50. - Bearish trend: MA20 is below MA50. - Neutral market: The moving averages are very close together or repeatedly crossing. Optionally use the slopes of the moving averages to strengthen trend confirmation: - Bullish confirmation: MA20 is above MA50 and both moving averages are rising. - Bearish confirmation: MA20 is below MA50 and both moving averages are falling. Make the slope filter configurable so users can switch it on or off. Important: A crossover is a change in the relationship between the two averages. Two averages both sloping upward or both sloping downward is not, by itself, a crossover. ## 5. OPTIONAL PULLBACK SIGNALS Add a separate setting to enable or disable pullback signals. Keep this feature disabled by default. Potential BUY pullback: - MA20 is above MA50. - Price pulls back toward the MA20 or MA50. - A bullish candle closes after the pullback. Potential SELL pullback: - MA20 is below MA50. - Price rallies toward the MA20 or MA50. - A bearish candle closes after the rally. Make the pullback tolerance configurable using points or a suitable ATR-based distance. Do not generate repeated arrows on every candle during the same pullback. Define clear conditions for a new pullback signal and document them. ## 6. MOVING AVERAGE DISPLAY Display both moving averages clearly on the price chart: - MA20: Blue line. - MA50: Orange line. Make the line colors, widths, and visibility configurable. Ensure the moving averages are calculated using the selected MA method and applied price. ## 7. LAST CROSSOVER STATUS PANEL Create a small, readable panel in a chart corner displaying:
Открыть в Telegram