Click here to Login





                                                   How do I simulate if then statements for the simulator?

  0

0
Bain
2013-01-22 00:23:43


I want to backtest a strategy with the following rules but I do not know how to program it into quantshare:

Daily Strategy:

Buy VXX Short VXZ if VXX/VXZ > 1.1; Close positions at end of day
Buy VXZ Short VXZ if VXX/VXZ < 0.9; Close positions at end of day






QuantShare
2013-01-22 09:41:26

  2

In "Symbols & Dates" tab, add VXX and VXZ symbols.
In the strategy formula, type:

a = GetSeries("VXX", close);
b = GetSeries("VXZ", close);
ratio = a / b;

buy = iff(stringequal(name(), "VXX") and ratio > 1.1, 1, 0);
short = iff(stringequal(name(), "VXZ") and ratio > 1.1, 1, 0);

buy = iff(stringequal(name(), "VXZ") and ratio < 0.9, 1, 0);
short = iff(stringequal(name(), "VXX") and ratio < 0.9, 1, 0);

For more advanced "if then" statements, you can either create a custom indicator or you can use the money management script.



Alpha Trader
2013-04-23 01:27:02

  0

I have a similar question. I'm trying to backtest a system that looks at SPY and IWM but with different parameters. I'd like to use the C# method of If in the simulator... or any other method..? Here's what I was hoping would work, but apparently it doesn't like the statement. Would the "Choose" Function work somehow?

if(Name()== %u201CSPY%u201D)
{
op0 = 80;
op1 = 50;
}

if(Name()== %u201CIWM%u201D)
{
op0 = 80;
op1 = 50;
}

Rule1 = (Close) > (SMA(Close,op0));
Rule2 = (Close) < (SMA(Close,op1));

buy = (Rule1);
sell = (Rule2);

Thanks!



Alpha Trader
2013-04-23 01:27:57

  0

- Correction -
if(Name()== %u201CIWM%u201D)
{
op0 = 200;
op1 = 200;

}



Alpha Trader
2013-04-23 01:29:12

  0

Full Correction -

if(Name()== "SPY")
{
op0 = 80;
op1 = 50;
}

if(Name()== "IWM")
{
op0 = 200;
op1 = 200;
}

Rule1 = (Close) > (SMA(Close,op0));
Rule2 = (Close) < (SMA(Close,op1));

buy = (Rule1);
sell = (Rule2);

Thanks!

Read more: http://www.quantshare.com/index.php?option=thread&tid=881&screen=0&toend=1&ref=04798256777107868#ixzz2REK3e6Yg
Follow us: @quantshare on Twitter



QuantShare
2013-04-23 10:01:48

  0

QS language doesn't support "if(...){...}". If you want to use C#, you will have to create a custom function or use the money management script.

With QS language, you can implement your strategy by typing:

op0 = iff(stringequal(name(), "SPY"), 80, 200);
op1 = iff(stringequal(name(), "SPY"), 50, 200);

Rule1 = (Close) > (SMA(Close,op0));
Rule2 = (Close) < (SMA(Close,op1));

buy = (Rule1);
sell = (Rule2);



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
Industry and Sector Information for the US Stock Market
The Best trading rules for the ADX technical indicator
Market Cap Historical Data for the US Stock Market
Stop Loss for the N-first Trading Bars only
Market Index for the Gold and Silver Industry

How-to Lessons
How to display the number of stocks per day for different RSI gro...
How to get stocks for a particular index using the global script
How to quickly download the most recent EOD data for your stocks
How to screen for stocks having a high correlation with the Dow J...
How to download earnings calendar data for various stocks

Related Forum Threads
How do you retrieve the entry and exit price for a position?
How do I find the close price for an entry matching a custom DB
How can I view signals rejected by the simulator?
Automatic screener for checking Equities against the index trend
How to browse and search the blog?

Blog Posts
How to download the history of dividend payments for stocks in th...
How to Select the Best Market Indicator for your Trading System
How to Scan for Parallel Resistance and Support Lines
How to use the new Market Regimes Feature in QuantShare Trading S...
Sentiment Analysis: How to measure the sentiment score of your st...









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 2020 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.