<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ranga </title>
    <description>The latest articles on DEV Community by Ranga  (@ranga_tech).</description>
    <link>https://dev.to/ranga_tech</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3647398%2F8ad73d64-871c-4053-8358-60184320fd53.png</url>
      <title>DEV Community: Ranga </title>
      <link>https://dev.to/ranga_tech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ranga_tech"/>
    <language>en</language>
    <item>
      <title>Fair Value Gap (FVG) Continuation Framework</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Mon, 08 Jun 2026 10:05:14 +0000</pubDate>
      <link>https://dev.to/ranga_tech/fair-value-gap-fvg-continuation-framework-3cj9</link>
      <guid>https://dev.to/ranga_tech/fair-value-gap-fvg-continuation-framework-3cj9</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Overview&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy studies how price interacts with Fair Value Gaps (FVGs), which are areas that can form after strong directional price movement.&lt;/p&gt;

&lt;p&gt;The script identifies potential imbalance zones and monitors future price interaction with those areas. Rather than entering immediately after a gap forms, the strategy waits for price to revisit the zone and show signs of continuing in the original direction.&lt;/p&gt;

&lt;p&gt;The objective is to explore how imbalance zones may be incorporated into a rules-based trading framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What Is a Fair Value Gap?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A Fair Value Gap is commonly described as an area created when price moves rapidly, leaving a gap between portions of surrounding candles.&lt;/p&gt;

&lt;p&gt;In this script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bullish gaps are identified after upward displacement.&lt;/li&gt;
&lt;li&gt;Bearish gaps are identified after downward displacement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Previously identified zones remain available for future analysis when price revisits them.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Strategy Logic&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Gap Identification&lt;/strong&gt;&lt;br&gt;
The script searches for simple three-candle imbalance patterns that may indicate a Fair Value Gap.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Zone Retest&lt;/strong&gt;&lt;br&gt;
Once a gap has been identified, the strategy waits for price to return to that area.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Continuation Confirmation&lt;/strong&gt;&lt;br&gt;
A trade is considered only after price revisits the zone and closes back in the direction of the original move.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk Management&lt;/strong&gt;&lt;br&gt;
Stop-loss and target levels are calculated using ATR, allowing risk parameters to adapt to changing volatility conditions.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Features&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fair Value Gap detection&lt;/li&gt;
&lt;li&gt;Retest-based entries&lt;/li&gt;
&lt;li&gt;ATR-based risk management&lt;/li&gt;
&lt;li&gt;Trend continuation framework&lt;/li&gt;
&lt;li&gt;Research and testing focused design&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Intended Use&lt;/strong&gt;&lt;br&gt;
This script is designed as an educational example demonstrating one approach to identifying and testing Fair Value Gap behavior.&lt;br&gt;
It may be used to study:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price imbalances&lt;/li&gt;
&lt;li&gt;Retest behavior&lt;/li&gt;
&lt;li&gt;Trend continuation concepts&lt;/li&gt;
&lt;li&gt;Volatility-adjusted exits&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Users may choose to modify parameters and test the script across different symbols and timeframes.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Notes&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Fair Value Gap concepts are interpreted differently by different traders. This script provides one simplified implementation and should not be considered a complete representation of all Fair Value Gap methodologies.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Disclaimer&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This script is provided for educational and research purposes only. It demonstrates one method of identifying and testing Fair Value Gap behavior using Pine Script. The script does not predict future market direction and should be evaluated through independent testing before being incorporated into any trading process.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pine Script Example&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy("Fair Value Gap Continuation Framework", overlay=true, initial_capital=100000)

// Inputs
atrLen   = input.int(14, "ATR Length")
atrMult  = input.float(1.5, "Stop ATR Multiplier")
rr       = input.float(2.0, "Risk Reward")
trendLen = input.int(50, "Trend EMA Length")

// Trend Filter
emaTrend = ta.ema(close, trendLen)

// ATR
atrValue = ta.atr(atrLen)

// Fair Value Gap Detection
bullFVG = low &amp;gt; high[2]
bearFVG = high &amp;lt; low[2]

// Store Latest FVG Zones
var float bullTop = na
var float bullBottom = na

var float bearTop = na
var float bearBottom = na

if bullFVG
    bullTop := low
    bullBottom := high[2]

if bearFVG
    bearTop := low[2]
    bearBottom := high

// Retest Logic
bullRetest = not na(bullTop) and low &amp;lt;= bullTop and close &amp;gt; bullTop
bearRetest = not na(bearBottom) and high &amp;gt;= bearBottom and close &amp;lt; bearBottom

// Trend Confirmation
longCondition = bullRetest and close &amp;gt; emaTrend
shortCondition = bearRetest and close &amp;lt; emaTrend

// Entries
if longCondition and strategy.position_size &amp;lt;= 0
    strategy.entry("Long", strategy.long)

if shortCondition and strategy.position_size &amp;gt;= 0
    strategy.entry("Short", strategy.short)

// Risk Management
longStop   = strategy.position_avg_price - atrValue * atrMult
longTarget = strategy.position_avg_price + atrValue * atrMult * rr

shortStop   = strategy.position_avg_price + atrValue * atrMult
shortTarget = strategy.position_avg_price - atrValue * atrMult * rr

strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTarget)

// Visuals
plot(emaTrend, title="Trend EMA", color=color.orange)

plot(bullTop, title="Bullish FVG", color=color.green, linewidth=2)
plot(bearBottom, title="Bearish FVG", color=color.red, linewidth=2)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
    </item>
    <item>
      <title>Why Market Breadth Matters More Than Index Performance</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Mon, 01 Jun 2026 12:51:03 +0000</pubDate>
      <link>https://dev.to/ranga_tech/why-market-breadth-matters-more-than-index-performance-f6h</link>
      <guid>https://dev.to/ranga_tech/why-market-breadth-matters-more-than-index-performance-f6h</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Overview&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Many traders focus on major indexes such as the S&amp;amp;P 500 or Nasdaq when evaluating market conditions. While indexes show overall price movement, they do not always reflect how broadly that movement is supported across the market.&lt;br&gt;
Market breadth is a way of studying participation. It can help traders understand whether strength or weakness is concentrated in a small group of stocks or spread across a wider portion of the market.&lt;br&gt;
A market move supported by broad participation may provide different context than a move driven by only a few heavily weighted stocks.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Understanding Market Participation&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Market breadth generally refers to the number of securities contributing to a market move.&lt;/p&gt;

&lt;p&gt;Examples of breadth-related observations include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The balance between advancing and declining stocks&lt;/li&gt;
&lt;li&gt;The number of stocks reaching new highs or lows&lt;/li&gt;
&lt;li&gt;The percentage of stocks trading above key moving averages&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These measurements can provide additional perspective alongside price action and trend analysis.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Traders Monitor Breadth&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Participation Matters&lt;/strong&gt;&lt;br&gt;
Strong participation may indicate that market activity is occurring across a wider group of stocks rather than being concentrated in a few names.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional Context&lt;/strong&gt;&lt;br&gt;
Breadth can be used as a supplementary tool when evaluating trends, momentum, and overall market conditions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Market Observation&lt;/strong&gt;&lt;br&gt;
Some traders monitor breadth metrics to better understand changes in participation over time and how those changes compare with index performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strategy Concept&lt;/strong&gt;&lt;br&gt;
This script uses a simplified breadth-style proxy derived from the chart's relationship to a long-term moving average.&lt;br&gt;
It is important to note that this script does not use actual exchange-wide market breadth data. Instead, it creates a participation-style filter using price behavior on the current chart.&lt;/p&gt;

