Overall Statistics Total Trades151Average Win0.34%Average Loss-0.17%Compounding Annual Return-84.696%Drawdown4.000%Expectancy-0.260Net Profit-3.038%Sharpe Ratio-12.623Loss Rate75%Win Rate25%Profit-Loss Ratio2.00Alpha-1.994Beta27.174Annual Standard Deviation0.122Annual Variance0.015Information Ratio-12.779Tracking Error0.122Treynor Ratio-0.057Total Fees\$0.00
```### <summary>
### Simple RSI Strategy intended to provide a minimal algorithm example using
### one indicator
### </summary>
import time
import matplotlib.pyplot as plt
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from datetime import datetime
from System import *
from QuantConnect import *
from QuantConnect.Data.Consolidators import *
from QuantConnect.Data.Market import *
from QuantConnect.Orders import OrderStatus
from QuantConnect.Algorithm import QCAlgorithm
from QuantConnect.Indicators import *
import numpy as np
from datetime import timedelta, datetime
import pandas
import numpy as np
### <summary>
### Simple RSI Strategy intended to provide a minimal algorithm example using
### one indicator
### </summary>
class MultipleSymbolConsolidationAlgorithm(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.'''

# Set our main strategy parameters
self.SetStartDate(2015, 1, 1)
self.SetEndDate(2015, 1, 6)      # Set End Date
self.SetCash(10000)
self.quant = 10000

self.first_stg_up = 0
self.first_stg_down = 0

self.pip_s = 5

self.tp = 33/10000
self.sl = 14/10000
self.tp_s = {}
self.sl_s = {}
self.tp_s_n = 0
self.sl_s_n = 0
self.long = {}
self.short = {}
self.price = {}
self.first_stg_up = {}
self.first_stg_down = {}
self.Data = {}
self.c = 0

BarPeriod = TimeSpan.FromHours(20)
SimpleMovingAveragePeriod = 20
RollingWindowSize = 20
self.quoteBarWindow = RollingWindow[QuoteBar](20)

ForexSymbols =["EURUSD", "GBPUSD", "USDCHF", "AUDUSD","NZDUSD"]

for symbol in ForexSymbols:
self.Data[symbol] = SymbolData(forex.Symbol, BarPeriod, RollingWindowSize)
self.price[symbol] = 0
self.short[symbol] = 0
self.long[symbol] = 0
self.sl_s[symbol] = 0
self.tp_s[symbol] = 0
self.first_stg_up[symbol] = 0
self.first_stg_down[symbol] = 0

def SmaUpdated(self, sender, updated):

def OnData(self,data):

for symbol in self.Data.keys():
symbolData = self.Data[symbol]

self.SMA(symbol, 20).Updated += self.SmaUpdated
self.smaWindow = RollingWindow[IndicatorDataPoint](20)

self.bb_ind = self.BB(symbol, 20, 1, MovingAverageType.Simple, Resolution.Hour);
self.slow = self.SMA(symbol, 1, Resolution.Hour)
self.fast = self.SMA(symbol, 1, Resolution.Hour)

fxOpen = data[symbol].Open
fxClose = data[symbol].Close
fxHigh = data[symbol].High
fxLow = data[symbol].Low
price = data[symbol].Price
pip = (fxHigh - fxLow)*10000

trend_sma = np.where(self.fast.Current.Value > self.slow.Current.Value,1,0)

Console.Write(self.smaWindow[0]) # this is a test to write the sma value to the consol, this is where the error occure.

if  self.long[symbol] == 0 and self.short[symbol] == 0:
if not self.Portfolio[symbol].Invested:
if  fxClose > fxOpen:# and trend_sma == 1 :         # The trend sma parameter do not work as i do not get any parameters from the sma
self.first_stg_up[symbol] = 1

if self.first_stg_up[symbol] == 1 and fxClose > self.bb_ind.LowerBand.Current.Value:

self.first_stg_down[symbol] = 0

# Line 137 - 161 take trade, stopp loss and tp function (works not any faults in here)

if not self.Portfolio[symbol].Invested:
if pip >self.pip_s and fxOpen < fxClose and self.trade_ind[symbol] == 1 :
if  self.long[symbol] == 0 and self.short[symbol] == 0:

self.price[symbol] = data[symbol].Price
self.tp_s[symbol] = price + self.tp
self.sl_s[symbol] = price - self.sl
self.long[symbol] = 1
self.MarketOrder(symbol, self.quant)

if self.price[symbol] > 0 and self.long[symbol] == 1 :

if data[symbol].Price >= self.tp_s[symbol] :
self.long[symbol] = 0
self.Liquidate(symbol)
if data[symbol].Price <= self.sl_s[symbol] :
self.long[symbol] = 0

self.Liquidate(symbol)

# this is a part of an example, do not think that i am

class SymbolData(object):

def __init__(self, symbol, barPeriod, windowSize):
self.Symbol = symbol

self.BarPeriod = barPeriod

self.Bars = RollingWindow[IBaseDataBar](windowSize)```