Add to the bottom of your studyIm looking to add alert when value of Hull changes directions up or down when above zero to alert when the hull changes directions upwards or below to downwards
def AboveZero = Hull > 0 and Hull < Hull[1] and Hull[1] > Hull[2] #above zero and changes direction down
Hull > 0 and Hull > Hull[1] and Hull[1] < Hull[2] #above zero and changes direction up
# Alert AboveZero change in direction
Alert(AboveZero , "AboveZero change in direction", Alert.Bar, Sound.Chimes);
def BelowZero = Hull < 0 and Hull < Hull[1] and Hull[1] > Hull[2] #below zero and changes direction down
# Alert BelowZero change to downward direction
Alert(BelowZero , "BelowZero change in direction", Alert.Bar, Sound.Chimes);
A VERY GOOD SYSTEM, CAN SOMEONE HELP TO LOCATE THE ARROW SIGNAL FROM THE LOWER INDICATOR AND PLOT IT INTO THE UPPER CHART? THANK YOU VERY MUCH IN ADVANCE..Not sure if this is what you are looking for but this might help.
Code:#MACD based on Hull Moving Average W/peak/ebb arrows #TOS title = MACD_via_Hull_MA_fav declare lower; input fastLength = 12; input slowLength = 26; input MACDLength = 9; input AverageType = {SMA, EMA, default HULL}; plot Value; plot Avg; switch (AverageType) { case SMA: Value = Average(close, fastLength) - Average(close, slowLength); Avg = Average(Value, MACDLength); case EMA: Value = ExpAverage(close, fastLength) - ExpAverage(close, slowLength); Avg = ExpAverage(Value, MACDLength); case HULL: Value = MovingAverage(AverageType.HULL, close, fastLength) - MovingAverage(AverageType.HULL, close, slowLength); Avg = Average(Value, MACDLength); } plot Diff = Value - Avg; plot ZeroLine = 0; Value.SetDefaultColor(GetColor(1)); Avg.SetDefaultColor(GetColor(8)); Diff.SetDefaultColor(GetColor(5)); Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); Diff.SetLineWeight(3); Diff.DefineColor("Positive and Up", Color.GREEN); Diff.DefineColor("Positive and Down", Color.DARK_GREEN); Diff.DefineColor("Negative and Down", Color.RED); Diff.DefineColor("Negative and Up", Color.DARK_RED); Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up")); ZeroLine.SetDefaultColor(GetColor(0)); #plot Min arrows* def MinArrow = if (Value < Value[1] and value[1] < Value[2] and value[2] < Value[3] and value[-1] > Value and value < 0) then 0 else if (Value > Value[1]) then double.nan else double.nan; plot UpArrow = if(MinArrow == 0, value, double.nan); UpArrow.AssignValueColor(Color.Green); UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP); UpArrow.SetLineWeight(1); UpArrow.HideBubble(); #plot Max arrows* def MaxArrow = if (Value > Value[1] and value[1] > Value[2] and value[2] > Value[3] and value[-1] < Value and value > 0) then 0 else if (Value > Value[1]) then double.nan else double.nan; plot DwnArrow = if(MaxArrow == 0, value, double.nan); DwnArrow.AssignValueColor(Color.cyan); DwnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_Down); DwnArrow.SetLineWeight(1); DwnArrow.HideBubble(); #plot Max signal(Avg) arrows* def SignalArrow = if (Avg > Avg[1] and Avg[1] > Avg[2] and Avg[2] > Avg[3] and Avg[-1] < Avg and Avg > 0) then 0 else if (Avg > Avg[1]) then double.nan else double.nan; plot downSignalArrow = if(SignalArrow == 0, avg, double.nan); downSignalArrow.AssignValueColor(Color.yellow); downSignalArrow.SetPaintingStrategy(PaintingStrategy.ARROW_Down); downSignalArrow.SetLineWeight(1); downSignalArrow.HideBubble(); AddCloud(ZeroLine, Value, color.RED, color.GREEN); # end
This is the source I found it from.
https://github.com/jshingler/TOS-an...llection.md#MACD_BASED_ON_HULL_MOVING_AVERAGE
The ToS platform does not allow for the use of MTF (multi-timeframe) indicators in scans or watchlists.I want to look for up (Hull ascending) at a certain aggregation and going up from down (hull descending) at a certain aggregation.
# Hull_Average_Change from scan
# @DataDriven 5/19/2022
input agg2 = AggregationPeriod.FOUR_HOURS;
input agg1 = AggregationPeriod.FIVE_MIN ;
def price1 = Close(Period =agg1);
def price2 = Close(Period =agg2);
input length = 20;
input displace = 0;
input choice1 = {default Up, Down};
input choice2 = {default Down, Up};
plot HMA1 = MovingAverage(AverageType.HULL, price1, length)[-displace];
def HMA2 = MovingAverage(AverageType.HULL, price2, length)[-displace];
def condition1;
switch (choice1) {
case Up:
condition1 = HMA1[1] > HMA1[2];
case Down:
condition1 = HMA1[1] < HMA1[2];
}
def condition2;
switch (choice2) {
case Up:
condition2 = HMA2 > HMA2[1];
case Down:
condition2 = HMA2 < HMA2[1];
}
def scan = condition1 and condition2;
HMA1.AssignValueColor(if scan then color.blue else color.pink);
plot ConditionsBegin = if scan and !scan[1] then HMA1 else double.NaN ;
ConditionsBegin.SetPaintingStrategy(PaintingStrategy.ARROW_up);
ConditionsBegin.SetDefaultColor(color.blue) ;
ConditionsBegin.SetLineWeight(1);
plot ConditionsEnd = if !scan and scan[1] then HMA1 else double.NaN ;
ConditionsEnd.SetPaintingStrategy(PaintingStrategy.ARROw_DOWN);
ConditionsEnd.SetDefaultColor(color.blue) ;
ConditionsEnd.SetLineWeight(1);
#
# TD Ameritrade IP Company, Inc. (c) 2008-2022
#
input price = close;
input length = 20;
input displace = 0;
plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace];
HMA.DefineColor("Up", GetColor(1));
HMA.DefineColor("Down", GetColor(0));
HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down"));
Here you go. Give it a try. I added a color price bar and alert.Hi, would anyone be able to modify the ToS 'HullMovingAvg' and add a syntax to color the price bars based on the HMA Down/Up trend?
Would be indebted if so.
Original code below.
Thanks.
Code:# # TD Ameritrade IP Company, Inc. (c) 2008-2022 # input price = close; input length = 20; input displace = 0; plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace]; HMA.DefineColor("Up", GetColor(1)); HMA.DefineColor("Down", GetColor(0)); HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down"));
# TD Ameritrade IP Company, Inc. (c) 2008-2022
#
input price = close;
input length = 20;
input displace = 0;
plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace];
HMA.DefineColor("Up", GetColor(1));
HMA.DefineColor("Down", GetColor(0));
HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down"));
def bullish = HMA > HMA[1];
def bearish = HMA < HMA[1];
# Alerts
Alert(bullish, "UP arrow alert", Alert.BAR, Sound.Chimes);
Alert(bearish, "DOWN arrow alert", Alert.BAR, Sound.Ring);
AssignPriceColor(if bullish then color.Green else color.Red);
Here you go. Give it a try. I added a color price bar and alert.
Code:# TD Ameritrade IP Company, Inc. (c) 2008-2022 # input price = close; input length = 20; input displace = 0; plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace]; HMA.DefineColor("Up", GetColor(1)); HMA.DefineColor("Down", GetColor(0)); HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down")); def bullish = HMA > HMA[1]; def bearish = HMA < HMA[1]; # Alerts Alert(bullish, "UP arrow alert", Alert.BAR, Sound.Chimes); Alert(bearish, "DOWN arrow alert", Alert.BAR, Sound.Ring); AssignPriceColor(if bullish then color.Green else color.Red);
You’re welcome, happy trading. Remember nothing is perfect as market can change directions any time.Wow, @s1111 - totally flawless. Can't thank you enough, you're friggin' ace. And what a cheetah fast turn-around!
And the alerts, a nice ancillary bonus!! Thank you!!!
https://usethinkscript.com/threads/...ist-scan-for-thinkorswim.947/page-2#post-7685Does someone have the Hull Shuite Indicator from Trading View to ThinkorSwim?
https://www.tradingview.com/script/hg92pFwS-Hull-Suite/
#
# TD Ameritrade IP Company, Inc. (c) 2008-2019
input price = close;
input length = 20;
input displace = 0;
plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace];
HMA.DefineColor("Up", GetColor(1));
HMA.DefineColor("Down", GetColor(0));
HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down"));
#I added these arrows:
plot U1 = HMA > HMA[1];
U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
U1.SetDefaultColor(Color.GREEN);
U1.SetLineWeight(4);
plot D1 = HMA < HMA[1];
D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
D1.SetDefaultColor(Color.RED);
D1.SetLineWeight(4);
Code:# # TD Ameritrade IP Company, Inc. (c) 2008-2019 input price = close; input length = 20; input displace = 0; plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace]; HMA.DefineColor("Up", GetColor(1)); HMA.DefineColor("Down", GetColor(0)); HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down")); #I added these arrows: plot U1 = HMA > HMA[1]; U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); U1.SetDefaultColor(Color.GREEN); U1.SetLineWeight(4); plot D1 = HMA < HMA[1]; D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); D1.SetDefaultColor(Color.RED); D1.SetLineWeight(4);
How would I change my code to where it only plots an up or down arrow on only the 1st candle that changes trend
instead of ALL the candles that are the same direction? Thanks
Ruby:input price = close; input length = 20; input displace = 0; plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace]; HMA.DefineColor("Up", GetColor(1)); HMA.DefineColor("Down", GetColor(0)); HMA.AssignValueColor(if HMA > HMA[1] then HMA.Color("Up") else HMA.Color("Down")); #I added these arrows: plot U1 = HMA > HMA[1] and HMA[1] < HMA[2]; U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); U1.SetDefaultColor(Color.GREEN); U1.SetLineWeight(4); plot D1 = HMA < HMA[1] and HMA[1] > HMA[2] ; D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); D1.SetDefaultColor(Color.RED); D1.SetLineWeight(4);
Thats perfect. Exactly what I wanted.
I noticed my arrows come a bar after the HMA color has changed.
Is there a way to make it bar[0] immediate?
Ruby:input price = close; input length = 20; input displace = 0; plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace]; HMA.DefineColor("Up", GetColor(1)); HMA.DefineColor("Down", GetColor(0)); HMA.AssignValueColor(if HMA > HMA[1] then HMA.Color("Up") else HMA.Color("Down")); #I added these arrows: plot U1 = HMA < HMA[-1] and HMA < HMA[1]; U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); U1.SetDefaultColor(Color.GREEN); U1.SetLineWeight(4); plot D1 = HMA > HMA[-1] and HMA > HMA[1] ; D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); D1.SetDefaultColor(Color.RED); D1.SetLineWeight(4);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.