Follow up with Original Code - QQE painting strat Help

grapetux

Member
I had posted about getting some help creating a few functions in my qqe indicator


Heres the original code with all the details, apologies for not including originally! I'll be sure to do this moving forward

Need help with -
-Paint a cloud down to the zero line when the rsi_ma crosses 0
-Repaint the rsi_ma to red in an downtrend and green in an uptrend


# QQE Indicator
# Converted by Kory Gill for BenTen at useThinkScript.com
# Original https://www.tradingview.com/script/zwbe2plA-Ghosty-s-Zero-Line-QQE/
# Final Version of my QQE before my Leave for a few months 4/16/21 - Xiuying

# Whats been added-
# Points for crossings to let you know what to watch out for
# Labels for when it reaches O/S or O/B and colors change depending on level. Going from Less severity to most, It's Orange , Dark Orange, and Red. Red being the "Watch the **** out" Level.
# Oversold and Overbought levels were added and adjusted to my preferences.
# Added labels for instances where it crosses the 50
# Added Labels for 50 crosses and indicated to watch for Sup/Res

declare lower;

input RSI_Period = 20;
input Slow_Factor = 5;
input QQE = 4.236;




def Wilder_Period = RSI_Period * 2 - 1;
def vClose = close;

def rsi = RSI(price = vClose, length = RSI_Period).RSI;
def rsi_ma = MovingAverage(AverageType.EXPONENTIAL, rsi, Slow_Factor);
def atr_rsi = AbsValue(rsi_ma[1] - rsi_ma);
def atr_rsi_ma = MovingAverage(AverageType.EXPONENTIAL, atr_rsi, Wilder_Period);
def dar = MovingAverage(AverageType.EXPONENTIAL, atr_rsi_ma, Wilder_Period) * QQE;

def DeltaFastAtrRsi = dar;
def RSIndex = rsi_ma;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;

def longband = if RSIndex[1] > longband[1] and RSIndex > longband[1]
then Max(longband[1], newlongband)
else newlongband;

def shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1]
then Min(shortband[1], newshortband)
else newshortband;

def trend = if Crosses(RSIndex, shortband[1])
then 1
else if Crosses(longband[1], RSIndex)
then -1
else if !IsNaN(trend[1])
then trend[1]
else 1;

def FastAtrRsiTL = if trend == 1
then longband
else shortband;





plot pFastAtrRsiTL = FastAtrRsiTL;
plot pRsiMa = rsi_ma;
plot line50 = 50;
plot OB = 67;
plot OS = 33;
plot care = if pRsiMa crosses 50 then pRsiMa else Double.NaN;
plot BReversal = if pRsiMa crosses below 30 then pRsiMa else Double.NaN;
plot SReversal = if pRsiMa crosses above 70 then pRsiMa else Double.NaN;
plot Cross = if pRsiMa crosses 50 then pRsiMa else Double.NaN;


BReversal.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
BReversal.SetLineWeight(3);
SReversal.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
SReversal.SetLineWeight(3);
Cross.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
Cross.SetLineWeight(2);





pRsiMa.SetDefaultColor(CreateColor(113, 225, 180));

OB.SetDefaultColor(color = Color.GRAY);
OS.SetDefaultColor(color = Color.GRAY);

#pFastAtrRsiTL.SetDefaultColor(CreateColor(225, 109, 47));
pFastAtrRsiTL.AssignValueColor(if pFastAtrRsiTL == pFastAtrRsiTL[1] then Color.RED else CreateColor(225, 109, 47));



AddLabel(yes, if rsi_ma > 50 then " QQE " else " QQE ", if rsi_ma > 50 then Color.GREEN else Color.RED);
 
@grapetux question
1. Paint a cloud 'from where' down to zero line?
hey there
if you check this link, https://usethinkscript.com/threads/...system-for-thinkorswim.5457/page-3#post-84195
the image near the top of the page shows what im referring to

essentially the cloud will fill the space inbetween the gap from the RSI_Ma passing the zero line and thezero line, hopefully im explaining that ok

I would need help defining conditions for the rsi_ma to be in an uptrend, assuming its more complicated that 'its pointing up paint it green!"

for simplicity, the RSI_MA could be painted red when <50 and green when >50

but it would be dope to see it flips colors when a reversal is happening
 
Ruby:
# QQE Indicator
# Converted by Kory Gill for BenTen at useThinkScript.com
# Original https://www.tradingview.com/script/zwbe2plA-Ghosty-s-Zero-Line-QQE/
# Final Version of my QQE before my Leave for a few months 4/16/21 - Xiuying

# Whats been added-
# Points for crossings to let you know what to watch out for
# Labels for when it reaches O/S or O/B and colors change depending on level. Going from Less severity to most, It's Orange , Dark Orange, and Red. Red being the "Watch the **** out" Level.
# Oversold and Overbought levels were added and adjusted to my preferences.
# Added labels for instances where it crosses the 50
# Added Labels for 50 crosses and indicated to watch for Sup/Res

declare lower;

input RSI_Period = 20;
input Slow_Factor = 5;
input QQE = 4.236;

def Wilder_Period = RSI_Period * 2 - 1;
def vClose = close;

def rsi = RSI(price = vClose, length = RSI_Period).RSI;
def rsi_ma = MovingAverage(AverageType.EXPONENTIAL, rsi, Slow_Factor);
def atr_rsi = AbsValue(rsi_ma[1] - rsi_ma);
def atr_rsi_ma = MovingAverage(AverageType.EXPONENTIAL, atr_rsi, Wilder_Period);
def dar = MovingAverage(AverageType.EXPONENTIAL, atr_rsi_ma, Wilder_Period) * QQE;

