PGO Indicator for ThinkorSwim

diazlaz

Well-known member
2019 Donor
VIP
Hi Everyone,

I took a pass at the port of this indicator, looks interesting. the source behaves slightly different from the TC2000 and Trade view. I attempted to reconcile the code base in this thinkscript port.

I also enhanced it with an optional visual of the Ergodic Indicator that can help further spot and validate the wave in the trend.

Please review and backtest and let us know if you all find a good pattern or trading strategy leveraging this indicator or pairing it up with others.

PGO Indicator (colorPGO = yes, colorErgodic = no)

IS2Ql5W.png


PGO Indicator + Ergodic (colorPGO = yes, colorErgodic = yes)

qI9IvLR.png


Ergodic (colorPGO = no, colorErgodic = yes)

7bOMGlg.png


Ruby:
#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.GREEN else
    if colorPGO and isPurpleDot then COLOR.MAGENTA else
    if colorPGO and isOrangeDot then COLOR.ORANGE else
    if colorPGO and isGreenDot then COLOR.DARK_GREEN else

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

#End OF PGO Indicator
 
Last edited:

redaresg

New member
Hi Everyone,

I took a pass at the port of this indicator, looks interesting. the source behaves slightly different from the TC2000 and Trade view. I attempted to reconcile the code base in this thinkscript port.

I also enhanced it with an optional visual of the Ergodic Indicator that can help further spot and validate the wave in the trend.

Please review and backtest and let us know if you all find a good pattern or trading strategy leveraging this indicator or pairing it up with others.

PGO Indicator (colorPGO = yes, colorErgodic = no)

IS2Ql5W.png


PGO Indicator + Ergodic (colorPGO = yes, colorErgodic = yes)

qI9IvLR.png


Ergodic (colorPGO = no, colorErgodic = yes)

7bOMGlg.png


Ruby:
#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.GREEN else
    if colorPGO and isPurpleDot then COLOR.MAGENTA else
    if colorPGO and isOrangeDot then COLOR.ORANGE else
    if colorPGO and isGreenDot then COLOR.DARK_GREEN else

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

#End OF PGO Indicator
Good job!
How can I use this study in a scanner?
I know how to add it as a filter but cannot figure out how to set the condition, I guess it should be the color change?
 
Last edited:

hellocucen

New member
VIP
Thanks @diazlaz for your great help in posting some good indicators. I am fairly new to the thinkscript and looking to learn understanding the scripts. I tried pulling up this indicator on TOS but fail to understand when should be the entry for calls or puts. Can someone shed some light on how to use this indicator for trading.. Thanks in advance.
 

Trader Raider

Well-known member
VIP
Have been playing around with this but am having some trouble understanding what causes a candle to plot dark blue or yellow. My (limited!) understanding of the code was that I should be looking for dark green entry candles but they seem to be plotting blue, at least for longs. Nothing is plotting dark green except shorts. What am I missing in the code to explain blue and yellow candles?
 

hellocucen

New member
VIP
Hi @diazlaz can you help us understand more on this. We are assuming or deriving lot due to lack of info. It would be great if you could share more info on this. Thanks in advance
 

Trader Raider

Well-known member
VIP
@hellocucen, are you still playing around with this? I've had success with what I believe is the orange dot portion of the indicator. My win rate with it on stocks is 100% (4 of 4 trades) and 87% on futures (6 of 7 trades) trading off a daily chart. That's not a lot of trades but the results make it worth watching. I'm still trying to get it to plot as dots but can't figure out my coding error. If you haven't seen it, here's a more recent video than the one posted above. Happy trading!

 
Last edited:

Moose

Member
@hellocucen, are you still playing around with this? I've had success with what I believe is the orange dot portion of the indicator. My win rate with it on stocks is 100% (4 of 4 trades) and 87% on futures (6 of 7 trades) trading off a daily chart. That's not a lot of trades but the results make it worth watching. I'm still trying to get it to plot as dots but can't figure out my coding error. If you haven't seen it, here's a more recent video than the one posted above. Happy trading!

Can you share the code for the orange dot? Thank you.
 

FOTM_8888

Active member
good job, thanks for share with us.. do you have the indicator with the dot? will be nice. thank you once again
 

ext99k

Member
Backtesting this, it doesn't look too good on several time frames... no where close to 70% trade efficiency as he mentions in his YouTube video
 
Last edited:
Hey guys, I have been trying to modify this indicator to show Dots only and not paint the price. I am stuck on the Ergodic section at very bottom of code. Line 72 through 74. Here is the mod I have so far, can anyone help me get the final piece to work?
Thank you in advance
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;

plot gDotLB = if green then D else Double.NaN;
gDotLB.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
gDotLB.SetLineWeight(2);
gDotLB.SetDefaultColor(Color.MAGENTA);

plot gDotLB = if green then D else Double.NaN;
gDotLB.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
gDotLB.SetLineWeight(2);
gDotLB.SetDefaultColor(color.Orang);