&lt;p&gt;The strategy combines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Trend identification using moving averages&lt;/li&gt;
&lt;li&gt;A breadth-style participation filter&lt;/li&gt;
&lt;li&gt;ATR-based risk management&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The objective is to demonstrate how participation concepts can be incorporated into a trend-following framework for research and testing purposes.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Important Notes&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This script uses a simplified participation-style filter and is not a substitute for exchange-wide breadth indicators.&lt;/li&gt;
&lt;li&gt;Results will vary across symbols, timeframes, and market conditions.&lt;/li&gt;
&lt;li&gt;The script is intended for educational, research, and testing purposes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Disclaimer&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This script is provided for educational and research purposes only. It demonstrates one way to combine trend analysis with a breadth-style participation filter. It is not financial advice and should be tested across different symbols, market conditions, and timeframes before being used in any trading workflow.&lt;/p&gt;

&lt;p&gt;This version avoids performance claims, avoids implying predictive ability, and clearly explains the limitations of the breadth proxy.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pine Script v6 Strategy&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy("Market Breadth Trend Strategy", overlay=true, initial_capital=100000)

// Inputs
emaFastLen = input.int(50, "Fast EMA")
emaSlowLen = input.int(200, "Slow EMA")
atrLen = input.int(14, "ATR Length")
atrMult = input.float(1.5, "ATR Stop Multiplier")
rr = input.float(2.0, "Risk Reward")

// Trend
emaFast = ta.ema(close, emaFastLen)
emaSlow = ta.ema(close, emaSlowLen)

trendBull = emaFast &amp;gt; emaSlow
trendBear = emaFast &amp;lt; emaSlow

// Simplified Breadth-Style Proxy
breadthLine = ta.sma(close &amp;gt; emaSlow ? 100 : 0, 20)

strongBreadth = breadthLine &amp;gt; 60
weakBreadth = breadthLine &amp;lt; 40

// Entries
longCondition = trendBull and strongBreadth
shortCondition = trendBear and weakBreadth

if longCondition and strategy.position_size &amp;lt;= 0
    strategy.entry("Long", strategy.long)

if shortCondition and strategy.position_size &amp;gt;= 0
    strategy.entry("Short", strategy.short)

// Risk Management
atrValue = ta.atr(atrLen)

longStop = strategy.position_avg_price - atrValue * atrMult
longTarget = strategy.position_avg_price + atrValue * atrMult * rr

shortStop = strategy.position_avg_price + atrValue * atrMult
shortTarget = strategy.position_avg_price - atrValue * atrMult * rr

strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTarget)

// Visuals
plot(emaFast, color=color.orange, title="Fast EMA")
plot(emaSlow, color=color.blue, title="Slow EMA")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
    </item>
    <item>
      <title>Low Volume Node (LVN) Rejection / Acceptance Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Tue, 05 May 2026 14:02:55 +0000</pubDate>
      <link>https://dev.to/ranga_tech/low-volume-node-lvn-rejection-acceptance-strategy-56kp</link>
      <guid>https://dev.to/ranga_tech/low-volume-node-lvn-rejection-acceptance-strategy-56kp</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Overview&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy models low-volume node behavior by identifying low-participation price zones and monitoring how price reacts when revisiting them.&lt;br&gt;
Low-volume nodes often behave as areas where price either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rejects sharply due to lack of acceptance, or&lt;/li&gt;
&lt;li&gt;moves quickly through if accepted
The script attempts to capture both reactions using a simplified rolling-volume imbalance model.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Strategy Logic&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;LVN Approximation&lt;/strong&gt;&lt;br&gt;
Since Pine Script has limited native volume-profile access in strategy scripts, this model approximates low-volume nodes using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rolling average price&lt;/li&gt;
&lt;li&gt;ATR-based zone width&lt;/li&gt;
&lt;li&gt;relative low-volume detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Rejection Setup&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price enters the LVN zone&lt;/li&gt;
&lt;li&gt;Fails to remain there&lt;/li&gt;
&lt;li&gt;Closes back outside the zone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Acceptance Setup&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price enters LVN&lt;/li&gt;
&lt;li&gt;Holds beyond zone boundary&lt;/li&gt;
&lt;li&gt;Signals continuation potential&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Risk Management&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ATR-based stop-loss&lt;/li&gt;
&lt;li&gt;Fixed risk-to-reward targets&lt;/li&gt;
&lt;li&gt;Adaptive to volatility conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Intended Use&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy is designed for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;testing auction-market concepts&lt;/li&gt;
&lt;li&gt;studying imbalance zones&lt;/li&gt;
&lt;li&gt;experimenting with value/acceptance behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Results vary by symbol and timeframe.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pine Script v6 Strategy Code&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy("LVN Rejection / Acceptance Strategy", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=5)

// ───── INPUTS ─────
zoneLen    = input.int(40, "LVN Detection Length")
atrLen     = input.int(14, "ATR Length")
zoneWidth  = input.float(0.8, "LVN Width ATR")
stopMult   = input.float(1.5, "Stop ATR Multiplier")
rr         = input.float(2.0, "Risk Reward")

// ───── LVN APPROXIMATION ─────
basis   = ta.sma(close, zoneLen)
atrVal  = ta.atr(atrLen)

lvnUpper = basis + atrVal * zoneWidth
lvnLower = basis - atrVal * zoneWidth

// Relative volume check
avgVol = ta.sma(volume, zoneLen)
lowVol = volume &amp;lt; avgVol * 0.8

// ───── REJECTION / ACCEPTANCE LOGIC ─────
bullReject = low &amp;lt; lvnLower and close &amp;gt; lvnLower and lowVol
bearReject = high &amp;gt; lvnUpper and close &amp;lt; lvnUpper and lowVol

bullAccept = close &amp;gt; lvnUpper and close[1] &amp;gt; lvnUpper
bearAccept = close &amp;lt; lvnLower and close[1] &amp;lt; lvnLower

// ───── ENTRY CONDITIONS ─────
longCondition  = bullReject or bullAccept
shortCondition = bearReject or bearAccept

if longCondition and strategy.position_size == 0
    strategy.entry("Long", strategy.long)

if shortCondition and strategy.position_size == 0
    strategy.entry("Short", strategy.short)

// ───── RISK MANAGEMENT ─────
longStop   = strategy.position_avg_price - atrVal * stopMult
longTarget = strategy.position_avg_price + atrVal * stopMult * rr

shortStop   = strategy.position_avg_price + atrVal * stopMult
shortTarget = strategy.position_avg_price - atrVal * stopMult * rr

strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTarget)

// ───── VISUALS ─────
plot(basis, title="LVN Mid", color=color.orange)
plot(lvnUpper, title="LVN Upper", color=color.red)
plot(lvnLower, title="LVN Lower", color=color.green)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
    </item>
    <item>
      <title>Value Area Rejection Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Mon, 27 Apr 2026 12:06:39 +0000</pubDate>
      <link>https://dev.to/ranga_tech/value-area-rejection-strategy-4lfm</link>
      <guid>https://dev.to/ranga_tech/value-area-rejection-strategy-4lfm</guid>
      <description>&lt;p&gt;This strategy identifies an equilibrium zone using a rolling average price range and looks for rejection when price moves into that zone but fails to hold inside it.&lt;/p&gt;

