Run Buy Codes When SPX in MACD Crossover Territory; Sell When SPX in MACD Crossunder Territory?
Author: swuzy
Creation Date: 7/14/2010 5:38 PM
profile picture

swuzy

#1
Could you please help me with coding a strategy to execute my Buy code when the .SPX's MACD is in crossed over territory, and to sell all multiple open shares when the .SPX's MACD is in crossed under territory? Thanks.
profile picture

Eugene

#2
Start by checking out:

*DataSeries > Accessing Secondary Symbols > How to: Access DataSeries of Secondary Symbols in the WealthScript Programming Guide and
* GetExternalSymbol in the QuickRef.

Here are a few threads containing code samples or pointers to help you out with accessing secondary symbol's data:

Basketing / Indexing - Applying Strategy to collective price action versus individual symbols
how to do GetExternalSeries in WL.net
How to add a comparative index...like .spx...to a symbol chart to see if,for exaple, a sentiment symbol, offers good signals for entries and exits.

Selling all open shares is accomplished by passing Position.AllPositions as a Position object when exiting; example:
CODE:
Please log in to see this code.
profile picture

swuzy

#3
Hi,
I have no idea what I am doing, and this will show in my non-working effort below:

CODE:
Please log in to see this code.

profile picture

Eugene

#4
CODE:
Please log in to see this code.
profile picture

swuzy

#5
Ah! That is clear and flows nicely. Thanks very much, Eugene, for your kind help.