Overall Statistics
Total Trades
1301
Average Win
0.01%
Average Loss
-0.01%
Compounding Annual Return
0.693%
Drawdown
1.500%
Expectancy
-0.106
Net Profit
0.180%
Sharpe Ratio
0.179
Probabilistic Sharpe Ratio
30.853%
Loss Rate
54%
Win Rate
46%
Profit-Loss Ratio
0.94
Alpha
0.011
Beta
0.057
Annual Standard Deviation
0.029
Annual Variance
0.001
Information Ratio
0.676
Tracking Error
0.168
Treynor Ratio
0.092
Total Fees
$0.00
Estimated Strategy Capacity
$280000.00
Lowest Capacity Asset
NZDUSD 8G
# Forex Intraday Strategy v2

# https://www.quantconnect.com/forum/discussion/13418/intraday-mean-reversion-strategy-helpneed

# ------------------------------------------------------------------------
ASSETS = ["EURUSD","GBPUSD","AUDUSD","NZDUSD","USDCHF","USDJPY","USDCAD"]; 
MA = 15; STD = 8; STD_MAX = 15;
# ------------------------------------------------------------------------

class IntradayMR_FX(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2022, 1, 1) 
        self.SetCash(1000000)
        self.assets =  [self.AddForex(ticker, Resolution.Daily).Symbol for ticker in ASSETS]
        self.std = {}; self.ma = {}; self.YestHigh = {}; self.YestLow = {};
        for sec in self.assets:
            self.ma[sec] = self.SMA(sec, MA, Resolution.Daily)
            self.std[sec] = self.STD(sec, STD, Resolution.Daily)
            self.YestHigh[sec] = self.SMA(sec, 1, Resolution.Daily, Field.High)
            self.YestLow[sec] = self.SMA(sec, 1, Resolution.Daily, Field.Low)
        self.selected = []    
        self.SetWarmUp(MA, Resolution.Daily)
        
            
    def OnData(self, data):
        if self.IsWarmingUp: return

        for sec in self.assets:
            if not (self.ma[sec].IsReady and self.std[sec].IsReady): continue
            if not (self.YestHigh[sec].IsReady and self.YestLow[sec].IsReady): continue

            ma = self.ma[sec].Current.Value
            std = self.std[sec].Current.Value
            O = self.Securities[sec].Open
            YH = self.YestHigh[sec].Current.Value
            YL = self.YestLow[sec].Current.Value

            if not self.Portfolio[sec].Invested: 
                if abs(O - YL) < std and O > ma and std <= STD_MAX:
                    self.selected.append(sec)
                    
            elif self.Portfolio[sec].Invested:
                if (abs(O - YH) > std and O < ma) or std > STD_MAX:
                    self.Liquidate(sec)
                    
            for sec in self.selected:
                self.SetHoldings(sec, 1/len(self.selected))