• Get $40 off VIP by signing up for a free account! Sign Up

Round with a if

I would like to put in a variable: the percentage difference of the daily low to open on average for the last 240 days.
Code:
((Low-open)/open * 100)

percentage difference of the low to open on average for the last 240 days.

Thanks
 

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

Portfolio functions: https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio
  • In order to utilize portfolio functions you must have Advanced Features enabled on your account.
The following limitations apply when using the GetAveragePrice, GetOpenPL, and GetQuantity functions:
  • They cannot be used on charts with a price type other than LAST (i.e., they won't work with MARK, ASK, or BID price types).
  • If applied to a futures product chart, they subscribe to the active contract data.
  • Note also that Portfolio functions can only be used with the following aggregation periods: 1 min, 2 min, 3 min, 4 min, 5 min, 10 min, 15 min, 20 min, 30 min, 1h, or 1 day. Time period for the aggregation of 1 day is limited to 1 year.
 
@CapitaineFlam88 Your code is doing what you have told it to do, plot a straight line... A trendline has two price points and the plot is from one to the other... I am not a trendline guy but I know there are several topics with examples here in these forums... The search feature should guide you to them...
 
@CapitaineFlam88 Can you please elaborate on how to edit custom quotes? I created some (to add additional columns) in my search results but don't seen an option for 'edit formula'.
Ok, If you created a custom quote for a watchlist and want to edit it later.
Follow the picture here. if need more help tell me.
You need to be in watchlist, then have you custom quote showing in the watchlist. Then follow instructions on the picture.

https://1drv.ms/u/s!ArwCtqnS855ggeUaYqS9bnuimB5luQ?e=bjJvCQ
 
Last edited:
Can you help fix my code?
I usualy get a % profit with variable PourcentProfit. But when it's PrixAchat= 0. The PourcentProfit get to 900000000. And it trigger an alarm.

Code:
def PourcentProfit = Round ( (close - PrixAchat) / PrixAchat * 100) if (PourcentProfit  >= 1000000 ) then 0 else  Round ( (close - PrixAchat) / PrixAchat * 100);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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