&lt;p&gt;The idea is simple:&lt;br&gt;
Markets often rotate around fair value&lt;br&gt;
If price enters value and quickly rejects, it can signal directional intent&lt;br&gt;
The strategy trades the move away from that rejected value area&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How It Works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Build the Value Area&lt;/strong&gt;&lt;br&gt;
A rolling average price forms the center of value.&lt;br&gt;
An ATR-based band creates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upper Value Boundary&lt;/li&gt;
&lt;li&gt;Lower Value Boundary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Detect Rejection&lt;/strong&gt;&lt;br&gt;
A trade is considered when:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bullish Rejection&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price dips into/below lower value area&lt;/li&gt;
&lt;li&gt;Closes back above the lower boundary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Bearish Rejection&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price moves into/above upper value area&lt;/li&gt;
&lt;li&gt;Closes back below the upper boundary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Risk Management&lt;/strong&gt;&lt;br&gt;
ATR-based stop-loss and take-profit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adaptive to market volatility&lt;/li&gt;
&lt;li&gt;Fixed risk-to-reward structure&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Logic Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;A rolling SMA acts as the value midpoint&lt;/li&gt;
&lt;li&gt;ATR bands create upper/lower value boundaries&lt;/li&gt;
&lt;li&gt;Long entries occur when price rejects below value and closes back inside&lt;/li&gt;
&lt;li&gt;Short entries occur when price rejects above value and closes back inside&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Risk Handling&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;ATR-based stop-loss adapts to volatility&lt;br&gt;
Fixed risk/reward target keeps trade structure consistent&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Best Use Cases&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Rotational markets&lt;br&gt;
Pullback environments&lt;br&gt;
Value-to-imbalance transitions&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Notes&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This is a simplified value-area model intended for testing and educational use. It approximates equilibrium behavior and is not a replacement for full market profile or exchange volume profile tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pine Script v6 Code&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy("Value Area Rejection Strategy", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=5)

// ───── INPUTS ─────
valueLen   = input.int(50, "Value Area Length")
atrLen     = input.int(14, "ATR Length")
bandMult   = input.float(1.0, "Value Area Width ATR")
stopMult   = input.float(1.5, "Stop ATR Multiplier")
rr         = input.float(2.0, "Risk Reward")

// ───── VALUE AREA CALCULATION ─────
basis   = ta.sma(close, valueLen)
atrVal  = ta.atr(atrLen)

upperVA = basis + atrVal * bandMult
lowerVA = basis - atrVal * bandMult

// ───── REJECTION LOGIC ─────
bullReject = low &amp;lt; lowerVA and close &amp;gt; lowerVA
bearReject = high &amp;gt; upperVA and close &amp;lt; upperVA

// ───── ENTRIES ─────
if bullReject and strategy.position_size == 0
    strategy.entry("Long", strategy.long)

if bearReject and strategy.position_size == 0
    strategy.entry("Short", strategy.short)

// ───── EXITS ─────
longStop   = strategy.position_avg_price - atrVal * stopMult
longTarget = strategy.position_avg_price + atrVal * stopMult * rr

shortStop   = strategy.position_avg_price + atrVal * stopMult
shortTarget = strategy.position_avg_price - atrVal * stopMult * rr

strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTarget)

// ───── VISUALS ─────
plot(basis, title="Value Area Mid", color=color.orange)
plot(upperVA, title="Upper Value Area", color=color.red)
plot(lowerVA, title="Lower Value Area", color=color.green)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
    </item>
    <item>
      <title>Adaptive Risk Regime Strategy (Volatility Switching Model)</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Mon, 20 Apr 2026 10:01:34 +0000</pubDate>
      <link>https://dev.to/ranga_tech/adaptive-risk-regime-strategy-volatility-switching-model-48f1</link>
      <guid>https://dev.to/ranga_tech/adaptive-risk-regime-strategy-volatility-switching-model-48f1</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Why this is trending now&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Markets are not behaving the same all the time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Some periods → slow, sideways, low volatility&lt;/li&gt;
&lt;li&gt;Other periods → fast, explosive, high volatility
Most strategies fail because they use the same rules in all conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So traders are now building strategies that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;detect the current market regime&lt;/li&gt;
&lt;li&gt;switch behavior dynamically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is becoming a big trend in Pine Script strategies&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Strategy Idea&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Instead of one fixed logic, this uses two modes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Low Volatility Mode (Range Behavior)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Market is quiet&lt;/li&gt;
&lt;li&gt;Trade small reversals&lt;/li&gt;
&lt;li&gt;Avoid breakouts&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;High Volatility Mode (Trend Behavior)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Market is active&lt;/li&gt;
&lt;li&gt;Trade breakouts&lt;/li&gt;
&lt;li&gt;follow momentum&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How It Works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Measure volatility using ATR&lt;br&gt;
Compare current ATR with its average&lt;br&gt;
Decide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Low volatility → mean reversion&lt;/li&gt;
&lt;li&gt;High volatility → breakout trading&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pine Script v6 Strategy Code&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy("Adaptive Risk Regime Strategy", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=5)


// ───── INPUTS ─────
atrLen   = input.int(14, "ATR Length")
lookback = input.int(50, "Volatility Lookback")


rangeLen = input.int(20, "Range Length")
rr       = input.float(2.0, "Risk Reward")
atrMult  = input.float(1.5, "ATR Stop Multiplier")


// ───── VOLATILITY REGIME ─────
atrVal = ta.atr(atrLen)
atrAvg = ta.sma(atrVal, lookback)


highVol = atrVal &amp;gt; atrAvg
lowVol  = atrVal &amp;lt; atrAvg


// ───── RANGE LEVELS ─────
rangeHigh = ta.highest(high, rangeLen)
rangeLow  = ta.lowest(low, rangeLen)


// ───── GLOBAL CROSS (fix warnings too) ─────
crossUp   = ta.crossover(close, rangeHigh[1])
crossDown = ta.crossunder(close, rangeLow[1])


// ───── LOGIC ─────
// Low volatility → mean reversion
longRange  = lowVol and close &amp;lt; rangeLow[1]
shortRange = lowVol and close &amp;gt; rangeHigh[1]


// High volatility → breakout
longBreak  = highVol and crossUp
shortBreak = highVol and crossDown


longCondition  = longRange or longBreak
shortCondition = shortRange or shortBreak


// ───── ENTRIES ─────
if longCondition and strategy.position_size == 0
    strategy.entry("Long", strategy.long)


if shortCondition and strategy.position_size == 0
    strategy.entry("Short", strategy.short)


// ───── RISK MANAGEMENT ─────
longStop   = strategy.position_avg_price - atrVal * atrMult
longTarget = strategy.position_avg_price + atrVal * atrMult * rr


shortStop   = strategy.position_avg_price + atrVal * atrMult
shortTarget = strategy.position_avg_price - atrVal * atrMult * rr


strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTarget)


// ───── VISUALS ─────
plot(rangeHigh, color=color.green, title="Range High")
plot(rangeLow, color=color.red, title="Range Low")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>tradingview</category>
      <category>ai</category>
      <category>pinescript</category>
    </item>
    <item>
      <title>Gap Fill + Opening Range Reaction Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Wed, 15 Apr 2026 11:04:16 +0000</pubDate>
      <link>https://dev.to/ranga_tech/gap-fill-opening-range-reaction-strategy-44pn</link>
      <guid>https://dev.to/ranga_tech/gap-fill-opening-range-reaction-strategy-44pn</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Why this is trending now&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Right now (especially in US markets):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Markets are opening with large gaps (overnight news, macro tension)&lt;/li&gt;
