Adding a cloud between two signals

Reasonable_Drag

New member
Hi, I've amalgamated a custom study that gives me either a long or short signal whenever two conditions are met. I currently have it set up to add an up arrow and down arrow to the chart, but I'm trying to figure out a way to create a cloud overlay that shows either a green cloud if I've gotten a long signal and there has not been a subsequent short signal, or a red cloud for the opposite conditions. Can anyone help me?

I've posted the code below. And to clarify, I'm not wanting to create a cloud between the two different HMA lengths, but rather the signals that are generated from the different variables of the HMA lengths. Thanks in advance for any help that can be offered!

Code:
############
# Second Derivative of HMA on 100 Length
############

input HMAprice = HL2;
input HMA_Length = 100;
input lookback = 2;

def HMA = HullMovingAvg(price = HMAprice, length = HMA_Length);

def delta = HMA[1] - HMA[lookback + 1];
def delta_per_bar = delta / lookback;

def next_bar = HMA[1] + delta_per_bar;
def concavity = if HMA > next_bar then 1 else -1;
def turning_point = if concavity[1] != concavity then HMA else double.nan;

def HMAsellSig = if turning_point and concavity == -1 then high else double.nan;
def HMAbuySig = if turning_point and concavity == 1 then low else double.nan;

def SlowHMABuy; if (HMABuysig) {SlowHMABuy = 1;} else if (HMASellSig) {SlowHMABuy = 0;} else {SlowHMABuy = SlowHMABuy [1];}
def SlowHMASell; if (HMASellSig) {SlowHMASell = 1;} else if (HMABuySig) {SlowHMASell = 0;} else {SlowHMASell = SlowHMASell[1];}

############
# Max and Min Point HMA on 22 Length
############

input HMA22price = HL2;
input HMA22_Length = 22;
input lookback22 = 2;

def HMA22 = HullMovingAvg(price = HMA22price, length = HMA22_Length);

def HMA22sellSig = if HMA22[-1] < HMA22 and HMA22 > HMA22[1] then HMA22 else Double.NaN;
def HMA22buySig = if HMA22[-1] > HMA22 and HMA22 < HMA22[1] then HMA22 else Double.Nan;

def HMA22Buy; if (HMA22Buysig) {HMA22Buy = 1;} else if (HMA22SellSig) {HMA22Buy = 0;} else {HMA22Buy = HMA22Buy [1];}
def HMA22Sell; if (HMA22SellSig) {HMA22Sell = 1;} else if (HMA22BuySig) {HMA22Sell = 0;} else {HMA22Sell = HMA22Sell[1];}


def HMABuy = (SlowHMABuy and HMA22Buy);
def HMASell = (SlowHMASell and HMA22Sell);

##########
# Orders #
##########

def up = HMABuy;
def down = HMASell;

def Hold_Up_Value = if up then 1 else if !down then Hold_Up_Value[1] else 0;
def Hold_Dn_Value = if down then 1 else if !up then Hold_Dn_Value[1] else 0;

#########
# Plots #
#########

plot Signal_Up = if up and Hold_Dn_Value[1] == 1 then low else Double.NaN;
Signal_Up.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Signal_Up.SetDefaultColor (color.GREEN);
Signal_Up.SetLineWeight(5);
plot Signal_Dn = if down and Hold_Up_Value[1] == 1 then high else Double.NaN;
Signal_Dn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Signal_Dn.SetDefaultColor (color.RED);
Signal_Dn.SetLineWeight(5);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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