Chandelier Exit Indicator for ThinkorSwim

Hi All, Thank you for the effort.

1. How can I replace the chartBubble with UPARROW and DOWNARROW?
def buySignal = direction == 1 and direction[1] == -1;
#AddChartBubble(buySignal and ShowLabels, low, "Buy Signal", Color.Green, no);

Tried simply
plot buySignal; # did not work

Tried the below did not work.
def bS1;
plot bS1 = if direction == 1 and direction[1] == -1 and ShowLabels == yes then ??


2. How do I use this code for scanning?

#Chandelier Exit (Upper Study)
#Version 1.0 Released 04/10/22
#Created by CustomThinkscript

input ATRLength = 22;
input ATRMultiplier = 3;
input ShowLabels = yes;
input UseClose = yes;
input HighlightState = yes;
input Alerts = no;

def atr = ATRMultiplier * ATR(ATRLength);

def longStop = (if UseClose then highest(close, ATRLength) else highest(high, ATRLength)) - atr;
def longStopPrev = if IsNan(LongStop[1]) then longStop else LongStop[1];
def LS =if close[1] > longStopPrev then max(longStop, longStopPrev) else longStop;


def shortStop = (if UseClose then lowest(close, ATRLength) else lowest(low, ATRLength)) + atr;
def shortStopPrev = if IsNan(shortStop[1]) then shortStop else shortStop[1];
def SS =if close[1] < shortStopPrev then min(shortStop, shortStopPrev) else shortStop;

def dir = if close > shortStopPrev then 1 else if close < longStopPrev then -1 else dir[1];
def direction = dir;

plot LongStopPlot = if direction == 1 then LS else double.Nan;
longStopPlot.SetDefaultColor(Color.Green);

plot ShortStopPlot = if direction == -1 then SS else Double.Nan;
shortStopPlot.SetDefaultColor(Color.Red);

def midPricePlot = OHLC4;

def buySignal = direction == 1 and direction[1] == -1;
def sellSignal = direction == -1 and direction[1] == 1;

AddChartBubble(buySignal and ShowLabels, low, "Buy Signal", Color.Green, no);
AddChartBubble(sellSignal and ShowLabels, high, "Sell Signal", Color.Red, yes);

AddCloud(if direction == 1 and HighlightState then longStopPlot else Double.Nan, If direction == 1 and HighlightState then midPricePlot else Double.Nan, Color.Green, Color.Green, no);

AddCloud(if direction == -1 and HighlightState then shortStopPlot else Double.Nan, If direction == -1 and HighlightState then midPricePlot else Double.Nan, Color.Red, Color.Red, no);

Alert(direction == 1 and direction[1] == -1 and Alerts, "'Chandelier Exit' Buy!", Alert.ONCE, Sound.Ding);
Alert(direction == -1 and direction[1] == 1 and Alerts, "'Chandelier Exit' Sell!", Alert.ONCE, Sound.Ding);

Thank you.
 

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

UPDATED VERSION
source link https://www.facebook.com/CustomThinkscript
https://tos.mx/zQWZdty

#Chandelier Exit (Upper Study)
#Version 1.1 Released 05/10/22
#Created by CustomThinkscript


input ATRLength = 22;
input ATRMultiplier = 3;
input ShowLabels = yes;
input UseClose = yes;
input HighlightState = yes;
input Alerts = no;

def atr = ATRMultiplier * ATR(ATRLength);

def longStop = (if UseClose then highest(close, ATRLength) else highest(high, ATRLength)) - atr;
def longStopPrev = if IsNan(LongStop[1]) then LongStop else LongStop[1];
def LS = if close[1] > LS[1] then max(max(longStop, longStopPrev), LS[1]) else longStop;

def shortStop = (if UseClose then lowest(close, ATRLength) else lowest(low, ATRLength)) + atr;
def shortStopPrev = if IsNan(shortStop[1]) then ShortStop else shortStop[1];
def SS =if close[1] < SS[1] then min(min(shortStop, shortStopPrev), SS[1]) else shortStop;

def dir = if close > SS then 1 else if close < LS then -1 else dir[1];
def direction = dir;

plot LongStopPlot = if direction == 1 then LS else double.Nan;
longStopPlot.SetDefaultColor(Color.Green);

plot ShortStopPlot = if direction == -1 then SS else Double.Nan;
shortStopPlot.SetDefaultColor(Color.Red);

def midPricePlot = OHLC4;

def buySignal = direction == 1 and direction[1] == -1;
def sellSignal = direction == -1 and direction[1] == 1;

AddChartBubble(buySignal and ShowLabels, low, "Buy Signal", Color.Green, no);
AddChartBubble(sellSignal and ShowLabels, high, "Sell Signal", Color.Red, yes);

AddCloud(if direction == 1 and HighlightState then longStopPlot else Double.Nan, If direction == 1 and HighlightState then midPricePlot else Double.Nan, Color.Green, Color.Green, no);

AddCloud(if direction == -1 and HighlightState then shortStopPlot else Double.Nan, If direction == -1 and HighlightState then midPricePlot else Double.Nan, Color.Red, Color.Red, no);

Alert(direction == 1 and direction[1] == -1 and Alerts, "'Chandelier Exit' Buy!", Alert.ONCE, Sound.Ding);
Alert(direction == -1 and direction[1] == 1 and Alerts, "'Chandelier Exit' Sell!", Alert.ONCE, Sound.Ding);
 
