Backtesting using external symbol and index
Author: systemamfry
Creation Date: 8/11/2011 11:02 AM
profile picture

systemamfry

#1
My current backtest includes:

Buy when the price of an ETF crosses above its moving average.
And sell when the price of an ETF crosses below its moving average.

I want to change it to:

Buy a specific ETF when the price on an Index crosses above the EMA for the Index.
And sell a specific ETF when the price of an Index crosses below the EMA for the Index.

What do I need to do to accomplish this?

Thank you,
Matt
profile picture

Eugene

#2
Matt,

Are you working with rules or in code?
profile picture

systemamfry

#3
Rules
profile picture

systemamfry

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

Eugene

#5
Unless Cone agrees to add these rules to Community.Rules, I guess you're out of luck with using rules.

QUOTE:
Buy a specific ETF when the price on an Index crosses above the EMA for the Index.
And sell a specific ETF when the price of an Index crosses below the EMA for the Index.


Assuming that you want to change the primary Bars object to the ETF, below is an example...
CODE:
Please log in to see this code.

...to be run on any symbol. Things get really simple if the ETF exists in current DataSet:
CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).