Click here to Login








Combination Element from Lexicographical Index

by QuantShare, 4924 days ago
Share |






The current algorithm calculates the mathematical combination element given the lexicographical index. The function gets several string values separated by a semi-colon, a value to test, the number of values per combination and the combination index (or what is called lexicographical index).

To understand the usefulness of this function, here is an example that lets you test several stock combinations. The function returns 1 or TRUE if a specific stock or ETF symbol is found in a combination element, otherwise it returns 0 or FALSE.
- The values to be passed to the function are A;AA;B;C;GOOG;MSFT;AAPL (Stock symbols separated by a comma)
- The value to be test is the current stock symbol (The stock that is currently tested in the analyzer, simulator or screener). To get the current stock symbol, we use the function: Name()
- The number of values per combinations (K) is set to 3

Given a K value of 3 and an N value of 7 (7 stock symbols passed in the first argument of our function), the total number of combinations is: 35

Combination 0: A;AA;B
Combination 1: A;AA;C
Combination 2: A;AA;GOOG
....
Combination 34: GOOG;MSFT;AAPL

By passing a lexicographical index of 34, the function calculates the combination string (GOOG;MSFT;AAPL) and tests whether the stock symbol provided in the second argument of our function is included in this string. In case we are analyzing Citigroup Inc. (C), the response is no and the trading function returns 0.

If we vary the lexicographical index from 0 to 34, we can test all stock names combinations. In a trading system, the formula may look like this:

Optimize("lexindex", 0, 34, 1);
buy = CombinationIndex("A;AA;B;C;GOOG;MSFT;AAPL", Name(), 3, lexindex) == 1;


An example of using this function is to test a strategy that combines different ETF or Stock symbols to check which combination of assets perform best.

Note: You can get the total number of combinations by setting the lexicographical index to -1.

nb1 = CombinationIndex("A;AA;B;C;GOOG;MSFT;AAPL", Name(), 3, -1);
Optimize("lexindex", 0, nb1, 1);


Share This ->
Share |


You have to log in to bookmark this object
What is this?
Additional Information




Type: Trading Indicator

Object ID: 977


Country:
All

Market: All

Style:
Technical Analysis

Reviews
You must log in first

Join now
and get instant access for free to the trading software, the Sharing server and the Social network website.
Click here


Related objects

Empty

Number of reviews
Click to add a review
Average rate
Click to rate this item
Number of times this object was downloaded
Number of rates the current object received
Report an object
if you can't run it for example or if it contains errors
Click to report this object

Technical Analysis


Fundamental Analysis



Random Blog Posts

How to turn any ordinary trading strategy into a very profitable one

Charting & Scripts - Manage stock charts using the global script

Trading System: Buy Stocks based on their Sharpe Ratio Rank

Creating and managing notes for your stocks

How to Quickly Create Fundamental Scans

Download Trading Data using the Post-Script

Download Trading Data using the Pre-Script

Download Trading Data using the URL-Script

Show All

Number of reviews
Click to add a review
Average rate
Click to rate this item
Number of times this object was downloaded
Number of rates the current object received
Report an object
if you can't run it for example or if it contains errors
Click to report this object






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.