Multipe time frame SMA setup, need to build a scanner

stockula

New member
Multiple time frame scanner:

Hi guys, i'll try to keep this as short and clear as possible, any help would be greatly appreciated. There is a setup that I look for which yields consistent results for day trades and short swings. Unfortunately, I am unable to build a scanner for it, for the life of me I have tried. The setup is really simple, but the conditions pretty much have to be exact. I will describe the bullish setup, any SMA combination can be used, but I find 5/10, 10/20, 13/21 etc work well, so having the ability to change the SMA's would be great.

The setup involves two SMAs and two time frames. (5 sma, 10 sma, and 1H and 4H)

The idea of this setup, is to go from the fast 4H sma to the slow 4Hsma, while fast is below slow, in terms of price target. i.e. I wanna enter on the 4H 5sma, and exit at the 4H 10sma... kinda thing, but using the 1H candle as my entry trigger.

1 Hour conditions:
-1 Hour candle is above the 1Hour 5sma and 30sma
-1 Hour candle CLOSES ABOVE the 4Hour 5sma but below the 4H 10sma

4Hour conditions:
-4Hour 10sma is above 4Hour 5sma ( the 10sma needs to be at least 3% away from the 5sma, and if this % is adjustable, it will make this scanner very accurate)

Entry conditions:
-Enter when the 1H closes above the 4H slow sma.

Notes:
-It is crucial that there is room between the 4H smas. Again, if this 'room' could be adjusted as a % of the price, it would make for very accurate scans.
-Works best on big cap stocks with high volume
-This play is basically a downtrend break continuation

(tried posting a pic ,but keep getting an error, not sure why)
 
Yup, tos definitely doesn’t allow that. I tried a work around; instead of scanning for 4H conditions, I tried using 1H smas multiplied by 4, since a 4H candle is 4 1H candles. It’s correct in theory, but it definitely doesn’t work the same way on the scanner. I will continue to work on this, but due to that tos time constraint, I fear it’s a fruitless endeavour.
 
@BenTen @stockula This is possible, took me a few minutes to figure it out, I'm still kinda new to this scripting thing and its 3am but you can reference a custom study in watchlist scripts it will require 2 custom scripts the hr4sma() set to 4hrs and convert the sma's to variables and then the second script set to hourly and reference the variables and viola! since it basically inputs the referenced into the other I'll just post the one, I colored it so that the signals pop as red when true(note this isn't possible in chart studies though, as you cant reference a custom script from another custom script and you get the secondary aggregation error) So just add this as a watchlist column and wait for it to pop, its like 3am so I didn't add the 3% part and its after hours so I haven't tested it but I didn't pop in any secondary aggregation reference error so give it a try!

Code:
script hr4sma5 {
Def A = close(GetSymbol(), AggregationPeriod.four_hours);
Def HR4SMA5=average(a,5);
def hrsma10=average(a,10);
plot A1=hr4sma5;


}
declare upper;
def A = close(GetSymbol(), AggregationPeriod.HOUR);


def conditionA = A > Average(A, 5) and Average(A, 30);
def conditionB =A> hr4sma5().a1;
def ConditionC =A< hr4sma5()."hrsma10";
def signal = if conditionA == 1 and ConditionB == 1 and conditionC==1 then 1 else Double.NaN ;
plot signal1=signal;
AssignBackgroundColor(if conditionA == 1 and ConditionB == 1 and conditionC==1 then color.red else  color.gray);
 

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