| Overall Statistics |
|
Total Trades 133 Average Win 3.61% Average Loss -2.27% Compounding Annual Return 3.222% Drawdown 27.100% Expectancy 0.100 Net Profit 39.194% Sharpe Ratio 0.256 Probabilistic Sharpe Ratio 0.186% Loss Rate 58% Win Rate 42% Profit-Loss Ratio 1.59 Alpha 0.03 Beta -0.016 Annual Standard Deviation 0.111 Annual Variance 0.012 Information Ratio -0.413 Tracking Error 0.177 Treynor Ratio -1.807 Total Fees $0.00 Estimated Strategy Capacity $150000.00 Lowest Capacity Asset EURUSD 8G |
class Crossing(QCAlgorithm):
'''Basic template algorithm simply initializes the date range and cash'''
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.SetTimeZone("Africa/Douala")
self.SetStartDate(2009,1, 1) #Set Start Date
self.SetEndDate(2019,6, 3) #Set End Date
self.SetCash(1000) #Set Strategy Cash
self.ProfitTarget = None
self.StopLoss = None
# Find more symbols here: http://quantconnect.com/data
self.eurusd = self.AddForex("EURUSD", Resolution.Daily)
self.window = RollingWindow[QuoteBar](53)
self.ichi = self.ICHIMOKU("EURUSD", 9, 26, 26, 52, 26, 26, Resolution.Daily)
self.ichi.Updated += self.ichiUpdated
self.ichiWin = RollingWindow[IndicatorDataPoint](2)
def ichiUpdated(self, sender, updated):
'''Adds updated values to rolling window'''
self.ichiWin.Add(updated)
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
'''
if data.ContainsKey("EURUSD"):
self.window.Add(data["EURUSD"])
# Wait for windows to be ready.
if not (self.window.IsReady and self.ichi.IsReady): return
currBar = self.window[0]
prev1 = self.window[1]
self.Debug("Price: {0} -> {1} ... {2} -> {3}".format(
prev1.Time, prev1.Low,
currBar.Time, currBar.Low
)
)
#self.Debug(str(self.ichi.Tenkan)+" "+str(self.ichi.Kijun))
sl = min([currBar.Low, prev1.Low])
tp = currBar.Open + ((prev1.Close - sl) * 1.5)
self.Debug("Prev open {} kijun {} prev close {}".format(prev1.Open, self.ichi.Kijun, prev1.Close))
self.Debug("Tenken {}, Kijun {}, Senkoua {} and SenkouB {}".format(self.ichi.Tenkan, self.ichi.Kijun, self.ichi.SenkouA, self.ichi.SenkouB))
if not self.Portfolio.Invested:
if prev1.Open < self.ichi.Kijun.Current.Value and prev1.Close > self.ichi.Kijun.Current.Value:
self.Debug("OK ooh")
self.MarketOrder("EURUSD", 2000)
self.ProfitTarget = self.LimitOrder("EURUSD", -2000, round(tp, 5))
self.StopLoss = self.StopMarketOrder("EURUSD", -2000, round(sl, 5))
def OnOrderEvent(self, orderEvent):
if not self.StopLoss or not self.ProfitTarget: return;
filledOrderId = orderEvent.OrderId
if self.StopLoss.OrderId == filledOrderId:
self.ProfitTarget.Cancel()
if self.ProfitTarget.OrderId == filledOrderId:
self.StopLoss.Cancel()