Hello Community,

I am trying to schedule a boolean function daily containing a certain condition, that if fulfilled, the OnData function will fire and do some work, otherwise I will wait for the firing of the scheduled function the next day. However, I am facing many weird problems:

1) In my log file, I am witnessing many SKIPPED days:

2013-10-11 00:00:00 Yesterday Close is: 1.349315
2013-10-11 00:00:00 The Close before yesterday is: 1.35674
2013-10-11 01:00:00 Test returned false
2013-10-17 01:00:00 Yesterday Close is: 1.35136
2013-10-17 01:00:00 The Close before yesterday is: 1.3567
2013-10-17 01:00:00 Test returned false
2013-10-22 01:00:00 Yesterday Close is: 1.367605
Why is there so many skipped days although I have scheduled the function to run daily?
2) The condition is not being fulfilled correctly; the OnData function is not firing when I want it to be fired,
that is when test function is True. What is the reason behind that?


def Initialize(self):

self.SetStartDate(2013,10, 11) #Set Start Date
self.SetEndDate(2013,11,11) #Set End Date
self.SetCash(10000) #Set Strategy Cash
self.AddForex("EURUSD", Resolution.Daily)
self.Schedule.On(self.DateRules.EveryDay(),self.TimeRules.At(00, 00),self.test)

def OnData(self, data):

if(self.test()):
self.Debug("We are in OnData, and test returned true")
else:
self.Debug("Test returned false")


def test(self):
eur_hist = self.History(['EURUSD'],2,Resolution.Daily)
if (eur_hist.loc['EURUSD']['close'][0] > eur_hist.loc['EURUSD']['close'][-1]):
self.Debug("Yesterday Close is: " + str(eur_hist.loc['EURUSD']['close'][-1]))
self.Debug("The Close before yesterday is: " + str(eur_hist.loc['EURUSD']['close'][0]))
return True
return False

3) I had an "Index out of bounds" error when I put ['EURUSD']['close'][1]  and had to change it to -1 for it to work. Why is that?

 

Thanks in advance,

Best Regards.