NexusFi: Find Your Edge


Home Menu

 





Price within 10% of 200sma? ThinkScript


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one Avestro with 7 posts (0 thanks)
    2. looks_two Massive l with 5 posts (2 thanks)
    3. looks_3 xplorer with 1 posts (0 thanks)
    4. looks_4 simonxda with 1 posts (0 thanks)
    1. trending_up 6,425 views
    2. thumb_up 2 thanks given
    3. group 6 followers
    1. forum 15 posts
    2. attach_file 0 attachments




 
Search this Thread

Price within 10% of 200sma? ThinkScript

  #1 (permalink)
Avestro
Sherman Oaks California
 
Posts: 7 since Mar 2019
Thanks Given: 0
Thanks Received: 0

Price within X percent of 200sma?

So I am working on a project where I need to add a custom study in my scan that will scan for stocks that have closes within (whatever %) of the 200sma.

I've tried to write it out visually here for those who want to see it

Close is within 10% of SimpleMovingAvg("length") = 200)."SMA"

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
How to apply profiles
Traders Hideout
 
  #2 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106

I use a chart label but you can turn it into a scan

AddLabel(yes, AsPercent((close - sma200) / sma200), if close > sma200 then color.green else color.red);

Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
Avestro
Sherman Oaks California
 
Posts: 7 since Mar 2019
Thanks Given: 0
Thanks Received: 0



Massive l View Post
I use a chart label but you can turn it into a scan

AddLabel(yes, AsPercent((close - sma200) / sma200), if close > sma200 then color.green else color.red);

How would I turn it into a scan where I can look for stocks that are within 10% of it

Reply With Quote
  #4 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106


Avestro View Post
How would I turn it into a scan where I can look for stocks that are within 10% of it

define it as a variable

Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
Avestro
Sherman Oaks California
 
Posts: 7 since Mar 2019
Thanks Given: 0
Thanks Received: 0


Massive l View Post
define it as a variable

I have literally no coding experience, would you mind posting it here?

Reply With Quote
  #6 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106


Avestro View Post
I have literally no coding experience, would you mind posting it here?

I didn't have coding experience either. I'm trying to help you learn.

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
Avestro
Sherman Oaks California
 
Posts: 7 since Mar 2019
Thanks Given: 0
Thanks Received: 0


Massive l View Post
I didn't have coding experience either. I'm trying to help you learn.

Come on, Please? Or a scan that scans for wicks rejecting the 200sma

Reply With Quote
  #8 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106


Massive l View Post
I use a chart label but you can turn it into a scan

AddLabel(yes, AsPercent((close - sma200) / sma200), if close > sma200 then color.green else color.red);


 
Code
input price = close;
input length = 200;

def sma = Average(price, length);
def sma_scan_value = ((close - sma) / sma);
Your scan criteria would then be sma_scan_value = .1

I recommend making a set of criteria. <=.1 and >.15 or whatever so you have a range otherswise you'll only get stocks when they hit the absolute value of 10%.

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #9 (permalink)
Avestro
Sherman Oaks California
 
Posts: 7 since Mar 2019
Thanks Given: 0
Thanks Received: 0


Massive l View Post
 
Code
input price = close;
input length = 200;

def sma = Average(price, length);
def sma_scan_value = ((close - sma) / sma);
Your scan criteria would then be sma_scan_value = .1

I recommend making a set of criteria. <=.1 and >.15 or whatever so you have a range otherswise you'll only get stocks when they hit the absolute value of 10%.

Appreciate it, working on making the criteria now. That's hard. I'm getting an "at least one plot should be defined" error

Reply With Quote
  #10 (permalink)
Avestro
Sherman Oaks California
 
Posts: 7 since Mar 2019
Thanks Given: 0
Thanks Received: 0



Massive l View Post
 
Code
input price = close;
input length = 200;

def sma = Average(price, length);
def sma_scan_value = ((close - sma) / sma);
Your scan criteria would then be sma_scan_value = .1

I recommend making a set of criteria. <=.1 and >.15 or whatever so you have a range otherswise you'll only get stocks when they hit the absolute value of 10%.

I've also thought about it, How can I make it so that the scan shows when the 200sma is within X percent of Ichimoku()."Span A" then that'd be perfect

Reply With Quote




Last Updated on December 7, 2019


© 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