Click here to Login








Choose function

by Tom Huggens, 5510 days ago
Share |






The 'Choose' function is a small piece of code that returns a vector given an index. The function accepts six parameters, the first one is the index and it is used to select one the next five parameters. The others parameters accept any numeric vectors.

Example:
a = rsi(14);
b = rsi(14) > 50;
c = rsi(2);
d = rsi(360);
e = month() == 4;
i = 0;
f = choose(i, a, b, c, d, e);

Depending on the value of 'i', the function 'choose' will return one the following vectors: a, b, c, d or e.

The function can be very useful for optimization purpose. Suppose you have a trading system with its own buy and sell rules and you want to optimize one buy rule. You already have another five rules and want to see which one is the best. By adding, the five rules into the simulator and define an optimizable variable that varies from 0 to 4. You can easily create five trading systems and assess the performance of each one.

Another example is when using the neural network model. This function can be useful in case you want to create an input that is different for each symbol.

Here are the steps to follow if you want one more parameter to the function (You can add as many parameters as you want):
- Open the 'Custom Functions' editor
- Select 'Choose' function and click on 'Add a parameter', set the variable name to var5.
- Update the 'nbvars' variable. It must have a value of six.
- At the end of the conditional statement, add the following code:

else if(_index == 5)
{
result = var5;
}


Share This ->
Share |


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




Type: Trading Indicator

Object ID: 207


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

Introduction to the trading rules analyzer

Sharpe Ratio - Part 2

Sharpe Ratio - Part 1

How to speed up quotes and news downloads

The 'inside period' function

How to use date components in your trading rules

Quantshare version 1.4

Programming skills are not that important

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.