GNGTrader08

Multi-Timeframe Trend Following with 200 EMA Filter - Longs Only

Overview

This strategy is designed to trade long positions based on multiple timeframe Exponential Moving Averages (EMAs) and a 200 EMA filter. The strategy ensures that trades are only entered in strong uptrends and aims to capitalize on sustained upward movements while minimizing risk with a defined stop-loss and take-profit mechanism.

Key Components

Initial Capital and Position Sizing

Initial Capital: $1000.
Lot Size: 1 unit per trade.
Inputs

Fast EMA Length (fast_length): The period for the fast EMA.
Slow EMA Length (slow_length): The period for the slow EMA.
200 EMA Length (filter_length_200): Set to 200 periods for the primary trend filter.
Stop Loss Percentage (stop_loss_perc): Set to 1% of the entry price.
Take Profit Percentage (take_profit_perc): Set to 3% of the entry price.
Timeframes and EMAs

EMAs are calculated for the following timeframes using the request.security function:
5-minute: Short-term trend detection.
15-minute: Intermediate-term trend detection.
30-minute: Long-term trend detection.
The strategy also calculates a 200-period EMA on the 5-minute timeframe to serve as a primary trend filter.
Trend Calculation

The strategy determines the trend for each timeframe by comparing the fast and slow EMAs:
If the fast EMA is above the slow EMA, the trend is considered positive (1).
If the fast EMA is below the slow EMA, the trend is considered negative (-1).
Combined Trend Signal

The combined trend signal is derived by summing the individual trends from the 5-minute, 15-minute, and 30-minute timeframes.
A combined trend value of 3 indicates a strong uptrend across all timeframes.
Any combined trend value less than 3 indicates a weakening or negative trend.
Entry and Exit Conditions

Entry Condition:
A long position is entered if:
The combined trend signal is 3 (indicating a strong uptrend across all timeframes).
The current close price is above the 200 EMA on the 5-minute timeframe.
Exit Condition:
The long position is exited if:
The combined trend signal is less than 3 (indicating a weakening trend).
The current close price falls below the 200 EMA on the 5-minute timeframe.
Stop Loss and Take Profit

Stop Loss: Set at 1% below the entry price.
Take Profit: Set at 3% above the entry price.
These levels are automatically set when entering a trade using the strategy.entry function with stop and limit parameters.
Plotting

The strategy plots the fast and slow EMAs for the 5-minute timeframe and the 200 EMA for visual reference on the chart:
Fast EMA (5-min): Plotted in blue.
Slow EMA (5-min): Plotted in red.
200 EMA (5-min): Plotted in green.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?