Repaints Wolf Waves for ThinkorSwim

Repaints
@PlayTrader Here is what you asked for. I took the liberty to add R1 line too along with S1.

Setup your scanner as custom script and your scan query will look like the below.

For finding the support AKA S1 of Wolf_Wave indicator posted in Original Comment here.
Code:
Wolf_Waves_Scan().Bull within 25 bars

Code:
Wolf_Waves_Scan().Bear within 25 bars

Code:
# Modified by @SuryaKiranC, An Attempt to create S1 & R1 for Scan #Requested by @PlayTrader
# Wolf_Waves_Scan
# Mobius
# V01.05.22.2018

input n = 10;

script LinePlot {
    input BarID = 0;
    input Value = 0;
    input BarOrigin = 0;
    def ThisBar = HighestAll(BarOrigin);
    def ValueLine = if BarOrigin == ThisBar then Value else Double.NaN;
    plot P = if ThisBar - BarID <= BarOrigin then HighestAll(ValueLine) else Double.NaN;
}

# Variables
def o = open;
def h = high;
def l = low;
def c = close;
def x = BarNumber();
def xN = x == HighestAll(x);

# R1
def hh = fold i = 1 to n + 1with p = 1 while p do h > GetValue(h, -i);
def PivotH = if (x > n and h == Highest(h, n) and hh) then h else Double.NaN;
def PHValue = if !IsNaN(PivotH) then PivotH else PHValue[1];
def PHBarOrigin = if !IsNaN(PivotH) then x else PHBarOrigin[1];
def PHBarID = x - PHBarOrigin;

# S1
def ll = fold j = 1 to n + 1 with q = 1 while q do l < GetValue(l, -j);
def PivotL = if (x > n and l == Lowest(l, n) and ll) then l else Double.NaN;
def PLValue = if !IsNaN(PivotL) then PivotL else PLValue[1];
def PLBarOrigin = if !IsNaN(PivotL) then x else PLBarOrigin[1];
def PLBarID = x - PLBarOrigin;

plot Bear = if (x == HighestAll(PHBarOrigin) and PHValue) then 1 else 0;
Bear.Hide();

plot Bull = if (x == HighestAll(PLBarOrigin) and PLValue) then 1 else 0;
Bull.Hide();

plot scan = (Bear or Bull);
 
Last edited:

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

Is there any way of persisting the support/resistance labels instead of just having the latest ones? In other words, is it possible to show n number of R1/S1 on the chart?
 
Last edited:
@scalper81 No. The only workaround that I can think of is using the drawing tool in TOS to draw over the auto support/resistance lines.
 
@PlayTrader Here is what you asked for. I took the liberty to add R1 line too along with S1.

Setup your scanner as custom script and your scan query will look like the below.

For finding the support AKA S1 of Wolf_Wave indicator posted in Original Comment here.
Code:
Wolf_Waves_Scan().Bull within 25 bars

Code:
Wolf_Waves_Scan().Bear within 25 bars

Code:
# Modified by @SuryaKiranC, An Attempt to create S1 & R1 for Scan #Requested by @PlayTrader
# Wolf_Waves_Scan
# Mobius
# V01.05.22.2018

input n = 10;

script LinePlot {
    input BarID = 0;
    input Value = 0;
    input BarOrigin = 0;
    def ThisBar = HighestAll(BarOrigin);
    def ValueLine = if BarOrigin == ThisBar then Value else Double.NaN;
    plot P = if ThisBar - BarID <= BarOrigin then HighestAll(ValueLine) else Double.NaN;
}

# Variables
def o = open;
def h = high;
def l = low;
def c = close;
def x = BarNumber();
def xN = x == HighestAll(x);

# R1
def hh = fold i = 1 to n + 1with p = 1 while p do h > GetValue(h, -i);
def PivotH = if (x > n and h == Highest(h, n) and hh) then h else Double.NaN;
def PHValue = if !IsNaN(PivotH) then PivotH else PHValue[1];
def PHBarOrigin = if !IsNaN(PivotH) then x else PHBarOrigin[1];
def PHBarID = x - PHBarOrigin;

# S1
def ll = fold j = 1 to n + 1 with q = 1 while q do l < GetValue(l, -j);
def PivotL = if (x > n and l == Lowest(l, n) and ll) then l else Double.NaN;
def PLValue = if !IsNaN(PivotL) then PivotL else PLValue[1];
def PLBarOrigin = if !IsNaN(PivotL) then x else PLBarOrigin[1];
def PLBarID = x - PLBarOrigin;

