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");
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.
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.
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.