Quarterly EPS Shown as a Line Graph in thinkscript

One aspect I really appreciate of charting apps that offer custom coding capabilities is that you can present information visually that typically is not shown in that manner. For example with a few lines of thinkscript code you can plot a line graph of quarterly EPS in thinkorswim.

What follows is a screenshot of the line graph I wrote in less than 30 lines of code. The red and green dots represent the quarterly earnings, indicating if the current results were up/down from the previous report. I also appended at the bottom of the image the optional EPS bubble.

Installing the EPS Line Graph

If you have thinkorswim installed, click here to install the EPS line graph from the thinkorswim Sharing Center.

You can also copy/paste the link into thinkorswim’s Open Shared Item feature, the link is: https://tos.mx/gzJMkvw.

EPS Line Graph thinkscript Code

Here’s the code to create the line graph as well as show the optional chart bubble.

# 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 = e;
earningsLine.SetDefaultColor(CreateColor(90, 122, 176));
# Given earnings are not relevant for each bar, approximate line from bar to bar

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

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


  1. Nice. Thanks John. Should be on MarketSmith too (it’s on WONDA).

  2. Great Study, Thanks John.
    Is it possible to add future estimates on a box to the side of the plot?, not sure if the raw data is actually available on TOS.

  3. John

    This is great really helpful.

    I have two requests for you:

    Is it possible to do the comparison to the same quarter the previous year rather then the previous quarter?
    Could the bubble display percentage growth vs same quarter previous year as well as the EPS?

    Thank You

    • John

      September 13, 2020 at 8:16 pm

      Thanks Esteban, the results show quarterly earnings per share compared to earnings in the same quarter of the previous year. Same with the chart bubble.

      • Thanks john
        Is there any way to show percentage growth vs previous quarter?

        • John

          September 17, 2020 at 7:06 pm

          Esteban, you might be able make this work by keeping track of the EPS of the current quarter and then when you find the next quarter, do the math to determine the % change. You could add the information into the chart bubble.

      • I could be wrong, but to me color of earning green or red is based on previous quarter vs same quarter previous year. correct me if I am wrong. I am very thankful of you doing good work here. I copied webbi’s RSI. i will copy earning graph too. Thank you again.

        • John

          September 19, 2020 at 5:37 pm

          Rakesh, the results show quarterly earnings per share compared to earnings in the same quarter of the previous year. Same with the chart bubble. Check out this tweet that shows the results are the same in MarketSmith as they are with the TOS script (for MSFT): Quarterly Earnings Tweet

  4. Looks great – thank you!

  5. Totally going to use this!!!! Nice work!!!