plot Bear = if (x == HighestAll(PHBarOrigin) and PHValue) then 1 else 0;
Bear.Hide();

plot Bull = if (x == HighestAll(PLBarOrigin) and PLValue) then 1 else 0;
Bull.Hide();

plot scan = (Bear or Bull);

Thank you for posting this. I wanted a scan that would show a bull/bear breakout sooner. I tried adjusting the Input n =10 and scan queries to reduce the bars so the event is closer to the S1 / R1 but I'm not able to refine the search.

Any ideas as to what I'm missing.

Also, is there a way to create the R1 -3 and S1-3 in the watchlist? Maybe a user defined X bars from each point?
There are some great opportunities using the GRab candles / Squeeze squeeze indicators waiting for an S1/R1 event.

Example: When the watchlist showed candles 3 bars from an S2,

Letting the user know where their favorite symbols are within the wave would give them the best tool (indicator ) for each section.

Thanks
Brett
These charts also include weekly pivots and the darvas box 2.0 - I don't follow Petsmart, it was pulled from the scan.
The other 3 charts I do watch / trade.

DcSU17L.jpg


nFmmO2a.jpg

FDiixqq.jpg

ZmOETts.jpg
 
Thank you for posting this. I wanted a scan that would show a bull/bear breakout sooner. I tried adjusting the Input n =10 and scan queries to reduce the bars so the event is closer to the S1 / R1 but I'm not able to refine the search.

Any ideas as to what I'm missing.

Also, is there a way to create the R1 -3 and S1-3 in the watchlist? Maybe a user defined X bars from each point?
There are some great opportunities using the GRab candles / Squeeze squeeze indicators waiting for an S1/R1 event.

Example: When the watchlist showed candles 3 bars from an S2,

Letting the user know where their favorite symbols are within the wave would give them the best tool (indicator ) for each section.

Thanks
Brett
These charts also include weekly pivots and the darvas box 2.0 - I don't follow Petsmart, it was pulled from the scan.
The other 3 charts I do watch / trade.
Sorry, couldn't get back to you sooner, dealing with, sort of family emergency.

1) Main script input = 10 , is the lookback period, to determine how many bars to look for to determine S1/R1 (please note, the scanner is only coded to identify S1/R1, Where as the main indicator can identify and print S3/S2/S1 & R3/R2/R1.

2) Yes, you can determine the bar sooner by adjusting the scan query ex: "Wolf_Waves_Scan().Bull within 5 bars", Please note: original Scan query is set an example too.

3)Haven't though about a Watchlist, I will look at it, but suspect, given the complexity of the code, it might slowdown.

I realize quite a lot has been said on this topic. I haven't gone through all the comments and processed them. So I apologies to anyone if I ended up repeating what has already been said.

Will give this a through read again and try respond better.
 
@brettji Pretty much caught-up the entire thread since my Scan post. It looks like all the answers to the questions are valid. If you are looking to catch the S1 or R1 bar earlier than the 25Bars suggested, you just change the scan query within bars not the input in Scanner Script.

Also, side note, in both the indicator and scanner script I see "input n = 13" yielding better results than "input n = 10". Just an observation.
 
@brettji Pretty much caught-up the entire thread since my Scan post. It looks like all the answers to the questions are valid. If you are looking to catch the S1 or R1 bar earlier than the 25Bars suggested, you just change the scan query within bars not the input in Scanner Script.

Also, side note, in both the indicator and scanner script I see "input n = 13" yielding better results than "input n = 10". Just an observation.
Thank you for answers ~ They are appreciated.
 
@PlayTrader Here is what you asked for. I took the liberty to add R1 line too along with S1.

Setup your scanner as custom script and your scan query will look like the below.

For finding the support AKA S1 of Wolf_Wave indicator posted in Original Comment here.
Code:
Wolf_Waves_Scan().Bull within 25 bars

Code:
Wolf_Waves_Scan().Bear within 25 bars

Code:
# Modified by @SuryaKiranC, An Attempt to create S1 & R1 for Scan #Requested by @PlayTrader
# Wolf_Waves_Scan
# Mobius
# V01.05.22.2018

input n = 10;

script LinePlot {
    input BarID = 0;
    input Value = 0;
    input BarOrigin = 0;
    def ThisBar = HighestAll(BarOrigin);
    def ValueLine = if BarOrigin == ThisBar then Value else Double.NaN;
    plot P = if ThisBar - BarID <= BarOrigin then HighestAll(ValueLine) else Double.NaN;
}

