SMA Breakout with RSI<50

AggieEMT

New member
So I’ll preface by saying I know just enough about coding to be dangerous. I’ve written a little bit mostly from trial-and-error with copy/paste, but this has had me stumped for several days. I’m trying to build a scan that alerts when the SMA1 pulls away from SMA2 when both are above SMA3 and RSI is <=50 to alert of a potential breakout (where SMA1 < SMA2 < SMA3)….. I’ve tried to pull down code snippets and put them together but can’t get them quite right. I currently have the 9, 12, and 26 SMA overlaid on my chart, with RSI and volume below but know it can be coded into a scan with an alert.

I watched the Hahn Tech video on the MACD RSI squeeze and tried to emulate the spike on the bottom of the chart when the criteria are met, but I can't quite figure it out.... . If everything goes the way it is in my head, it would display the spike on this chart and/or pop up as an alert when the above criteria are met The problem right now is that I’m not sure what definition to use where the ****** is, which (if it works out like I envision) is where the SMA9 starts to pull away from the SMA27 but it’s not yet oversold.


Here’s what I’ve got so far:
Code:
input price = close;
input length1 = 9;
input length2 = 27;
input length3 = 42;
input barsAfterCross = 2;

def SMA1 = SimpleMovingAvg(price, length1);
def SMA2 = SimpleMovingAvg(price, length2);
def SMA3= SimpleMovingAvg(price, length3);
def crossAbove = SMA1[1] < SMA2[1] and SMA1 > SMA2;
def crossBelow = SMA1[1] > SMA2[1] and SMA1 < SMA2;

SMA1.SetDefaultColor(CreateColor(0, 197, 47));
SMA2.SetDefaultColor(CreateColor(255, 126, 0));
SMA3.SetDefaultColor(CreateColor(204, 0, 51));

def overSoldRSI = RSI <= 40;

def ******** = SMA1 > SMA2 and SMA2 > SMA3
plot ******* if highest(overSoldRSI[1], 4) > 0;

TIA!
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Well, that’s what I thought... so when I tried to name it “Breakout”, it was highlighted in red with an error. I didn’t know if it rejected it because I’d syntax or bc that definition is already used somewhere else.....?
 
SO AHH, this is not doing something & I cant' program. Down at line 20 "plot...>0:" is red on thinkscript editor. Can someone help out?
I thought adding the last bottom two lines would work, well no such luck. It's Chinese to me

Code:
input price = close;
input length1 = 9;
input length2 = 27;
input length3 = 42;
input barsAfterCross = 2;

def SMA1 = SimpleMovingAvg(price, length1);
def SMA2 = SimpleMovingAvg(price, length2);
def SMA3 = SimpleMovingAvg(price, length3);
def crossAbove = SMA1[1] < SMA2[1] and SMA1 > SMA2;
def crossBelow = SMA1[1] > SMA2[1] and SMA1 < SMA2;

SMA1.SetDefaultColor(CreateColor(0, 197, 47));
SMA2.SetDefaultColor(CreateColor(255, 126, 0));
SMA3.SetDefaultColor(CreateColor(204, 0, 51));

def overSoldRSI = RSI <= 40;

def breakout = SMA1 > SMA2 and SMA2 > SMA3;
plot breakout if highest(overSoldRSI[1], 4) > 0;

plot breakout = asd;
breakout.SetDefaultColor(GetColor(0));
 
OK thanks, I just want to see a code to plot three SMA as the move up or down and cross, maybe four, nothing fancy. I thought AggieEMT had a nice one started but it's bust and but i cant write code. Back to square one again.
 
@Adeodatus

Code:
input price = close;
input length1 = 9;
input length2 = 27;
input length3 = 42;

plot SMA1 = SimpleMovingAvg(price, length1);
plot SMA2 = SimpleMovingAvg(price, length2);
plot SMA3 = SimpleMovingAvg(price, length3);

SMA1.SetDefaultColor(CreateColor(0, 197, 47));
SMA2.SetDefaultColor(CreateColor(255, 126, 0));
SMA3.SetDefaultColor(CreateColor(204, 0, 51));
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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