OnTradeBar was deprecated, you need to use OnData instead:
def OnData(self,slice):
for chain in slice.FutureChains:
# Get contracts expiring no earlier than in 90 days
contracts = filter(lambda x: x.Expiry > self.Time + timedelta(90), chain.Value)
# if there is any contract, trade the front contract
if len(contracts) == 0: continue
front = sorted(contracts, key = lambda x: x.Expiry, reverse=True)[0]
self.MarketOrder(front.Symbol , 1)
The slice object has the FutureChains object that includes futures contracts for each future you have subscribed to (ES, CL, GC, etc). In the above example, chain.Value are the contracts of a given future. You can use the contract symbol to access OHLC information:
bar = slice[front.Symbol]
open = bar.Open
high = bar.High
low = bar.Low
close = bar.Close