Extending Opening Price

Cribbage

Member
I'm trying to get the opening price of the hourly extend right for two hours and keep a single color. I chopped up one of PelonSax's codes and added a displacer thinking this would work. Only problem is that on lower time frames, the displacer uses the opening price of the lower timeframe so the extensions change colors.

In other words, on the Hourly timeframe, the script works properly, but on the 5min time frame, the first plot follows the color I want it to, but the second plot may sometimes change.

If anyone can help it would be appreciated.

Code:
#-----------------------------------------------------
#
#       S I M P L E
#    C A N D L E      O V E R L A Y
#
# Open line red/green for visualizing FTC
#
#
# a STRAT study by Ramon DV. aka Pelonsax
# based on Rob Smith's The STRAT
# Original Candle Overlay concept by Paul Townsend
#
#-----------------------------------------------------
DECLARE UPPER;
#------------------------------------
# MTF SECTION
#------------------------------------

###6/14/24 Cribbage added code to help identify OB opening price, marked below

input AddOutline = no;
input Time_Frame = AggregationPeriod.FIFTEEN_MIN;
plot H = high(period = Time_Frame);
H.setDefaultColor(color.gray);
H.setHiding(!AddOutline);
plot L = low(period = Time_Frame);
L.setDefaultColor(color.gray);
L.setHiding(!AddOutline);
def O = open(period = Time_Frame);
def C = close(period = Time_Frame);

plot zeroline = O;
zeroline.AssignValueColor(if C > O then color.red else if C < O then color.green else color.white);
zeroline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zeroline.setlineWeight(2);

###Cribbage

input displaceLength = 1;
plot Displacer = zeroline[displaceLength];
displacer.AssignValueColor(if C[displacelength] > O[displacelength] then color.red else if C[displacelength] < O[displacelength] then color.green else color.white);
displacer.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
displacer.setlineWeight(2);

###Cribbage End

# ADD LABEL
#------------------------------------
input Show_Label = yes;
AddLabel(Show_Label, Concat(if Time_Frame < 3600000 then Time_Frame / 60000 + "m" else if Time_Frame < 86400000 then Time_Frame / 3600000 + "h" else if Time_Frame < 604800000 then Time_Frame / 86400000 + "D" else if Time_Frame < 2592000000 then Time_Frame / 604800000 + "Wk" else if Time_Frame < 31536000000 then Time_Frame / 2592000000 + "Mo" else Time_Frame / 31536000000 + "Yr", if Time_Frame then " CANDLES" else ""), Color.light_Gray);

# end
 

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