def DeltaFastAtrRsi = dar;
def RSIndex = rsi_ma;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;

def longband = if RSIndex[1] > longband[1] and RSIndex > longband[1]
then Max(longband[1], newlongband)
else newlongband;

def shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1]
then Min(shortband[1], newshortband)
else newshortband;

def trend = if Crosses(RSIndex, shortband[1])
then 1
else if Crosses(longband[1], RSIndex)
then -1
else if !IsNaN(trend[1])
then trend[1]
else 1;

def FastAtrRsiTL = if trend == 1
then longband
else shortband;

plot pFastAtrRsiTL = FastAtrRsiTL;
plot pRsiMa = rsi_ma;
plot line50 = 50;
plot OB = 67;
plot OS = 33;
plot care = if pRsiMa crosses 50 then pRsiMa else Double.NaN;
plot BReversal = if pRsiMa crosses below 30 then pRsiMa else Double.NaN;
plot SReversal = if pRsiMa crosses above 70 then pRsiMa else Double.NaN;
plot Cross = if pRsiMa crosses 50 then pRsiMa else Double.NaN;

BReversal.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
BReversal.SetLineWeight(3);
SReversal.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
SReversal.SetLineWeight(3);
Cross.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
Cross.SetLineWeight(2);

########################################################################
pRsima.assignValueColor(if trend == 1 then color.GREEN else color.RED);
AddCloud(rsi_ma, 50, color.GREEN, color.RED);
########################################################################

#pRsiMa.SetDefaultColor(CreateColor(113, 225, 180));

OB.SetDefaultColor(color = Color.GRAY);
OS.SetDefaultColor(color = Color.GRAY);

#pFastAtrRsiTL.SetDefaultColor(CreateColor(225, 109, 47));
pFastAtrRsiTL.AssignValueColor(if pFastAtrRsiTL == pFastAtrRsiTL[1] then Color.RED else CreateColor(225, 109, 47));

AddLabel(yes, if rsi_ma > 50 then " QQE " else " QQE ", if rsi_ma > 50 then Color.GREEN else Color.RED);
 
Ruby:
# QQE Indicator
# Converted by Kory Gill for BenTen at useThinkScript.com
# Original https://www.tradingview.com/script/zwbe2plA-Ghosty-s-Zero-Line-QQE/
# Final Version of my QQE before my Leave for a few months 4/16/21 - Xiuying

# Whats been added-
# Points for crossings to let you know what to watch out for
# Labels for when it reaches O/S or O/B and colors change depending on level. Going from Less severity to most, It's Orange , Dark Orange, and Red. Red being the "Watch the **** out" Level.
# Oversold and Overbought levels were added and adjusted to my preferences.
# Added labels for instances where it crosses the 50
# Added Labels for 50 crosses and indicated to watch for Sup/Res

declare lower;

input RSI_Period = 20;
input Slow_Factor = 5;
input QQE = 4.236;

def Wilder_Period = RSI_Period * 2 - 1;
def vClose = close;

def rsi = RSI(price = vClose, length = RSI_Period).RSI;
def rsi_ma = MovingAverage(AverageType.EXPONENTIAL, rsi, Slow_Factor);
def atr_rsi = AbsValue(rsi_ma[1] - rsi_ma);
def atr_rsi_ma = MovingAverage(AverageType.EXPONENTIAL, atr_rsi, Wilder_Period);
def dar = MovingAverage(AverageType.EXPONENTIAL, atr_rsi_ma, Wilder_Period) * QQE;

def DeltaFastAtrRsi = dar;
def RSIndex = rsi_ma;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;

def longband = if RSIndex[1] > longband[1] and RSIndex > longband[1]
then Max(longband[1], newlongband)
else newlongband;

def shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1]
then Min(shortband[1], newshortband)
else newshortband;

def trend = if Crosses(RSIndex, shortband[1])
then 1
else if Crosses(longband[1], RSIndex)
then -1
else if !IsNaN(trend[1])
then trend[1]
else 1;

def FastAtrRsiTL = if trend == 1
then longband
else shortband;

plot pFastAtrRsiTL = FastAtrRsiTL;
plot pRsiMa = rsi_ma;
plot line50 = 50;
plot OB = 67;
plot OS = 33;
plot care = if pRsiMa crosses 50 then pRsiMa else Double.NaN;
plot BReversal = if pRsiMa crosses below 30 then pRsiMa else Double.NaN;
plot SReversal = if pRsiMa crosses above 70 then pRsiMa else Double.NaN;
plot Cross = if pRsiMa crosses 50 then pRsiMa else Double.NaN;

BReversal.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
BReversal.SetLineWeight(3);
SReversal.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
SReversal.SetLineWeight(3);
Cross.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
Cross.SetLineWeight(2);

########################################################################
pRsima.assignValueColor(if trend == 1 then color.GREEN else color.RED);
AddCloud(rsi_ma, 50, color.GREEN, color.RED);
########################################################################

#pRsiMa.SetDefaultColor(CreateColor(113, 225, 180));

OB.SetDefaultColor(color = Color.GRAY);
OS.SetDefaultColor(color = Color.GRAY);

#pFastAtrRsiTL.SetDefaultColor(CreateColor(225, 109, 47));
pFastAtrRsiTL.AssignValueColor(if pFastAtrRsiTL == pFastAtrRsiTL[1] then Color.RED else CreateColor(225, 109, 47));

AddLabel(yes, if rsi_ma > 50 then " QQE " else " QQE ", if rsi_ma > 50 then Color.GREEN else Color.RED);

wow..
you really did that,
you're amazing
cant wait to tinker with it tomorrow . Seriously, thank you so much
 

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