Time based strategies using Rules
Author: jholmberg083
Creation Date: 8/4/2019 1:29 AM
profile picture

jholmberg083

#1
I'm considering a reversal strategy that's probably pretty common, where you assume that the initial price direction after the market open will likely lose its momentum after about 20 minutes into the trading day, then start to reverse. Can anyone think of a way to put this into a backtest?

For instance, "IF price change from 9:30am to 9:50am is more than +2%, THEN enter a short position at 9:51am with profit target of 1% and fixed stop loss of 0.5%"

I know how to set up the rules for going into a short position, and to set up the profit target and stop loss, but not the rest. Thank you!

P.S. - I'm hoping the backtest can be done using only the drag and drop features of the Rules tab. I've pretty much given up on trying to solve problems using code offered in this forum. Not because the code isn't good, I'm sure it is, but because I'm not a programmer and whenever I try to tweak something in the code I just get error messages I don't understand.
profile picture

Eugene

#2
The Rules Wizard is powerful but our strategy ideas can naturally exceed its capabilities. Such trading ideas may not have a straightforward implementation using Rules - can't promise that it's feasible at all. That's because they require "memory" of what conditions took place several bars ago at certain time period. Called a "setup", it's a condition (or conditions) which precede another action.

You can try to approach it through the Multi-Condition Group feature of Rule-based Strategies. See Strategy Window > Strategy Builder > MC, Multi-Condition Group in the Wealth-Lab User Guide. The next piece of the puzzle is Community.Rules library which adds ability to define two rules required:

1. "Intraday Rule: Time is later (earlier) than HHmm" (Conditions > Date/Time group)
2. "Price is higher (lower) by X% than it was a number of bars ago" (Conditions > Price group)



Problem is, even then you'd have to switch to 20-minute bars exactly and leave your preferred bar scale as the "price change" condition would not be evaluated on the time span but on any given bar (including yesterday's). If you're still interested, to get the library please sign up for a Wiki account and then become authorized for download after a technician "greenlists" it shortly after.

Should you have some success without changing the logic, let the forum know. Getting it done in code should be a piece of cake. It's a pity that you've given up on it.
profile picture

jholmberg083

#3
Thanks Eugene. I have tried signing up for the Wiki account, not sure if it worked though. After I fill out the fields and hit "create account", the page reloads, but then doesn't show me anything new, just all the fields I have filled out. I'll keep watching my email for the activation email.
profile picture

Eugene

#4
Now it has worked, your account is verified.
profile picture

jholmberg083

#5
Thank you! I have downloaded the community rules and started playing with the strategy, using your suggestion above as a starting point.

As far as sharing success: I made the strategy long instead of short, and instead of defining the price movement as a % change, I said it must have fallen by 3 consecutive bars. Then I set up a fixed 1% profit target and 0.5% stop loss, and said the entry must be between 9:49am and 10:09am. Testing the SPY for YTD 2019, it looks to be profitable. Much more testing to be done yet of course.

Thanks for the help!
profile picture

Eugene

#6
You're welcome. Cheers!
profile picture

Eugene

#7
To anybody interested in MC Groups. Check out our tutorial video on Youtube:

Wealth-Lab 101: Strategy Builder Multi-Condition Groups
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).