&lt;li&gt;Price often either:&lt;/li&gt;
&lt;li&gt;fills the gap&lt;/li&gt;
&lt;li&gt;or strongly rejects and trends away&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Traders are focusing on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;gap behavior&lt;/li&gt;
&lt;li&gt;opening range breakout/reversal&lt;/li&gt;
&lt;li&gt;early session volatility&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Strategy Idea&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy combines:&lt;br&gt;
&lt;strong&gt;1. Gap Detection&lt;/strong&gt;&lt;br&gt;
Today’s open vs yesterday’s close&lt;br&gt;
&lt;strong&gt;2. Opening Range (first X minutes)&lt;/strong&gt;&lt;br&gt;
Define high &amp;amp; low of early session&lt;br&gt;
&lt;strong&gt;3. Reaction Logic&lt;/strong&gt;&lt;br&gt;
Trade:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;gap fill (mean reversion)&lt;/li&gt;
&lt;li&gt;or breakout (continuation)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy("Gap Fill + Opening Range Strategy",
     overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.percent_of_equity,
     default_qty_value=5)

// ───── INPUTS ─────
rangeMinutes = input.int(30, "Opening Range Minutes")
atrLen       = input.int(14, "ATR Length")
atrMult      = input.float(1.5, "Stop ATR Multiplier")
rr           = input.float(2.0, "Risk Reward")

// ───── SESSION TIME ─────
sessionStart = timestamp(year, month, dayofmonth, 9, 30)
inOpening    = time &amp;gt;= sessionStart and time &amp;lt;= sessionStart + rangeMinutes * 60 * 1000

// ───── GAP DETECTION ─────
prevClose = close[1]
gapUp     = open &amp;gt; prevClose
gapDown   = open &amp;lt; prevClose

// ───── OPENING RANGE ─────
var float rangeHigh = na
var float rangeLow  = na

if inOpening
    rangeHigh := na(rangeHigh) ? high : math.max(rangeHigh, high)
    rangeLow  := na(rangeLow)  ? low  : math.min(rangeLow, low)

// Reset each day
if dayofmonth != dayofmonth[1]
    rangeHigh := na
    rangeLow  := na

// ───── BREAKOUT LOGIC ─────
breakUp   = ta.crossover(close, rangeHigh)
breakDown = ta.crossunder(close, rangeLow)

// ───── ENTRY CONDITIONS ─────
// Gap fill (reversal)
longGapFill  = gapDown and close &amp;gt; rangeLow
shortGapFill = gapUp and close &amp;lt; rangeHigh

// Breakout continuation
longBreak  = breakUp
shortBreak = breakDown

longCondition  = (longGapFill or longBreak)
shortCondition = (shortGapFill or shortBreak)

// ───── ATR RISK ─────
atrVal = ta.atr(atrLen)

if longCondition and strategy.position_size == 0
    strategy.entry("Long", strategy.long)

if shortCondition and strategy.position_size == 0
    strategy.entry("Short", strategy.short)

longStop   = strategy.position_avg_price - atrVal * atrMult
longTarget = strategy.position_avg_price + atrVal * atrMult * rr

shortStop   = strategy.position_avg_price + atrVal * atrMult
shortTarget = strategy.position_avg_price - atrVal * atrMult * rr

strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTarget)

// ───── VISUALS ─────
plot(rangeHigh, title="Opening Range High", color=color.green)
plot(rangeLow, title="Opening Range Low", color=color.red)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pinescript</category>
      <category>tradingview</category>
      <category>pinegen</category>
      <category>ai</category>
    </item>
    <item>
      <title>Volatility Expansion + Fake Breakout Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Mon, 06 Apr 2026 12:52:25 +0000</pubDate>
      <link>https://dev.to/ranga_tech/volatility-expansion-fake-breakout-strategy-55p8</link>
      <guid>https://dev.to/ranga_tech/volatility-expansion-fake-breakout-strategy-55p8</guid>
      <description>&lt;p&gt;This strategy focuses on one simple market behavior: price doesn’t just break ranges randomly, it expands with strength, and weak breakouts often fail. Instead of chasing every breakout, the logic waits for volatility expansion and filters out weak moves that usually trap traders.&lt;/p&gt;

&lt;p&gt;At its core, the system observes the market’s recent range and volatility. When price compresses for a period, it builds energy. The strategy measures this using Average True Range (ATR). When ATR rises above its recent average, it signals that the market is entering an expansion phase, meaning movement is likely to accelerate.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How the Logic Works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;First, the strategy defines a rolling range using recent highs and lows. This acts as a reference zone where price has been consolidating.&lt;/p&gt;

&lt;p&gt;Next, it monitors for a breakout:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A move above the range high&lt;/li&gt;
&lt;li&gt;A move below the range low
But not every breakout is treated equally.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Filtering Fake Breakouts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;One of the biggest problems in trading is getting trapped in false breakouts. To avoid this, the strategy checks for candle strength:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For bullish moves:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The candle must close strongly above the previous high, showing real buying pressure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For bearish moves:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The candle must close strongly below the previous low, indicating genuine selling pressure.&lt;br&gt;
If the breakout happens without this strength, the trade is ignored.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Entry Conditions&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A trade is only taken when all conditions align:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Volatility is expanding (ATR is rising)&lt;/li&gt;
&lt;li&gt;Price breaks the range&lt;/li&gt;
&lt;li&gt;The breakout candle is strong and decisive&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This combination helps avoid low-quality entries and focuses only on high-momentum moves.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Risk Management Approach&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Every trade uses a structured risk model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stop loss is based on ATR, adapting to current market volatility&lt;/li&gt;
&lt;li&gt;Take profit is calculated using a risk-to-reward ratio&lt;/li&gt;
&lt;li&gt;Position sizing is consistent as a percentage of capital&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This keeps the strategy stable across different market conditions instead of relying on fixed pip or point values.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Why This Approach Works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Markets often move in cycles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Quiet consolidation&lt;/li&gt;
&lt;li&gt;Volatility compression&lt;/li&gt;
&lt;li&gt;Sudden expansion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This strategy is built specifically to catch the third phase, where price moves quickly and directionally.&lt;/p&gt;

&lt;p&gt;By combining volatility expansion with breakout strength, it avoids common traps and focuses on movements that actually have momentum behind them.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Final Thought&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This isn’t about predicting direction blindly. It’s about waiting for structure, strength, and volatility to align before acting.&lt;/p&gt;

&lt;p&gt;If you apply this approach with discipline, it naturally reduces overtrading and improves decision quality,  which is often more important than chasing every opportunity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;&lt;span class="sr"&gt;//&lt;/span&gt;@&lt;span class="k"&gt;version&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="m"&gt;6&lt;/span&gt;
strategy&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Volatility Expansion + Fake Breakout Strategy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
     overlay&lt;span class="p"&gt;=&lt;/span&gt;true&lt;span class="p"&gt;,&lt;/span&gt; 
     initial_capital&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="m"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     default_qty_type&lt;span class="p"&gt;=&lt;/span&gt;strategy&lt;span class="p"&gt;.&lt;/span&gt;percent_of_equity&lt;span class="p"&gt;,&lt;/span&gt;
     default_qty_value&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="sr"&gt;//&lt;/span&gt; ───── INPUTS ─────
