Click here to Login

Trading Software Trading objects Features How-to Blog Search


                                                   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
Measure the value of the stock market using the Q-Ratio valuation...
Indicator/Price Value on a Specific Trading Date
Market Timing Rules - Used to construct profitable trading strate...
Horizontal Line - Changes by Value and Percentage

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
Indicator - forward bar value
"perf" used in script
MODIFICATION REQUIRED TO FORTFOLIO
Buy/Sell order types w/Simulator

Blog Posts
Ranking System Engine
Trading System: Buy stocks with the highest Sharpe ratio
Custom Indicator: Relative Strength
Day Trading: A trading system that combines intraday and EOD data
Basic trading system implemented using the money management tool









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 © 2012 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items