Gains Indicators

2Tradez

New member
Can someone please write a script that will automatically take the open price and the H.O.D., add them together, then divide that number by 2 and take that answer and show a price line? As the H.O.D changes and goes higher, then it will keep recalculating that price with the open price, and re-plot the price line? Its a good indicator for me to gauge if I should get out of a trade.
 
Solution
Can someone please write a script that will automatically take the open price and the H.O.D., add them together, then divide that number by 2 and take that answer and show a price line? As the H.O.D changes and goes higher, then it will keep recalculating that price with the open price, and re-plot the price line? Its a good indicator for me to gauge if I should get out of a trade.


this can display several lines,
..cyan line at (high of day + open of day)/2
..magenta line at (low of day + open of day)/2
..lime dashed line from the open of day
..gray lines at high of day and low of day



Code:
# hod_open_avg_00

#https://usethinkscript.com/threads/gains-indicators.15494/
#Gains Indicators

def na = double.nan;
def bn =...
Can someone please write a script that will automatically take the open price and the H.O.D., add them together, then divide that number by 2 and take that answer and show a price line? As the H.O.D changes and goes higher, then it will keep recalculating that price with the open price, and re-plot the price line? Its a good indicator for me to gauge if I should get out of a trade.


this can display several lines,
..cyan line at (high of day + open of day)/2
..magenta line at (low of day + open of day)/2
..lime dashed line from the open of day
..gray lines at high of day and low of day



Code:
# hod_open_avg_00

#https://usethinkscript.com/threads/gains-indicators.15494/
#Gains Indicators

def na = double.nan;
def bn = barnumber();

def istoday = if GetLastDay() == GetDay() then 1 else 0;

input show_only_today = yes;
input show_lines_only_on_bars = yes;

def x = if show_only_today then istoday else 1;
def linez = if show_lines_only_on_bars then !isnan(close) else 1;

#----------------------------

def agg = AggregationPeriod.day;
def day_open = open(period = agg);
def day_high = high(period = agg);
def day_low = low(period = agg);
def day_close = close(period = agg);

def hiopn = (day_high + day_open)/2;
def loopn = (day_open + day_low)/2;

input show_open_avg_lines = yes;
plot zhiop = if show_open_avg_lines and x and linez then hiopn else na;
plot zloop = if show_open_avg_lines and x and linez then loopn else na;
zhiop.setdefaultcolor(color.cyan);
zloop.setdefaultcolor(color.magenta);
zhiop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zloop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

input show_highest_lowest_lines = yes;
plot zhix = if show_highest_lowest_lines and x and linez then day_high else na;
plot zlox = if show_highest_lowest_lines and x and linez then day_low else na;
zhix.setdefaultcolor(color.light_gray);
zlox.setdefaultcolor(color.light_gray);
zhix.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zlox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot zopn = if x and linez then day_open else na;
#zopn.SetPaintingStrategy(PaintingStrategy.DASHES);
zopn.SetStyle(Curve.MEDIUM_DASH);
zopn.setdefaultcolor(color.lime);
zopn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#

YNwIH8U.jpg
 
Solution

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

this can display several lines,
..cyan line at (high of day + open of day)/2
..magenta line at (low of day + open of day)/2
..lime dashed line from the open of day
..gray lines at high of day and low of day



Code:
# hod_open_avg_00

#https://usethinkscript.com/threads/gains-indicators.15494/
#Gains Indicators

def na = double.nan;
def bn = barnumber();

def istoday = if GetLastDay() == GetDay() then 1 else 0;

input show_only_today = yes;
input show_lines_only_on_bars = yes;

def x = if show_only_today then istoday else 1;
def linez = if show_lines_only_on_bars then !isnan(close) else 1;

#----------------------------

def agg = AggregationPeriod.day;
def day_open = open(period = agg);
def day_high = high(period = agg);
def day_low = low(period = agg);
def day_close = close(period = agg);

def hiopn = (day_high + day_open)/2;
def loopn = (day_open + day_low)/2;

input show_open_avg_lines = yes;
plot zhiop = if show_open_avg_lines and x and linez then hiopn else na;
plot zloop = if show_open_avg_lines and x and linez then loopn else na;
zhiop.setdefaultcolor(color.cyan);
zloop.setdefaultcolor(color.magenta);
zhiop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zloop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

input show_highest_lowest_lines = yes;
plot zhix = if show_highest_lowest_lines and x and linez then day_high else na;
plot zlox = if show_highest_lowest_lines and x and linez then day_low else na;
zhix.setdefaultcolor(color.light_gray);
zlox.setdefaultcolor(color.light_gray);
zhix.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zlox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot zopn = if x and linez then day_open else na;
#zopn.SetPaintingStrategy(PaintingStrategy.DASHES);
zopn.SetStyle(Curve.MEDIUM_DASH);
zopn.setdefaultcolor(color.lime);
zopn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#

View attachment 18699
OMG!!!! Thank you so much. This is exactly what I was looking for. You are awesome!!!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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