Heikin Ashi Smoothed Alerts

OutsideTrades

New member
I was wondering if any one knows how to add an alert to this Heikin Ashi Smoothed code below to signal when the trend has change and closed in a new direction. I have added a screen shot of when I am looking for it to alert, the purple vertical line is where the signal should trigger. I pulled the alert code from another one of my scripts but for some reason I havent been able to figure out what part of the Heikin code will actually make this one trigger on the switch.

Thanks a bunch in advance!!!



https://usethinkscript.com/threads/smoothed-heikin-ashi-for-thinkorswim.216/
Code Below

# Heikin Ashi Smoothed
# HoboTheClown / blt
# 9.15.2016

input period = 6;
input hideCandles = no;
input candleSmoothing = {default Valcu, Vervoort};

DefineGlobalColor("RisingMA", color.green);
DefineGlobalColor("FallingMA", color.red);

input movingAverageType = {Simple, default Weighted};

def openMA;
def closeMA;
def highMA;
def lowMA;

switch (movingAverageType) {
case Simple:
openMA = compoundValue(1, Average(open, period), open);
closeMA = compoundValue(1, Average(close, period), close);
highMA = compoundValue(1, Average(high, period), high);
lowMA = compoundValue(1, Average(low, period), low);
case Weighted:
openMA = compoundValue(1, WMA(open, period), open);
closeMA = compoundValue(1, WMA(close, period), close);
highMA = compoundValue(1, WMA(high, period), high);
lowMA = compoundValue(1, WMA(low, period), low);
}

#hidePricePlot(hideCandles);

def haOpen;
def haClose;

switch(candleSmoothing) {
case Valcu:
haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) /4.0)/2.0), open);
haClose = ((OpenMA + HighMA + LowMA + CloseMA)/4.0) ;

case Vervoort:
haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) /4.0)/2.0), open);
haClose = ((((OpenMA + HighMA + LowMA + CloseMA)/4.0) + haOpen + Max(HighMA, haOpen) + Min(LowMA, haOpen))/4.0);
}

plot o = haopen;
o.hide();

def haLow = min(lowMA, haOpen);
def haHigh = max(highMA,haOpen);

### NO LONGER SUPPORTED BY TOS
###
### AddChart(high = haHigh, low = haLow, open = o, close = haclose, type = ChartType.CANDLE, growColor = GlobalColor("RisingMA"), fallColor = GlobalColor("FallingMA"), neutralColor = color.gray);

####THIS IS FOR THE RED CANDLES OF THE HA

input charttype = ChartType.CANDLE;
def haopen_ = if haopen>haclose
then HAopen + 0
else double.nan;
def HAhi = if haopen>=haclose
then hahigh
else double.nan;
def HAlo = if haopen>=haclose
then halow
else double.nan;

AddChart(growColor = color.red, fallColor = Color.green, neutralColor = Color.current, high = HAhi, low = HAlow, open = haopen_, close = HAclose, type = ChartType.CANDLE);

####THIS IS FOR THE GREEN CANDLES OF THE HA

def HAclose1 = ohlc4;
def HAopen1 = if haopen<=haclose
then CompoundValue(1, (HAopen[1] + HAclose[1]) / 2, (open[1] + close[1]) / 2)
else double.nan;
def haopen_1 = if haopen<=haclose
then HAopen1 + 0
else double.nan;
def HAhigh1 = hahigh;
def HAlow1 = halow;

AddChart(growColor = Color.green, fallColor = Color.red, neutralColor = Color.current, high = HAhigh1, low = HAlow1, open = haopen_1, close = HAclose1, type = ChartType.CANDLE);

####This is the alert code, the next 2 lines are incorrect and need fixing, the last 2 ALERT codes work as they should.

#def SELL = hahigh1[1] > hahigh1 ;
#def BUY = halow1[1] < halow1 ;

#alert(SELL, "SELL", Alert.BAR, Sound.Ding);
#alert(BUY, "BUY", Alert.BAR, Sound.Ring);
 

Attachments

  • HAS.png
    HAS.png
    48.8 KB · Views: 56
Last edited by a moderator:
Solution
I was wondering if any one knows how to add an alert to this Heikin Ashi Smoothed code below to signal when the trend has change and closed in a new direction. I have added a screen shot of when I am looking for it to alert, the purple vertical line is where the signal should trigger. I pulled the alert code from another one of my scripts but for some reason I havent been able to figure out what part of the Heikin code will actually make this one trigger on the switch.

