| Overall Statistics |
|
Total Trades 1539 Average Win 0.71% Average Loss -1.13% Compounding Annual Return -14.626% Drawdown 52.500% Expectancy -0.001 Net Profit -21.827% Sharpe Ratio -0.117 Probabilistic Sharpe Ratio 6.104% Loss Rate 39% Win Rate 61% Profit-Loss Ratio 0.63 Alpha -0.027 Beta -0.099 Annual Standard Deviation 0.403 Annual Variance 0.162 Information Ratio -0.508 Tracking Error 0.486 Treynor Ratio 0.476 Total Fees $0.00 |
class DynamicUncoupledPrism(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 1) # Set Start Date
self.SetCash(1500) # Set Strategy Cash
self.symbol = "EURUSD"
# Add forex and set brokerage model
self.AddForex(self.symbol, Resolution.Minute, Market.Oanda, True, 50)
self.SetBrokerageModel(BrokerageName.OandaBrokerage)
# Setup indicators
self.rsi = RelativeStrengthIndex(6, MovingAverageType.Simple)
# Setup bar consolidator
thirtyMinuteConsolidator = QuoteBarConsolidator(timedelta(minutes=30))
self.SubscriptionManager.AddConsolidator(self.symbol, thirtyMinuteConsolidator)
self.RegisterIndicator(self.symbol, self.rsi, thirtyMinuteConsolidator)
# Setup window
self.rsiWindow = RollingWindow[float](5)
def OnData(self, data):
self.rsiWindow.Add(self.rsi.Current.Value)
# Wait for rsi
if not self.rsi.IsReady:
return
# Define the signals
should_buy = self.rsi.Current.Value < 30 and self.rsiWindow[1] > 30
should_short = self.rsi.Current.Value > 70 and self.rsiWindow[1] < 70
is_long = self.Portfolio[self.symbol].IsShort == False
is_short = self.Portfolio[self.symbol].IsShort
is_invested = self.Portfolio[self.symbol].Invested
if is_invested == False:
if should_buy:
self.MarketOrder(self.symbol, 10000)
if should_short:
self.MarketOrder(self.symbol, -10000)
else:
if should_buy and is_short:
self.MarketOrder(self.symbol, 20000)
if should_short and is_long:
self.MarketOrder(self.symbol, -20000)
# self.Debug("IS_INVESTED: " + str(is_invested))
# self.Debug("IS_LONG: " + str(is_long))
# self.Debug("IS_SHORT: " + str(is_short))
# self.Debug("SHOULD LONG: " + str(should_buy))
# self.Debug("SHOULD EXIT LONG: " + str(should_exit_buy))
# self.Debug("SHOULD SHORT: " + str(should_sell))
# self.Debug("SHOULD EXIT SHORT: " + str(should_exit_sell))
# self.Debug(data.Bars[self.symbol].EndTime)
# self.Debug("OPEN: " + str(data.Bars[self.symbol].Open))
# self.Debug("HIGH: " + str(data.Bars[self.symbol].High))
# self.Debug("LOW: " + str(data.Bars[self.symbol].Low))
# self.Debug("CLOSE: " + str(data.Bars[self.symbol].Close))