Quarterly EPS shown as a Line Graph

danpadcas

New member
Hi all.

I've been looking for a nice way of plotting %EPS increasing/decreasing qtr over qtr on ToS but I did not find anything appealing. I've come across this website and I reckon this is the most accurate indicator I found.

https://playthetrade.com/tradingview/technical-indicators/quarterly-eps-shown-as-a-line-graph/

52FI4Z7.png


What's on the screenshot is a line of graph that follows the EPS results qtr over qtr. The red and green dots represent whether the results were up or down from the previous report. What I'd like to know is if there is a way to calculate the % difference between EPS so we can see at a glance how much has increase or decrease in %.

I follow CANSLIM criteria so that's why I'm requesting it

For those interested in this indicator here is the link;

https://tos.mx/gzJMkvw

And here the Thinkscript Code;

Code:
# EPS line graph
#
# Written by:  @JohnMuchow http://twitter.com/JohnMuchow
# Website:     PlayTheTrade.com
#
# v1.0

declare lower;

input showEPSBubble = yes;

def e = GetActualEarnings();
def earnings = CompoundValue(1, if IsNaN(e) then earnings[1] else e, e);

# Plot the earnings as a line
plot earningsLine = GetActualEarnings();

# Given earnings are not relevant for each bar, approximate line from bar to bar
earningsLine.EnableApproximation();

# Change as you like
earningsLine.SetPaintingStrategy(PaintingStrategy.POINTS);
earningsLine.SetDefaultColor(CreateColor(90, 122, 176));
earningsLine.hideTitle();

# Plot green/red dot indicating earnings up/down
plot earningsUpDownIndicator = GetActualEarnings();
earningsUpDownIndicator.SetPaintingStrategy(PaintingStrategy.SQUARES);
earningsUpDownIndicator.AssignValueColor(if earnings > earnings[1] then (CreateColor(120, 184, 86)) else CreateColor(164, 36, 22));
earningsUpDownIndicator.SetLineWeight(4);
earningsUpDownIndicator.hideTitle();

# Optional EPS bubble
AddChartBubble(showEPSBubble, earningsUpDownIndicator, earnings, Color.GRAY);
 

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

Hi folks!
As a start, this is a good earnings line. I pushed it up to the main chart and it could use your help.
Can this be programed to show % change on the left side and keep it equal between charts so that a 20% increase in earnings will look the same from chart to chart, even though the price scale varies widely?
Thank you. I hope all is well with the team!
 
Here is a improved version read notes for my add-ons. Enjoy

thinkorswim_KOsRDqyGu7.png

Code:
#====================================================================================================================
# EPS LINE GRAPH
#--------------------------------------------------------------------------------------------------------------------
# Original concept by: @JohnMuchow
# Refined / expanded version
# By: Richard Campbell / AKA Tricky Rick
#
# WHAT THIS STUDY DOES
# - Plots actual EPS reports in a lower study
# - Marks each EPS event with a color-coded square
# - Optionally adds arrows, bubbles, or both
# - Optionally colors main-chart price bars on EPS events
# - Displays current EPS, prior EPS, dollar delta, and percent delta in labels
#
# COLOR LOGIC
# - Green = current EPS improved vs prior EPS
# - Red   = current EPS declined vs prior EPS
# - Gray  = flat or no valid prior comparison
#====================================================================================================================

declare lower;

#====================================================================================================================
# INPUTS
#====================================================================================================================
input epsDisplay = {Arrows, Bubbles, default "Arrows & Bubbles"};
input showZeroLine = yes;
input showEPSLabel = yes;
input bubbleOffset = 0.10;
input arrowOffset = 0.10;
input colorEpsOnPriceBars = no;

#====================================================================================================================
# GLOBAL COLORS
#====================================================================================================================
# Lower-study colors
DefineGlobalColor("EPSLine",  CreateColor(90, 122, 176));
DefineGlobalColor("EPSUp",    CreateColor(50, 205, 50));
DefineGlobalColor("EPSDown",  CreateColor(220, 20, 60));
DefineGlobalColor("EPSFlat",  Color.GRAY);
DefineGlobalColor("ZeroLine", CreateColor(80, 80, 80));

