<?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>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>
    <item>
      <title>Volatility Squeeze Expansion Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Thu, 26 Feb 2026 10:19:26 +0000</pubDate>
      <link>https://dev.to/ranga_tech/volatility-squeeze-expansion-strategy-223a</link>
      <guid>https://dev.to/ranga_tech/volatility-squeeze-expansion-strategy-223a</guid>
      <description>&lt;p&gt;This strategy is built around a simple idea: strong directional moves often begin after periods of low volatility. Instead of chasing trends late, it waits for price compression and then trades the breakout when expansion begins.&lt;br&gt;
The approach combines volatility structure and trend alignment to reduce random entries.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Core Concept&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Markets cycle between quiet phases and expansion phases.&lt;br&gt;
When volatility contracts, it often leads to a stronger move once price breaks out of that range.&lt;br&gt;
This strategy attempts to capture that transition.&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. Volatility Compression Detection&lt;/strong&gt;&lt;br&gt;
A squeeze condition is identified when Bollinger Bands contract inside Keltner Channels.&lt;br&gt;
This signals reduced volatility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Squeeze Release&lt;/strong&gt;&lt;br&gt;
The strategy waits for volatility to expand again.&lt;br&gt;
Trades are only considered when the squeeze ends.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Breakout Confirmation&lt;/strong&gt;&lt;br&gt;
Entries occur when price breaks above or below the Bollinger Bands after the squeeze release.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Trend Alignment&lt;/strong&gt;&lt;br&gt;
A long-term EMA is used to filter direction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Above EMA → bullish bias&lt;/li&gt;
&lt;li&gt;Below EMA → bearish bias
This helps reduce counter-trend trades.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Risk Management&lt;/strong&gt;&lt;br&gt;
Stop-loss and take-profit levels are based on ATR.&lt;br&gt;
This allows exits to adapt to current market volatility.&lt;br&gt;
A configurable risk-to-reward ratio defines profit targets.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Key Features&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Structured volatility-based entries&lt;/li&gt;
&lt;li&gt;Trend confirmation filter&lt;/li&gt;
&lt;li&gt;ATR-based dynamic risk control&lt;/li&gt;
&lt;li&gt;Commission and slippage included for realistic testing&lt;/li&gt;
&lt;li&gt;No repainting logic&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Best Conditions&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This type of strategy tends to perform better during:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Volatility expansion phases&lt;/li&gt;
&lt;li&gt;Strong directional markets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Assets that experience compression before breakouts&lt;br&gt;
It may underperform in slow, range-bound environments.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Important Notes&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy is designed for research and backtesting purposes.&lt;br&gt;
Performance will vary across different markets and timeframes.&lt;br&gt;
Always evaluate across multiple conditions before considering live deployment.&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("Improved EMA Trend + ATR Strategy with Arrows",
     overlay=true,
     commission_type=strategy.commission.percent,
     commission_value=0.1,
     slippage=2,
     initial_capital=10000)


// Inputs
fastLen   = input.int(12, "Fast EMA Length")
slowLen   = input.int(26, "Slow EMA Length")
atrLen    = input.int(14, "ATR Length")
riskATR   = input.float(2.0, "ATR Stop Multiplier")
rewardATR = input.float(4.0, "ATR Limit Multiplier")
minBars   = input.int(2, "Minimum Bars Before Exit")
atrFilter = input.float(0.0, "ATR Minimum Threshold (0=auto)")


// Indicators
fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)
atr     = ta.atr(atrLen)


// Trend Filter
trendUp   = close &amp;gt; slowEMA
trendDown = close &amp;lt; slowEMA


// ATR Threshold filter
atrThreshold = atrFilter &amp;gt; 0 ? atrFilter : ta.sma(atr, atrLen)


// Entry Conditions
longCondition  = ta.crossover(fastEMA, slowEMA) and trendUp and atr &amp;gt; atrThreshold and barstate.isconfirmed
shortCondition = ta.crossunder(fastEMA, slowEMA) and trendDown and atr &amp;gt; atrThreshold and barstate.isconfirmed