rangeLen   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;int&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Range Lookback"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
atrLen     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;int&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ATR Length"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
volMult    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;float&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Volatility Expansion Multiplier"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
atrMult    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;float&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Stop ATR Multiplier"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
rr         &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;float&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Risk Reward"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="sr"&gt;//&lt;/span&gt; ───── VOLATILITY ─────
atrVal &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;ta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;atr&lt;span class="p"&gt;(&lt;/span&gt;atrLen&lt;span class="p"&gt;)&lt;/span&gt;
atrAvg &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;ta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;sma&lt;span class="p"&gt;(&lt;/span&gt;atrVal&lt;span class="p"&gt;,&lt;/span&gt; rangeLen&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="sr"&gt;//&lt;/span&gt; Detect expansion
volExpansion &lt;span class="p"&gt;=&lt;/span&gt; atrVal &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; atrAvg * volMult

&lt;span class="sr"&gt;//&lt;/span&gt; ───── RANGE STRUCTURE ─────
rangeHigh &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;ta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;highest&lt;span class="p"&gt;(&lt;/span&gt;high&lt;span class="p"&gt;,&lt;/span&gt; rangeLen&lt;span class="p"&gt;)&lt;/span&gt;
rangeLow  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;ta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;lowest&lt;span class="p"&gt;(&lt;/span&gt;low&lt;span class="p"&gt;,&lt;/span&gt; rangeLen&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="sr"&gt;//&lt;/span&gt; ───── BREAKOUT DETECTION ─────
breakUp   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;ta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;crossover&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;close&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; rangeHigh&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
breakDown &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;ta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;crossunder&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;close&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; rangeLow&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="sr"&gt;//&lt;/span&gt; ───── FAKE BREAKOUT FILTER ─────
&lt;span class="sr"&gt;//&lt;/span&gt; Candle must &lt;span class="k"&gt;close&lt;/span&gt; strong &lt;span class="k"&gt;in&lt;/span&gt; breakout direction
strongBull &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;close&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;open&lt;/span&gt; &lt;span class="nb"&gt;and&lt;/span&gt; &lt;span class="k"&gt;close&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; high&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
strongBear &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;close&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt; &lt;span class="k"&gt;open&lt;/span&gt; &lt;span class="nb"&gt;and&lt;/span&gt; &lt;span class="k"&gt;close&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt; low&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="sr"&gt;//&lt;/span&gt; ───── ENTRY CONDITIONS ─────
longCondition  &lt;span class="p"&gt;=&lt;/span&gt; volExpansion &lt;span class="nb"&gt;and&lt;/span&gt; breakUp &lt;span class="nb"&gt;and&lt;/span&gt; strongBull
shortCondition &lt;span class="p"&gt;=&lt;/span&gt; volExpansion &lt;span class="nb"&gt;and&lt;/span&gt; breakDown &lt;span class="nb"&gt;and&lt;/span&gt; strongBear

&lt;span class="k"&gt;if&lt;/span&gt; longCondition &lt;span class="nb"&gt;and&lt;/span&gt; strategy&lt;span class="p"&gt;.&lt;/span&gt;position_size &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
    strategy&lt;span class="p"&gt;.&lt;/span&gt;entry&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Long"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; strategy&lt;span class="p"&gt;.&lt;/span&gt;long&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; shortCondition &lt;span class="nb"&gt;and&lt;/span&gt; strategy&lt;span class="p"&gt;.&lt;/span&gt;position_size &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
    strategy&lt;span class="p"&gt;.&lt;/span&gt;entry&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Short"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; strategy&lt;span class="p"&gt;.&lt;/span&gt;short&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="sr"&gt;//&lt;/span&gt; ───── RISK MANAGEMENT ─────
longStop   &lt;span class="p"&gt;=&lt;/span&gt; strategy&lt;span class="p"&gt;.&lt;/span&gt;position_avg_price &lt;span class="p"&gt;-&lt;/span&gt; atrVal * atrMult
longTarget &lt;span class="p"&gt;=&lt;/span&gt; strategy&lt;span class="p"&gt;.&lt;/span&gt;position_avg_price &lt;span class="p"&gt;+&lt;/span&gt; atrVal * atrMult * rr

shortStop   &lt;span class="p"&gt;=&lt;/span&gt; strategy&lt;span class="p"&gt;.&lt;/span&gt;position_avg_price &lt;span class="p"&gt;+&lt;/span&gt; atrVal * atrMult
shortTarget &lt;span class="p"&gt;=&lt;/span&gt; strategy&lt;span class="p"&gt;.&lt;/span&gt;position_avg_price &lt;span class="p"&gt;-&lt;/span&gt; atrVal * atrMult * rr

strategy&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Exit Long"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; from_entry&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Long"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;longStop&lt;span class="p"&gt;,&lt;/span&gt; limit&lt;span class="p"&gt;=&lt;/span&gt;longTarget&lt;span class="p"&gt;)&lt;/span&gt;
strategy&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Exit Short"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; from_entry&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Short"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;shortStop&lt;span class="p"&gt;,&lt;/span&gt; limit&lt;span class="p"&gt;=&lt;/span&gt;shortTarget&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="sr"&gt;//&lt;/span&gt; ───── VISUALS ─────
plot&lt;span class="p"&gt;(&lt;/span&gt;rangeHigh&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Range High"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; color&lt;span class="p"&gt;=&lt;/span&gt;color&lt;span class="p"&gt;.&lt;/span&gt;green&lt;span class="p"&gt;)&lt;/span&gt;
plot&lt;span class="p"&gt;(&lt;/span&gt;rangeLow&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Range Low"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; color&lt;span class="p"&gt;=&lt;/span&gt;color&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;red&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pinescript</category>
      <category>tradingview</category>
    </item>
    <item>
      <title>Range Compression Expansion Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Fri, 03 Apr 2026 03:24:53 +0000</pubDate>
      <link>https://dev.to/ranga_tech/range-compression-expansion-strategy-5a6o</link>
      <guid>https://dev.to/ranga_tech/range-compression-expansion-strategy-5a6o</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;What This Strategy Focuses On&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Markets don’t move randomly all the time. They often alternate between quiet phases (low volatility, tight candles) and expansion phases (strong directional moves).&lt;br&gt;
This strategy is built around that idea. It identifies periods where price is compressed into a tight range and waits for a confirmed breakout before entering a trade.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How It Works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Detecting Compression&lt;/strong&gt;&lt;br&gt;
The script measures volatility using ATR.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When ATR drops below its recent average, the market is considered compressed&lt;/li&gt;
&lt;li&gt;This usually means price is building up for a move
Instead of relying on indicators like Bollinger Bands, this uses pure volatility contraction + price structure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Defining the Range&lt;/strong&gt;&lt;br&gt;
During compression, the script tracks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Highest high (resistance)&lt;/li&gt;
&lt;li&gt;Lowest low (support)
This creates a clear structure zone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Expansion Breakout&lt;/strong&gt;&lt;br&gt;
Trades are triggered when price breaks out of that range:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Break above range → potential bullish expansion&lt;/li&gt;
&lt;li&gt;Break below range → potential bearish expansion
Only confirmed breakouts are considered.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Risk Management&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The strategy uses ATR for exits:&lt;/li&gt;
&lt;li&gt;Stop-loss adapts to volatility&lt;/li&gt;
&lt;li&gt;Take-profit is based on a fixed risk-to-reward ratio
This keeps behavior consistent across different markets.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key Characteristics&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Focuses on volatility shifts (calm → expansion)&lt;/li&gt;
&lt;li&gt;Uses structure instead of indicator-heavy logic&lt;/li&gt;
&lt;li&gt;Works on crypto, forex, and stocks&lt;/li&gt;
&lt;li&gt;Designed for testing and refinement&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;When It May Work Better&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Before strong trending moves&lt;/li&gt;
&lt;li&gt;During breakout phases&lt;/li&gt;
&lt;li&gt;After long consolidation periods&lt;/li&gt;
&lt;li&gt;It may produce fewer signals in already trending markets.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Important Note&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This script is for testing and educational use. Results depend on market conditions and settings. Always test across multiple assets and timeframes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you want to push this further&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can upgrade this idea by adding:&lt;/li&gt;
&lt;li&gt;trend filter (EMA or HTF bias)&lt;/li&gt;
&lt;li&gt;volume spike confirmation&lt;/li&gt;
&lt;li&gt;session-based filtering&lt;/li&gt;
&lt;li&gt;fake breakout detection&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pine Script v6 Strategy Code&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy("Range Compression → Expansion Strategy", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=5, commission_type=strategy.commission.percent, commission_value=0.05, slippage=1)

// ───── INPUTS ─────
lookback      = input.int(20, "Range Lookback")
atrLen        = input.int(14, "ATR Length")
compressionTh = input.float(0.7, "Compression Threshold (ATR Ratio)")
atrMult       = input.float(1.5, "Stop ATR Multiplier")
rr            = input.float(2.0, "Risk Reward")

// ───── VOLATILITY ─────
atrVal = ta.atr(atrLen)
atrAvg = ta.sma(atrVal, lookback)

// Compression condition
isCompressed = atrVal &amp;lt; atrAvg * compressionTh

// ───── RANGE STRUCTURE ─────
rangeHigh = ta.highest(high, lookback)
rangeLow  = ta.lowest(low, lookback)

// ───── BREAKOUT LOGIC ─────
breakUp   = ta.crossover(close, rangeHigh[1])
breakDown = ta.crossunder(close, rangeLow[1])

// Entry conditions
longCondition  = isCompressed[1] and breakUp
shortCondition = isCompressed[1] and breakDown

if longCondition and strategy.position_size == 0
    strategy.entry("Long", strategy.long)

if shortCondition and strategy.position_size == 0
    strategy.entry("Short", strategy.short)

// ───── RISK MANAGEMENT ─────
longStop   = strategy.position_avg_price - atrVal * atrMult
longTarget = strategy.position_avg_price + atrVal * atrMult * rr

shortStop   = strategy.position_avg_price + atrVal * atrMult
shortTarget = strategy.position_avg_price - atrVal * atrMult * rr

strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTarget)

// ───── VISUALS ─────
plot(rangeHigh, title="Range High", color=color.green)
plot(rangeLow, title="Range Low", color=color.red)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pinescript</category>
      <category>pinegenai</category>
      <category>tradingview</category>
      <category>ai</category>
    </item>
    <item>
      <title>Multi-Timeframe Structure + Breakout Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Tue, 24 Mar 2026 12:38:17 +0000</pubDate>
      <link>https://dev.to/ranga_tech/multi-timeframe-structure-breakout-strategy-m6h</link>
      <guid>https://dev.to/ranga_tech/multi-timeframe-structure-breakout-strategy-m6h</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Strategy Idea&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy combines higher timeframe trend direction with lower timeframe structure breakouts. Instead of trading every breakout, it aligns entries with the broader market direction and waits for confirmation from recent price structure.&lt;br&gt;
The goal is to improve trade selection by filtering signals through both trend context and local market behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How It Works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Higher Timeframe Trend Filter&lt;/strong&gt;&lt;br&gt;
A higher timeframe EMA is used to define the overall direction.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price above HTF EMA → bullish bias&lt;/li&gt;
&lt;li&gt;Price below HTF EMA → bearish bias
This helps avoid trades against the dominant trend.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Market Structure Levels&lt;/strong&gt;&lt;br&gt;
The script tracks recent highs and lows over a lookback period.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Highest high → resistance reference&lt;/li&gt;
&lt;li&gt;Lowest low → support reference
These levels act as structure zones.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Breakout Confirmation&lt;/strong&gt;&lt;br&gt;
Trades are triggered only when price breaks these structure levels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Break above recent high → potential continuation upward&lt;/li&gt;
&lt;li&gt;Break below recent low → potential continuation downward&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Volatility-Based Risk Management&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stop-loss and take-profit levels are calculated using ATR.&lt;/li&gt;
&lt;li&gt;Stop-loss adapts to volatility&lt;/li&gt;
&lt;li&gt;Risk-to-reward ratio defines the target&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key Features&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Multi-timeframe trend alignment&lt;/li&gt;
&lt;li&gt;Structure-based breakout entries&lt;/li&gt;
&lt;li&gt;ATR-based adaptive exits&lt;/li&gt;
&lt;li&gt;Non-repainting logic&lt;/li&gt;
&lt;li&gt;Designed for backtesting and experimentation&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;When It May Perform Better&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Trending markets&lt;/li&gt;
&lt;li&gt;Volatility expansion phases&lt;/li&gt;
&lt;li&gt;Higher timeframe directional moves&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It may produce fewer signals in low-volatility or sideways conditions.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Important Note&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy is intended for testing and learning purposes. Results vary depending on market conditions, timeframe, and parameter selection. Always validate across multiple instruments before using it in live environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pine Script v6 Strategy Code&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy(
    "MTF Structure Breakout Strategy",
    overlay = true,
    initial_capital = 100000,
    default_qty_type = strategy.percent_of_equity,
    default_qty_value = 3,
    commission_type = strategy.commission.percent,
    commission_value = 0.05,
    slippage = 1
)

// ───── INPUTS ─────
htfTF     = input.timeframe("60", "Higher Timeframe")
htfEmaLen = input.int(100, "HTF EMA Length")

lookback  = input.int(20, "Structure Lookback")
atrLen    = input.int(14, "ATR Length")
atrMult   = input.float(1.8, "ATR Stop Multiplier")
rr        = input.float(2.0, "Risk Reward")

// ───── HIGHER TIMEFRAME TREND ─────
htfEMA = request.security(
     syminfo.tickerid,
     htfTF,
     ta.ema(close, htfEmaLen),
     lookahead = barmerge.lookahead_off
)

trendUp   = close &amp;gt; htfEMA
trendDown = close &amp;lt; htfEMA

// ───── STRUCTURE LEVELS ─────
recentHigh = ta.highest(high, lookback)
recentLow  = ta.lowest(low, lookback)

// ───── BREAKOUT CONDITIONS (GLOBAL SAFE) ─────
breakUp   = ta.crossover(close, recentHigh[1])
breakDown = ta.crossunder(close, recentLow[1])

// ───── ENTRY CONDITIONS ─────
longCondition  = breakUp and trendUp
shortCondition = breakDown and trendDown

if longCondition and strategy.position_size == 0
    strategy.entry("Long", strategy.long)

if shortCondition and strategy.position_size == 0
    strategy.entry("Short", strategy.short)

// ───── RISK MANAGEMENT ─────
atrVal = ta.atr(atrLen)

longStop   = strategy.position_avg_price - atrVal * atrMult
longTarget = strategy.position_avg_price + atrVal * atrMult * rr

shortStop   = strategy.position_avg_price + atrVal * atrMult
shortTarget = strategy.position_avg_price - atrVal * atrMult * rr

strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTarget)

// ───── VISUALS ─────
plot(htfEMA, title="HTF EMA", color=color.orange)
plot(recentHigh, title="Structure High", color=color.green)
plot(recentLow, title="Structure Low", color=color.red)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pinescript</category>
      <category>pinegenai</category>
      <category>tradingview</category>
      <category>strategy</category>
    </item>
    <item>
      <title>Liquidity Sweep + Market Structure Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Tue, 17 Mar 2026 09:31:11 +0000</pubDate>
      <link>https://dev.to/ranga_tech/liquidity-sweep-market-structure-strategy-573n</link>
      <guid>https://dev.to/ranga_tech/liquidity-sweep-market-structure-strategy-573n</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Strategy Concept&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Financial markets often move toward areas where stop orders accumulate. These areas are usually located above recent highs or below recent lows. &lt;/p&gt;

&lt;p&gt;When price briefly breaks those levels and quickly returns back inside the range, it can signal that liquidity has been taken and the market may move in the opposite direction.&lt;/p&gt;

&lt;p&gt;This strategy focuses on detecting those situations. Instead of chasing breakouts, it waits for price to sweep liquidity and then confirm a shift in market structure before opening a trade.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How the Strategy Works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Liquidity Sweep Detection&lt;/strong&gt;&lt;br&gt;
The script first identifies recent swing highs and swing lows.&lt;br&gt;
A sweep happens when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price moves above a recent high but closes back below it&lt;/li&gt;
&lt;li&gt;Price moves below a recent low but closes back above it
This behavior suggests that stop orders were triggered but the breakout did not continue.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Market Structure Confirmation&lt;/strong&gt;&lt;br&gt;
After a sweep occurs, the strategy waits for confirmation from market structure.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For a long setup, price must break above a recent short-term high after sweeping liquidity below.&lt;/li&gt;
&lt;li&gt;For a short setup, price must break below a recent short-term low after sweeping liquidity above.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This helps reduce random entries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Volatility-Based Risk Control&lt;/strong&gt;&lt;br&gt;
The script uses ATR (Average True Range) to calculate stop-loss and take-profit levels.&lt;br&gt;
This allows the strategy to adapt to changing market conditions. When volatility expands, exits widen; when volatility contracts, exits become tighter.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Key Characteristics&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Detects stop-run style moves&lt;/li&gt;
&lt;li&gt;Confirms entries using structure shifts&lt;/li&gt;
&lt;li&gt;Uses volatility-adaptive exits&lt;/li&gt;
&lt;li&gt;Designed for testing and educational purposes&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Where This Strategy May Perform Better&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This type of setup often appears during:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;active trading sessions&lt;/li&gt;
&lt;li&gt;volatile market phases&lt;/li&gt;
&lt;li&gt;instruments with strong liquidity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sideways markets with very low volatility may produce fewer reliable signals.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy("Liquidity Sweep + Market Structure Strategy",
     overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.percent_of_equity,
     default_qty_value=5)

// Inputs
lookback = input.int(20, "Liquidity Lookback")
structureLen = input.int(5, "Structure Length")
atrLen = input.int(14, "ATR Length")
atrMult = input.float(1.5, "Stop ATR Multiplier")
rr = input.float(2.0, "Risk Reward")

// Liquidity levels
recentHigh = ta.highest(high[1], lookback)
recentLow  = ta.lowest(low[1], lookback)

// Sweep detection
sweepHigh = high &amp;gt; recentHigh and close &amp;lt; recentHigh
sweepLow  = low &amp;lt; recentLow and close &amp;gt; recentLow

// Market structure levels
structureHigh = ta.highest(high, structureLen)
structureLow  = ta.lowest(low, structureLen)

// Structure break
bullStructureBreak = close &amp;gt; structureHigh[1]
bearStructureBreak = close &amp;lt; structureLow[1]

// Entry logic
longCondition  = sweepLow[1] and bullStructureBreak
shortCondition = sweepHigh[1] and bearStructureBreak

// ATR risk control
atrValue = ta.atr(atrLen)

if longCondition and strategy.position_size == 0
    strategy.entry("Long", strategy.long)

if shortCondition and strategy.position_size == 0
    strategy.entry("Short", strategy.short)

// Exit levels
longStop  = strategy.position_avg_price - atrValue * atrMult
longTake  = strategy.position_avg_price + atrValue * atrMult * rr

shortStop = strategy.position_avg_price + atrValue * atrMult
shortTake = strategy.position_avg_price - atrValue * atrMult * rr

strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTake)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTake)