# Main-chart candle reference colors
DefineGlobalColor("EPSPriceUp",   Color.CYAN);
DefineGlobalColor("EPSPriceDown", Color.MAGENTA);
DefineGlobalColor("EPSPriceFlat", Color.GRAY);

# Label spacer color
DefineGlobalColor("LabelSpacer", Color.BLACK);

#====================================================================================================================
# CORE EPS DATA
#====================================================================================================================
# Actual EPS only exists on earnings-event bars
def e = GetActualEarnings();
def hasEvent = !IsNaN(e);

# Carry forward the most recent EPS report between event bars
def earnings = CompoundValue(1, if IsNaN(e) then earnings[1] else e, e);

# Previous reported EPS value
def prevEPS = CompoundValue(1,
    if hasEvent then earnings[1] else prevEPS[1],
    Double.NaN
);

# Current event state relative to previous EPS report
def isUp   = hasEvent and !IsNaN(prevEPS) and e > prevEPS;
def isDown = hasEvent and !IsNaN(prevEPS) and e < prevEPS;

# Held trend state used for persistent label coloring between reports
#  1 = improved, -1 = declined, 0 = flat / no valid comparison
def trendState = CompoundValue(1,
    if hasEvent then
        if IsNaN(prevEPS) then 0
        else if e > prevEPS then 1
        else if e < prevEPS then -1
        else 0
    else trendState[1],
    0
);

# EPS dollar change from previous report
def epsDelta =
    if !IsNaN(prevEPS) and !IsNaN(earnings)
    then earnings - prevEPS
    else Double.NaN;

# EPS percent change from previous report
# Uses AbsValue(prevEPS) so percent math remains readable when prior EPS was negative
def epsPctDelta =
    if !IsNaN(prevEPS) and prevEPS != 0 and !IsNaN(earnings)
    then ((earnings - prevEPS) / AbsValue(prevEPS)) * 100
    else Double.NaN;

#====================================================================================================================
# MAIN CHART PRICE-BAR REFERENCE
#====================================================================================================================
# Optional candle-color reference on the main chart for EPS event bars only
#   Cyan    = EPS improved
#   Magenta = EPS declined
#   Gray    = EPS flat / no valid comparison
AssignPriceColor(
    if colorEpsOnPriceBars and hasEvent then
        if isUp then GlobalColor("EPSPriceUp")
        else if isDown then GlobalColor("EPSPriceDown")
        else GlobalColor("EPSPriceFlat")
    else Color.CURRENT
);

#====================================================================================================================
# EPS EVENT SQUARE
#====================================================================================================================
# Primary EPS event marker
# Left title-visible so hover/readout can reference the EPS event value directly
plot EPS = if hasEvent then e else Double.NaN;
EPS.SetPaintingStrategy(PaintingStrategy.SQUARES);
EPS.SetLineWeight(4);
EPS.AssignValueColor(
    if isUp then GlobalColor("EPSUp")
    else if isDown then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat")
);
EPS.HideBubble();

#====================================================================================================================
# OPTIONAL ARROWS
#====================================================================================================================
# Arrow mode:
#   - Up arrow above EPS square when EPS improved
#   - Down arrow below EPS square when EPS declined
#
# Arrows & Bubbles mode:
#   - Same arrow placement as Arrow mode
plot EPSUpArrow =
    if (epsDisplay == epsDisplay.Arrows or epsDisplay == epsDisplay."Arrows & Bubbles") and isUp
    then e + arrowOffset
    else Double.NaN;
EPSUpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
EPSUpArrow.SetLineWeight(3);
EPSUpArrow.AssignValueColor(GlobalColor("EPSUp"));
EPSUpArrow.HideBubble();
EPSUpArrow.HideTitle();

