Click here to Login





                                                   Conditional Buy/Sell

  0

0
Jeff D
2014-01-18 11:37:40


Trying to do a conditional buy where if the stock is above its ema(20) then buy otherwise buy SPY. This works fine (buy = (res <= 1) and newmonth;) so i'm just tryning to add the ema filter.


Here are just the lines I'm not sure of:

1. Can I assign a symbol to cahs in this way?

2. Is conditional in this way feasible?

cash = "SHY";
mafilter = close > ema(20);

buy = iff(mafilter==1, (res <= 1) && newmonth, cash);


Thanks guys.



QuantShare
2014-01-18 11:48:12

  0

Best Answer
It doesn't work that way.

In the trading system symbols, add one or several stocks then add SPY.

Type the following formula:

isSPY = StringEqual(Name(), "SPY");
mafilter = close > ema(20);
buy = iff(mafilter, (res <= 1) && newmonth && !isSPY, isSPY);




Jeff D
2014-01-18 13:53:09

  0

Perfect. Thanks.


Kiran
2016-02-10 20:37:25

  0

This logic works if there are only 2 stocks SPY and the other.
How do we implement logic in a simulation of 20 positions, where in each position, it buys the stock if Condition is met, else it buys SPY for each position?



QuantShare
2016-02-11 02:59:27

  0

The simulation formula is run for each security. For each run, it checks the security close price and compares it with the moving average.
So the logic works with any number of positions.



Nuno
2016-06-11 08:37:11

  0

What is "res"?


QuantShare
2016-06-11 10:43:04

  0

"res" is a simple variable (like isSPy and mafilter) used by "Jeff D". He did not specify how that variable was calculated.


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
Analyst Rating (Yahoo Historical Buy/Sell Recommendations)
Yahoo Historical Buy/Sell Recommendations
Translation into Binary Buy/Sell
Conditional Trailing Stop Exit 2013-10-18
Percentage of Bars a Trading rule Generates Buy/Sell Signals

How-to Lessons
How to generate buy/sell signals from a trading system
How to quickly select stocks based on the last value of a databas...
How to create histogram charts
How to create a composite index/indicator
How to create and trade a Neural Network model

Related Forum Threads
Late portfolio buy/sell signals
conditional color not working
Buy/Sell order types w/Simulator
How is buy/sell price calculated when running a backtest?
Conditional count countif to determine avg analyst rating

Blog Posts
Synchronize Buy/Sell List of Rules in the Trading System Optimize...
Programming skills are not that important
How to Create a Custom Real-Time Table using QS Trading Software
Let me Show You How to Create Hundreds of Profitable Trading Syst...
The Ultimate Guide to Create Trading Systems in QuantShare









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.