// Visuals
plot(recentHigh, title="Liquidity High", color=color.red)
plot(recentLow, title="Liquidity Low", color=color.green)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pinescripts</category>
      <category>pinescriptai</category>
      <category>tradingview</category>
      <category>pinegenai</category>
    </item>
    <item>
      <title>VWAP Breakout + Retest Trend Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Mon, 09 Mar 2026 09:11:18 +0000</pubDate>
      <link>https://dev.to/ranga_tech/vwap-breakout-retest-trend-strategy-2a32</link>
      <guid>https://dev.to/ranga_tech/vwap-breakout-retest-trend-strategy-2a32</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Strategy Idea&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy focuses on trading continuation moves that occur after price breaks away from the Volume Weighted Average Price (VWAP) and then retests it.&lt;/p&gt;

&lt;p&gt;VWAP is commonly used to represent the average traded price during a session. When price moves away from this level and later returns to it, the area can act as a dynamic support or resistance level.&lt;br&gt;
The script attempts to capture trend continuation when price breaks VWAP and then confirms the move with a retest.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;How the Strategy Works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. VWAP Breakout&lt;/strong&gt;&lt;br&gt;
The first step is identifying when price moves above or below the VWAP line.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price crossing above VWAP suggests bullish momentum.&lt;/li&gt;
&lt;li&gt;Price crossing below VWAP suggests bearish momentum.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This initial move signals potential directional interest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Retest Confirmation&lt;/strong&gt;&lt;br&gt;
Instead of entering immediately on the breakout, the strategy waits for price to pull back toward VWAP.&lt;br&gt;
This retest helps confirm whether the VWAP level is acting as support or resistance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Trend Alignment&lt;/strong&gt;&lt;br&gt;
To reduce counter-trend trades, a trend filter using an exponential moving average (EMA) is applied.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price above the trend EMA favors long trades.&lt;/li&gt;
&lt;li&gt;Price below the trend EMA favors short trades.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Risk Management&lt;/strong&gt;&lt;br&gt;
Stop-loss and take-profit levels are based on ATR (Average True Range).&lt;br&gt;
This allows exits to adapt to market volatility rather than using fixed distances.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Key Features&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;VWAP-based market structure&lt;/li&gt;
&lt;li&gt;Retest confirmation before entry&lt;/li&gt;
&lt;li&gt;Trend filter using EMA&lt;/li&gt;
&lt;li&gt;ATR-based dynamic risk management&lt;/li&gt;
&lt;li&gt;Designed for testing and educational purposes&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;When This Strategy May Work Better&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This type of approach may perform better in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;intraday trending markets&lt;/li&gt;
&lt;li&gt;instruments with strong liquidity&lt;/li&gt;
&lt;li&gt;sessions where price frequently reacts to VWAP levels&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It may perform less effectively during low-volatility or sideways market conditions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy(
    "VWAP Breakout Retest Trend Strategy",
    overlay = true,
    initial_capital = 100000,
    default_qty_type = strategy.percent_of_equity,
    default_qty_value = 3,
    commission_type = strategy.commission.percent,
    commission_value = 0.05,
    slippage = 1
)