plot EPSDownArrow =
    if (epsDisplay == epsDisplay.Arrows or epsDisplay == epsDisplay."Arrows & Bubbles") and isDown
    then e - arrowOffset
    else Double.NaN;
EPSDownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
EPSDownArrow.SetLineWeight(3);
EPSDownArrow.AssignValueColor(GlobalColor("EPSDown"));
EPSDownArrow.HideBubble();
EPSDownArrow.HideTitle();

#====================================================================================================================
# OPTIONAL BUBBLES
#====================================================================================================================
# Bubble mode:
#   - Red/down bubbles are forced below
#   - Green/gray bubbles are placed above
AddChartBubble(
    epsDisplay == epsDisplay.Bubbles and hasEvent,
    if isDown then e - bubbleOffset
    else e + bubbleOffset,
    (if e < 0 then "-$" else "$") + AsText(Round(AbsValue(e), 2)),
    if isUp then GlobalColor("EPSUp")
    else if isDown then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat"),
    if isDown then no else yes
);

# Arrows & Bubbles mode:
#   - Bubble is placed opposite the standard arrow side
#   - EPS up   -> arrow above, bubble below
#   - EPS down -> arrow below, bubble above
#   - EPS flat -> bubble above
AddChartBubble(
    epsDisplay == epsDisplay."Arrows & Bubbles" and hasEvent,
    if isUp then e - bubbleOffset
    else if isDown then e + bubbleOffset
    else e + bubbleOffset,
    (if e < 0 then "-$" else "$") + AsText(Round(AbsValue(e), 2)),
    if isUp then GlobalColor("EPSUp")
    else if isDown then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat"),
    if isUp then no else yes
);

#====================================================================================================================
# EPS LINE
#====================================================================================================================
# Original EPS plot using actual reported EPS values
# Approximation visually connects earnings-event points from report to report
# Title is hidden so hover/readout favors the EPS square plot
plot EPSLine = GetActualEarnings();
EPSLine.EnableApproximation();
EPSLine.SetPaintingStrategy(PaintingStrategy.POINTS);
EPSLine.SetDefaultColor(GlobalColor("EPSLine"));
EPSLine.SetLineWeight(2);
EPSLine.HideBubble();
EPSLine.HideTitle();

#====================================================================================================================
# ZERO LINE
#====================================================================================================================
# Optional zero reference to separate positive vs negative EPS
plot ZeroLine = if showZeroLine then 0 else Double.NaN;
ZeroLine.SetDefaultColor(GlobalColor("ZeroLine"));
ZeroLine.SetLineWeight(1);
ZeroLine.HideBubble();
ZeroLine.HideTitle();

#====================================================================================================================
# LABELS
#====================================================================================================================
# Title
AddLabel(showEPSLabel, "   EPS Line Graph    ", Color.LIGHT_GREEN);

# Spacer
AddLabel(showEPSLabel, " ", GlobalColor("LabelSpacer"));

# Primary state label:
#   - Current EPS
#   - Previous EPS
#   - Colored by current EPS state
AddLabel(showEPSLabel and !IsNaN(earnings),
    "   EPS:  $" + AsText(Round(earnings, 2)) +
    (if !IsNaN(prevEPS)
     then "    Prev:  $" + AsText(Round(prevEPS, 2)) + "   "
     else ""),
    if trendState == 1 then GlobalColor("EPSUp")
    else if trendState == -1 then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat")
);

# Secondary stats label:
#   - Dollar delta
#   - Percent delta
#   - Neutral light-gray presentation
AddLabel(showEPSLabel and !IsNaN(earnings),
    (if !IsNaN(prevEPS)
     then "   Δ:  " + (if epsDelta < 0 then "-$" else "$") + AsText(Round(AbsValue(epsDelta), 2)) +
          "   or   " +
          (if !IsNaN(epsPctDelta)
           then AsText(Round(epsPctDelta, 1)) + " %   "
           else "N/A")
     else ""),
    Color.LIGHT_GRAY
);

