Click here to Login





                                                   How do you check for NaN?

  1

0
Stefan Kroscen
2012-10-14 03:10:02


What is the proper way to check if the current bar is NaN?


Thanks!



QuantShare
2012-10-15 10:54:29

  0

Best Answer
Let us say, you want to detect NaN bars for the variable "a".

b = (a != a);



Kiran
2016-06-23 00:18:14

  0

This doesn't seem to work - i'm passing atr(50) to a Function that expects a number and it flat-lines. So, i tried to plot this logic on a chart and it doesn't plot b for the first 50 bars because atr(50) doesn't exist.

b = iff((atr(50) != atr(50)),5,3*atr(50));
Plot(b, "ATR50: ", colorBlue,ChartBar);

How do i say either
- for first 50 bars, use a hard number (say 3), else use atr(50) OR
- for bars where atr(50) doesn't exist, use a hard number else use atr(50)



Kiran
2016-06-23 14:45:02

  0

I tried this below so i have a valid non-NaN value for b in the first 50 bars - however, the plot still shows NaN for first 50 bars and shows ATR(50) after. Why isn't the iff condition working?

b = iff(sum(1)<51,1, atr(50));
Plot(b, "ATR50: ", colorPurple,ChartBar);



QuantShare
2016-06-23 19:37:00

  0

Use this instead:

b = iff(sum(1)<51,1, NaNtoZero(atr(50),0));
Plot(b, "ATR50: ", colorPurple,ChartBar);



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Industry and Sector Information for the US Stock Market
High to low stock pattern for the close price
EOD Data for Muscat Securities Market
Average Stock Performance for each U.S Exchange
Historical Earnings Calendar Data for U.S. Stocks - Date/Time and...

How-to Lessons
How to download earnings calendar data for various stocks
How to quickly download the most recent EOD data for your stocks
How to download EOD quotes for active and valid stocks only
How to download historical EOD data for penny stocks
How to get fundamental data for U.S. Stocks

Related Forum Threads
how do you check if the price data is up to date?
How do you retrieve the entry and exit price for a position?
How do I find the close price for an entry matching a custom DB
May Quantshare check "Intraday Data for US Stocks" conn...
How to adjust for splits in QS

Blog Posts
How to download the history of dividend payments for stocks in th...
Let me Show You How to Create Hundreds of Profitable Trading Syst...
How to Download Trading Data for Certain Securities Only
How to Scan for Parallel Resistance and Support Lines
Step by step on how to get free realtime/delayed data for stocks,...









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.