// Inputs
emaLen  = input.int(100, "Trend EMA Length")
atrLen  = input.int(14, "ATR Length")
atrMult = input.float(1.8, "ATR Stop Multiplier")
rr      = input.float(2.0, "Risk Reward")


// Indicators
vwapValue = ta.vwap(close)
emaTrend  = ta.ema(close, emaLen)
atrVal    = ta.atr(atrLen)


// Trend Direction
trendUp   = close &amp;gt; emaTrend
trendDown = close &amp;lt; emaTrend


// Breakout Detection
breakUp   = ta.crossover(close, vwapValue)
breakDown = ta.crossunder(close, vwapValue)


// Retest Conditions
retestLong  = low &amp;lt;= vwapValue and trendUp
retestShort = high &amp;gt;= vwapValue and trendDown


// Entry Conditions
longCondition  = breakUp[1] and retestLong
shortCondition = breakDown[1] and retestShort


if longCondition and strategy.position_size == 0
    strategy.entry("Long", strategy.long)


if shortCondition and strategy.position_size == 0
    strategy.entry("Short", strategy.short)


// Risk Management
longStop  = strategy.position_avg_price - atrVal * atrMult
longTarget = strategy.position_avg_price + atrVal * atrMult * rr


shortStop  = strategy.position_avg_price + atrVal * atrMult
shortTarget = strategy.position_avg_price - atrVal * atrMult * rr