plot gDotLB = if green then D else Double.NaN;
gDotLB.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
gDotLB.SetLineWeight(2);
gDotLB.SetDefaultColor(Color.DARK_GREEN);

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

#End OF PGO Indicator
 

RickAns

Active member
Is this what you are looking to do, @Break Trader ? If so then you were close. You had an un-referenced variable D in your plot statements unless you want to include the part of my code for the 5 day low placement. Wasn't sure so I just made it candle low for this case. Each plot needs it's own name as well as in the line descriptions, plus Points instead of Horizontal. Keep chugging at coding, I'm learning by trial and error. :)

Code:
# Break Trader add in

plot Pdot = if isPurpleDot then low else Double.NaN;
Pdot.SetPaintingStrategy(PaintingStrategy.Points);
Pdot.SetLineWeight(2);
Pdot.SetDefaultColor(Color.MAGENTA);

plot Odot = if isOrangeDot then low else Double.NaN;
Odot.SetPaintingStrategy(PaintingStrategy.Points);
Odot.SetLineWeight(2);
Odot.SetDefaultColor(color.Orange);

plot Gdot = if isGreenDot then low else Double.NaN;
Gdot.SetPaintingStrategy(PaintingStrategy.Points);
Gdot.SetLineWeight(2);
Gdot.SetDefaultColor(Color.DARK_GREEN);

plot ErgoUp = if colorErgodic and ErgodiIndicator >= 0 then low else Double.NaN;
ErgoUp.SetPaintingStrategy(PaintingStrategy.Points);
ErgoUp.SetLineWeight(2);
ErgoUp.SetDefaultColor(Color.Uptick);

plot ErgoDn = if colorErgodic and ErgodiIndicator <= 0 then low else Double.NaN;
ErgoDn.SetPaintingStrategy(PaintingStrategy.Points);
ErgoDn.SetLineWeight(2);
ErgoDn.SetDefaultColor(Color.Downtick);

edit: corrected <= error
 
Last edited:
Is this what you are looking to do, @Break Trader ? If so then you were close. You had an un-referenced variable D in your plot statements unless you want to include the part of my code for the 5 day low placement. Wasn't sure so I just made it candle low for this case. Each plot needs it's own name as well as in the line descriptions, plus Points instead of Horizontal. Keep chugging at coding, I'm learning by trial and error. :)

Code:
# Break Trader add in

plot Pdot = if isPurpleDot then low else Double.NaN;
Pdot.SetPaintingStrategy(PaintingStrategy.Points);
Pdot.SetLineWeight(2);
Pdot.SetDefaultColor(Color.MAGENTA);

plot Odot = if isOrangeDot then low else Double.NaN;
Odot.SetPaintingStrategy(PaintingStrategy.Points);
Odot.SetLineWeight(2);
Odot.SetDefaultColor(color.Orange);

plot Gdot = if isGreenDot then low else Double.NaN;
Gdot.SetPaintingStrategy(PaintingStrategy.Points);
Gdot.SetLineWeight(2);
Gdot.SetDefaultColor(Color.DARK_GREEN);

plot ErgoUp = if colorErgodic and ErgodiIndicator >= 0 then low else Double.NaN;
ErgoUp.SetPaintingStrategy(PaintingStrategy.Points);
ErgoUp.SetLineWeight(2);
ErgoUp.SetDefaultColor(Color.Uptick);

plot ErgoDn = if colorErgodic and ErgodiIndicator >= 0 then low else Double.NaN;
ErgoDn.SetPaintingStrategy(PaintingStrategy.Points);
ErgoDn.SetLineWeight(2);
ErgoDn.SetDefaultColor(Color.Downtick);
@RickAns Dam, that seems to work perfectly, ill test it during the week as the PGO has been discovered by me over the weekend, I just couldn't stand the painted price, yes i was trying to put in the 5 day low like on your Geren dot indicator as i know that indicator has been working pretty well even though the market is not playing nice and im not really buying much but looking at the history we can see its pretty accurate
Thank you for your help im sure other will appreciate it also, no disrespect to @diazlaz without you we wouldnt be here and your PGO indicator seems to work fine, just a preference on visuals for me.
Thank you to all in this community
 

Paldil1323

New member
@hellocucen, are you still playing around with this? I've had success with what I believe is the orange dot portion of the indicator. My win rate with it on stocks is 100% (4 of 4 trades) and 87% on futures (6 of 7 trades) trading off a daily chart. That's not a lot of trades but the results make it worth watching. I'm still trying to get it to plot as dots but can't figure out my coding error. If you haven't seen it, here's a more recent video than the one posted above. Happy trading!

Hello! Do you mind if you can share link or your orange dot indicator thank you
 

henry1224

Active member
VIP
plot ErgoUp = if colorErgodic and ErgodiIndicator >= 0 then low else Double.NaN;


plot ErgoDn = if colorErgodic and ErgodiIndicator <= 0 then low else Double.NaN;

If both ERGOUP & ERGODn = 0 then what happens?

You can't have it both ways
 

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.
Top