Rising & Falling Window Signals [LuxAlgo] for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
NUUGVVd.png


Author Message:

The Rising & Falling Window Signals indicator identifies Rising & Falling Window formations on the chart and manages them for use as support and resistance zones. The Rising and Falling Window methods used in this indicator are based on Steve Nison's techniques, emphasizing the importance of these areas to better identify continuation momentum and likely reversal points.

Various filtering settings are included to identify zones of a specific width, as well as hide shorter zones from displaying on their chart, helping the users focus on the most significant zones.

CODE:

CSS:
#// Indicator for TOS
#// © LuxAlgo
#indicator("Rising & Falling Window Signals [LuxAlgo]","LuxAlgo - Rising & Falling Window Signals"
#Hint MinimumAtrMulti: Width is in Multiples of ATR. Only Zones within the ATR Values are Displayed.
# Converted by Sam4Cok@Samer800    - 09/2024

input ShowZoneMidlines = yes;     # "Show Zone Midlines"
input signalMode = {"Regular", default "Engulfing", "Wick", "Don't Show Signals"}; # "Signal Type"
input MaximumLiveZoneLength = 50;     # "Maximum Live Zone Length"
input MinimumInactiveZoneLength = 0;  # "Minimum Inactive Zone Length"
input ExtendHistoricalZones = yes;    # "Extend Historical Zones on Touch"
input MinimumAtrMulti = 0.25;         # "Minimum Width"
input MaximumAtrMulti = 5.0;          # "Maximum Width"

def na = Double.NaN;
def last = isNaN(close);
def bar = barNumber();
def xot = ExtendHistoricalZones;
def n = MinimumInactiveZoneLength;
def atrHi = ATR(Length = 200) * MaximumAtrMulti;
def atrLo = ATR(Length = 200) * MinimumAtrMulti;

#//Variables
def rc = close < open;
def gc = close > open;
def win_up = low > high[1];
def win_down = high < low[1];
def up_width = AbsValue(low - high[1]);
def down_width = AbsValue(low[1] - high);
def c_bot = Min(close, open);
def c_top = Max(close, open);
def topUp; def botUp; def cntUp; def activeUp;
def topUp1; def botUp1;
def crossUp; def crossUp1; def condUp;
if  bar > 0 and win_up and (up_width >= atrLo) and (up_width <= atrHi) {
    activeUp = no;
    topUp = if !topUp[1] then low else topUp[1];
    botUp = if !topUp[1] then high[1] else botUp[1];
    topUp1 = low;
    botUp1 = high[1];
    cntUp = 0;
    } else {
    cntUp = (if isNaN(cntUp[1]) then 0 else cntUp[1]) + 1;
    activeUp = if condUp[1] then yes else activeUp[1];
if (if activeUp then crossUp[1] else (crossUp[1] or (cntUp >= MaximumLiveZoneLength))) {
    topUp = 0;
    botUp = 0;
    topUp1 = if crossUp1[1] then 0 else topUp1[1];
    botUp1 = if crossUp1[1] then 0 else botUp1[1];
    } else {
    topUp = topUp[1];
    botUp = botUp[1];
    topUp1 = if crossUp1[1] or cntUp >= MaximumLiveZoneLength then 0 else topUp1[1];
    botUp1 = if crossUp1[1] or cntUp >= MaximumLiveZoneLength then 0 else botUp1[1];
    }}
    condUp  = (xot and low < topUp);
    crossUp = (c_bot < botUp);
    crossUp1 = (c_bot < botUp1);
def topDn; def botDn; def cntDn; def activeDn;
def topDn1; def botDn1;
def crossDn; def crossDn1; def condDn;
if  bar > 0 and win_down and (down_width >= atrLo) and (down_width <= atrHi) {
    activeDn = no;
    topDn = if !botDn[1] then low[1] else topDn[1];
    botDn = if !botDn[1] then high else botDn[1];
    topDn1 = low[1];
    botDn1 = high;
    cntDn = 0;
    } else {
    cntDn = (if isNaN(cntDn[1]) then 0 else cntDn[1]) + 1;
    activeDn = if condDn[1] then yes else activeDn[1]; #
if (if activeDn then crossDn[1] else (crossDn[1] or cntDn >= MaximumLiveZoneLength)) {
    topDn = 0;
    botDn = 0;
    topDn1 = if crossDn1[1] then 0 else topDn1[1];
    botDn1 = if crossDn1[1] then 0 else botDn1[1];
    } else {
    topDn = topDn[1];
    botDn = botDn[1];
    topDn1 = if crossDn1[1] or cntDn >= MaximumLiveZoneLength then 0 else topDn1[1];
    botDn1 = if crossDn1[1] or cntDn >= MaximumLiveZoneLength then 0 else botDn1[1];
}}
    condDn =  (xot and high > if(!botDn, Double.POSITIVE_INFINITY, botDn));
    crossDn = (c_top > topDn);
    crossDn1 = (c_top > topDn1);

