HTF Condition Strategy is a multi-timeframe trading strategy that evaluates market structure conditions on both a higher timeframe and the current chart timeframe.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
73 lines of Pine Script v5 from Tradingview/htf-condition-strategy.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
Users can configure entry rules combining conditions such as bullish bias, higher lows, or lower lows using AND/OR logic. Exits are triggered by market structure reversals or configurable percentage Take Profit and Stop Loss levels. The strategy plots on the main price chart and displays an on-chart performance dashboard.
Multi-timeframe condition builder with customizable logic
Higher timeframe and chart timeframe structure evaluation
Percentage-based stop loss and take profit controls
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Higher Timeframe
timeframe
D
higher_tf
Long Condition 1
string
Bullish on HTF
long_condition_1
string
AND
long_and_or_1
Long Condition 2
string
Bullish on HTF
long_condition_2
Long Exit Condition
string
Reversal on HTF
long_exit
Short Condition 1
string
Bullish on HTF
short_condition_1
string
AND
short_and_or_1
Short Condition 2
string
Bullish on HTF
short_condition_2
Short Exit Condition
string
Reversal on HTF
short_exit
TP %
float
2.00
tp_pct
SL %
float
1.00
sl_pct
Dashboard Size
string
Medium
LabelSize
Show all 16 settings
Setting
Type
Default
Variable
Bull Color
color
color.new(#04fc04,0)
bull_color
Bear Color
color
color.new(#fc0404,0)
bear_color
Neutral Color 1
color
color.new(#b2b5be,0)
neutral_color
Neutral Color 2
color
color.new(#8b8f9e,0)
neutral_color2
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This strategy plots an Optimized Trend Tracker and a selectable moving-average support line on the price chart. It builds the average as SMA, EMA, WMA, TMA, VAR, WWMA, ZLEMA, or TSF, then offsets long and short stops by a percent of that average. Optional mark
This strategy automates the TradingLatino methodology by evaluating Squeeze Momentum combined with the Average Directional Index (ADX). It executes long or short positions based on momentum shifts and directional strength. Risk management options include const
Calculates a custom moving average (MaMA) by modifying the source price with price momentum, acceleration, and psychological win-rate probability before applying an EMA or SMA. Plots the adjusted moving average directly on the price chart alongside optional re
This long-only trend-following strategy combines Ichimoku Kinko Hyo components with higher timeframe moving average filters. It triggers long entries when price trades above a higher timeframe EMA and a bullish Tenkan-Sen cross above Kijun-Sen occurs under fav
RG Structure is a pivot-constrained break-and-retest strategy that calculates dynamic trendlines, market structure changes, and regime states on the price chart. It identifies support and resistance lines through pivot points and evaluates break-and-retest sig
Momentum Rotation (Top 3) ranks ten large-cap US tech stocks by their six-month returns using daily closes. It rebalances monthly and holds the top three performing stocks long only on the price chart. A ranking table shows the current order. Main settings adj