how to add in a Barsheld to trailing stop loss

0Predictions

New member
Any idea how to add in a Barsheld to this portion of the below script (highest(high, ATRLength)))? I'm using this on a N day breakout strategy and using the ATR as a trailing stop loss. tyia.

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

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

def dir = if close > shortStopPrev then 1 else if close < longStopPrev then -1 else dir[1];
def direction = dir;
 
Last edited by a moderator:

halcyonguy

Well-known member
VIP
Lifetime
Any idea how to add in a Barsheld to this portion of the below script (highest(high, ATRLength)))? I'm using this on a N day breakout strategy and using the ATR as a trailing stop loss. tyia.

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

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

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

you can't make up words, like barsheld, and expect others to know what you are talking about.
you will have to explain some more on what you want to have happen.
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
Any idea how to add in a Barsheld to this portion of the below script (highest(high, ATRLength)))? I'm using this on a N day breakout strategy and using the ATR as a trailing stop loss. tyia.
Your post doesn't have enough information for anyone to be able to assist you.
To make sure your post gets the attention and assistance it deserves, here are a few directions to keep in mind:
  • Make sure to post your question in the Questions Forum. This is where all the questions go, and where you'll find the most eyes to help you out.
  • Include a screenshot of your chart and a shared chart link. This will help others understand the context of your question and allow them to replicate the conditions that you are describing.
  • Annotate your image, highlighting the confluence that you're trying to achieve, along with a more detailed written explanation. This will help others understand your question even better and give them more specific information to work with.
If you're unsure of how to share chart links or upload screenshots to the forum, don't worry, we've included some easy-to-follow directions for you.
How to create a shared chart link:
https://usethinkscript.com/threads/how-to-share-a-chart-in-thinkorswim.14221/
How to upload screenshots to the forum:
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-58714


We look forward to seeing your next post and helping you out!
 
Last edited:

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.
Top