Hi I was wondering how could i make my algorithm go:

-long when the ema indicator value > vwap indicator value 

-short when ema < vwap 

I'm quite sure that I have mistaken some points..

Could you help me?

Thankyou in advance for your time!

import numpy as np from clr import AddReference AddReference("System") AddReference("NodaTime") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Indicators") AddReference("QuantConnect.Common") from datetime import datetime, timedelta from System import * from NodaTime import DateTimeZone from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Brokerages import * from QuantConnect.Data.Market import * def Initialize(self): if self.Portfolio.TotalUnrealizedProfit > 1999.99: #take profit self.Liquidate() class DataConsolidationAlgorithm(QCAlgorithm): def Initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.SetCash(100000) self.StopRisk = 1 self.SetStartDate(2018,1,1) #Set Start Date self.SetEndDate(datetime.now()) #Set End Date # Find more symbols here: http://quantconnect.com/data self.AddEquity("BOXL", Resolution.Minute) self.ema = self.EMA("BOXL", 30, MovingAverageType.Simple, Resolution.Minute) self.vwap = self.VWAP("BOXL", 30, Resoltion.Minute) # define our 5 minute trade bar consolidator. we can # access the 5 minute bar from the DataConsolidated events fiveMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=5)) # attach our event handler. The event handler is a function that will # be called each time we produce a new consolidated piece of data. fiveMinuteConsolidator.DataConsolidated += self.fiveMinuteBarHandler # this call adds our 5-minute consolidator to # the manager to receive updates from the engine self.SubscriptionManager.AddConsolidator("BOXL", fiveMinuteConsolidator) def fiveMinuteBarHandler(self, sender, bar): '''This is our event handler for our 5-minute trade bar defined above in Initialize(). So each time the consolidator produces a new 5-minute bar, this function will be called automatically. The sender parameter will be the instance of the IDataConsolidator that invoked the event ''' self.Debug(str(self.Time) + " " + str(bar)) def OnData(self, data): pass if self.ema > self.vwap return True if self.ema < self.vwap return True