# Variables
def o = open;
def h = high;
def l = low;
def c = close;
def x = BarNumber();
def xN = x == HighestAll(x);

# R1
def hh = fold i = 1 to n + 1with p = 1 while p do h > GetValue(h, -i);
def PivotH = if (x > n and h == Highest(h, n) and hh) then h else Double.NaN;
def PHValue = if !IsNaN(PivotH) then PivotH else PHValue[1];
def PHBarOrigin = if !IsNaN(PivotH) then x else PHBarOrigin[1];
def PHBarID = x - PHBarOrigin;

# S1
def ll = fold j = 1 to n + 1 with q = 1 while q do l < GetValue(l, -j);
def PivotL = if (x > n and l == Lowest(l, n) and ll) then l else Double.NaN;
def PLValue = if !IsNaN(PivotL) then PivotL else PLValue[1];
def PLBarOrigin = if !IsNaN(PivotL) then x else PLBarOrigin[1];
def PLBarID = x - PLBarOrigin;

plot Bear = if (x == HighestAll(PHBarOrigin) and PHValue) then 1 else 0;
Bear.Hide();

plot Bull = if (x == HighestAll(PLBarOrigin) and PLValue) then 1 else 0;
Bull.Hide();

plot scan = (Bear or Bull);
Is this a scanner for a watchlist?
 
A great script I also run the swing waves hi-lo script and this will also catch the swing hi-low waves better seen as the black lines yes they repaint so read the candles too and until the price has set then I have the next wave direction up/down and those are what I trade. Keep in mind and out of respect for the author, not public scripts. I like simple the swing hi/los allow me to trade while I wait for the wolfe wave points 1-5 form.

 
Last edited:
Below is Ben's wolf script along with the swing waves hi/lo and basic market structure lines drawn on an hourly chart a 3-day swing lo to hi. Waves are clearly seen on a 2 hr chart..... Watch candles for best entry/exit. Also confluence of both the major and minor lines on shorter time frames for best entries.

 
Last edited:
plot Data = close;input n = 5;#hint n: For pivot and standard deviation
input addAtPercentStDev = 75;#hint addAtPercentStDev: Add at this percent of standard deviation below previous low
input initialLots = 4;#hint initialLots: Set to preference
input lotsToAdd = 2;#hint lotsToAdd: Number of lots to add on a pull back
input stDevMult = 2.0;#hint stDevMult: trail stop multiplier
input labels = yes;

def openingLots = Max(4, initialLots);
def addedlots = Max(2, lotsToAdd);
AddLabel(initialLots < openingLots, " Error: Initial lots must be 4 or more ", Color.Cyan);
AddLabel(lotsToAdd < addedLots, " Error: Lots to add must be 2 or more ", Color.Cyan);
def h = high;
def l = low;
def c = close;
def nan = Double.NaN;
def tick = TickSize();
def x = BarNumber();
def stDev = CompoundValue(1, StDev(c, n), nan);
def ll = l == Lowest(l, n);
def LPx = if ll then x else nan;
def LP_low = if !IsNaN(LPx) then l else LP_Low[1];
def LP_High = if !IsNaN(LPx) then h else LP_High[1];
def confirmation_count = if ll then 0 else
if c crosses above LP_high
then confirmation_count[1] + 1
else confirmation_count[1];
def confirmationX = if confirmation_count crosses above 0
then x else nan;
def confirmed = confirmation_count crosses above 0;

def ro;
def stc;
def trail;
def retrace;
if confirmed {
ro = Round((c + (c - LP_Low) / (openingLots - 2)) / tick, 0) * tick;
stc = LP_Low;
trail = LP_Low;
retrace = LP_Low;
}else{
ro = CompoundValue(1, ro[1], nan);
stc = stc[1];
trail = Round(Max(trail[1], l[1] - stDev[1] * stDevMult) / tick, 0) * tick;
retrace = Round(Max(retrace[1], l[1] - StDev[1] * addAtPercentStDev / 100) / tick, 0) * tick;
}

def ro_reached = if confirmed then 0 else
if h > ro then 1 else ro_reached[1];
def added = if confirmed then 0 else
if l crosses below retrace then 1 else added[1];
def trail_hit = if confirmed then 0 else
if c < trail then 1 else trail_hit[1];
def stop_hit = if confirmed then 0 else
if l < stc then 1 else stop_hit[1];


plot
PivotConfirmed = confirmed;
PivotConfirmed.SetDefaultColor(Color.Light_Green);
PivotConfirmed.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

