Different up/dn strategy/dataset based on external symbol
Author: set2win
Creation Date: 11/28/2012 5:44 PM
profile picture

set2win

#1
Have a limited programming ability but that said I will layout my idea and maybe you can point me to an example or two.
Based on the Value Line Index (VAY on Fidelity)
If Vay close > VAY wma(30) AND VAY dpo > 0 considered as an Uptrend signal
Else it would be a Downtrend signal
One other signal would be to note if this is a trend reversal by comparing to previous trading day condition:
Perhaps something like:
CODE:
Please log in to see this code.

Now based on that signal:
1. Uptrend I would like to execute a certain strategy against a certain dataset.
ie Active Trader 2012-12 WLMA with dataset based on SP 500
2. Dntrend ie Active Trader 2012-12 WLMA with a different dataset based on Contra ETF's
So in essence its using the same strategy but two different datasets ( I don't know how to specify in the strategy the two datasets to choose from.)
3. If trend is changing to sell all shares next day prior to buying into the next trend.

I tried to review several existing strategies but none seem to accomplish what I want.

My struggle seems to be with incorporating the VAY symbol to determine the trend in with the loop for the dataset.
profile picture

Cone

#2
It would be easiest (I think) to create two strategies with the slightly different rules and combine them in a Combination Strategy, selecting the appropriate DataSet for each version of the strategy.
profile picture

set2win

#3
I think that is true but I am having problem just creating the rules.
Using the example of the WLMA strategy that is in Wealth labs Counter Trends., how do I incorporate the VAY signal to determine if the "for loop" should run?
the things I tried don't seem to activate the dataset (Object reference not set to an instance of an object)
CODE:
Please log in to see this code.

how to setup a for loop that decides to run the for loop for the WLMA code
is it a loop inside a loop?
profile picture

Eugene

#4
As Cone suggests, you really should consider Combination Strategies. This is by far the easiest way of running a multi-system multi-portfolio backtest. Note: it's not a "Rule-based strategy" we're talking about.

You need to create two copies of the Strategy (be it the AT Mag WLMA or whatever). Define your vayBars (and the rest from 11/28/2012 6:18 PM) before the trading loop starts, then insert "bool UpTrend..." after it has started. Here's an excerpt:
CODE:
Please log in to see this code.

In the 2nd copy, if I understood your "else it would be downtrend" correctly, change the filter this way:
CODE:
Please log in to see this code.

Now, User Guide > Strategy Window > Combination Strategy will light up your way. Add these two saved Strategies to a Combo Strategy, specify appropriate DataSets, the position sizing, and you're ready to go.
profile picture

set2win

#5
So for the Up Trend this is code I got with added check of the previous days trend, if the trend changed I want to exit all positions of the previous trading strategy.
Thanks for your help, Eugene.
I think it's working but look it over one more time to make sure it is doing the intended task.


CODE:
Please log in to see this code.


and the Down trend has this code change:


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

Eugene

#6
Appears OK on the surface (disclaimer: I didn't test it).
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).