# Spacer before optional candle-reference label
AddLabel(showEPSLabel and colorEpsOnPriceBars, " ", GlobalColor("LabelSpacer"));

# Confirms EPS event price-bar coloring is active on the main chart
AddLabel(showEPSLabel and colorEpsOnPriceBars, "  EPS Candle Reference is Active  ", Color.CYAN);
 
Here is another update ........ read notes for my additional add-ons. Please keep in mind all TOS earnings shown on chart are Non GAAP which is where earnings where extracted for this study. Enjoy
thinkorswim_pBVw1B7DyT.png

Code:
#====================================================================================================================
# EPS LINE GRAPH
#--------------------------------------------------------------------------------------------------------------------
# Original concept by: @JohnMuchow
# Refined / expanded version
# By: Richard Campbell / AKA Tricky Rick
#
# WHAT THIS STUDY DOES
# - Plots actual reported EPS history in a lower study
# - Marks each actual EPS report with a color-coded square
# - Optionally adds no marker, arrows, bubbles, or arrows & bubbles for actual EPS events
# - Plots estimated EPS history and connects estimate points with a dashed line
# - Optionally colors main-chart price bars on actual EPS event bars
# - Displays current actual EPS, prior actual EPS, dollar delta, and percent delta in labels
# - Displays EPS Beat / Missed / Flat using actual EPS vs the estimate tied to that report snapshot
# - Displays current estimated EPS, previous estimated EPS, dollar delta, and percent delta in labels
# - Marks stock split / reverse split events with vertical lines
#
# COLOR LOGIC
# - Actual EPS Green = current actual EPS improved vs prior actual EPS
# - Actual EPS Red   = current actual EPS declined vs prior actual EPS
# - Actual EPS Gray  = flat or no valid prior comparison
# - Estimated EPS Green = current estimate is above current actual EPS reference
# - Estimated EPS Red   = current estimate is below current actual EPS reference
# - Estimated EPS Gray  = flat or no valid comparison
# - EPS Beat label Green  = actual EPS came in above estimate
# - EPS Missed label Red  = actual EPS came in below estimate
# - EPS Flat label Gray   = actual EPS matched estimate
#====================================================================================================================

declare lower;

#====================================================================================================================
# INPUTS
#====================================================================================================================
input epsDisplay = {None, Arrows, Bubbles, default "Arrows & Bubbles"};
input showEstEPS = yes;
input colorEpsOnPriceBars = no;
input showZeroLine = yes;
input showEPSLabel = yes;
input bubbleOffset = 0.10;
input arrowOffset = 0.10;

#====================================================================================================================
# GLOBAL COLORS
#====================================================================================================================
DefineGlobalColor("EPSLine",  CreateColor(0,127,191));
DefineGlobalColor("EPSUp",    CreateColor(50, 205, 50));
DefineGlobalColor("EPSDown",  CreateColor(220, 20, 60));
DefineGlobalColor("EPSFlat",  Color.GRAY);
DefineGlobalColor("ZeroLine", CreateColor(134,1,17));

DefineGlobalColor("EPSPriceUp",   Color.CYAN);
DefineGlobalColor("EPSPriceDown", Color.MAGENTA);
DefineGlobalColor("EPSPriceFlat", Color.GRAY);

DefineGlobalColor("LabelSpacer", Color.BLACK);

#====================================================================================================================
# CORE EPS DATA
#====================================================================================================================
def e = GetActualEarnings();
def hasEvent = !IsNaN(e);

def earnings = CompoundValue(1, if IsNaN(e) then earnings[1] else e, e);

def prevEPS = CompoundValue(1,
    if hasEvent then earnings[1] else prevEPS[1],
    Double.NaN
);

def isUp   = hasEvent and !IsNaN(prevEPS) and e > prevEPS;
def isDown = hasEvent and !IsNaN(prevEPS) and e < prevEPS;

def trendState = CompoundValue(1,
    if hasEvent then
        if IsNaN(prevEPS) then 0
        else if e > prevEPS then 1
        else if e < prevEPS then -1
        else 0
    else trendState[1],
    0
);

