$PCall Label

J

jayabner

Guest
Hey there, so I was wondering if anyone can please help me create a label that displays $PCALL current condition that works across all time frames. If above 1 it can be color green & if below, say, .60 it could be color red else neutral gray. The code below is the one I currently have but every time I switch over to a smaller time frame than the Daily the info on the label disappears and goes blank. Any and all help is much appreciated! Thank you in advance.

def pcClose = close(symbol = "$PCALL");
def pcSMA = Average(pcClose, 10);
def value = pcClose / pcSMA;
AddLabel(yes, Concat(Concat(Concat("P/C: ", Round(pcClose, 2)), " SMA: "), Round(pcSMA, 2)), if value > 1.0 then Color.RED else if value > 0.8 then Color.GRAY else Color.GREEN);
 
Last edited by a moderator:
Solution
Hey there, so I was wondering if anyone can please help me create a label that displays $PCALL current condition that works across all time frames. If above 1 it can be color green & if below, say, .60 it could be color red else neutral gray. The code below is the one I currently have but every time I switch over to a smaller time frame than the Daily the info on the label disappears and goes blank. Any and all help is much appreciated! Thank you in advance.

def pcClose = close(symbol = "$PCALL");
def pcSMA = Average(pcClose, 10);
def value = pcClose / pcSMA;
AddLabel(yes, Concat(Concat(Concat("P/C: ", Round(pcClose, 2)), " SMA: "), Round(pcSMA, 2)), if value > 1.0 then Color.RED else if value > 0.8 then Color.GRAY else...
Hey there, so I was wondering if anyone can please help me create a label that displays $PCALL current condition that works across all time frames. If above 1 it can be color green & if below, say, .60 it could be color red else neutral gray. The code below is the one I currently have but every time I switch over to a smaller time frame than the Daily the info on the label disappears and goes blank. Any and all help is much appreciated! Thank you in advance.

def pcClose = close(symbol = "$PCALL");
def pcSMA = Average(pcClose, 10);
def value = pcClose / pcSMA;
AddLabel(yes, Concat(Concat(Concat("P/C: ", Round(pcClose, 2)), " SMA: "), Round(pcSMA, 2)), if value > 1.0 then Color.RED else if value > 0.8 then Color.GRAY else Color.GREEN);

Since you had both in one label, I assume the following seperating them for the coloring is what you wanted.

Capture.jpg
Ruby:
def pcClose = close(symbol = "$PCALL");
plot pcSMA   = Average(pcClose, 10);
def value   = pcClose / pcSMA;

AddLabel(yes, "P/C: " + Round(pcClose), if pcClose > 1 then Color.GREEN else if pcClose < 0.60 then Color.RED else Color.GRAY);
AddLabel(yes, " SMA: " + Round(pcSMA, 2), if value > 1.0 then Color.RED else if value > 0.8 then Color.GRAY else Color.GREEN);
 
Solution
Thanks SleepyZ! No, the issue I was running into was that the P/C ratio label was only being displayed while on the Daily time frame and when I would switch over to any other time frame info on the label would disappear. Any idea how I could fix this? Thanks again!
 
Thanks SleepyZ! No, the issue I was running into was that the P/C ratio label was only being displayed while on the Daily time frame and when I would switch over to any other time frame info on the label would disappear. Any idea how I could fix this? Thanks again!

This should fix that issue.

Whenever that happens, try the fix to the def pcClose close(symbol = "$PCALL") as shown in the code below
1) By having any missing periods in def pcClose, shown as isnan(close(symbol = "$PCALL")) ,
filled by referencing those to the prior value of pcClose, shown as pcClose[1]
2) otherwise pcClose will use the actual value of close(symbol = "$PCALL").

Ruby:
def pcClose = if isnan(close(symbol = "$PCALL"))
              then pcClose[1]
              else close(symbol = "$PCALL");
plot pcSMA  = Average(pcClose, 10);
def value   = pcClose / pcSMA;

AddLabel(yes, "P/C: " + Round(pcClose), if pcClose > 1 then Color.GREEN else if pcClose < 0.60 then Color.RED else Color.GRAY);
AddLabel(yes, " SMA: " + Round(pcSMA, 2), if value > 1.0 then Color.RED else if value > 0.8 then Color.GRAY else Color.GREEN);
 

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