Hello Traders,

I am trying to create "chandelier exit" stock scanner. Can anyone help me create this scanner, please? Thanks
 
Hello Traders,

I am trying to create "chandelier exit" stock scanner. Can anyone help me create this scanner, please? Thanks
Change:
Rich (BB code):
def buySignal = direction == 1 and direction[1] == -1;
def sellSignal = direction == -1 and direction[1] == 1;
To:
Rich (BB code):
plot buySignal = direction == 1 and direction[1] == -1;
plot sellSignal = direction == -1 and direction[1] == 1;

Then in the scan hacker:
1. Select the study
2. filter: buySignal is true
 
Change:
Rich (BB code):
def buySignal = direction == 1 and direction[1] == -1;
def sellSignal = direction == -1 and direction[1] == 1;
To:
Rich (BB code):
plot buySignal = direction == 1 and direction[1] == -1;
plot sellSignal = direction == -1 and direction[1] == 1;

Then in the scan hacker:
1. Select the study
2. filter: buySignal is true

Tried it and and it worked great...THANKS
 
Last edited by a moderator:
Tried it and and it worked great...THANKS
When I paste the code, I get the message "Exactly one plot expected". What does that mean?
thanks

I'm sorry...I pasted the code into the thinkScript editor. I've read through this thread quite a few times, and don't know how to get past the "Exactly one plot expected" message. What other instructions have I missed?
Thanks for your help
 
Change:
Rich (BB code):
def buySignal = direction == 1 and direction[1] == -1;
def sellSignal = direction == -1 and direction[1] == 1;
To:
Rich (BB code):
plot buySignal = direction == 1 and direction[1] == -1;
plot sellSignal = direction == -1 and direction[1] == 1;

Then in the scan hacker:
1. Select the study
2. filter: buySignal is true
Anybody know , Is there a way to make it paint the bars, when the bars cross the red zone they are painted red and when they turn to the green they painted green ? Thanks
 
Last edited:
Anybody know , Is there a way to make it paint the bars, when the bars cross the red zone they are painted red and when they turn to the green they painted green ? Thanks
Add this to the bottom of your script:
Ruby:
input paintBars = yes ;
AssignPriceColor(if !paintBars
    then Color.CURRENT
    else if direction == 1 then color.green else color.red);
 
When I paste the code, I get the message "Exactly one plot expected". What does that mean?
thanks


I'm sorry...I pasted the code into the thinkScript editor. I've read through this thread quite a few times, and don't know how to get past the "Exactly one plot expected" message. What other instructions have I missed?
Thanks for your help
Can you please share this scanner ,i have tried but cant get it.
Any help with the scanner?
Shared Scan Link: http://tos.mx/WcBRNMf Click here for --> Easiest way to load shared links
ztkS3KJ.png
 
Here is a TOS Thinkscript version of "Chandelier Exit" translated from Tradingview.
source link: https://www.facebook.com/CustomThinkscript
http://tos.mx/7C9Ahas
Ruby:
#Chandelier Exit (Upper Study)
#Version 1.0 Released 04/10/22
#Created by CustomThinkscript

input ATRLength = 22;
input ATRMultiplier = 3;
input ShowLabels = yes;
input UseClose = yes;
input HighlightState = yes;
input Alerts = no;

def atr = ATRMultiplier * ATR(ATRLength);

def longStop = (if UseClose then highest(close, ATRLength) else highest(high, ATRLength)) - atr;
def longStopPrev = if IsNan(LongStop[1]) then longStop else LongStop[1];
def LS =if close[1] > longStopPrev then max(longStop, longStopPrev) else longStop;


def shortStop = (if UseClose then lowest(close, ATRLength) else lowest(low, ATRLength)) + atr;
def shortStopPrev = if IsNan(shortStop[1]) then shortStop else shortStop[1];
def SS =if close[1] < shortStopPrev then min(shortStop, shortStopPrev) else shortStop;

def dir = if close > shortStopPrev then 1 else if close < longStopPrev then -1 else dir[1];
def direction = dir;

plot LongStopPlot = if direction == 1 then LS else double.Nan;
longStopPlot.SetDefaultColor(Color.Green);

plot ShortStopPlot = if direction == -1 then SS else Double.Nan;
shortStopPlot.SetDefaultColor(Color.Red);

def midPricePlot = OHLC4;

def buySignal = direction == 1 and direction[1] == -1;
def sellSignal = direction == -1 and direction[1] == 1;

AddChartBubble(buySignal and ShowLabels, low, "Buy Signal", Color.Green, no);
AddChartBubble(sellSignal and ShowLabels, high, "Sell Signal", Color.Red, yes);

AddCloud(if direction == 1 and HighlightState then longStopPlot else Double.Nan, If direction == 1 and HighlightState then midPricePlot else Double.Nan, Color.Green, Color.Green, no);

AddCloud(if direction == -1 and HighlightState then shortStopPlot else Double.Nan, If direction == -1 and HighlightState then midPricePlot else Double.Nan, Color.Red, Color.Red, no);

Alert(direction == 1 and direction[1] == -1 and Alerts, "'Chandelier Exit' Buy!", Alert.ONCE, Sound.Ding);
Alert(direction == -1 and direction[1] == 1 and Alerts, "'Chandelier Exit' Sell!", Alert.ONCE, Sound.Ding);
Thanks JP, I tried this script and results are very close. Trying to use it for S&P futures. Please let me know your thoughts.
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
331 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