// Entries
if longCondition
    strategy.entry("Long", strategy.long)
if shortCondition
    strategy.entry("Short", strategy.short)


// Exits with minimum bar hold
if strategy.position_size &amp;gt; 0
    barsHeld = bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1)
    if barsHeld &amp;gt;= minBars
        strategy.exit("Long Exit", "Long", stop=close - atr * riskATR, limit=close + atr * rewardATR)


if strategy.position_size &amp;lt; 0
    barsHeld = bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1)
    if barsHeld &amp;gt;= minBars
        strategy.exit("Short Exit", "Short", stop=close + atr * riskATR, limit=close - atr * rewardATR)


// Plot arrows on chart
plotshape(longCondition, title="Buy Arrow", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(shortCondition, title="Sell Arrow", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)

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

&lt;/div&gt;



</description>
      <category>pinescript</category>
      <category>pinescriptai</category>
      <category>tradingview</category>
    </item>
    <item>
      <title>Modular Trend Pullback Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Tue, 17 Feb 2026 08:02:38 +0000</pubDate>
      <link>https://dev.to/ranga_tech/modular-trend-pullback-strategy-5f48</link>
      <guid>https://dev.to/ranga_tech/modular-trend-pullback-strategy-5f48</guid>
      <description>&lt;p&gt;This strategy focuses on trading pullbacks within established trends. Instead of entering immediately when a trend forms, it waits for a temporary retracement and then looks for confirmation before placing a trade. The goal is to improve entry timing while keeping risk controlled.&lt;/p&gt;

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

&lt;p&gt;Markets often move in waves. During a strong trend, price tends to retrace toward a short-term average before continuing in the dominant direction. This script attempts to participate in those continuation moves.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  &lt;strong&gt;1. Trend Identification&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Two exponential moving averages (EMAs) define direction.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast EMA above Slow EMA → bullish environment&lt;/li&gt;
&lt;li&gt;Fast EMA below Slow EMA → bearish environment&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;2. Pullback Condition&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In an uptrend, price must retrace below the fast EMA.&lt;/li&gt;
&lt;li&gt;In a downtrend, price must retrace above the fast EMA.
This avoids chasing extended moves.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3. Break Confirmation&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;After a pullback, the strategy waits for price to break the previous candle’s high (for longs) or low (for shorts).&lt;br&gt;
This acts as confirmation that momentum is returning in the direction of the trend.&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), allowing exits to adapt to current volatility.&lt;br&gt;
A configurable risk-reward ratio defines profit targets.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Key Features&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Non-repainting logic&lt;/li&gt;
&lt;li&gt;Entries only when flat (no stacking positions)&lt;/li&gt;
&lt;li&gt;ATR-based dynamic stop and target levels&lt;/li&gt;
&lt;li&gt;Commission and slippage included for more realistic backtests&lt;/li&gt;
&lt;li&gt;Structured, modular logic for easier testing and adjustment&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Suitable Market Conditions&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This type of approach generally performs best in:&lt;/li&gt;
&lt;li&gt;Trending environments&lt;/li&gt;
&lt;li&gt;Instruments with sustained directional movement&lt;/li&gt;
&lt;li&gt;Timeframes where pullbacks are clearly visible
It may underperform in sideways or low-volatility markets.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Notes&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This script is intended for research and testing purposes. Results will vary depending on symbol, timeframe, and market regime. Always evaluate performance across multiple market conditions before considering live execution.&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(
    "Modular Trend Pullback 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 ─────────
fastLen = input.int(20, "Fast EMA")
slowLen = input.int(50, "Slow EMA")
atrLen  = input.int(14, "ATR Length")
atrMult = input.float(1.5, "Stop ATR Mult")
rr      = input.float(2.0, "Risk Reward")

// ───────── INDICATORS ─────────
emaFast = ta.ema(close, fastLen)
emaSlow = ta.ema(close, slowLen)
atrVal  = ta.atr(atrLen)

// ───────── TREND ─────────
trendUp   = emaFast &amp;gt; emaSlow
trendDown = emaFast &amp;lt; emaSlow

// ───────── GLOBAL TRIGGERS (ALWAYS EXECUTE) ─────────
breakHigh = ta.crossover(close, high[1])
breakLow  = ta.crossunder(close, low[1])

// ───────── PULLBACK LOGIC ─────────
pullbackLong  = trendUp and close &amp;lt; emaFast
pullbackShort = trendDown and close &amp;gt; emaFast

longTrigger  = pullbackLong and breakHigh
shortTrigger = pullbackShort and breakLow

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

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

// ───────── RISK MANAGEMENT ─────────
longSL  = strategy.position_avg_price - atrVal * atrMult
longTP  = strategy.position_avg_price + atrVal * atrMult * rr

shortSL = strategy.position_avg_price + atrVal * atrMult
shortTP = strategy.position_avg_price - atrVal * atrMult * rr

strategy.exit("Long Exit", from_entry="Long", stop=longSL, limit=longTP)
strategy.exit("Short Exit", from_entry="Short", stop=shortSL, limit=shortTP)

// ───────── VISUALS ─────────
plot(emaFast, color=color.orange)
plot(emaSlow, color=color.blue)`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pinescripts</category>
      <category>pinescriptsai</category>
      <category>tradingview</category>
    </item>
    <item>
      <title>Trading the Stop Hunts: Session Liquidity Sweep Strategy</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Tue, 10 Feb 2026 03:58:08 +0000</pubDate>
      <link>https://dev.to/ranga_tech/trading-the-stop-hunts-session-liquidity-sweep-strategy-4ocm</link>
      <guid>https://dev.to/ranga_tech/trading-the-stop-hunts-session-liquidity-sweep-strategy-4ocm</guid>
      <description>&lt;p&gt;This strategy focuses on liquidity sweeps during active market sessions and only trades when the overall trend agrees. The goal is to avoid random entries and concentrate on moves that happen after stop orders are cleared.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Liquidity Sweep&lt;/strong&gt;&lt;br&gt;
Price moves above a recent high or below a recent low during a session, hinting that stops were taken.&lt;br&gt;
&lt;strong&gt;Trend Check&lt;/strong&gt;&lt;br&gt;
A simple trend filter confirms whether the market direction supports the move.&lt;br&gt;
&lt;strong&gt;Confirmed Entries&lt;/strong&gt;&lt;br&gt;
Trades are placed only after the candle closes, so results stay realistic and non-repainting.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Risk Handling&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Stop-loss and take-profit levels are based on ATR, so they adapt to volatility.&lt;/li&gt;
&lt;li&gt;Risk and reward stay consistent even when the market speeds up or slows down.&lt;/li&gt;
&lt;li&gt;Position size can be set as a percentage of equity.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Why This Approach Helps&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Fewer trades, better structure&lt;/li&gt;
&lt;li&gt;Less noise during sideways markets&lt;/li&gt;
&lt;li&gt;More realistic backtest behavior&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Reminder&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy is meant for testing and learning, not guaranteed results. Always forward-test before using it with real money.&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(
     "Small Logic Change → Big P&amp;amp;L Difference",
     overlay = true,
     initial_capital = 100000,
     default_qty_type = strategy.percent_of_equity,
     default_qty_value = 5
)

// INPUTS
fastLen   = input.int(20, "Fast EMA")
slowLen   = input.int(50, "Slow EMA")
atrLen    = input.int(14, "ATR Length")
riskATR   = input.float(1.5, "Stop Loss ATR")
rr        = input.float(2.0, "Risk Reward")

useConfirmedBars = input.bool(true, "Use Confirmed Bars")

// INDICATORS
emaFast = ta.ema(close, fastLen)
emaSlow = ta.ema(close, slowLen)
atrVal  = ta.atr(atrLen)

// TREND CONTEXT
trendUp   = emaFast &amp;gt; emaSlow
trendDown = emaFast &amp;lt; emaSlow

// ✅ CROSS LOGIC (GLOBAL — ALWAYS EXECUTES)
emaCrossUp   = ta.crossover(emaFast, emaSlow)
emaCrossDown = ta.crossunder(emaFast, emaSlow)

// ENTRY CONDITIONS
rawLong  = trendUp and emaCrossUp
rawShort = trendDown and emaCrossDown

longCond  = useConfirmedBars ? (rawLong and barstate.isconfirmed) : rawLong
shortCond = useConfirmedBars ? (rawShort and barstate.isconfirmed) : rawShort

// ENTRIES
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
longSL  = strategy.position_avg_price - atrVal * riskATR
longTP  = strategy.position_avg_price + atrVal * riskATR * rr

shortSL = strategy.position_avg_price + atrVal * riskATR
shortTP = strategy.position_avg_price - atrVal * riskATR * rr

strategy.exit("Long Exit", "Long", stop = longSL, limit = longTP)
strategy.exit("Short Exit", "Short", stop = shortSL, limit = shortTP)

// 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>pinescripts</category>
      <category>pinegenai</category>
      <category>pinescriptsai</category>
    </item>
    <item>
      <title>Pivot-Based Dynamic Trend Strategy (Quality-Controlled)</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Thu, 05 Feb 2026 04:01:01 +0000</pubDate>
      <link>https://dev.to/ranga_tech/pivot-based-dynamic-trend-strategy-quality-controlled-47kp</link>
      <guid>https://dev.to/ranga_tech/pivot-based-dynamic-trend-strategy-quality-controlled-47kp</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Overview&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This strategy demonstrates a pivot-based trend continuation approach built with execution realism in mind.&lt;br&gt;
It combines confirmed swing structure (pivot highs/lows), a higher-timeframe EMA trend filter, and ATR-based risk management to create a clean, auditable trading framework suitable for backtesting and experimentation.&lt;br&gt;
All logic is evaluated on confirmed bars only, with no repainting or intrabar assumptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Core idea&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Markets often form identifiable swing highs and lows while trending.&lt;br&gt;
When price pulls back toward a trend reference (EMA) and then breaks a prior swing level, continuation becomes more likely, provided overall trend strength is present.&lt;br&gt;
This strategy focuses on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structure first&lt;/li&gt;
&lt;li&gt;Trend alignment&lt;/li&gt;
&lt;li&gt;Defined risk on every trade&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How it works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1) Trend context&lt;/strong&gt;&lt;br&gt;
A single EMA is used to define directional bias:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price above the EMA → bullish context&lt;/li&gt;
&lt;li&gt;Price below the EMA → bearish context&lt;/li&gt;
&lt;li&gt;This keeps the logic simple and consistent.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2) Pivot structure&lt;/strong&gt;&lt;br&gt;
Confirmed pivot highs and lows are detected using a fixed lookback window.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pivot highs represent recent resistance&lt;/li&gt;
&lt;li&gt;Pivot lows represent recent support
Only confirmed pivots are used, no future data or repainting behavior.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3) Trend strength filter&lt;/strong&gt;&lt;br&gt;
Directional strength is evaluated using ADX (via DMI):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Trades are allowed only when trend strength exceeds a minimum threshold&lt;/li&gt;
&lt;li&gt;This helps reduce signals during low-energy or choppy market conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4) Entry logic&lt;/strong&gt;&lt;br&gt;
Entries are evaluated only when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Price is aligned with the EMA trend&lt;/li&gt;
&lt;li&gt;Trend strength is sufficient&lt;/li&gt;
&lt;li&gt;Price pulls back toward the EMA&lt;/li&gt;
&lt;li&gt;Price then breaks the most recent confirmed pivot level
This avoids chasing extended moves and helps improve entry quality.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5) Risk management&lt;/strong&gt;&lt;br&gt;
Risk is fully defined at entry:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stop-loss is based on an ATR multiple&lt;/li&gt;
&lt;li&gt;Take-profit uses a fixed risk-to-reward ratio&lt;/li&gt;
&lt;li&gt;Position sizing is capped at a fixed percentage of equity&lt;/li&gt;
&lt;li&gt;One position at a time&lt;/li&gt;
&lt;li&gt;No trailing stops, no hidden exits, no retroactive adjustments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Usage notes&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Results vary by symbol, timeframe, volatility regime, and session&lt;/li&gt;
&lt;li&gt;This is not a signal service or a finished trading system&lt;/li&gt;
&lt;li&gt;Best used as a structural template for studying trend continuation and swing-based entries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Users are encouraged to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test across multiple markets&lt;/li&gt;
&lt;li&gt;Adjust pivot length, EMA length, and ATR parameters&lt;/li&gt;
&lt;li&gt;Validate behavior with forward testing before using alerts or automation&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Purpose&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This script is designed to emphasize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;confirmed-bar logic&lt;/li&gt;
&lt;li&gt;realistic execution&lt;/li&gt;
&lt;li&gt;explicit risk definition&lt;/li&gt;
&lt;li&gt;repeatable behavior
It intentionally prioritizes quality and clarity over optimization or curve-fitted performance.
&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(
    "Pivot-Based Dynamic Trend Strategy (QC – Fixed)",
    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
// ─────────────────────
pivotLen   = input.int(5, "Pivot Length")
emaLen     = input.int(100, "Trend EMA Length")
atrLen     = input.int(14, "ATR Length")
slMult     = input.float(1.4, "Stop ATR Multiplier")
rr         = input.float(2.0, "Risk–Reward")
sessionTime = input.session("0930-1600", "Trading Session")


// ─────────────────────
// SESSION FILTER
// ─────────────────────
inSession = not na(time(timeframe.period, sessionTime))


// ─────────────────────
// INDICATORS
// ─────────────────────
emaTrend = ta.ema(close, emaLen)
atrVal   = ta.atr(atrLen)


// ADX (v6-correct via DMI)
[dip, dim, adxVal] = ta.dmi(14, 14)
trendStrong = adxVal &amp;gt; 20


// ─────────────────────
// CONFIRMED PIVOTS
// ─────────────────────
ph = ta.pivothigh(high, pivotLen, pivotLen)
pl = ta.pivotlow(low, pivotLen, pivotLen)


var float lastHigh = na
var float lastLow  = na


if not na(ph)
    lastHigh := ph


if not na(pl)
    lastLow := pl


// ─────────────────────
// TREND CONTEXT
// ─────────────────────
trendUp   = close &amp;gt; emaTrend
trendDown = close &amp;lt; emaTrend


// ─────────────────────
// ENTRY CONDITIONS (SINGLE-LINE → NO SYNTAX ERROR)
// ─────────────────────
longCond  = inSession and trendUp and trendStrong and low &amp;lt;= emaTrend and not na(lastHigh) and close &amp;gt; lastHigh and strategy.position_size == 0
shortCond = inSession and trendDown and trendStrong and high &amp;gt;= emaTrend and not na(lastLow)  and close &amp;lt; lastLow  and strategy.position_size == 0


if longCond
    strategy.entry("Long", strategy.long)


if shortCond
    strategy.entry("Short", strategy.short)


// ─────────────────────
// RISK MANAGEMENT
// ─────────────────────
longStop  = strategy.position_avg_price - atrVal * slMult
longLimit = strategy.position_avg_price + atrVal * slMult * rr


shortStop  = strategy.position_avg_price + atrVal * slMult
shortLimit = strategy.position_avg_price - atrVal * slMult * rr


strategy.exit("Long Exit",  "Long",  stop=longStop,  limit=longLimit)
strategy.exit("Short Exit", "Short", stop=shortStop, limit=shortLimit)


// ─────────────────────
// VISUALS
// ─────────────────────
plot(emaTrend, "Trend EMA", color=color.orange)
plot(lastHigh, "Last Pivot High", color=color.new(color.red, 40), style=plot.style_linebr)
plot(lastLow,  "Last Pivot Low",  color=color.new(color.green, 40), style=plot.style_linebr)



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

&lt;/div&gt;



</description>
      <category>pinescriptsai</category>
      <category>pinescripts</category>
      <category>tradingview</category>
    </item>
    <item>
      <title>Block-Based Visual Logic Builder Framework (Modular Strategy Template)</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Fri, 30 Jan 2026 10:17:43 +0000</pubDate>
      <link>https://dev.to/ranga_tech/block-based-visual-logic-builder-framework-modular-strategy-template-16e1</link>
      <guid>https://dev.to/ranga_tech/block-based-visual-logic-builder-framework-modular-strategy-template-16e1</guid>
      <description>&lt;p&gt;This strategy demonstrates a modular, block-based approach to strategy design in Pine Script. While TradingView does not support true drag-and-drop strategy builders, this script is structured to simulate a visual logic builder by separating trading logic into independent, configurable blocks.&lt;/p&gt;

&lt;p&gt;Each block represents a conceptual component (trend, momentum, volatility, session, and risk), allowing users to enable, disable, or modify individual modules for testing and experimentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Visual Logic Builder Concept&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The strategy is organized into distinct logic blocks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Session Block - controls when trades are allowed&lt;/li&gt;
&lt;li&gt;Trend Block - defines directional bias&lt;/li&gt;
&lt;li&gt;Momentum Block - confirms directional strength&lt;/li&gt;
&lt;li&gt;Volatility Block - filters for sufficient market movement&lt;/li&gt;
&lt;li&gt;Risk Block - standardized ATR-based stop and target logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This structure mirrors how visual trading systems and drag-and-drop interfaces organize logic into reusable components.&lt;/p&gt;

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

&lt;p&gt;Market conditions are evaluated through separate logic blocks.&lt;br&gt;
Each block can be enabled or disabled using inputs.&lt;br&gt;
Final entry decisions are based on the combined output of active blocks.&lt;br&gt;
All exits are managed through a centralized risk block using ATR-based stops and fixed risk-reward.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Purpose&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This script is intended as a structural template for building and testing modular trading systems. It emphasizes clarity, execution realism, and repeatable logic rather than optimization or signal density.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Usage Notes&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Results depend on symbol, timeframe, volatility regime, and selected block settings. Users are encouraged to experiment with different combinations of blocks and validate behavior across multiple markets before relying on any configuration.&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(
    "Block-Based Visual Logic Builder Framework",
    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
)

// ─────────────────────
// BLOCK TOGGLES
// ─────────────────────
useTrendBlock    = input.bool(true,  "Enable Trend Block")
useMomentumBlock = input.bool(true,  "Enable Momentum Block")
useVolBlock      = input.bool(true,  "Enable Volatility Block")
useSessionBlock  = input.bool(true,  "Enable Session Block")

// ─────────────────────
// INPUTS
// ─────────────────────
emaFastLen = input.int(50,  "Fast EMA")
emaSlowLen = input.int(200, "Slow EMA")

rsiLen = input.int(14, "RSI Length")
rsiMid = input.float(50, "RSI Midline")

atrLen = input.int(14, "ATR Length")
slMult = input.float(1.5, "Stop ATR Multiplier")
rr     = input.float(2.0, "Risk-Reward")

tradeSession = input.session("0930-1600", "Trade Session")

// ─────────────────────
// INDICATORS
// ─────────────────────
emaFast = ta.ema(close, emaFastLen)
emaSlow = ta.ema(close, emaSlowLen)
rsiVal  = ta.rsi(close, rsiLen)
atrVal  = ta.atr(atrLen)

// ─────────────────────
// BLOCKS
// ─────────────────────
sessionOk = not na(time(timeframe.period, tradeSession))
sessionPass = useSessionBlock ? sessionOk : true

trendUp   = close &amp;gt; emaSlow
trendDown = close &amp;lt; emaSlow
trendPassLong  = useTrendBlock ? trendUp   : true
trendPassShort = useTrendBlock ? trendDown : true

momentumLong  = rsiVal &amp;gt; rsiMid
momentumShort = rsiVal &amp;lt; rsiMid
momentumPassLong  = useMomentumBlock ? momentumLong  : true
momentumPassShort = useMomentumBlock ? momentumShort : true

volOk   = atrVal &amp;gt; ta.sma(atrVal, 50)
volPass = useVolBlock ? volOk : true

// ─────────────────────
// FINAL ENTRY LOGIC (SINGLE LINE — NO ERRORS)
// ─────────────────────
longCond  = sessionPass and trendPassLong and momentumPassLong and volPass and strategy.position_size == 0
shortCond = sessionPass and trendPassShort and momentumPassShort and volPass and strategy.position_size == 0

if longCond
    strategy.entry("Long", strategy.long)

if shortCond
    strategy.entry("Short", strategy.short)

// ─────────────────────
// RISK BLOCK
// ─────────────────────
longStop  = strategy.position_avg_price - atrVal * slMult
longLimit = strategy.position_avg_price + atrVal * slMult * rr

shortStop  = strategy.position_avg_price + atrVal * slMult
shortLimit = strategy.position_avg_price - atrVal * slMult * rr

strategy.exit("Long Exit",  "Long",  stop=longStop,  limit=longLimit)
strategy.exit("Short Exit", "Short", stop=shortStop, limit=shortLimit)

// ─────────────────────
// VISUALS
// ─────────────────────
plot(emaFast, "Fast EMA", color=color.orange)
plot(emaSlow, "Slow EMA", color=color.blue)


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

&lt;/div&gt;



</description>
      <category>aitrading</category>
      <category>pinescriptv6</category>
      <category>pinescriptai</category>
    </item>
    <item>
      <title>Session Liquidity Sweep + Trend Confirmation</title>
      <dc:creator>Ranga </dc:creator>
      <pubDate>Mon, 19 Jan 2026 12:27:58 +0000</pubDate>
      <link>https://dev.to/ranga_tech/session-liquidity-sweep-trend-confirmation-4o9g</link>
      <guid>https://dev.to/ranga_tech/session-liquidity-sweep-trend-confirmation-4o9g</guid>
      <description>&lt;p&gt;This strategy aims to capture high-probability intraday trades by combining liquidity sweeps with a trend confirmation filter. It is designed for traders who want a systematic approach to trade breakouts during specific market sessions while controlling risk with ATR-based stops.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How it Works:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Session Filter:&lt;/strong&gt; Trades are only considered during a defined session (default 9:30 - 11:00). This helps avoid low-volume periods that can lead to false signals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trend Confirmation:&lt;/strong&gt; The strategy uses a 50-period EMA to identify the market trend. Long trades are only taken in an uptrend, and short trades in a downtrend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Liquidity Sweep Detection:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A long entry occurs when price dips below the prior N-bar low but closes back above it, indicating a potential liquidity sweep that stops being triggered before the trend continues upward.&lt;/li&gt;
&lt;li&gt;A short entry occurs when price spikes above the prior N-bar high but closes below it, signaling a potential sweep of stops before the downward trend resumes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;ATR-Based Risk Management:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stop loss is calculated using the Average True Range (ATR) multiplied by a configurable factor (default 1.5).&lt;/li&gt;
&lt;li&gt;Take profit is set based on a risk-reward ratio (default 2.5x).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Position Sizing:&lt;/strong&gt; Default position size is 5% of equity per trade, making it suitable for risk-conscious trading.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Inputs:&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Session Start/End (HHMM)&lt;/li&gt;
&lt;li&gt;Liquidity Lookback Period (number of bars to define prior high/low)&lt;/li&gt;
&lt;li&gt;ATR Length for stop calculation&lt;/li&gt;
&lt;li&gt;ATR Stop Multiplier&lt;/li&gt;
&lt;li&gt;Risk-Reward Ratio&lt;/li&gt;
&lt;li&gt;EMA Trend Filter Length&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Visuals:&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Prior Liquidity High (red)&lt;/li&gt;
&lt;li&gt;Prior Liquidity Low (green)&lt;/li&gt;
&lt;li&gt;EMA Trend (blue)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Use This Strategy:&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Captures stop-hunt moves often triggered by larger market participants.&lt;/li&gt;
&lt;li&gt;Only trades with trend confirmation, reducing false signals.&lt;/li&gt;
&lt;li&gt;Provides automatic ATR-based stop loss and take profit for consistent risk management.&lt;/li&gt;
&lt;li&gt;Easy to adjust session time, ATR, EMA length, and risk-reward to suit your trading style.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Assumes 0.05% commission and 1-pip slippage. Adjust according to your broker.&lt;br&gt;
Not financial advice; intended for educational, backtesting, or paper trading purposes.&lt;br&gt;
Always test strategies thoroughly before applying to live accounts.&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(
    "Session Liquidity Sweep + Trend Confirmation",
    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
// ─────────────────────
sessionStart = input.int(930, "Session Start (HHMM)")
sessionEnd   = input.int(1100, "Session End (HHMM)")
lookbackBars = input.int(20, "Liquidity Lookback")
atrLen       = input.int(14, "ATR Length")
slMult       = input.float(1.5, "Stop ATR Multiplier")
rr           = input.float(2.5, "Risk-Reward")
emaTrendLen  = input.int(50, "EMA Trend Filter")


// ─────────────────────
// SESSION FILTER
// ─────────────────────
hourMinute = hour * 100 + minute
inSession  = (hourMinute &amp;gt;= sessionStart) and (hourMinute &amp;lt;= sessionEnd)


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


// ─────────────────────
// LIQUIDITY LEVELS
// ─────────────────────
prevHigh = ta.highest(high[1], lookbackBars)
prevLow  = ta.lowest(low[1], lookbackBars)


// ─────────────────────
// SWEEP + CONFIRMATION
// ─────────────────────
sweepHigh = (high &amp;gt; prevHigh) and (close &amp;lt; prevHigh)
sweepLow  = (low &amp;lt; prevLow) and (close &amp;gt; prevLow)


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


// ─────────────────────
// ENTRY CONDITIONS
// ─────────────────────
longCond  = inSession and sweepLow and trendUp and (close &amp;gt; open) and (strategy.position_size == 0)
shortCond = inSession and sweepHigh and trendDown and (close &amp;lt; open) and (strategy.position_size == 0)


if longCond
    strategy.entry("Long", strategy.long)


if shortCond
    strategy.entry("Short", strategy.short)


// ─────────────────────
// RISK MANAGEMENT
// ─────────────────────
longStop  = strategy.position_avg_price - atrVal * slMult
longLimit = strategy.position_avg_price + atrVal * slMult * rr


shortStop  = strategy.position_avg_price + atrVal * slMult
shortLimit = strategy.position_avg_price - atrVal * slMult * rr


strategy.exit("Long Exit", "Long", stop=longStop, limit=longLimit)
strategy.exit("Short Exit", "Short", stop=shortStop, limit=shortLimit)


// ─────────────────────
// VISUALS
// ─────────────────────
plot(prevHigh, "Prior Liquidity High", color=color.new(color.red, 40))
plot(prevLow, "Prior Liquidity Low", color=color.new(color.green, 40))
plot(emaTrend, "EMA Trend", color=color.new(color.blue, 0))

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

&lt;/div&gt;



</description>
      <category>pinescript</category>
      <category>trading</category>
    </item>
  </channel>
</rss>