def epsDelta =
    if !IsNaN(prevEPS) and !IsNaN(earnings)
    then earnings - prevEPS
    else Double.NaN;

def epsPctDelta =
    if !IsNaN(prevEPS) and prevEPS != 0 and !IsNaN(earnings)
    then ((earnings - prevEPS) / AbsValue(prevEPS)) * 100
    else Double.NaN;

#====================================================================================================================
# ESTIMATED EPS DATA
#====================================================================================================================
def est = GetEstimatedEarnings();

def estEarnings = CompoundValue(1, if IsNaN(est) then estEarnings[1] else est, est);

def prevEstEPS = CompoundValue(1,
    if !IsNaN(est) then estEarnings[1] else prevEstEPS[1],
    Double.NaN
);

def estDeltaPrev =
    if !IsNaN(estEarnings) and !IsNaN(prevEstEPS)
    then estEarnings - prevEstEPS
    else Double.NaN;

def estPctDeltaPrev =
    if !IsNaN(estEarnings) and !IsNaN(prevEstEPS) and prevEstEPS != 0
    then ((estEarnings - prevEstEPS) / AbsValue(prevEstEPS)) * 100
    else Double.NaN;

#====================================================================================================================
# EARNINGs SURPISE EPS DATA
#====================================================================================================================

# EPS surprise vs carried estimate snapshot at the actual earnings report bar
def epsSurpriseDeltaRaw =
    if hasEvent and !IsNaN(estEarnings)
    then e - estEarnings
    else Double.NaN;

def epsSurprisePctRaw =
    if hasEvent and !IsNaN(estEarnings) and estEarnings != 0
    then ((e - estEarnings) / AbsValue(estEarnings)) * 100
    else Double.NaN;

def epsSurpriseDelta = CompoundValue(1,
    if hasEvent and !IsNaN(estEarnings)
    then epsSurpriseDeltaRaw
    else epsSurpriseDelta[1],
    Double.NaN
);

def epsSurprisePct = CompoundValue(1,
    if hasEvent and !IsNaN(estEarnings) and estEarnings != 0
    then epsSurprisePctRaw
    else epsSurprisePct[1],
    Double.NaN
);

def epsSurpriseState = CompoundValue(1,
    if hasEvent and !IsNaN(estEarnings) then
        if epsSurpriseDeltaRaw > 0 then 1
        else if epsSurpriseDeltaRaw < 0 then -1
        else 0
    else epsSurpriseState[1],
    0
);

#====================================================================================================================
# DISPLAY-MODE HELPERS
#====================================================================================================================
def showEPSArrows =
    epsDisplay == epsDisplay.Arrows
    or epsDisplay == epsDisplay."Arrows & Bubbles";

def showEPSArrowAndBubble =
    epsDisplay == epsDisplay."Arrows & Bubbles";

#====================================================================================================================
# MAIN CHART PRICE-BAR REFERENCE
#====================================================================================================================
AssignPriceColor(
    if colorEpsOnPriceBars and hasEvent then
        if isUp then GlobalColor("EPSPriceUp")
        else if isDown then GlobalColor("EPSPriceDown")
        else GlobalColor("EPSPriceFlat")
    else Color.CURRENT
);

#====================================================================================================================
# EPS EVENT SQUARE
#====================================================================================================================
plot EPS = if hasEvent then e else Double.NaN;
EPS.SetPaintingStrategy(PaintingStrategy.SQUARES);
EPS.SetLineWeight(5);
EPS.AssignValueColor(
    if isUp then GlobalColor("EPSUp")
    else if isDown then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat")
);
EPS.HideBubble();

#====================================================================================================================
# OPTIONAL ARROWS
#====================================================================================================================
plot EPSUpArrow =
    if showEPSArrows and isUp
    then e + arrowOffset
    else Double.NaN;
EPSUpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
EPSUpArrow.SetLineWeight(3);
EPSUpArrow.AssignValueColor(GlobalColor("EPSUp"));
EPSUpArrow.HideBubble();
EPSUpArrow.HideTitle();

plot EPSDownArrow =
    if showEPSArrows and isDown
    then e - arrowOffset
    else Double.NaN;
EPSDownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
EPSDownArrow.SetLineWeight(3);
EPSDownArrow.AssignValueColor(GlobalColor("EPSDown"));
EPSDownArrow.HideBubble();
EPSDownArrow.HideTitle();

#====================================================================================================================
# OPTIONAL BUBBLES
#====================================================================================================================
AddChartBubble(
    epsDisplay == epsDisplay.Bubbles and hasEvent,
    if isDown then e - bubbleOffset else e + bubbleOffset,
    (if e < 0 then "-$" else "$") + AsText(Round(AbsValue(e), 2)),
    if isUp then GlobalColor("EPSUp")
    else if isDown then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat"),
    if isDown then no else yes
);

AddChartBubble(
    showEPSArrowAndBubble and hasEvent,
    if isUp then e - bubbleOffset else e + bubbleOffset,
    (if e < 0 then "-$" else "$") + AsText(Round(AbsValue(e), 2)),
    if isUp then GlobalColor("EPSUp")
    else if isDown then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat"),
    if isUp then no else yes
);

#====================================================================================================================
# EPS LINE
#====================================================================================================================
plot EPSLine = e;
EPSLine.EnableApproximation();
EPSLine.SetPaintingStrategy(PaintingStrategy.POINTS);
EPSLine.SetDefaultColor(GlobalColor("EPSLine"));
EPSLine.SetLineWeight(2);
EPSLine.HideBubble();
EPSLine.HideTitle();

#====================================================================================================================
# ZERO LINE
#====================================================================================================================
plot ZeroLine = if showZeroLine then 0 else Double.NaN;
ZeroLine.SetDefaultColor(GlobalColor("ZeroLine"));
ZeroLine.SetLineWeight(1);
ZeroLine.SetStyle(Curve.MEDIUM_DASH);
ZeroLine.HideBubble();
ZeroLine.HideTitle();

#====================================================================================================================
# ESTIMATED EPS
#====================================================================================================================
plot EstimatedEPS =
    if showEstEPS then est
    else Double.NaN;
EstimatedEPS.SetPaintingStrategy(PaintingStrategy.POINTS);
EstimatedEPS.SetLineWeight(3);
EstimatedEPS.AssignValueColor(
    if !IsNaN(earnings) and !IsNaN(est) then
        if est > earnings then GlobalColor("EPSUp")
        else if est < earnings then GlobalColor("EPSDown")
        else GlobalColor("EPSFlat")
    else GlobalColor("EPSFlat")
);
EstimatedEPS.HideBubble();

plot EstimatedEPSLine =
    if showEstEPS then est
    else Double.NaN;
EstimatedEPSLine.SetStyle(Curve.SHORT_DASH);
EstimatedEPSLine.EnableApproximation();
EstimatedEPSLine.SetLineWeight(1);
EstimatedEPSLine.SetDefaultColor(Color.GRAY);
EstimatedEPSLine.HideBubble();
EstimatedEPSLine.HideTitle();

#====================================================================================================================
# SPLIT EVENT VERTICAL LINES
#====================================================================================================================
def splitNum = GetSplitNumerator();
def splitDen = GetSplitDenominator();
def hasSplit = !IsNaN(splitDen);

def isRegularSplit = hasSplit and splitNum > splitDen;
def isReverseSplit = hasSplit and splitNum < splitDen;

AddVerticalLine(
    hasSplit,
    if isRegularSplit then "Split " + AsText(splitNum, "%1$.0f") + ":" + AsText(splitDen, "%1$.0f")
    else if isReverseSplit then "Reverse " + AsText(splitNum, "%1$.0f") + ":" + AsText(splitDen, "%1$.0f")
    else "Split " + AsText(splitNum, "%1$.0f") + ":" + AsText(splitDen, "%1$.0f"),
    if isRegularSplit then GlobalColor("EPSUp")
    else if isReverseSplit then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat"),
    Curve.SHORT_DASH
);