plot
BuyToOpen = if confirmed then c else nan;
BuyToOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
BuyToOpen.SetDefaultColor(Color.Light_Green);

plot
SellToClose = if !stop_hit or stop_hit crosses above 0 then stc else nan;
SellToClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SellToClose.SetDefaultColor(Color.RED);

plot
TrailingStop = if ! trail_hit or trail_hit crosses above 0 then trail else nan;
TrailingStop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TrailingStop.SetDefaultColor(Color.Pink);

plot
Add = if !added or added crosses above 0 then retrace else nan;
Add.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Add.SetDefaultColor(Color.Dark_Green);

plot
RiskOut = if !ro_reached or ro_reached crosses above 0 then ro else nan;
RiskOut.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RiskOut.SetDefaultColor(CreateColor(215, 215, 215));

AddLabel(labels and BuyToOpen, " BTO "+ openingLots +" = " + BuyToOpen + " ", Color.Light_Green);
Addlabel(labels and BuyToOpen, " ", CreateColor(0, 0, 0));
AddLabel(labels and ro_reached and Add, " Add "+ addedlots +" at = " + Add + " ", Color.Dark_Green);
AddLabel(labels and ro_reached and Add, " ", CreateColor(0, 0, 0));
AddLabel(labels and RiskOut, " Sell " + (openingLots - 2) + " = " + ro + " ", CreateColor(215, 215, 215));
AddLabel(labels and RiskOut, " ", CreateColor(0, 0, 0));
AddLabel(labels and ro_reached and TrailingStop, " Sell "+(1+addedLots-1)+" at = "+trail+" ", Color.Pink);
Addlabel(labels and ro_reached and TrailingStop, " ", CreateColor(0, 0, 0));
AddLabel(labels and SellToClose, " Sell All = " + stc + " ", Color.Red);
Addlabel(labels and SellToClose, " ", CreateColor(0, 0, 0));

#f/ Pivot Confirmation With Trading Levels
 
@Ronathan Edwards The Scanner I made is a support script for what has been posted here in the Original Post.
Save the Original Post Code and the Scanner Code in 2 different TOS Studies, Say Wofl_Waves and Wolf_Waves_Scan.

You can use Wolf_Wave in you charts, the Scanner doesn't belong in your charts, but must exist in your TOS as a script.

Wolf_Waves
https://usethinkscript.com/threads/wolf-waves-trendline-breakouts-indicator-for-thinkorswim.66/
Wolf_Waves_Scan
https://usethinkscript.com/threads/...kouts-indicator-for-thinkorswim.66/post-52233

Once you have the Wolf_Waves_Scan script, all you write in your thinkScriptEditor in your Scan, is as following.

Code:
Wolf_Waves_Scan().Bull within 25 bars
or
Code:
Wolf_Waves_Scan().Bear within 25 bars

PS: the 25 bars is only an example, not an advice for trading. You should adjust that to you needs and based on what timeframe you are running your scanners. Also I personally found the "input n = 13" yields better results. if you are doing this you must adjust this in both Main Indicator script as well as Scanner.

Hope this helps.
-Surya
 
Last edited:
For example I have both wolf wave indicators the priemum one gives you a nice up arrow plot for confirmation the wave has began and it would be nice to have a scanner that can pick up those signals and alert me with a bar or 2 when it happens, using TSLA as an example beautiful move
 
For example I have both wolf wave indicators the priemum one gives you a nice up arrow plot for confirmation the wave has began and it would be nice to have a scanner that can pick up those signals and alert me with a bar or 2 when it happens, using TSLA as an example beautiful move
and do you have a the Premium Version of Wolfe_Wave_Scanner too? if yes you shouldn't need this one. In case if you don't have premium scanner, you see how the Wave 4 and 5 Line-up with R1 & S1? all you have to do us run the query like in the example but set it for with in 2 bars.

-S
 
and do you have a the Premium Version of Wolfe_Wave_Scanner too? if yes you shouldn't need this one. In case if you don't have premium scanner, you see how the Wave 4 and 5 Line-up with R1 & S1? all you have to do us run the query like in the example but set it for with in 2 bars.

-S
Only issue is the premium one is too complex to run any scans on, i figured i could do bullentry(which is the blue arrow it gives) is true within 2 bars but the indcator is too complex and thats why I got this one on here to see if i can make a scan based off that code, want to get an entry as close to that 5th wave as possible because that would be game changer if you can scan stocks that are just starting their 5th wave. hope this makes sense what im asking dont know if you have the other wolf wave as well
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
205 Online
Create Post

Similar threads

Similar threads

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