Hi,I have no experience coding,but wanted to try creating a custom function using C#.The formula I was trying to create is the formula RatioSpread,which is
symbol1 = "spy";
op1 = close / GetSeries(symbol1, Close);
I tried
VectorD close = cFunctions.Close;
VectorD symbol1= TA."spy";
VectorD RS=TA.close/getseries(symbol1,close);
result=RS;
It doesnt work and I am stumped.I still dont quite understand what the purpose of "Formulas" are vs Functions.Other than plotting a "Formula" what can you
do with it???Can you reference it in a line of code?
"Formulas" are implemented in QuantShare language. They can be used in charts, screens, composites, trading systems...
"Functions" are implemented in C# and they can be used in "Formulas". This tool allows you to implement complex code so that you can use it later in a formula with a simple function call.
Here is the correct implementation of the RatioSpread:
VectorD close = cFunctions.Close;
string symbol1 = "spy";
VectorD symbol1Data = cFunctions.GetTimeframeData(symbol1, cFunctions.Timeframe, "close").ToVectorD();
VectorD RS= close / symbol1Data;
result=RS;
Thanks for the code.It appears that C3 is still beyond my caoabilities
I am still confused with Formula and implementing them
I understand that one codes with QS language in Formulas.That is no problem,and I have created many "formulas".What I dont understamd is how
they are implemented in trading systems,screens and I assume watchlists.
In the example above,I have a formula named "Ratiospread".I use it in Charting all the time.
symbol1 = "spy";
op1 = close / GetSeries(symbol1, Close);
If I am running a very simple dynamic watchlist and I want to add a column or filter,can I simply type in "Ratiospread"??
I have created watchlists with Relative strength,but I had to type in the above rules.I cant get it too function by simply typing in "ratiospread".
It appears that I should be able to according to what you wrote.How could I do that?
You should type the formula again or use the "Load Formula" option to load the formula from a file. (Click on the button above the formula control next to "Switch to ...").
If you want to use a function like "ratiospread", then you should create a custom function and use the code I have sent you above.
After that, you can type:
addcolumn("ratiospread",ratiospread()); // Do not forget the parentheses after typing the function name