Multi-time frame Strategy Coding
Author: tejas parekh
Creation Date: 3/15/2011 5:30 AM
profile picture

tejas parekh

#1
Can you please give me a complete code fragment for the following strategy :

Buy at market - if
1) DI+ is above DI- for more than one month
2) MACD is above Zero for more than one week
3) Last friday of the month
4) Fast moving average is above Slow Moving Average for more than one week

Sell at market - if
1) MACD crosses below zero
profile picture

Cone

#2
Doesn't do too well for the Dow 30, but works pretty well for AAPL :)
CODE:
Please log in to see this code.
profile picture

Eugene

#3
I thought since he's a trial user w/o access to Community.Indicators, an Extension-less version would be appropriate too (although it's not possible to do so in each case, just in this particular one):
CODE:
Please log in to see this code.
profile picture

Cone

#4
@Eugene:
touché on the IsLastFriday function.

I think the docs for the SeriesIsAbove/Below indicators needs to change. It states, for example, "Returns the number of bars that the Series1 has been above the Series2 over the most-recent Period bars." In reality, for SeriesIsAbove, for example, if Series1 has been above Series2 for the specified period, it returns the number of bars that it continues to be above following the period that it was already above. (I can't figure out a good way to say that.)

I guess it's too late to change those functions now, but I think it would be more straightforward to have an indicator that summed the number of bars that Series1 was above Series2, and it resets when Series1 crosses below Series2.
profile picture

Eugene

#5
Hi Robert,
Thank you. Please feel free to reflect your vision in the docs.
profile picture

Cone

#6
I think I see how it works. If you use a period of 1, it does what I expect. It just needs a better description, which I can't seem to put into words.

By the way, it's your version of the indicator!

By the way #2, our results for the scripts above are different.
profile picture

tejas parekh

#7
Thank you.

I require a strategy code for one more strategy.

The following conditions must be satisfied for all transactions


Strategy to be played on long side :

Condition 1 - Weekly adx is moving up, DI+ is above DI- and ADX is greater than 15.
Buy trigger - Buy when Daily MACD (e12 e26 e9)is giving Buy signal (i.e. crossing above trigger line)
Exit criteria - Exit (Sell) when daily MACD (e12 e26 e9)is giving SELL signal (i.e. crossing below trigger line)
Entry Stop to be placed at 3 days low including date of taking position.
There is no trailing stop to be used.
Buy or sell on the close of the same day when Buy signal or exit signal is generated.
In case of Entry stop, execute stop when the stop price is violated.

The exact opposite strategy is also needed where the condition would be :

Condn 1 - Weekly adx is moving up and DI- is above DI+ and ADX is greater than 15

Sell trigger - Sell when Daily MACD (e12 e26 e9)is giving sell signal (i.e. crossing below trigger line)
Exit criteria - Exit (Buy) when daily MACD (e12 e26 e9)is giving Buy signal (i.e. crossing above trigger line)
Entry Stop to be placed at 3 days high including date of taking position.
There is no trailing stop to be used.
Buy or sell on the close of the same day when Sell signal or exit signal is generated.
In case of Entry stop, execute stop when the stop price is violated.
profile picture

Eugene

#8
QUOTE:
I require a strategy code for one more strategy.

Looks like your requirements are pretty high for a trial user: as per our support policy, we will not do your programming for you because it's time consuming process and we cannot properly serve all of our customers by dedicating resources to a single user's solutions.

Here are some hints to aid in your strategy development:
QUOTE:
Condition 1 - Weekly adx is moving up, DI+ is above DI- and ADX is greater than 15.

CODE:
Please log in to see this code.

QUOTE:
Buy trigger - Buy when Daily MACD (e12 e26 e9)is giving Buy signal (i.e. crossing above trigger line)
Exit criteria - Exit (Sell) when daily MACD (e12 e26 e9)is giving SELL signal (i.e. crossing below trigger line)

Working from Daily scale, no further manipulations required. See the QuickRef for CrossOver and CrossUnder for general syntax and the Wiki for MACD online help (open the Indicators list, highlight MACD, click "More info" to visit the link.)
QUOTE:
Entry Stop to be placed at 3 days low including date of taking position.

CODE:
Please log in to see this code.

QUOTE:
Buy or sell on the close of the same day when Buy signal or exit signal is generated.

Check out BuyAtClose/SellAtClose code examples in the QuickRef.
QUOTE:
In case of Entry stop, execute stop when the stop price is violated.

Same advice but look at *AtStop methods.
profile picture

tejas parekh

#9
Thank you.

Can you please my following queries :

1) After a DataSet is created,is it possible to add any other stock data( Example : If i have a Datset named 'Sensex' which contains 15 stocks.Now, If I wish to add one more stock..How to do that?)Because it creates a new dataset altogether everytime a new stock is to be added.

2) In 'Strategy by Rules' when i use condition 'MACD crosses above the signal line' why it does not ask for three parameters ( It asks only one parameter).

3) Please explain me MAE/ MFE.

4) Yahoo Finance considers Splits/ Dividends in its price.But how to adjust it in wealth lab?
profile picture

Eugene

#10
1, 2, 3 - Already answered all of them in your last support ticket. Switch to Closed Tickets, open the last one to read my replies.

4 - This is also explained in the User Guide > Data ... Yahoo.

Please do take some time to study the Wealth-Lab User Guide as you will find many questions answered instantly.
profile picture

tejas parekh

#11

With reference to your reply to my post(point no.2).

When i try to download Community.Extension, I get this message :

"Download failed
Wealth-Lab extensions are available only to customers using Wealth-Lab Version 5 or higher. If you are a Wealth-Lab Pro/Developer 5 or higher customer and do not have access to extensions, please Create a Support Ticket. "
profile picture

Eugene

#12
That's right. Wealth-Lab extensions are available only to customers i.e. those who purchased the application.

Extensions are premium content available to our registered customers, for free. They are not a part of Wealth-Lab Developer/Pro (excluding those already shipped with the installation and available without downloading), they're free, and are not subject to "try before you buy". No downloadable extension is an inherent part of the application without which it would cease to function.
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).