Click here to Login





                                                   Examining value used

  0

0
Peter Gum
2011-06-30 13:39:13


What are the differences in the way 'aday' is calculated? The first way calculates a value(s) close to the second way.
bday=Atr(7);
1) aday=Round(bday*3.0,2); // This never works.
2) aday=1.5; // This always works as expected.
var4 =AnotherFunction(aday,25) == 0; // This is where the value is used. It always fails (false) if the value is computed the first way. ('25' is a lookback value.)

I suspect is has to do with vectors, but how?

(I cannot find a way to enter a 'debug' mode that will let me step through a script (watchlist filter here) and look at how variable values change.)

Thanks. ~Pete



QuantShare
2011-07-01 07:31:34

  0

Best Answer
It fails certainly because in the function "AnotherFunction" you are using the first value of the "aday" variable which is NaN. (Atr returns NaN for the first N elements).

You can debug the script by ploting the vector it returns on a chart



Peter Gum
2011-07-01 10:16:36

  0

Thanks! That helps, but I wish there was a better way of helping myself. A better debugging methodology would certainly help. Plotting just that one vector doesn't seem like a good general approach [grin]. Indeed, I tried 'AddColumn("aday",aday)' to plot the result of the first computation and it showed a good result, not NaN. How do I reference that value in the computation? Index the vector, but with what index? Indexing with '[0]' doesn't work and 'ref(bday,0)' doesn't work.

~Pete



QuantShare
2011-07-02 05:21:15

  0

This is because "AddColumn" shows the last value (or the value for the specified bar)

Please send me your script to support@quantshare.com



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
Foreign Exchange Value of the Dollar - Nominal Indexes
Random Value for Each Trading Bar
PREV - Previous value of the same formula
Indicator/Price Value on a Specific Trading Date
Measure the value of the stock market using the Q-Ratio valuation...

How-to Lessons
How to quickly select stocks based on the last value of a databas...
How to create a screen
How to filter stocks in a market composite
How to plot arrows below/above candlesticks on a chart
How to plot the number of stock tweets per day

Related Forum Threads
Trailing stop value with Intraday data
Futures data - overwrites stock symbols, issues with point value
Indexing: First !NaN value w/o looping?
Compare an indicators current value to past values
Watchlist and adding a Value

Blog Posts
Stocks: Market Capitalization
How to Pick the Best Trend Indicators
Forecast volatility using trading rules and neural networks
The custom trading indicators tool explained
Optimize a trading strategy using the Sharpe ratio









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.