Detect start of each new quarter for rebalancing
Author: flroots
Creation Date: 6/25/2014 11:31 AM
profile picture

flroots

#1
My strategy calls for rebalancing at each new quarter. As I step through each new bar how do I detect the start of a new quarter? I am able to do it if the year is a constant, but unfortunately it's a variable. Thanks.

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

Eugene

#2
Here's how:

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

flroots

#3
Thanks. It worked great. The only mod I did was to change:
if( Bars.Count > 1 )
to
if( (Bars.Count > 1) & (bar > 1) )

to cover the call with bar = 0
profile picture

Eugene

#4
Right, but it makes zero sense to call it with bar 0: Wealth-Lab won't let you trade at bar #0 because the basis price for orders has not been determined yet.
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).