Click here to Login





                                                   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
Large Block Ratio Indicator
S&P 500 vs. Stock Volatility Ratio

How-to Lessons
How to plot put/call ratio of individual stocks
How to save and restore charts
How to plot the ratio of two stocks
How to create trading rules based on Put and Call volume data
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
Is it possible to make a spread chart with futures contracts?
Set Global variable and running calculation Functions in MM scrip...

Blog Posts
How to Calculate and Display the Bid/Ask Spread on a Chart
Sharpe Ratio - Part 1
How To Create and Backtest an S&P 500 Trend Following System
Fundamental Stock Analysis: Rank stocks based on a valuation rati...
Trading System Analysis: Backtesting report and custom measures









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 © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



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.