Overall Statistics
Total Trades
113
Average Win
0.11%
Average Loss
-0.08%
Compounding Annual Return
0.085%
Drawdown
1.100%
Expectancy
0.057
Net Profit
0.085%
Sharpe Ratio
0.069
Loss Rate
55%
Win Rate
45%
Profit-Loss Ratio
1.37
Alpha
0.001
Beta
0.003
Annual Standard Deviation
0.011
Annual Variance
0
Information Ratio
-0.356
Tracking Error
0.134
Treynor Ratio
0.218
Total Fees
$0.00
class heikinAshi(QCAlgorithm):
    
    buy = 0
    sell = 0

    def Initialize(self):
        self.SetStartDate(2018, 6, 1)
        self.SetEndDate(2019, 6, 1)
        self.SetCash(5000)
        self.SetBrokerageModel(BrokerageName.OandaBrokerage)
        self.USDJPY = self.AddForex("USDJPY", Resolution.Daily, Market.Oanda)
        self.heikinAshi = self.HeikinAshi(self.USDJPY.Symbol, Resolution.Daily)
        
    def OnData(self,data):
        
        if not self.heikinAshi.IsReady: 
            return
        
        if self.heikinAshi.Close > self.heikinAshi.Open and self.buy == 0:
            if self.sell == 1:
                self.Liquidate()
                self.sell = 0                
            self.MarketOrder("USDJPY", 1000)
            self.buy = 1
            
        if self.heikinAshi.Close < self.heikinAshi.Open and self.sell == 0:
            if self.buy == 1:
                self.Liquidate()
                self.buy = 0
            self.MarketOrder("USDJPY", -1000)
            self.sell = 1