NexusFi: Find Your Edge


Home Menu

 





Select stocks whose last price is within 2% from its high or low in last 10 days


Discussion in ThinkOrSwim

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




 
Search this Thread

Select stocks whose last price is within 2% from its high or low in last 10 days

  #1 (permalink)
 reachgpm 
boston
 
Experience: Beginner
Platform: Thinkorswim
Trading: stocks, options, futures
Posts: 4 since Jan 2021
Thanks Given: 4
Thanks Received: 3

Hi All,

I have recently joined this forum. I am looking for help in creating a thinkscript (ThinkOrSwim Platform) for the following criteria and need help with the same. The objective is to get the list of stocks whose price has been relatively stable in the last 10 days even though there has been considerable (200k +) volume every day. If this is already existing or if anyone can help share this script, kindly do so. My apologies in case I am posting this in the wrong place.

Additional clarity on the Scan Criteria: Want to create a scan wherein I select all stocks whose last price is within the range of 2% from its high and low in the last 10 days. It would help if I can change this 10 days to be any number of days. Also the last price can be the last price for today or yesterday. For e.g. a stock has high of 100$ in the last 1 month and low of 98$ then I want this particular stock to be selected in the scan I write in the TOS platform. Please let me know if you need any additional information.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Exit Strategy
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
Deepmoney LLM
Elite Quantitative GenAI/LLM
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
18 thanks
The Program
18 thanks
  #2 (permalink)
VanDriver
Jackson, MS
 
Posts: 34 since Dec 2015
Thanks Given: 1
Thanks Received: 5

Your scan criteria can be selected in the stock hacker scanner by adding each criteria and using the wizard for finer adjustments. Several videos are on YouTube or Read more about it at the online manual.

https://tlc.thinkorswim.com/center/howToTos/thinkManual/Scan/Stock-Hacker

Reply With Quote
  #3 (permalink)
 JayC 
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43


Here's what I came up with, but this could use some testing. Please let me know if this is what you were looking for or if you need help setting it up.

Jay

WithinRange Scan Script



 
Code
input rangePct = 2;
input daysBack = 10;
input minVolume = 200000;

def recentHigh = Highest(high, daysBack);
def recentLow = Lowest(low, daysBack);
def recentVolume = Average(volume, daysBack);

def pctFromHigh = close / recentHigh - 1;
def pctFromLow = close / recentLow - 1;


plot result = -1 * pctFromHigh <= rangePct / 100 and 
                   pctFromLow <= rangePct / 100 and 
                   recentVolume > minVolume;

RecentRange Chart Study
This is a chart study that draws the recent high and low lines based on the days back input. There's also a label that shows the percent from high and low along with the average volume. If they are within range, then the label is colored green, otherwise red.



 
Code
input rangePct = 2;
input daysBack = 10;
input minVolume = 200000;

def lastBar = !IsNaN(open) and IsNaN(open[-1]);

def recentHigh = if lastBar then Highest(high, daysBack) else Double.NaN;
def recentLow = if lastBar then Lowest(low, daysBack) else Double.NaN;
def recentVolume = if lastBar then Average(volume, daysBack) else Double.NaN;

plot highPlot = HighestAll(recentHigh);
plot lowPlot = LowestAll(recentLow);

def pctFromHigh = close / recentHigh - 1;
def pctFromLow = close / recentLow - 1;

AddLabel(yes, 
 "FromH: " + AsPercent(pctFromHigh) +
 " FromL: " + AsPercent(pctFromLow) +
 " AvgVol: " + recentVolume,
if -1 * pctFromHigh <= rangePct / 100 and 
   pctFromLow <= rangePct / 100 and 
   recentVolume > minVolume
then Color.GREEN else Color.RED);

Reply With Quote




Last Updated on February 10, 2021


© 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