logo
Developers

Moving Stop-Loss mechanism + alerts to MT4/MT5

Script from: TradingViewIntradayMomentumTrend following

Enhance your MT4/MT5 trading with a Moving Stop-Loss mechanism that automatically adjusts as new pivot highs/lows are detected during an open trade. This dynamic scripting enables traders to exit positions via Stochastic crossovers and manage risk in real-time by updating the stop-loss levels directly within the strategy.exit() function. Incorporate automated alerts to TradingConnector for seamless execution across various markets. Recent script improvements eliminate the need for 'tradeid=' in single-position trades.

DOT / TetherUS (DOTUSDT)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ Daily

1.10

Risk Reward

237.31 %

Total ROI

382

Total Trades

CAKE / TetherUS (CAKEUSDT)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ 4 h

1.09

Risk Reward

1,599.42 %

Total ROI

2135

Total Trades

VeChain / TetherUS (VETUSDT)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ Daily

1.09

Risk Reward

229.24 %

Total ROI

529

Total Trades

VIRTUAL / TetherUS (VIRTUALUSDT)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ 4 h

1.05

Risk Reward

80.73 %

Total ROI

470

Total Trades

Algorand / TetherUS (ALGOUSDT)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ Daily

1.05

Risk Reward

183.42 %

Total ROI

465

Total Trades

FLOW / TetherUS (FLOWUSDT)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ Daily

1.01

Risk Reward

13.72 %

Total ROI

296

Total Trades

Cardio Diagnostics Holdings Inc. (CDIO)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ Daily

1.58

Risk Reward

1,411.58 %

Total ROI

180

Total Trades

Renault (RNO)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ 1 h

1.24

Risk Reward

1,008.76 %

Total ROI

3790

Total Trades

Uber Technologies, Inc. (UBER)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ Daily

1.23

Risk Reward

246.96 %

Total ROI

297

Total Trades

Alpine Immune Sciences, Inc. (ALPN)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ 4 h

1.23

Risk Reward

462.11 %

Total ROI

900

Total Trades

Energy Transfer LP (ET)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ 4 h

1.22

Risk Reward

9,728.50 %

Total ROI

1739

Total Trades

XP Inc. (XP)

+ Moving Stop-Loss mechanism + alerts to MT4/MT5

@ 1 h

1.22

Risk Reward

4,001.38 %

Total ROI

1958

Total Trades
Create your account for free to see all 182+ backtests

Access filters, details, best timeframes, explore 100K+ backtests and more

Active Trades

Create your account to see on which symbols Moving Stop-Loss mechanism + alerts to MT4/MT5 is currently trading on.

Guide

How does the Moving Stop-Loss mechanism + alerts to MT4/MT5 strategy work ?

The Moving Stop-Loss mechanism strategy utilizes a dynamic approach by adjusting the stop-loss level each time a new pivot high or low is identified while a trade is active. The adjustment is accomplished by mutating the stoploss_long or stoploss_short variables upon detecting UpdateLongStopLoss or UpdateShortStopLoss events, respectively. This alteration must be encapsulated within the strategy.exit() function to execute correctly.

Entry signals are generated by Stochastic (Stoch) crossovers, where a long position is initiated if the Stoch crosses above the signal line and remains under 80 (overbought threshold), and a short position is taken if the Stoch crosses below the signal line and is over 20 (oversold threshold).

Moreover, the last portion of the script integrates commands to formulate updates and trigger alerts that are sent to MetaTrader through TradingConnector for application in Forex, indices, commodities, and crypto markets. Notably, with the recent update, single-position trades do not require a tradeid= parameter, thus simplifying the alert mechanism.

How to use the Moving Stop-Loss mechanism + alerts to MT4/MT5 strategy ?

This trading strategy uses Moving Stop-Loss mechanism based on Stochastic Oscillator for entry signals and pivot points for a dynamic stop-loss adjustment. Long and Short entries are triggered by Stochastic crossovers and protected by stop-losses that shift with new pivot high or low detections.

To trade this strategy manually on TradingView:

  • Apply the Stochastic Oscillator with settings: %K period = 13, %D period = 3, and a Smoothing of 4.
  • Enter a Long position when the Stochastic %K line crosses above the %D line and %K is below 80.
  • Enter a Short position when the Stochastic %K line crosses below the %D line and %K is above 20.
  • Use the last pivot low to place the initial stop-loss for a Long position and the last pivot high for a Short position.
  • Adjust the stop-loss to the new pivot lows (for Long positions) or pivot highs (for Short positions) if a new pivot is detected after entering the trade.
  • Take Profit level is statically set 400 pips/points from the entry.
  • Optionally, you can use on-chart visuals like arrows or icons to mark entry points, stop-loss movements, and take profit levels.

