Stop Loss Take Profit Tool For ThinkOrSwim

Here is a stop-loss and take-profit tool. I added Fibonacci levels for the take profit guidance and the close of a candle for the stop loss. Also includes visual and audio alerts and all are customizable with the menu to fit your needs. Let me know what I should add or fix and as always. Do not solely rely on one tool or indicator for your plays. Do your own due diligence! Let this serve as a guide. Happy trading! : )
Ruby:
#SLTP Tool Version 1.0 created by Trader4TOS 06/25/2023
#Inputs:

#stopLossCandle: Allows you to specify the number of candles back to use for setting the stop loss level.
#takeProfitLevels: Determines the number of take profit levels to plot.
#fibLevel1, fibLevel2, fibLevel3: Fibonacci levels used to calculate the take profit prices.
#Plotting:

#Stop Loss: Plots a line representing the stop loss level based on the specified stopLossCandle. It is colored in red.
#Take Profit Levels: Plots lines representing the take profit levels based on the Fibonacci levels. The colors of the lines are customizable: tp1 is light green, tp2 is green, and tp3 is dark green.
#Alerting:

#The script includes alerts for specific conditions:
#Stop Loss Triggered: Alerts when the current close price falls below or equals the stop loss level.
#Take Profit 1 Reached: Alerts when the current close price exceeds or equals the first take profit level.
#Take Profit 2 Reached: Alerts when the current close price exceeds or equals the second take profit level.
#Take Profit 3 Reached: Alerts when the current close price exceeds or equals the third take profit level.
#Customization:

#Enable Alerts: Allows you to enable or disable the alerts by setting the enableAlerts input to "yes" or "no".
#Alert Sound: You can choose the alert sound from various options available in ThinkScript, such as Sound.Ring, Sound.Bell, etc.
#By using this script, you can plot the stop loss and take profit levels on your chart and receive audio alerts when the price reaches these levels or when the stop loss is triggered.



input stopLossCandle = 1;
input takeProfitLevels = 3;
input fibLevel1 = 0.382;
input fibLevel2 = 0.618;
input fibLevel3 = 1.0;

input enableAlerts = yes;
input alertSound = Sound.Ring;

def stopLossPrice = close[stopLossCandle];
def takeProfit1Price = close * fibLevel1;
def takeProfit2Price = close * fibLevel2;
def takeProfit3Price = close * fibLevel3;

# Plot Stop Loss
plot stopLoss = stopLossPrice;
stopLoss.SetDefaultColor(Color.RED);
stopLoss.SetLineWeight(2);

# Plot Take Profit Levels
def bullish = close > close[1];
def bearish = close < close[1];

plot tp1 = if bullish then takeProfit1Price else Double.NaN;
tp1.SetDefaultColor(Color.LIGHT_GREEN);
tp1.SetLineWeight(2);

plot tp2 = if bullish then takeProfit2Price else Double.NaN;
tp2.SetDefaultColor(Color.GREEN);
tp2.SetLineWeight(2);

plot tp3 = if bullish then takeProfit3Price else Double.NaN;
tp3.SetDefaultColor(Color.DARK_GREEN);
tp3.SetLineWeight(2);

# Alert Conditions
def alertCondition = close <= stopLossPrice;
def alertProfit1 = close >= takeProfit1Price;
def alertProfit2 = close >= takeProfit2Price;
def alertProfit3 = close >= takeProfit3Price;
def alertStopLoss = close <= stopLossPrice;

# Set alerts for conditions
Alert(enableAlerts and alertCondition, "Stop Loss Triggered", Alert.BAR, alertSound);
Alert(enableAlerts and alertProfit1, "Take Profit 1 Reached", Alert.BAR, alertSound);
Alert(enableAlerts and alertProfit2, "Take Profit 2 Reached", Alert.BAR, alertSound);
Alert(enableAlerts and alertProfit3, "Take Profit 3 Reached", Alert.BAR, alertSound);
Alert(enableAlerts and alertStopLoss, "Stop Loss Reached", Alert.BAR, alertSound);
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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