#twitter-follow { border: 0;position: fixed; top: 240px; left:0;} #live-support { border: 0;position: fixed; top: 370px; left:0;} #knowledge-base { border: 0;position: fixed; top: 170px; left:0;}

 How do I refer to the close price of another symbol in a formula? 0

 Stefan Kroscen 2010-07-19 22:23:38 I am trying to write a formula that uses another symbol as a reference. I am not sure how to look up the close price of that other symbol. Is there a method that does that? My specific problem is that I would like to revise the chande_trendscore to take a symbol as an arguement. result = cFunctions.CompileFormula("a = iff(close>=Ref(close,11),1,-1)+iff(close>=Ref(close,12),1,-1)+iff(close>=Ref(close,13),1,-1)+iff(close>=Ref(close,14),1,-1)+iff(close>=Ref(close,15),1,-1)+iff(close>=Ref(close,16),1,-1)+iff(close>=Ref(close,17),1,-1)+iff(close>=Ref(close,18),1,-1)+iff(close>=Ref(close,19),1,-1)+iff(close>=Ref(close,20),1,-1);").GetVectorDouble("a"); Thanks!
 QuantShare 2010-07-20 05:14:38   1 Best Answer Hi Stefan, To get the close price of another symbol you can use the GetSeries function. GetSeries("symbol", close) To optimize the above formula, do not replace "close" by the getseries function. Add a new variable "b" for example and replace "close" by "b". result = cFunctions.CompileFormula("b=GetSeries('" + symbol_parameter + "', close); a = iff(b>=Ref(b,11),1,-1)+iff(b>=Ref(b,12),1,-1)+iff(b>=Ref(b,13),1,-1)+iff(b>=Ref(b,14),1,-1)+iff(b>=Ref(b,15),1,-1)+iff(b>=Ref(b,16),1,-1)+iff(b>=Ref(b,17),1,-1)+iff(b>=Ref(b,18),1,-1)+iff(b>=Ref(b,19),1,-1)+iff(b>=Ref(b,20),1,-1);").GetVectorDouble("a");
 Stefan Kroscen 2010-07-20 15:34:47   0 Thanks for your prompt response!
 Stefan Kroscen 2010-07-20 18:41:56   0 Actually, I shouldn't have closed this issue so quickly... There is still a problem... when you pass symbol_parameter this way and compile the function, it compiles ok but does not work as expected. The value passed at runtime is not seen when the function runs. Is that because it is being concatenated into the string instead of passed as a parameter? Should QSFormula.SetParameter be overloaded to accept VectorS? It currently only accepts VectorD so I can't test to see if that would fix the problem.
 QuantShare 2010-07-21 03:35:12   1 Did you get the first or any value of the symbol parameter? The parameter that is passed is a String Vector. Also do not forget the single quote before and after the double quotes. -> "b = GetSeries(' " + symbol[0] + " ', close);" Let me know if this fixed your problem
 Stefan Kroscen 2010-07-21 09:00:12   0 That was the problem, thanks again!
No more messages