How to optimize the Moving Stop-Loss mechanism + alerts to MT4/MT5 trading strategy ?

To optimize the Moving Stop-Loss mechanism strategy with manual trading, several enhancements can be employed to refine entry points, manage risks more effectively, and maximize potential returns. These adjustments take advantage of nuanced trader insights and discretionary decision-making.

  • Tighten Entry Criteria: Instead of using only Stochastic crossovers, confirm entries with additional indicators such as Moving Averages (MA), Relative Strength Index (RSI), or candlestick patterns to ensure that trades align with the overall trend and momentum. For instance, only consider a Long entry if the price is above an MA, and the RSI is not in overbought territory.
  • Dynamic Profit Targets: A static Take Profit (TP) level could leave money on the table in strong trending markets or hit too early during volatility. Implement a trailing take profit or scale out of positions by taking partial profits at multiple predetermined levels or use indicators like Average True Range (ATR) to set TP relative to current market conditions.
  • Market Context Analysis: Incorporate fundamental analysis and market sentiment to fine-tune your strategy. Avoid entering trades before major news events or when high-impact economic data releases can cause increased volatility, affecting the reliability of technical signals.
  • Customize Stop-Loss Adjustments: While the pivot based stop-loss update is smart, consider adding a buffer to avoid stop hunting. Calculate this buffer using a fraction of the ATR to account for normal price fluctuations and prevent premature stop-outs.
  • Diversification: Expand the strategy across multiple timeframes and asset classes to benefit from varied market conditions. Different timeframes can provide insights into immediate and long-term trends. This approach can also balance the portfolio and reduce overall risk.
  • Manual Override: Use discretion to override automated signals when clear counter indicators are apparent. For example, avoid taking a short position during a strong bullish trend just because the Stochastic indicates a momentary overbought condition.
  • Risk Management: Adjust your position sizes based on the confidence level of each trade signal. Use a lower position size for signals that meet minimum criteria and increase it for those that align with multiple confluence factors for a higher probability of success.
  • Performance Review: Regularly review trade performance to identify patterns in successful and unsuccessful trades. Use this data to further refine entry, exit, and stop-loss adjustment criteria.

For which kind of traders is the Moving Stop-Loss mechanism + alerts to MT4/MT5 strategy suitable ?

This strategy is designed for traders who are comfortable with coding and automating their trading processes, particularly in the MT4/MT5 platforms. It suits those interested in a technical and systematic trading style, where trade entries and exits are determined by specific indicator conditions, in this case, Stochastic crossovers and pivot points for dynamic stop-loss adjustment.

  • Traders who prefer a hands-off approach to position management and appreciate the benefits of automated stop adjustments to secure profits and reduce losses.
  • Mid-term to short-term traders, including swing and day traders, will find this strategy beneficial due to the nature of stop-loss movement based on pivot high/low detection.
  • Those who value a mechanical execution style to minimize the emotional impact on trading decisions.

Key Takeaways of Moving Stop-Loss mechanism + alerts to MT4/MT5

  • Strategy Essence: Utilizes Stochastics for entry and pivot levels for dynamic stop-loss.
  • Automation Focus: Geared towards traders adept at scripting for the MT4/MT5 environment.
  • Manual Trading: Requires additional indicators and market analysis for enhanced decision-making.
  • Strategy Operation: Entry signals are automated; manual oversight for pivot-based stop-loss updates.
  • Optimization Approach: Tighten entries with trend confirmation and manage exits with dynamic profit targets.
  • Discretionary Inputs: Incorporate market context and fundamental analysis for better signal accuracy.
  • Stop-Loss Tweaks: Add ATR-based buffers to dynamic stop-loss to prevent premature exits.
  • Diversity of Application: Apply across various timeframes and markets to spread risk.
  • Risk Management: Adjust position sizes based on signal strength and pre-set criteria.
  • Continuous Review: Regularly assess trade outcomes to refine tactics.
Explore the best Trading & TradingView strategies

Stop trading blindly. Explore the best strategies among 100K+ backtests and improve your trading skills with data.

Start for free