Thanks a bunch in advance!!!



https://usethinkscript.com/threads/smoothed-heikin-ashi-for-thinkorswim.216/
Code Below

# Heikin Ashi Smoothed
# HoboTheClown / blt
# 9.15.2016

input period = 6;
input hideCandles = no;
input candleSmoothing = {default Valcu...
I was wondering if any one knows how to add an alert to this Heikin Ashi Smoothed code below to signal when the trend has change and closed in a new direction. I have added a screen shot of when I am looking for it to alert, the purple vertical line is where the signal should trigger. I pulled the alert code from another one of my scripts but for some reason I havent been able to figure out what part of the Heikin code will actually make this one trigger on the switch.

Thanks a bunch in advance!!!



https://usethinkscript.com/threads/smoothed-heikin-ashi-for-thinkorswim.216/
Code Below

# Heikin Ashi Smoothed
# HoboTheClown / blt
# 9.15.2016

input period = 6;
input hideCandles = no;
input candleSmoothing = {default Valcu, Vervoort};

DefineGlobalColor("RisingMA", color.green);
DefineGlobalColor("FallingMA", color.red);

input movingAverageType = {Simple, default Weighted};

def openMA;
def closeMA;
def highMA;
def lowMA;

switch (movingAverageType) {
case Simple:
openMA = compoundValue(1, Average(open, period), open);
closeMA = compoundValue(1, Average(close, period), close);
highMA = compoundValue(1, Average(high, period), high);
lowMA = compoundValue(1, Average(low, period), low);
case Weighted:
openMA = compoundValue(1, WMA(open, period), open);
closeMA = compoundValue(1, WMA(close, period), close);
highMA = compoundValue(1, WMA(high, period), high);
lowMA = compoundValue(1, WMA(low, period), low);
}

#hidePricePlot(hideCandles);

def haOpen;
def haClose;

switch(candleSmoothing) {
case Valcu:
haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) /4.0)/2.0), open);
haClose = ((OpenMA + HighMA + LowMA + CloseMA)/4.0) ;

case Vervoort:
haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) /4.0)/2.0), open);
haClose = ((((OpenMA + HighMA + LowMA + CloseMA)/4.0) + haOpen + Max(HighMA, haOpen) + Min(LowMA, haOpen))/4.0);
}

plot o = haopen;
o.hide();

def haLow = min(lowMA, haOpen);
def haHigh = max(highMA,haOpen);

### NO LONGER SUPPORTED BY TOS
###
### AddChart(high = haHigh, low = haLow, open = o, close = haclose, type = ChartType.CANDLE, growColor = GlobalColor("RisingMA"), fallColor = GlobalColor("FallingMA"), neutralColor = color.gray);

####THIS IS FOR THE RED CANDLES OF THE HA

input charttype = ChartType.CANDLE;
def haopen_ = if haopen>haclose
then HAopen + 0
else double.nan;
def HAhi = if haopen>=haclose
then hahigh
else double.nan;
def HAlo = if haopen>=haclose
then halow
else double.nan;

AddChart(growColor = color.red, fallColor = Color.green, neutralColor = Color.current, high = HAhi, low = HAlow, open = haopen_, close = HAclose, type = ChartType.CANDLE);

####THIS IS FOR THE GREEN CANDLES OF THE HA

def HAclose1 = ohlc4;
def HAopen1 = if haopen<=haclose
then CompoundValue(1, (HAopen[1] + HAclose[1]) / 2, (open[1] + close[1]) / 2)
else double.nan;
def haopen_1 = if haopen<=haclose
then HAopen1 + 0
else double.nan;
def HAhigh1 = hahigh;
def HAlow1 = halow;

AddChart(growColor = Color.green, fallColor = Color.red, neutralColor = Color.current, high = HAhigh1, low = HAlow1, open = haopen_1, close = HAclose1, type = ChartType.CANDLE);

####This is the alert code, the next 2 lines are incorrect and need fixing, the last 2 ALERT codes work as they should.

#def SELL = hahigh1[1] > hahigh1 ;
#def BUY = halow1[1] < halow1 ;

#alert(SELL, "SELL", Alert.BAR, Sound.Ding);
#alert(BUY, "BUY", Alert.BAR, Sound.Ring);

looks like you want lines from the peaks and valleys
take a look at this post
https://usethinkscript.com/threads/...y-demand-zones-for-thinkorswim.172/#post-7048
 
Solution

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