NexusFi: Find Your Edge


Home Menu

 





Custom field in the SCN for ATR for SPX


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,688 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?
CPI Eve: Fed Hike Odds Hold at 52% for the First Time, I …
Prediction Markets & Event Contracts
UCL Final Kicks Off at Noon ET: PSG at 56.5% as Iran May …
Prediction Markets & Event Contracts
Trump Media to sell instant access to market-moving soci …
Traders Hideout
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 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