I am struggling with two connected issues in what appears to be a simple price comparison. The following line of code is trying to compare the price at 7:10 to a price yesterday which is 300 1-min bars ago.
if (Close[0] > Close[300] && ToTime(Time[0]) == ToTime(7, 10, 0))
[1] The first problem is that a look back 300 bars ago doesn't appear to work. It does work for smaller numbers like 10 but I'm assuming there is some limit here. What I really would prefer is to be able to specify the exact time I am interested in, for example yesterday's 14:30 or 16:30 price. So, first question, is there a limit on how many bars I can specify and better still can I specify a time to take a price from instead?
[2] There is a second problem with me choosing this 7:10 time. For a low volume market during the first hours of electronic trading, it is possible that there is no bar for a given minute as nothing has traded. On the face of it, that means that if I generically look back 300 bars I will get back to differing times in yesterday which is far from ideal. I thought that maybe if I specified that the market hours were set to start at 7:10 then I could get rid of the random bar issue but I can't see a way of specifying a bespoke trading period for a market and even if I can, this may be only for charting purposes and the underlying strategy may still read all the available data anyway. Is this correct?
Many thanks,
darmbk.
Comment