Need help with my Projection tool Study

jgj

New member
VIP
Hi,

I have a study called projection tool and I am using different displacement figures for the different time frames I'm using. These are in a dropdown menu. I was wondering if it's possible to select from the dropdown menu the desired displacement and automatically populate it to the displacement input field.

I have attached an image. See below


Here's the study:
http://tos.mx/TMuBGyQ
Ruby:
#JJ Projection tool
#Definitions
def na = Double.NaN;
def h = HighestAll(high);
def l = LowestAll(low);

# Inputs for EMA2 and Inversion
input priceChartDisplay = close;
input avg_type = AverageType.SIMPLE;

#Switch for Chart Time Frame
input TimeFrame_Displacement = {default Daily_82, Hourly_140, Fifteen_Minute_520, Five_Minute_1560};
input avg_len = 5;
input displace = -82;

#MovingAverage
def ma1 = MovingAverage(avg_type, close, avg_len);

input show_ma1 = yes;
plot z1 = if show_ma1 then ma1[-displace] else na;
z1.SetDefaultColor(Color.CYAN);

def lowdiff = ma1 - l;
def ma1_inv = h - lowdiff;

input show_inverted_ma1 = yes;
plot z2 = if show_inverted_ma1 then ma1_inv[-displace] else na;
z2.SetDefaultColor(Color.YELLOW);
z2.SetStyle(Curve.SHORT_DASH);

#AddLabel(1, "   Normal   ", Color.CYAN);
#AddLabel(1, " Inversion ", Color.YELLOW);
 
Last edited by a moderator:
Solution
Hi,

I have a study called projection tool and I am using different displacement figures for the different time frames I'm using. These are in a dropdown menu. I was wondering if it's possible to select from the dropdown menu the desired displacement and automatically populate it to the displacement input field.

I have attached an image. See below


Here's the study:
http://tos.mx/TMuBGyQ
Ruby:
#JJ Projection tool
#Definitions
def na = Double.NaN;
def h = HighestAll(high);
def l = LowestAll(low);

# Inputs for EMA2 and Inversion
input priceChartDisplay = close;
input avg_type = AverageType.SIMPLE;

#Switch for Chart Time Frame
input TimeFrame_Displacement = {default Daily_82, Hourly_140, Fifteen_Minute_520...
Hi,

I have a study called projection tool and I am using different displacement figures for the different time frames I'm using. These are in a dropdown menu. I was wondering if it's possible to select from the dropdown menu the desired displacement and automatically populate it to the displacement input field.

I have attached an image. See below


Here's the study:
http://tos.mx/TMuBGyQ
Ruby:
#JJ Projection tool
#Definitions
def na = Double.NaN;
def h = HighestAll(high);
def l = LowestAll(low);

# Inputs for EMA2 and Inversion
input priceChartDisplay = close;
input avg_type = AverageType.SIMPLE;

#Switch for Chart Time Frame
input TimeFrame_Displacement = {default Daily_82, Hourly_140, Fifteen_Minute_520, Five_Minute_1560};
input avg_len = 5;
input displace = -82;

#MovingAverage
def ma1 = MovingAverage(avg_type, close, avg_len);

input show_ma1 = yes;
plot z1 = if show_ma1 then ma1[-displace] else na;
z1.SetDefaultColor(Color.CYAN);

def lowdiff = ma1 - l;
def ma1_inv = h - lowdiff;

input show_inverted_ma1 = yes;
plot z2 = if show_inverted_ma1 then ma1_inv[-displace] else na;
z2.SetDefaultColor(Color.YELLOW);
z2.SetStyle(Curve.SHORT_DASH);

#AddLabel(1, "   Normal   ", Color.CYAN);
#AddLabel(1, " Inversion ", Color.YELLOW);

no, can't use a formula with input.

could use an if then to assign the displace number.

an example of comparing agg times,
https://usethinkscript.com/threads/...icator-for-thinkorswim.1129/page-4#post-69106
 
Solution
Ok. So, the label would show the desired setting on the chart in the correct time frame but I would still have to manually input the displace number. I'll try that. Thanks for your help.

no, i meant you can use an if then to compare some values to a variable and assign a number, like in the example code i linked.
An if then could compare several values to TimeFrame_Displacement and when there's a match, it could assign a specific number, the displace number.
 
no, i meant you can use an if then to compare some values to a variable and assign a number, like in the example code i linked.
An if then could compare several values to TimeFrame_Displacement and when there's a match, it could assign a specific number, the displace number.
Ok. Now I understand what you mean ... but the reality is, it's going to take me a while to figure out how to do that on thinkscript but I will try. Thanks again for your time.
 

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