How to exit a startegy using 2 * ATR

T

Trendman

Guest
def averageType = AverageType.Exponential;
def exitPrice = ExpAverage(TrueRange(high, low, close), length);
AddOrder(OrderType.BUY_TO_CLOSE, EntryPrice() + exitPrice);

This is not giving me the expected results. I added a label to view the ATR. The ATR displays $4.16 and the 2 * ATR displays at $8.80. I see why my expected results are different, owever I can not find out why 2 * ATR is different than the ATR? HELP!

Thanks
Frank
 
Solution
def averageType = AverageType.Exponential;
def exitPrice = ExpAverage(TrueRange(high, low, close), length);
AddOrder(OrderType.BUY_TO_CLOSE, EntryPrice() + exitPrice);

This is not giving me the expected results. I added a label to view the ATR. The ATR displays $4.16 and the 2 * ATR displays at $8.80. I see why my expected results are different, owever I can not find out why 2 * ATR is different than the ATR? HELP!

Thanks
Frank

several issues,
. you didn't post the complete code
. averageType defined, but not used
. length not defined
. addorder data is wrong. 2nd parameter should be trigger condition, not a price.
. addorder, no order quantity. default listed as - , so i guess it won't be processed.
. you are asking...
def averageType = AverageType.Exponential;
def exitPrice = ExpAverage(TrueRange(high, low, close), length);
AddOrder(OrderType.BUY_TO_CLOSE, EntryPrice() + exitPrice);

This is not giving me the expected results. I added a label to view the ATR. The ATR displays $4.16 and the 2 * ATR displays at $8.80. I see why my expected results are different, owever I can not find out why 2 * ATR is different than the ATR? HELP!

Thanks
Frank

several issues,
. you didn't post the complete code
. averageType defined, but not used
. length not defined
. addorder data is wrong. 2nd parameter should be trigger condition, not a price.
. addorder, no order quantity. default listed as - , so i guess it won't be processed.
. you are asking about atr when you don't have a variable for it. ( i think it is what is in the expaverage( ) , i would define a variable , def atr1 = .... , then use atr1 in the expaverage, and put atr1 in a bubble to see the values


drf atr1 = TrueRange(high, low, close);
addchartbubble(1, low, atr1, color.yellow, no);

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/AddOrder
 
Solution
Thank you both for your responses. I looked at this for so long I needed a fresh set of eyes. I was able to make the corrections needed and am getting my expected results.
Thank you so much for your help.
Trendman
 
Thank you both for your responses. I looked at this for so long I needed a fresh set of eyes. I was able to make the corrections needed and am getting my expected results.
Thank you so much for your help.
Trendman
good to hear. sometimes you just need a break. just the other day , i had an unexpected code output, that turned out to be a silly mistake.
 

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
304 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