Is it possible to set a stop loss based on the close of a candlestick?

Ali_A

New member
VIP
Hello, i usually set a manual stop loss based on the close of a candlestick under a certain price. Do you know how i can automate this such that, instead of setting the stop order to trigger based on the underlying price ( which is currently in tos), the stop will only trigger if the candlestick closes below a certain price.
 
Just for clarity, you're talking about a closed bar that is fully completed, correct? Is this for actual order submission, or just something like a strategy? I would need to know the aggregation(s) that you plan on using for sure. If it is for actual order submission, provide as much miscellaneous detail as you can, for example, that you might be trying to close an option based on the underlying's price, and things like that.
 

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

Just for clarity, you're talking about a closed bar that is fully completed, correct? Is this for actual order submission, or just something like a strategy? I would need to know the aggregation(s) that you plan on using for sure. If it is for actual order submission, provide as much miscellaneous detail as you can, for example, that you might be trying to close an option based on the underlying's price, and things like that.
Hello Joshua, yes for a closed bar and for an actual order submission. Example is; i buy an option contract, i set a conditional stop loss at the low of the trigger candle of the underlying. My question is, is it possible to set the stop loss such that it only triggers only if the candle closes below the stop loss rather than when the candle touches the stop loss? (Note: i usually set the stop loss based on the underlying price not option contract price)
 
Yes, to a certain extent. ThinkScript has no proper way to detect the full completion of a bar, like a function, or an event handler. The typical method of doing so relies on the next bar opening. You would simply have to script the conditional as Close[1] < StopPrice. So, in the event that your stop is hit by a fully completed bar, It should trigger on the very first tick of the next bar.

This, of course, would run into issues on daily charts, and on the last intraday bar of the day, where it wont trigger until the next day. I can show you how to detect the final intraday bar of the day and arrange for an alternative method specific to that bar, if need be. You might want to have it revert back to the "touched" method on only that final bar, but It depends on how you want to handle it.
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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