Click here to Login

LiveZilla Live Help
LiveZilla Live Help




                                                   Ratio Spread and C#

  0

0
allan nathan
2012-05-07 10:54:59


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?

Allan



QuantShare
2012-05-07 12:58:53

  0

Best Answer
"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;




allan nathan
2012-05-07 14:29:11

  0

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?

Thank you,

Allan




allan nathan
2012-05-07 16:33:26

  0

I should have been more specific.If I have a "formula" "RatioSpread",and I create a dynamic watchlist,can I simply add a column

addcolumn("ratiospread",ratiospread);

I gave tried and it does not work.




QuantShare
2012-05-08 05:27:16

  0

No, you cannot 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



allan nathan
2012-05-08 10:30:39

  0

hi,
I finally see what you are referring to!!!
The button to Load a Formula is exactly what I was looking for,but there is one problem.

Currently,when I select "Load File",a pop up box comes up asking if "Are you sure you want to replace the current formula?"

It appears one can not load a formula without deleting all other code.That defeats the purpose of being able to load a formula.

Can you please give us the option to load as many formulas as we like without deleting all previous formulas/rules??

Thanks,

Allan



QuantShare
2012-05-08 10:43:24

  0

Ok. It will be done in the next release.


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
S&P 500 Earnings and Price Earnings Ratio Estimations
Ratio of Stocks above and below Bollinger Bands
Standard Deviation Ratio
Market Composite Index based on the Sharpe Ratio
Kaufman's Efficiency Ratio (Fractal Efficiency)

How-to Lessons
How to plot put/call ratio of individual stocks
How to create trading rules based on Put and Call volume data
How to save and restore charts
How to plot the ratio of two stocks
Difference between the watchlist and the screener tools

Related Forum Threads
VIX Indicator and Put/Call Ratio Indicator for NSE NIFTY
Aggregate PEG Ratio for the S&P500 overall?
Sharpe ratio of backtest/simulation aapears to be too high
Best way to precompute a custom formula and store it
INTRADAY VERSION AND SIZE OF DATA BASE

Blog Posts
Sharpe Ratio - Part 2
Inverse Fisher Transform: Indicator, composite and trading system
Trading System Analysis: Backtesting report and custom measures
Reducing risk and increasing return by combining several trading ...
Fundamental Screen based on Stock price, ROI and Market capitaliz...









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