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 DaveDoggyDogg with 1 posts (0 thanks)
    4. looks_4 salander with 1 posts (0 thanks)
    1. trending_up 6,418 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

  #11 (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
Appreciate it, working on making the criteria now. That's hard. I'm getting an "at least one plot should be defined" error

change the def = to plot =

Visit my NexusFi Trade Journal Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #12 (permalink)
Avestro
Sherman Oaks California
 
Posts: 7 since Mar 2019
Thanks Given: 0
Thanks Received: 0


Massive l View Post
change the def = to plot =

Still having issues

1. Scan that looks for 200SMA not moving average but Simple Moving Average to be within x% of Ichimoku(). "Span A"

2. Scan that looks for wicks rejecting 200SMA

Reply With Quote
  #13 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 5,978 since Sep 2015
Thanks Given: 15,502
Thanks Received: 15,402


@Avestro

You have created three or more threads for the same issue. I am going to close all the others as duplicate.


Please do not create others or they will be considered junk posting which is against the site's terms.

Reply With Quote
  #14 (permalink)
DaveDoggyDogg
Los Angeles,CA USA
 
Posts: 16 since Mar 2017
Thanks Given: 0
Thanks Received: 7


Avestro View Post
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"

here you go, here is the complete code
to change the percent just change 0.10 to whatever percent you want. 0.10 defines 10%

 
Code
#Code Below price is within 10 Percent of 200SMA
#
def ma = SimpleMovingAvg(close,200);
def percent = ma*0.10;
plot scan = absvalue(close - ma) <= percent;

Reply With Quote
  #15 (permalink)
Nube
Minneapolis Minnesota
 
Posts: 24 since Jul 2019
Thanks Given: 0
Thanks Received: 13


Avestro View Post
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"


Reference this in the scanner. It will return if price is inside the desired percentage above or below the selected moving average


 
Code
declare lower;

input percentWithin = 10;
input price = close;
input length = 200;
input avgType = AverageType.SIMPLE;

def ma = MovingAverage(avgType, price, length);

plot WithinPercent = Between(price, 
                             ma * (1 - (percentWithin / 100)),
                             ma * (1 + (percentWithin / 100)));

Reply With Quote
  #16 (permalink)
 salander 
orlando+florida/unitedstates
 
Experience: Intermediate
Platform: TS, TOS
Broker: TS, TDA, TW
Trading: Micros, Options
Posts: 15 since Jan 2019
Thanks Given: 12
Thanks Received: 5

I need a similar study that shows a user-defined percentage band around the price bars itself?



Nube View Post
Reference this in the scanner. It will return if price is inside the desired percentage above or below the selected moving average


 
Code
declare lower;

input percentWithin = 10;
input price = close;
input length = 200;
input avgType = AverageType.SIMPLE;

def ma = MovingAverage(avgType, price, length);

plot WithinPercent = Between(price, 
                             ma * (1 - (percentWithin / 100)),
                             ma * (1 + (percentWithin / 100)));


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