#====================================================================================================================
# LABELS
#====================================================================================================================
AddLabel(showEPSLabel, "   EPS Line Graph    ", Color.LIGHT_GREEN);

AddLabel(showEPSLabel, " ", GlobalColor("LabelSpacer"));

AddLabel(showEPSLabel and !IsNaN(epsSurpriseDelta),
    "   EPS " +
    (if epsSurpriseState == 1 then "Beat: "
     else if epsSurpriseState == -1 then "Missed: "
     else "Flat: ") +
    (if epsSurpriseDelta < 0 then "-$" else "+$") + AsText(Round(AbsValue(epsSurpriseDelta), 2)) +
    "   |   " +
    (if !IsNaN(epsSurprisePct)
     then AsText(Round(epsSurprisePct, 1)) + " %   "
     else "N/A"),
    if epsSurpriseState == 1 then GlobalColor("EPSUp")
    else if epsSurpriseState == -1 then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat")
);

AddLabel(showEPSLabel, " ", GlobalColor("LabelSpacer"));

AddLabel(showEPSLabel and !IsNaN(earnings),
    "   EPS:  " + (if earnings < 0 then "-$" else "$") + AsText(Round(AbsValue(earnings), 2)) +
    (if !IsNaN(prevEPS)
     then "    Prev:  " + (if prevEPS < 0 then "-$" else "$") + AsText(Round(AbsValue(prevEPS), 2)) + "   "
     else ""),
    if trendState == 1 then GlobalColor("EPSUp")
    else if trendState == -1 then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat")
);

AddLabel(showEPSLabel and !IsNaN(earnings) and !IsNaN(prevEPS),
    "   Δ:  " + (if epsDelta < 0 then "-$" else "$") + AsText(Round(AbsValue(epsDelta), 2)) +
    "   or   " +
    (if !IsNaN(epsPctDelta)
     then AsText(Round(epsPctDelta, 1)) + " %   "
     else "N/A"),
    Color.LIGHT_GRAY
);

AddLabel(showEPSLabel and showEstEPS, " ", GlobalColor("LabelSpacer"));

AddLabel(showEPSLabel and showEstEPS and !IsNaN(estEarnings) and !IsNaN(earnings),
    "   Estimated EPS:  " + (if estEarnings < 0 then "-$" else "$") + AsText(Round(AbsValue(estEarnings), 2)) +
    (if !IsNaN(prevEstEPS)
     then "    Prev Est:  " + (if prevEstEPS < 0 then "-$" else "$") + AsText(Round(AbsValue(prevEstEPS), 2)) + "   "
     else ""),
    if estEarnings > earnings then GlobalColor("EPSUp")
    else if estEarnings < earnings then GlobalColor("EPSDown")
    else GlobalColor("EPSFlat")
);

AddLabel(showEPSLabel and showEstEPS and !IsNaN(estEarnings) and !IsNaN(prevEstEPS),
    "   Δ:  " + (if estDeltaPrev < 0 then "-$" else "$") + AsText(Round(AbsValue(estDeltaPrev), 2)) +
    "   or   " +
    (if !IsNaN(estPctDeltaPrev)
     then AsText(Round(estPctDeltaPrev, 1)) + " %   "
     else "N/A   "),
    Color.LIGHT_GRAY
);

AddLabel(showEPSLabel and colorEpsOnPriceBars, " ", GlobalColor("LabelSpacer"));

AddLabel(showEPSLabel and colorEpsOnPriceBars, "  EPS Candle Reference is Active  ", Color.CYAN);

def hasAnyEPSInLoadedBars = HighestAll(if hasEvent then 1 else 0) == 1;

AddLabel(showEPSLabel and !hasAnyEPSInLoadedBars,
    "   No EPS data found in loaded chart history   ",
    Color.YELLOW
);
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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