Negative numbers on studies?

Is there a way to reference negative numbers on thinkscript? I'm using the MACD and want to enter short positions if the MACD is between 0.0 and -.75
 
Solution
Is there a way to reference negative numbers on thinkscript? I'm using the MACD and want to enter short positions if the MACD is between 0.0 and -.75
Use the between() function. In your case, the parameter will be part of the macd you are wanting to reference, value1 will be the negative number and value2 will be 0. Please note that value1 is always lower than value2.
Between ( double value2);

Default values:

Description​

Tests if the specified parameter is within the range of value1 and value2 inclusively. The function returns 1 (true) if the data is between the two parameter values, and 0 (false) if the data is outside of the two parameter values.

Input...​

Is there a way to reference negative numbers on thinkscript? I'm using the MACD and want to enter short positions if the MACD is between 0.0 and -.75
Use the between() function. In your case, the parameter will be part of the macd you are wanting to reference, value1 will be the negative number and value2 will be 0. Please note that value1 is always lower than value2.
Between ( double value2);

Default values:

Description​

Tests if the specified parameter is within the range of value1 and value2 inclusively. The function returns 1 (true) if the data is between the two parameter values, and 0 (false) if the data is outside of the two parameter values.

Input parameters​

ParameterDefault valueDescription
parameter-Defines parameter to test.
value1-Defines the first endpoint of the range.
value2-Defines the second endpoint of the range.

Example​

declare lower;
input lowLimit = 140.0;
input highLimit = 160.0;
plot Between1 = Between(close, lowLimit, highLimit);
plot Between2 = close >= lowLimit and close <= highLimit;
The code will return 1 if the closing price is between lowLimit and highLimit, and 0 if the closing price is below lowLimitor above highLimit. The example also shows the alternative solution to the between function implemented using the double inequality.
 
Solution

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