Hi,
I wonder if it is possible to mix intraday conditions into a strategy, that executes trades on daily data.
I have daily data from Yahoo for ^HSI and SPY, and
I have intraday 1 minute data for DAX30 from Metatrader static provider.
Rules:
-if ^HSI moved up from open to close +1% and DAX30 moved up from 09:00 (German merket open in
German time zone) to 15:30 (US market open in German time zone)
-then buy SPY at merket open and sell it at market close on the same day.
I tried to start writing the code, but can't work out how can I combine these conditions on data with different timeframes. Is it possible at all ?
Size:
Color:
Sorry the condition for DAX30 is moving up 1% from 09:00 to 15:30.
Size:
Color:
Sure it's possible. See the Help > WealthScript Prog. Guide > Multi-Time Frame Analysis
Size:
Color:
I found a description in the WealthScript Prog. Guide (Accessing Intraday data from Daily)
I tried the write the code according to it, but there are red underlined parts and it doesn't run.
What is wrong ?
I ran it on daily SPY data.
CODE:
Please log in to see this code.
Size:
Color:
Ok. Here's what you need to know:
1. If the Strategy Compiles sucessfully, don't worry about the red lines. But with a successful compile, you can avoid the red lines by give the WealthScript class a unique name, like you did here:
CODE:
Please log in to see this code.
2. If the Strategy compiles with errors - like this strategy - the red lines are likely to show you where the errors are. You need to correct those.
Size:
Color:
Yes, it is possible to mix intraday conditions with strategies that execute on daily data, but it requires careful handling of the different timeframes and proper synchronization of the data sources.
Since you're using daily data for ^HSI and SPY from Yahoo, and 1-minute intraday data for DAX30 from MetaTrader, you'd typically need to:
Pre-process all data into a unified format — for example, store them in a DataFrame where each row represents a trading day, and add custom columns like:
HSI_daily_return
DAX_intraday_return_0900_1530
etc.
Aggregate the intraday DAX30 data into daily values representing the return from 09:00 to 15:30 (German time), which you can calculate and append as a column to your daily strategy DataFrame.
Align time zones — this is crucial. You'll need to convert all timestamps to a consistent time zone (e.g., UTC or local time in Germany/US) before performing comparisons or merging datasets.
Implement logic conditionally — once your daily data includes the necessary conditions, your backtesting code can check:
Tradeiators comes in — a trading community focused on smart strategy development, proper risk management, and real trader collaboration. Whether you're new or experienced, Tradeiators offers tools, education, and mentorship to help you level up — and avoid the classic pitfalls.
Size:
Color: