Strategies based on multiple time frames?
Author: walzmark
Creation Date: 10/6/2011 9:41 AM
profile picture

walzmark

#1
Has any one attempted or had success with developing strategies which evaluate triggers based on multiple time analyses?
Say you have a trigger based on a moving average crossover on a 30 min basis.
I would also like to consider the state of the same moving average crossover on a daily basis.
So if the daily crossover is in an uptrend, how effective is my 30 minute strategy.
If the daily crossover is in a downtrend, then how effective is my 30 minute strategy.
Any suggestions or input is greatly appreciated.
profile picture

Eugene

#2
See the WealthScript Programming Guide > Multi-Time Frame Analysis > Intraday/Daily etc.

Plus many examples available by searching the forum for the keywords like multiple time frame, SetScaleDaily/SetScaleWeekly etc., in the Wealth-Lab Wiki (Knowledge Base section).
profile picture

sedelstein

#3
This is related. I'm somewhat suspicious of the opening prices that are officially recorded as the stocks "open"
The strategy I am looking at is daily, and generally execute via BuyAtMarket(bar+1), the next day's open

I've done some searching but have not found what I was looking for.
Is there example code that someone can point me to that uses an end-of-day signal but delays the buy until the open of the first, say, 5 minute bar? This will give me some idea of the slippage I might experience using opening prices

Thanks for the help
profile picture

Eugene

#4
Have you checked the GetSessionOpen property in the QuickRef?
profile picture

sedelstein

#5
Yes,

I know I can get the opening price out of the database. What I am saying is that the stock may have an opening range and in real trading, one never gets the "official" opening price. This opening range can be much wider than the typical bid/offer spread one might observe later in the day. By instituting a delay, I am hoping to get some idea of how different results might be by delaying. Might you have an example of how to do this?
profile picture

Eugene

#6
Well, you could access intraday data from Daily and set execution time by activating Daily Strategy Scheduling in Strategy Monitor. However, I'm not sure if execution time can be shifted to next date.
profile picture

sedelstein

#7
So there is no way to Set Scale to Daily, generate a signal at end of day, reset the scale to intraday and execute on the 2nd bar of the next day?

To be clear, are you saying that it's not possible to do this?

profile picture

Eugene

#8
Of course you can do that with intraday data. You created an impression of staying with Daily data: "The strategy I am looking at is daily,..." For examples, please refer to post #2 above.
profile picture

sjendoubi

#9
I was trying to use the Lowest.Series(Close,5) of daily time frame in an intraday strategy, but it did not work for me.
I took a code from the the WealthScript Programming Guide > Multi-Time Frame Analysis > Intraday/Daily
and modified it, but I found that I can not go back more than one day. I found out that for example
iDay.Close[bar-1] = iDay.Close[bar-2] = iDay.Close[bar-3]..... and this will note allow me to find the lowest price for 5 days.

Here Copy of the code that I was using (change the iDay.Close[bar-2] to iDay.Close[bar-1] and see for yourself that the graph does not change)
Any thoughts are really appreciated.

Thanks

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

Eugene

#10
QUOTE:
I was trying to use the Lowest.Series(Close,5) of daily time frame in an intraday strategy, but it did not work for me.


Not sure what's the connection of the intraday bar - 2 (you're requesting the value from) with Lowest.Series. Give this example a try:

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

sjendoubi

#11
I want to find the lowest value of the last 5 days closing price.
It is the Lowest.Series(Close,5), but it is not in the code submitted above, because it did not work for me.

Let's say Lowest.Series(Close,5) = Close[bar-2] for example.
If I use iDay.Close[bar-2] it gives me iDay.Close[bar-1].
if I use iDay.Close[bar-k] for k>=2 it still gives me iDay.Close[bar-1]???


if I use:

CODE:
Please log in to see this code.


I got the following error:



Thanks
profile picture

Eugene

#12
QUOTE:
I want to find the lowest value of the last 5 days closing price.

Could you put away your coding experiments and tell me in plain English what trading rules you want to have coded as clear as possible?
profile picture

sjendoubi

#13
This is what I want to do:

1) In a daily chart if the price go below the Lowest.Series(Close,5)[bar-1] then I will look if the price will bounce back today in a 15 Minutes chart.
let's say: (intraday Close[bar] = 5), Close[bar-1] = 6, Close[bar-2] = 5.2, Close[bar-3] = 5.7, Close[bar-4] = 5.1 and Close[bar-5] = 5.6
therefore Lowest.Series(Close,5)[bar-1]=Close[bar-4] = 5.1

5. < 5.1 =====> my daily condition is met.

2) Intraday price is now 5, I will watch the stock if it reverses back from here or it will continue down.
If it reverses back in a 15 Minutes Chart I want to buy the stock.

Thanks

profile picture

Eugene

#14
This makes it clearer. Here's example code to be executed on an intraday chart. It marks the bar (and price) when the intraday Close drops below the lowest 5-day Close, waits indefinitely for a pullback above the trigger price, and sells EOD. It's for backtesting only.

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

sjendoubi

#15
Eugene,

Thank you very much for your help. Your help was very beneficial and useful. I learned a lot from the code that you provided and I will be using the ideas and suggestions that you provided for many of my strategies.

Thank you again and keep the good work.
profile picture

Eugene

#16
Slah, glad I could be of assistance!
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).