[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Correlation Matrix - code help .... GOT IT!



PureBytes Links

Trading Reference Links

You've got a type mismatch.  Foreign doesn't accept float numbers to be passed as the 2nd argument.  You've made a formula that you've put quotes around, mistakenly notifying Foreign() to NOT evaluate it as a mathematical formula but rather to accept it as a string of characters, i.e., as a written word.  Foreign's second argument does indeed require a string, but only certain strings referring to datafields, like: "open, low, close, O, L, C" etc.  Read the online docs here:

http://www.amibroker.com/guide/afl/afl_view.php?id=54

What's confusing for you is that AB didn't balk (though it should have!) at accepting such nonsense in the 2nd argument, and instead allowed it but treated it for some reason as "C".  That's why you got the same result from both ways.

Try this instead, off the top of my head.  Let me know if it works.

Var1 = ROC(Foreign(Ticker1, "C"), 1);

Regarding your second question: Correlation() doesn't (or at least shouldn't!) automatically convert prices to ROCs without being told to do so explicitly by you.  Rather, it should examine a correlation between two arrays of your choice, without trying to second guess what's in the arrays.

    -Paul

At 05:46 PM 3/5/2005, you wrote:

Var1 =

Foreign
(Ticker1, "C");

To this:

Var1 =

Foreign
(Ticker1, "ROC(C,1)");

I'm not a great programmer so I have two questions:  1.  is this the correct way of manipulating the foreign argument and  2.  is the original formula already correctly measuring the correlations by using ROC vs. closing price?


Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links