Click here to Login





                                                   How do you go to cash in a simulation?

  0

0
Chaim6
2014-09-15 23:24:30


How can I go to "cash" (i.e. TLT) if the highest ranked ETF in my system is below it's moving average?

Here is the relevant code from the simulation:

r = Close/Close[63]-1;
SetSimLongRank(r);
timing = Close < SMA(200);
cashFund = StringEqual(Name(), "TLT");
Buy = Iff(timing, cashFund, !cashFund);

Obviously this code doesn't do the job. How can I modify it to go to TLT if the *highest* ranked symbol is below its moving average?

Thanks.



QuantShare
2014-09-16 05:11:58

  0

Note that QS formula is executed individually for each symbol.
If you need a rule or something that interacts between several symbols then you must use the money management script.



Chaim6
2014-09-16 15:01:29

  0

Thanks. After thinking it over, one workaround that should work before using the money management script (which is still a bit intimidating for me) is to use the Comp with Percentile, manually set the rank for the cash ticker to a lower number, and pick the and filter for the SMA rule if the ticker != cash.

EDIT:

cashFund = StringEqual(Name(), "TLT");
// IsNA() is a custom function that replaces all NAs in a vector with the second parameter
r = IsNA(Comp(Close[0]/Close[63]-1, "Percentile!", 1, 1, "AAA;BBB;CCC;DDD"), -1);
SetSimLongRank(r);
Buy = Close > SMA(P_SMA) || cashFund;

This seems to work. I am doing some more testing to verify it.



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
How far are the close prices from the support line
Invest Available Cash In a Security
PEG and Price to Free Cash Flow above Market Averages
Interest Rates Historical Data for Australia - Interbank and Targ...
ETF Number of securities, percent stock and cash - Historical Dat...

How-to Lessons
How to generate buy/sell signals from a trading system
How to draw distances on a chart?
How to dynamically update the settings of an indicator
How to create histogram charts
How to create a mobile database/account

Related Forum Threads
How do you retrieve the entry and exit price for a position?
How do you lag fundamental data?
how do you check if the price data is up to date?
how do you restore it to default settings
How do you check for NaN?

Blog Posts
Let me Show You How to Create Hundreds of Profitable Trading Syst...
How to get buy and sell orders for a portfolio based on a trading...
Fundamental analysis: How to track economic indicators in the For...
How to Backtest Each Stock or Asset Individually
How to Create a List of Ticker Symbols









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.