NexusFi: Find Your Edge


Home Menu

 





Custom field in the SCN for ATR for SPX


Discussion in ThinkOrSwim

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




 
Search this Thread

Custom field in the SCN for ATR for SPX

  #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?
Strategy stop orders partially filled
EasyLanguage Programming
Negative Balance Protection
Brokers
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Is there a way to simulate CONTINUOUS CONTRACT?
NinjaTrader
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Funded Trader platforms
62 thanks
Spoo-nalysis ES e-mini futures S&P 500
16 thanks
GFIs1 1 DAX trade per day journal
15 thanks
The Trading Pit "Futures VIP" Account Journal
15 thanks
Trading with Intuition
14 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


© 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