trading with conditions based on index oversold / overbought
Author: trade4more
Creation Date: 9/12/2008 7:41 AM
profile picture

trade4more

#1
I created a rule based strategy. Can I add a condition that checks the overbought/oversold level of a index if I am trading a stock in that index? For instance if I am going long on stock xyz I would like to also check if the .spx daily CMO (and possibly check if the weekly or monthly CMO is rising) is rising above -40 or not above +40 or has been above +40 for 2 days? I have a feeling that I can not do it in a rule based strategy so is there an example of code that could be added to a strategy?
profile picture

Cone

#2
There are some simple "External Symbol" wizard conditions, but to get the indicator of an external symbol, you need to code it yourself. See DataSeries > Accessing Secondary Symbols in the WealthScript Programming Guide.
profile picture

trade4more

#3
Thanks, Still have some issues. I'm not sure if I actually want to do this but for testing at this point.

I created the below:

CODE:
Please log in to see this code.


But now I don't know how to reference the external symbol for the BuyAtMarket where I want the spx CMO below 40 but greater than 0 and rising.

So the buy for the symbol if it has crossed over -50 on the CMO is something like this:
if (CrossOver(bar, CMOSeries_3, -50.00))

Than check the status of the CMO .spx secondary and make sure it meets the criteria I want it at. Is it spxBarsCMO and if so how would I code it?

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

Eugene

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

trade4more

#5
It works for the longs!!!, but tried to edit for the shorts and it doesn't do it. I tried to reverse the logic but dont' quite understand the Syntax I get a Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Here is the code,
CODE:
Please log in to see this code.
profile picture

Eugene

#6
My try:
CODE:
Please log in to see this code.
profile picture

trade4more

#7
I'm not quite sure if I understand this one line, could you explain what it does?

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

Eugene

#8
Highlight the indicator's entry (CumDn) in the Indicators list and click the "More info" link.
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).