#-- signals
def minLo = min(low,low[1]);
def maxHi = max(high, high[1]);
def up_signal; def dn_signal;
def up_signal1; def dn_signal1;
Switch (signalMode) {
Case "Don't Show Signals" :
    up_signal = no;
    dn_signal = no;
    up_signal1 = no;
    dn_signal1 = no;
Case "Regular" :
    up_signal = topUp and (open < topUp) and (close > topUp);
    dn_signal = botDn and (open > botDn) and (close < botDn);
    up_signal1 = topUp1 and (open < topUp1) and (close > topUp1);
    dn_signal1 = botDn1 and (open > botDn1) and (close < botDn1);
Case "Wick" :
    up_signal = topUp and (low < topUp) and (c_bot > topUp);
    dn_signal = botDn and (high > botDn) and (c_top < botDn);
    up_signal1 = topUp1 and (low < topUp1) and (c_bot > topUp1);
    dn_signal1 = botDn1 and (high > botDn1) and (c_top < botDn1);
Default :
    up_signal = topUp and (minLo < topUp) and rc[1] and (open <= close[1]) and (close > open[1]);
    dn_signal = botDn and (maxHi > botDn) and gc[1] and (open >= close[1]) and (close < open[1]);
    up_signal1 = topUp1 and (minLo < topUp1) and rc[1] and (open <= close[1]) and (close > open[1]);
    dn_signal1 = botDn1 and (maxHi > botDn1) and gc[1] and (open >= close[1]) and (close < open[1]);
}

plot sigUp = if (up_signal and !up_signal[1]) then low else 0;
plot sigDn = if (dn_signal and !dn_signal[1]) then high else 0;
plot sigUp1 = if (up_signal1 and !up_signal1[1]) and !sigUp then low else na;
plot sigDn1 = if (dn_signal1 and !dn_signal1[1]) and !sigDn then high else na;
sigUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
sigUp1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
sigDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
sigDn1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
sigUp.SetDefaultColor(Color.CYAN);
sigUp1.SetDefaultColor(Color.CYAN);
sigDn.SetDefaultColor(Color.MAGENTA);
sigDn1.SetDefaultColor(Color.MAGENTA);

#-- Lines

plot topSup = if !last and cntUp[-n] >= n and topUp then topUp else na;
plot btmSup = if !last and cntUp[-n] >= n and botUp then botUp else na;
plot avgSup = if ShowZoneMidlines then (topSup + btmSup) / 2 else na;

plot topRes = if !last and cntDn[-n] >= n and topDn then topDn else na;
plot btmRes = if !last and cntDn[-n] >= n and botDn then botDn else na;
plot avgRes = if ShowZoneMidlines then (topRes + btmRes) / 2 else na;

plot topSup1 = if !last and xot and topUp[-1]!=topUp1[-1] and topUp1[-1] then topUp1[-1] else na;
plot btmSup1 = if !last and xot and botUp[-1]!=botUp1[-1] and botUp1[-1] then botUp1[-1] else na;
plot avgSup1 = if ShowZoneMidlines then (topSup1 + btmSup1) / 2 else na;

plot topRes1 = if !last and xot and topDn[-1]!=topDn1[-1] and topDn1[-1] then topDn1[-1] else na;
plot btmRes1 = if !last and xot and botDn[-1]!=botDn1[-1] and botDn1[-1] then botDn1[-1] else na;
plot avgRes1 = if ShowZoneMidlines then (topRes1+ btmRes1) / 2 else na;

topSup.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
btmSup.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
topRes.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
btmRes.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
topSup1.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
btmSup1.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
topRes1.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
btmRes1.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
avgSup.SetPaintingStrategy(PaintingStrategy.DASHES);
topSup.SetDefaultColor(Color.GREEN);
avgSup.SetDefaultColor(Color.GREEN);
btmSup.SetDefaultColor(Color.GREEN);

avgRes.SetPaintingStrategy(PaintingStrategy.DASHES);
topRes.SetDefaultColor(Color.RED);
avgRes.SetDefaultColor(Color.RED);
btmRes.SetDefaultColor(Color.RED);

avgSup1.SetPaintingStrategy(PaintingStrategy.DASHES);
topSup1.SetDefaultColor(Color.GREEN);
avgSup1.SetDefaultColor(Color.GREEN);
btmSup1.SetDefaultColor(Color.GREEN);

avgRes1.SetPaintingStrategy(PaintingStrategy.DASHES);
topRes1.SetDefaultColor(Color.RED);
avgRes1.SetDefaultColor(Color.RED);
btmRes1.SetDefaultColor(Color.RED);

AddCloud(topSup, btmSup, Color.DARK_GREEN);
AddCloud(topRes, btmRes, Color.DARK_RED);
AddCloud(topSup1, btmSup1, Color.DARK_GREEN);
AddCloud(topRes1, btmRes1, Color.DARK_RED);


#-- END of CODE
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
210 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top