I am currently having two problems. The first problem is my algorithm keeps making trades @ 00:00:00. I then changed the order to a MarketOrder, but the same thing happens (It just gets filled at Market Open)   I tried writing some code so the Algo can only account for prices during open market and stop pre/post-market trade request. 

usa_after_hours = True #opentime = self.TimeRules.At(9, 30) #closetime = self.TimeRules.At(15, 59, 45) #if int(self.time) >= int(opentime) and <= int(closetime): #usa_after_hours = False '''I put the int() after i tried it without int()''' '''I then went on and tried this, which also isnt working''' if self.IsMarketOpen: usa_after_hours = False elif not self.IsMarketOpen: usa_after_hours = True if not self.Portfolio.Invested and already_traded and not usa_after_hours:

none of these seem to work and "usa_after_hours" is either stated to be already defined or not defined in the error logs. I saw something about SetMarketHours in an already closed discussion but I couldn't find it the API or documents.

The second problem is I am trying to create a T/F variable that only allows one entry trade in a given period. I named it "already_traded", but that also seems to be not working. So I am assuming that I am not using T/F statements correctly because I have seen QC algorithms use T/F as part of determining to get into a trade or not.