NexusFi: Find Your Edge


Home Menu

 





Custom field in the SCN for ATR for SPX


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
 sunilnpendse 
Cypress Tx
 
Experience: Intermediate
Platform: NinjaTrader ThinkorSwim
Trading: Stock Futures
Posts: 3 since Sep 2016
Thanks Given: 2
Thanks Received: 0

Hi all, I am new to coding on Think or swim. But trying to create a scan for stocks. I have got hand of how to create scan and add filters for stocks, studies. But I need another filter where I need to add ATR value for SPX into my scan. How do I add a custom field that will show ATR value of SPX?

I have tried below code but it does not calculate for SPX?

input symbol = "SPX";
declare upper;
input length = 9;

input price = close;
input ATR_Length = 14;
input Show_Labels = yes;
def ATR = hullMovingAvg(TrueRange(high(period = AggregationPeriod.DAY)[0], close(period = AggregationPeriod.DAY)[0], low(period = AggregationPeriod.DAY)[0]), ATR_Length);
#Def ATRRatio = ATR/100;
AddLabel(yes, AsText((ATR) / 100, NumberFormat.Three_DECIMAL_PLACES));
#plot myindicator = ATRRatio;

Please advice,
Thanks...Sunny


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Hormuz Surges From 14% to 26.5% Intraday as Irans Answer …
Prediction Markets & Event Contracts
After $87M Settles NO: Irans Nuclear Redline Sets Up the …
Prediction Markets & Event Contracts
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
CFTC Workforce Shrinks 24% to 15-Year Low While Predicti …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #2 (permalink)
AnyDozer
Novosibirsk, Russia
 
Posts: 11 since Apr 2018
Thanks Given: 6
Thanks Received: 4

it should work

def ATR = hullMovingAvg(TrueRange(high(period = AggregationPeriod.DAY, symbol = symbol)[0], close(period = AggregationPeriod.DAY, symbol = symbol)[0], low(period = AggregationPeriod.DAY, symbol = symbol)), ATR_Length);


Reply With Quote
Thanked by:
  #3 (permalink)
 sunilnpendse 
Cypress Tx
 
Experience: Intermediate
Platform: NinjaTrader ThinkorSwim
Trading: Stock Futures
Posts: 3 since Sep 2016
Thanks Given: 2
Thanks Received: 0


AnyDozer - Thanks a lot. Your answer helped me solve ATR calculation issue. But my code below is not taking CLOSE of SPX. It is selecting CLOSE of security in the line this is being calculated in the SCAN.

How do I select CLOSE of SPX?


Started this thread Reply With Quote
  #4 (permalink)
AnyDozer
Novosibirsk, Russia
 
Posts: 11 since Apr 2018
Thanks Given: 6
Thanks Received: 4

input symbol = "SPX";
def price = close(symbol = symbol);


Reply With Quote
Thanked by:




Last Updated on October 12, 2018


© 2026 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 - Downloads - Top
no new posts