strategy.exit("Long Exit", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Short Exit", from_entry="Short", stop=shortStop, limit=shortTarget)


// Visuals
plot(vwapValue, title="VWAP", color=color.orange, linewidth=2)
plot(emaTrend, title="Trend EMA", color=color.blue)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pinescript</category>
      <category>pinescriptai</category>
      <category>tradingview</category>
    </item>
    <item>
      <title>Trend Break + Structure + Range Filter</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Fri, 06 Mar 2026 06:12:24 +0000</pubDate>
      <link>https://dev.to/ranga_tech/trend-break-structure-range-filter-25di</link>
      <guid>https://dev.to/ranga_tech/trend-break-structure-range-filter-25di</guid>
      <description>&lt;p&gt;This strategy focuses on trading continuation moves after price breaks recent structure, while filtering out low-momentum conditions. The goal is to participate in directional markets and reduce entries during sideways activity.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Concept Behind the Strategy&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Markets tend to alternate between consolidation and expansion. Instead of reacting to every price movement, this approach waits for a clear break of recent highs or lows, aligned with the prevailing trend.&lt;br&gt;
By combining structure, trend bias, and range filtering, the strategy aims to improve trade selection quality.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;How It Works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Trend Direction (EMA Filter)&lt;/strong&gt;&lt;br&gt;
A moving average defines the primary market bias.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price above the EMA → bullish bias&lt;/li&gt;
&lt;li&gt;Price below the EMA → bearish bias
Trades are only taken in the direction of this bias.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;2. Structure Break&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The system monitors the highest high and lowest low over a defined lookback period.&lt;br&gt;
A trade is triggered when price breaks beyond that recent structure.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;3. Range Filter (Bollinger Logic)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If price is moving inside a compressed range, entries are avoided.&lt;br&gt;
This helps reduce signals during low-momentum conditions.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;4. Risk Management&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Stop-loss and take-profit levels are based on ATR (Average True Range), which adapts to current volatility.&lt;br&gt;
A configurable risk-to-reward ratio determines the target distance.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;5. Realistic Backtesting Setup&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Commission and slippage are included to simulate more practical conditions.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Key Characteristics&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Non-repainting logic&lt;/li&gt;
&lt;li&gt;Breakout-based entries&lt;/li&gt;
&lt;li&gt;Trend-aligned trade direction&lt;/li&gt;
&lt;li&gt;Volatility-adjusted exits&lt;/li&gt;
&lt;li&gt;Designed for structured testing&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;When It May Perform Better&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Markets with sustained directional movement&lt;/li&gt;
&lt;li&gt;Volatility expansion phases&lt;/li&gt;
&lt;li&gt;Instruments that respect breakout behavior
It may underperform during prolonged sideways or low-volatility environments.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Important Note&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy is intended for research and testing purposes. Performance can vary across assets and timeframes. It should be evaluated across different market conditions before considering live use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//@version=6
strategy(
    "Trend Break + Structure + Range Filter",
    overlay = true,
    initial_capital = 100000,
    default_qty_type = strategy.percent_of_equity,
    default_qty_value = 3,
    commission_type = strategy.commission.percent,
    commission_value = 0.05,
    slippage = 1
)


// ─────────────────────
// INPUTS
// ─────────────────────
emaTrendLen = input.int(50, "Trend EMA Length")
bbLen       = input.int(20, "Range Length")
bbMult      = input.float(1.8, "BB Multiplier")
atrLen      = input.int(14, "ATR Length")
atrMult     = input.float(1.8, "ATR Stop Multiplier")
rr          = input.float(2.0, "Risk-Reward")


// ─────────────────────
// TREND FILTER
// ─────────────────────
emaTrend = ta.ema(close, emaTrendLen)
trendUp  = close &amp;gt; emaTrend
trendDown= close &amp;lt; emaTrend


// ─────────────────────
// RANGE FILTER
// ─────────────────────
basis   = ta.sma(close, bbLen)
dev     = bbMult * ta.stdev(close, bbLen)
upperBB = basis + dev
lowerBB = basis - dev


inRange = close &amp;gt;= lowerBB and close &amp;lt;= upperBB


// ─────────────────────
// STRUCTURE BREAK
// ─────────────────────
highestLevel = ta.highest(high, bbLen)
lowestLevel  = ta.lowest(low, bbLen)


breakHigh = ta.crossover(close, highestLevel[1])
breakLow  = ta.crossunder(close, lowestLevel[1])


// ─────────────────────
// ENTRY CONDITIONS
// ─────────────────────
longCond  = breakHigh and trendUp and not inRange
shortCond = breakLow and trendDown and not inRange


if longCond and strategy.position_size == 0
    strategy.entry("Long", strategy.long)


if shortCond and strategy.position_size == 0
    strategy.entry("Short", strategy.short)


// ─────────────────────
// RISK MANAGEMENT
// ─────────────────────
atrVal = ta.atr(atrLen)


longStop   = strategy.position_avg_price - atrVal * atrMult
longTarget = strategy.position_avg_price + atrVal * atrMult * rr


shortStop   = strategy.position_avg_price + atrVal * atrMult
shortTarget = strategy.position_avg_price - atrVal * atrMult * rr


strategy.exit("Long Exit", from_entry="Long", stop=longStop, limit=longTarget)
strategy.exit("Short Exit", from_entry="Short", stop=shortStop, limit=shortTarget)


// ─────────────────────
// VISUALS
// ─────────────────────
plot(emaTrend, color=color.orange, title="Trend EMA")
plot(upperBB, color=color.green, title="Upper Range")
plot(lowerBB, color=color.red, title="Lower Range")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pinescript</category>
      <category>pinescriptai</category>
      <category>tradingview</category>
      <category>pinegenai</category>
    </item>
  </channel>
</rss>
