Click here to Login








Market trading rules

by bug man, 5431 days ago
Share |






This function accepts a list of rules and an index as parameters and returns a rule for the specified index.
The Market trading rules function can be very useful when applied in an optimization or backtesting process. Imagine you have a trading system and you would like to test different exit strategies. You first need to compile a list of rules that will be used as exits.
Let us say, these are your exit rules:
rsi(14) < 30
roc(close, 2) < -10
sma(volume, 30) < sma(volume, 10)
close < ref(close, 1) && ref(close, 1) < ref(close, 2)

And this is your trading system:
buy = sma(30) > sma(14) && roc(close, 20) < -10 && roc(close, 2) > 3;
sell = ??

Because you have four exit rules, you would like to test four strategies. You can of course create a trading system for each exit rule or you can use this market trading rules function and only one trading system to accomplish the same result. The usefulness of this function may not seem obvious with this example, however if you had more than 20 exit rules to test then this function will save you a lot of time.
Here is a trading system based on the market trading rules function:
Optimize("varindex", 0, 3, 1);
buy = sma(30) > sma(14) && roc(close, 20) < -10 && roc(close, 2) > 3;
sell = rules_select("rsi(14) < 30;roc(close, 2) < -10;sma(volume, 30) < sma(volume, 10);close < ref(close, 1) && ref(close, 1) < ref(close, 2)", varindex);

When you optimize this strategy, the variable 'varindex' will varies from 0 to 3 and this in turn will create 4 strategies.

You can also use this function to create more variations and combinations. Instead of using the function once, you can use it several times, each time with the same rules or different ones. This will create several combinations.
Example:
Optimize("varindex1", 0, 2, 1);
Optimize("varindex2", 0, 1, 1);
s1 = rules_select("rule1;rule2;rule3", varindex1)
s2 = rules_select("rule4;rule5", varindex2)
sell = s1 || s2;

The above example will create six strategies. You can calculate the number of combinations by multiplying the number of iterations in every function (3 * 2 = 6).
Here is the list of all the generated trading rules combinations:
sell = rule1 || rule4;
sell = rule1 || rule5;
sell = rule2 || rule4;
sell = rule2 || rule5;
sell = rule3 || rule4;
sell = rule3 || rule5;

The rules passed to the Market trading rules function must be separated by a semi-colon and must be entered as a string (between quotes).


Share This ->
Share |


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




Type: Trading Indicator

Object ID: 326


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

Stock split & dividend

Survivorship bias

Transaction Costs

How scripts communicate with each other

How to simulate options strategies

Organizing Trading Objects

Creating a download item: Initial Jobless Claims

How to search for a download item

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.