Overall Statistics Total Trades 4942 Average Win 0.05% Average Loss -0.32% Compounding Annual Return 4050.671% Drawdown 66.600% Expectancy 0.042 Net Profit 33.654% Sharpe Ratio 2.225 Loss Rate 9% Win Rate 91% Profit-Loss Ratio 0.14 Alpha 6.697 Beta -25.208 Annual Standard Deviation 3.444 Annual Variance 11.859 Information Ratio 2.173 Tracking Error 3.543 Treynor Ratio -0.304 Total Fees \$0.00
```#
#   Trading Orders Algorithm
#
#        https://www.quantconnect.com/docs#Charting
#
import decimal
from datetime import timedelta

def Initialize(self):
# Set cash allocation for backtest
# In live trading this is ignored and your real account is used.
# cash = 7000 * 50 leverage = 350,000
self.SetCash(350000);

# Start and end dates for the backtest.
# These are ignored in live trading.
self.SetStartDate(2016,6,1)
self.SetEndDate(2017,6,1)

# Specify the OANDA Brokerage: This lets us know the fee models & data.
self.SetBrokerageModel(BrokerageName.OandaBrokerage)

# Add assets you'd like to see

self.SetBenchmark("EURUSD")

#5 day mean
#*****************THIS IS THE MEAN YOU CAN CHANGE THE 5 ******************
self.sma = self.SMA("EURUSD", 5, Resolution.Daily)
self.SetWarmup(timedelta(5))

def OnData(self, slice):
price = slice["EURUSD"].Value

difference = self.sma.Current.Value - price

# order amount = 3% cash / current price
# need to figure out how to get the current cash
#***************THIS IS THE AMOUNT OF THE PORTFOLIO PUT INTO EACH TRADE YOU CAN CHANGE THE 0.03*******************
amount = (self.Portfolio.TotalPortfolioValue * decimal.Decimal(0.03)) / price

if difference > decimal.Decimal(0.01):
# Buy shares of EURUSD

#************************THIS IS THE TAKE PROFIT YOU CAN CHANGE THE 1.005************
# Place a Take Profit Limit order for .005% gain
self.LimitOrder("EURUSD", -amount, price * decimal.Decimal(1.00005))

#************************THIS IS THE STOP LOSS YOU CAN CHANGE THE 0.997******************
# Place a Stop Loss (Stop Market) order for a .003% loss
self.StopMarketOrder("EURUSD", -amount, price * decimal.Decimal(0.99997))

if difference < decimal.Decimal(-0.01):
# Sell 1000 shares of EURUSD
self.Sell("EURUSD", amount)

#************************THIS IS THE TAKE PROFIT YOU CAN CHANGE THE 1.005************
#Place a Take Profit Limit order for .005% gain
self.LimitOrder("EURUSD", -amount, price * decimal.Decimal(1.00005))

#************************THIS IS THE STOP LOSS YOU CAN CHANGE THE 0.99997******************
# Place a Stop Loss (Stop Market) order for a .003% loss
self.StopMarketOrder("EURUSD", -amount, price * decimal.Decimal(0.997))

def OnOrderEvent(self, orderEvent):
if orderEvent.Status == OrderStatus.Submitted or orderEvent.Status == OrderStatus.Canceled:
return

#	if orderEvent.FillQuantity < 0:
#		self.Transactions.CancelOpenOrders("EURUSD")
else:
self.Log("Buy EURUSD at {0}. SMA30d: {1}".format(orderEvent.FillPrice, self.sma.Current.Value))                        ```