I have a very simple multi-time frame tryout strategy:
The script checks the 1-minute and the 5-minute charts for "long" bars (close > open). If it finds the last 1-minute bar was a "long" bar AND the last 5-minute bar was a long bar as well, it buys the stock.
The problem is: It works well except for the times when both the 1- and the 5-minute bars update.
An example:
2.40pm: The 5-minute bar closes at "long" (close > open).
2.41pm: The 1-minute bar closes at "long" -> strategy buys stock -> ok.
2.42pm: The 1-minute bar closes at "short" (close < open).
2.43pm: The 1-minute bar closes at "long" -> strategy buys stock -> ok.
2.44pm: The 1-minute bar closes at "short" (close < open).
2.45pm: The new 5-minute bar closes at "short" (close < open). The 1-minute bar closes again at "long" again. Although the system shouldn't do anything now (since the newly-updated 1- and 5-minute bars do not both show "long"), it buys the stock. I assume it still thinks the 2.40pm 5-minute bar to be the current one.
Is there a way I can tell the system to "wait" for the update of the 5-minute bar? Or can I somehow pause or delay the code execution to make sure the most recent 5-minute bar is being taken into account?
Thanks,
n.i.n.j.n.a.
Comment