Click here to Login





                                                   Buy-sell rules using a composite

  0

0
F Mazandarany
2010-12-13 12:54:05


I have created a composite called Nasdaq 52 week highs minus 52 lows (symbol is _NASDAQ_52WK_His_LOs). I want to use this composite using the MM script to optimize for buy-sell rules as follows:

Buy SPY when composite >a
Sell Spy when composite <b
So I would be optimizing for "a" and "b".

The script for the composite is:

highs= Ticker("^52-week-highs-nasdaq",close,zero);
lows= Ticker("^52-week-lows-nasdaq",close,zero);
composite=highs-lows;

Could you please create the MM script to do this?



QuantShare
2010-12-13 13:30:24

  0

Hi,

For this, you don't have to create a MM Script.

Simply type the following formula: (And select SPY in the simulation symbols)

nasdcomp = GetSeries("_NASDAQ_52WK_His_LOs", close) ;

// Buy rules
Optimize("a", 10, 100, 10);
Rule1 = nasdcomp > a;
buy = Rule1;

// Sell rules

Optimize("b", 10, 100, 10);
Rule2 = nasdcomp < b;
sell = Rule2;


Let me know if you need the MM Script.



F Mazandarany
2010-12-13 15:02:24

  0

Thanks, this works. I tried to add a second rule to buy and sell so that in addition to the composite condition, I must satisfy an sma condition, but I get errors. Here is what I did.

nasdcomp = GetSeries("_NASDAQ_52WK_His_LOs", close) ;

// Buy rules
Rule1 = nasdcomp > 0 and close>sma(200)*1.02;
buy = Rule1

// Sell rules

Rule2 = nasdcomp < -100 and close<sma(200)*0.98;

sell = Rule2;




QuantShare
2010-12-14 04:27:40

  0

Best Answer
Note that when you put this formula, the word "Rule2" is underlined.

This means that there is an error near this keyword and the error is that you forget to add the semi-colon after the "buy = Rule1".



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
Trading rules using the VIX Index
Market Volatility - Composite Indicator using Stocks Standard Dev...
Simple pattern detection rules using close and open prices
Trading Rules using Trend Indicators
Market Composite Index based on the Sharpe Ratio

How-to Lessons
How to create trading rules based on Put and Call volume data
How to filter stocks in a market composite
How to perform a basic quantitative analysis using the S&P 500
How to plot a stock using different periods in the same chart
How to calculate the average of a time series using the money man...

Related Forum Threads
Using Drawdown in sell rules
Buy and Sell rules combination in Optimizer.
Rules manager - comparing results - back testing vs rules analysi...
Composite tickers under custom database
Testing Rules with AI Optimizer

Blog Posts
Create a stock index or a trading indicator using the composite t...
How to create a trading system, screen and composite using earnin...
How to create market indicators using the composite function - Pa...
How to create market indicators using the composite function - Pa...
How to create market indicators using the composite function - Pa...









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.