PGO Indicator for ThinkorSwim

Just checking after watching Richard's video again - is there a most recent script with the dots, not the colored price bars that someone can post here? Most grateful if you can. Thanks!
 

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

I didnt even notice that, I made the change, should be fine
Cant wait to see how this works in real time

I think that what was shared for painting dots earlier isn't the same because the PGO condition in the original indicator is met when all three dot conditions are met. I've updated the dot code to reflect this and made it so that PGO and ERGO dots can also be toggled on or off. Also, you can easily customize the position of the dots by finding the variable "Dots_Position" in the new section of the code, and making that whatever you want. I currently have it set as the middle of the candle, but you can change it to low or high for example.

I also changed the coloring, but notated this in the code. (*Explanation for the reasoning is at the bottom of this post.)

Also note that for the Ergodi dots, I made the downtrend color of these dots PINK instead of COLOR.DOWNTICK because most people will have down candles set to appear filled in. In such case the dots won't show up on down candles if they're the same color as the candle body.

EDIT: I realized that when no condition for a PGO or Ergodi plot was met, a GRAY dot would still appear. So I have updated the code to use "DefineGlobalColor("Blank")" for that instead of GRAY. It's kind of a dumb workaround, but it's the easiest fix. You just have to go into the study settings and change the color transparency for the Global Color "Blank" (under "Globals" section at the bottom) to 100% transparent. Then no dot will appear if no condition for a PGO or Ergodi plot is met.

Code:
#PGO Indicator
#Ported from TC2000 Code from Richard Moglen
#https://www.youtube.com/watch?v=_XNwgIQEhe4
#
#The PGO Indicator is a combination of my Purple and Orange Dot indicators and
#Dr. Wish's Green Dot Indicator.
#It represents a stock moving out of consolidation on volume.
#It provides an excellent entry point for swing and #momentum trades in growth stocks.
#
#
#Ported from TC2000 and Tradeview Source
# 2019.10.12 - diazlaz - Initial Port +
#                      - Integrated the Ergodic Indicator

declare upper;

input longLength = 25;
input shortLength = 13;
input signalLength = 8;
input averageType = AverageType.Exponential;

input period = 10;
input KPeriod = 4;
input colorPGO = yes;
input colorErgodic = no;


#Ergodic Indicator
def ErgodiIndicator = TrueStrengthIndex(longLength, shortLength, signalLength, averageType).TSI - TrueStrengthIndex(longLength, shortLength, signalLength, averageType).Signal;

# Green Dot Indicator
def lowest_k = Lowest(low, KPeriod);
def c1 = close - lowest_k;
def c2 = Highest(high, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;

def stoc = MovingAverage(AverageType.SIMPLE, FastK, period);
def isGreenDot = stoc[1] / average(stoc[1],4) < 1 and stoc[1] < 60 and stoc / average(stoc,4) > 1;

# Purple Dot Indicator
def isPurpleDot = ( (ExpAverage(close, 2) /  ExpAverage(close, 8) > 1) and
(ExpAverage(close, 3) /  ExpAverage(close, 5) < 1.5) and
(ExpAverage(close, 4) /  ExpAverage(close, 8) > .7) and
(ExpAverage(close, 5) /  ExpAverage(close, 30) > .95) ) and
close > close[1] and close > close[2] and close > close[3];

# Orange Dot Indicator
def MACD = MovingAverage(AverageType, close, 12) -
MovingAverage(AverageType, close, 26);

def isOrangeDot = (MACD - ExpAverage(MACD, 9)) > (MACD[1] - ExpAverage(MACD[1], 9)) > 0
and (volume > (0.90 * Average(volume,50)) > 0);

# PGO
def PGO = isGreenDot and isPurpleDot and isOrangeDot;

AssignPriceColor (
    if colorPGO and PGO then COLOR.LIME else #changed to LIME from GREEN for easier visibility
    if colorPGO and isPurpleDot then COLOR.MAGENTA else
    if colorPGO and isOrangeDot then COLOR.PLUM else #changed to PLUM from ORANGE for easier visibility
    if colorPGO and isGreenDot then Color.WHITE else #changed to COLOR.WHITE from DARK_GREEN

    if colorErgodic and ErgodiIndicator >= 0 then COLOR.UPTICK else
    if colorErgodic and ErgodiIndicator <= 0 then Color.DOWNTICK else
COLOR.Current);

# Option for dots as alternative to coloring price candle, and color of plots updated per reasoning in https://usethinkscript.com/threads/pgo-indicator-for-thinkorswim.812/post-103310

input PGO_Dots_On = yes;
input ERGO_Dots_On = yes;
def Dots_Position = ((low+high)/2); #you can change the position to anything you want here - e.g. "low", "high", or mid as "((low+high)/2))"

DefineGlobalColor("Blank", Color.White); #go into the study settings and under Globals, change this color to be 100% transparent

def PGOdotCond =
if !isNan(isPurpleDot) and PGO_Dots_On then Dots_Position else
if !isNan(isOrangeDot) and PGO_Dots_On then Dots_Position else
if !isNan(isGreenDot) and PGO_Dots_On then Dots_Position else
if  ERGO_Dots_On and ErgodiIndicator >= 0 then Dots_Position else
if  ERGO_Dots_On and ErgodiIndicator <= 0 then Dots_Position else
double.nan;

plot PGOdot = PGOdotCond;
PGOdot.SetPaintingStrategy(PaintingStrategy.Points);
PGOdot.SetLineWeight(1);
PGOdot.AssignValueColor(
if PGO_Dots_On and PGO then Color.LIME else #changed to LIME from GREEN for easier visibility
if PGO_Dots_On and isPurpleDot then Color.MAGENTA else
if PGO_Dots_On and isOrangeDot then Color.PLUM else #changed to PLUM from ORANGE for easier visibility
if PGO_Dots_On and isGreenDot then Color.DARK_GREEN else #changed to COLOR.WHITE from DARK_GREEN
if ERGO_Dots_On and ErgodiIndicator >= 0 then Color.Uptick else
if ERGO_Dots_On and ErgodiIndicator <= 0 then Color.Pink
else GlobalColor("Blank"));


#End OF PGO Indicator

*Reasoning for plot color changes:

I changed the "GREEN" color for PGO to LIME and changed the ORANGE condition for the Orange Dot to be PLUM (a better visual complement to the MAGENTA coloring for the Purple Dot condition). I also changed the DARK_GREEN color for the Green Dot that appears by itself to WHITE. Aside from finding this visually better, my reasoning for this change may not be correct, but is as follows:

The PGO condition should be painted LIME because it is the most bullish, but also therefore probably near exhaustion of the uptrend, and LIME is close to yellow as a bullish-shaded "warning" tone of color. (On the TSLA chart on 5/4/2022 for example, there was a PGO candle like this that was a huge bull trap.)

The second-most bullish color is MAGENTA, which makes it logical for the third-most bullish color to be PLUM (a weaker version of MAGENTA).

I changed DARK_GREEN as the least bullish PGO plot to WHITE because I noticed that this was often a potential pivot candle. If it appeared at the bottom of a violent dump then it was sometimes followed by a bounce but if it appeared at the end of a gradual price bleed or downward-sloped consolidation, it was usually following by a breakdown to a lower price level. So I find it more helpful to regard this plot as signaling a potential bounce after a steep drop (but not if it's the first candle in the drop), or a probable breakdown if it appears in a bearish looking stretch of consolidation.
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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