NexusFi: Find Your Edge


Home Menu

 





Moving Average Price Scan


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,098 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 2 posts
    2. attach_file 1 attachments




 
Search this Thread

Moving Average Price Scan

  #1 (permalink)
vrinx3547
Newark, Ohio
 
Posts: 2 since Apr 2021
Thanks Given: 0
Thanks Received: 0

I need to know how to scan in thinkorswim for a stock price that closed above or below a moving average for a certain number of days. EXAMPLE: On a chart the price has consistently closed above the 12 simple moving average for 42 days. how would I scan for this? Thank you.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Deepmoney LLM
Elite Quantitative GenAI/LLM
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
60 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #2 (permalink)
 elitecamper 
McAllen, TX
 
Experience: Advanced
Platform: Multicharts, Jigsaw
Broker: Ironbeam
Trading: ES, ZN, ZB, ZF
Posts: 104 since May 2013
Thanks Given: 108
Thanks Received: 133

Hello, you are going to have to create an indicator that can look back and check if the last 42 bars have been above the 12 SMA.
To accomplish that you are going to have to use the fold operator in thinkscript to iterate through the last 42 bars and return a true or false value.

https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/fold.html


I haven't coded in thinkscript in years so this is as far as I can help.

Good luck maybe someone here at futures.io will volunteer to help code your indicator.

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
 
TrendFollower1's Avatar
 TrendFollower1 
Austin, TX
 
Experience: Advanced
Platform: ThinkOrSwim
Trading: Currency, index, commodity futures
Posts: 9 since Mar 2012
Thanks Given: 18
Thanks Received: 8



vrinx3547 View Post
I need to know how to scan in thinkorswim for a stock price that closed above or below a moving average for a certain number of days. EXAMPLE: On a chart the price has consistently closed above the 12 simple moving average for 42 days. how would I scan for this? Thank you.

Hi vrinx,

Here are two indicators, called ChronicCloseAboveMA and ChronicCloseBelowMA. The first puts a red up arrow when the close has been above the MA for a long time and the second puts a blue down arrow when the close has been below the MA.

You can go to Edit studies, select Create, delete the default text in the box, and paste these codes in separately and then name each indicator up at the top of the page. To perform a scan, select one of the two studies and "is true" "within 1 bar" and the scan will work.

There were no stocks that fit the criteria you set for a close above the moving average when I used 42 days, so I've set the default to 25 days. When I scanned with 25 there were several hits using each indicator (for stocks with a close of 10 or higher and minimum volume of 100,000 shares).

You can change the 25 days to any length you want in the inputs. You can also change the 12 period SMA to different periods and different moving averages.

I pasted a chart of a stock that shows both types of arrows down below. Not sure if it will show up properly...

# ChronicCloseAboveMA
# Response to vrinx3547 question
# malength is the number of periods used for the moving average and length2 is the number of bars with their close above the moving average

input price = close;
input malength = 12;
input length2 = 25;
input avgtype = averagetype.SIMPLE;

def MA = MovingAverage(avgtype, close, malength);
def MAoverClose = MA > close within length2 bars;

plot highclose = MAoverClose is false;

highclose.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
highclose.SetDefaultColor(Color.RED);
highclose.SetLineWeight(3);

---------------------------


# ChronicCloseBelowMA
# Response to vrinx3547 question
# malength is the number of periods used for the moving average and length2 is the number of bars with their close below the moving average

input price = close;
input malength = 12;
input length2 = 25;
input avgtype = averagetype.SIMPLE;

def MA = MovingAverage(avgtype, close, malength);
def MAoverClose = MA < close within length2 bars;

plot highclose = MAoverClose is false;

highclose.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
highclose.SetDefaultColor(Color.BLUE);
highclose.SetLineWeight(3);




Reply With Quote
Thanked by:




Last Updated on September 5, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts