Hilega Milega For ThinkOrSwim

sandy_s157

New member
Can someone help with the following Hilega Milega setup on ThinkorSwim? This is from TradingView. I am not able to replicate this on ThinkorSwim


1.RSI: RSI (9)

a.Period – 9
b.Overbought –50
c.Oversold - 50

2.Weighted Moving average: WMA (21, RSI (9))

a.Period–21
b.Field–RSI (9)
c.Type–weighted

3.Exponential Moving average: EMA (3, RSI (9))

a.Period–3
b.Field–RSI (9)
c.Type- Exponential
 
Code:
Declare Lower;
Input RS_Pd = 9;
Input WMA_Pd = 21;
Input Displace = 0;
Input EMA_Pd = 3;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input Arrows_1 = no;
input Arrows_2 = no;
input Arrows_3 = no;
input Dotsize = 3;
def NetChgAvg = MovingAverage(averageType, price - price[1], RS_Pd);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), RS_Pd);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
Plot A_RSI = ExpAverage(RSI,EMA_Pd);
Plot B_RSI = WMA(RSI,WMA_Pd)[-displace];
def MMAX = MAX(RSI,A_RSI);
def MMin = Min(RSI,A_RSI);
def MMaxAll = Max(RSI,Max(A_RSI,B_RSI));
def MMinAll = Min(RSI,Min(A_RSI,B_RSI));
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;

UpSignal.SetHiding(!Arrows_1);
DownSignal.SetHiding(!Arrows_1);

RSI.setdefaultColor(Color.Cyan);
A_RSI.setdefaultColor(Color.Magenta);
B_RSI.setdefaultColor(Color.Yellow);
RSI.SetLineWeight(2);
A_RSI.SetLineWeight(2);
B_RSI.SetLineWeight(2);
AddCloud(RSI,A_RSI,Color.Cyan,Color.Magenta);
AddCloud(MMin,B_RSI,Color.Yellow,Color.Black);
AddCloud(B_RSI,MMax,Color.Yellow,Color.Black);
AddCloud(MMinAll,50,Color.Green,Color.Black);
AddCloud(50,MMaxAll,Color.Red,Color.Black);
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpSignal.setLineWeight(Dotsize -1);
DownSignal.setLineWeight(Dotsize -1);
#ARROWS
plot ArrowDown = if Arrows_2 and (RSI Crosses below A_RSI) then A_RSI else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Red);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if Arrows_2 and (RSI crosses above A_RSI) then A_RSI else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);

plot ArrowDown2 = if Arrows_3 and (RSI Crosses below B_RSI) then B_RSI else double.nan;
ArrowDown2.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown2.setDefaultColor(color.Yellow);
ArrowDown2.setLineWeight(dotsize+1);

plot ArrowUp2 = if Arrows_3 and (RSI crosses above B_RSI ) then B_RSI else double.nan;
ArrowUp2.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp2.setDefaultColor(color.Yellow);
ArrowUp2.setLineWeight(dotsize+1);
 
Code:
Declare Lower;
Input RS_Pd = 9;
Input WMA_Pd = 21;
Input Displace = 0;
Input EMA_Pd = 3;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input Arrows_1 = no;
input Arrows_2 = no;
input Arrows_3 = no;
input Dotsize = 3;
def NetChgAvg = MovingAverage(averageType, price - price[1], RS_Pd);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), RS_Pd);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
Plot A_RSI = ExpAverage(RSI,EMA_Pd);
Plot B_RSI = WMA(RSI,WMA_Pd)[-displace];
def MMAX = MAX(RSI,A_RSI);
def MMin = Min(RSI,A_RSI);
def MMaxAll = Max(RSI,Max(A_RSI,B_RSI));
def MMinAll = Min(RSI,Min(A_RSI,B_RSI));
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;

UpSignal.SetHiding(!Arrows_1);
DownSignal.SetHiding(!Arrows_1);

RSI.setdefaultColor(Color.Cyan);
A_RSI.setdefaultColor(Color.Magenta);
B_RSI.setdefaultColor(Color.Yellow);
RSI.SetLineWeight(2);
A_RSI.SetLineWeight(2);
B_RSI.SetLineWeight(2);
AddCloud(RSI,A_RSI,Color.Cyan,Color.Magenta);
AddCloud(MMin,B_RSI,Color.Yellow,Color.Black);
AddCloud(B_RSI,MMax,Color.Yellow,Color.Black);
AddCloud(MMinAll,50,Color.Green,Color.Black);
AddCloud(50,MMaxAll,Color.Red,Color.Black);
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpSignal.setLineWeight(Dotsize -1);
DownSignal.setLineWeight(Dotsize -1);
#ARROWS
plot ArrowDown = if Arrows_2 and (RSI Crosses below A_RSI) then A_RSI else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Red);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if Arrows_2 and (RSI crosses above A_RSI) then A_RSI else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);

plot ArrowDown2 = if Arrows_3 and (RSI Crosses below B_RSI) then B_RSI else double.nan;
ArrowDown2.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown2.setDefaultColor(color.Yellow);
ArrowDown2.setLineWeight(dotsize+1);

plot ArrowUp2 = if Arrows_3 and (RSI crosses above B_RSI ) then B_RSI else double.nan;
ArrowUp2.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp2.setDefaultColor(color.Yellow);
ArrowUp2.setLineWeight(dotsize+1);

Awesome! Thank you for quick turnaround!
 

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