Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-0.106%
Drawdown
0.000%
Expectancy
0
Net Profit
-0.002%
Sharpe Ratio
-1.767
Probabilistic Sharpe Ratio
35.410%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.001
Beta
-0.001
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
2.919
Tracking Error
0.201
Treynor Ratio
1.367
Total Fees
$0.00
/*
 * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
 * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

using QuantConnect.Data;
using QuantConnect.Data.Market;
using System;



namespace QuantConnect.Algorithm.CSharp
{
    /// <summary>
    /// Algorithm demonstrating FOREX asset types and requesting history on them in bulk. As FOREX uses
    /// QuoteBars you should request slices or QuoteBars


    public class MainAlgo : QCAlgorithm
    {
        readonly static int slen = 60;
        readonly static int flen = 40;
        readonly decimal a1 = 5m / (decimal)flen;
        readonly decimal a2 = 5m / (decimal)slen;

        private RollingWindow<decimal> close;
        private RollingWindow<decimal> _PB;

        int count = 0;
       

        public override void Initialize()
        {

            SetStartDate(2020, 5, 8);
            SetEndDate(2020, 5, 15);
            SetCash(100000);

        	AddForex("EURUSD", Resolution.Hour, Market.Oanda);
            
            close = new RollingWindow<decimal>(3);
            _PB = new RollingWindow<decimal>(3);
            _PB.Add(0);
            _PB.Add(0);
            _PB.Add(0);
            
            var _chart = new Chart("PB Chart");
            
            AddChart(_chart);
            
        }

        public override void OnData(Slice data)
        {
            
            
            close.Add(data["EURUSD"].Close);
            

            if (!close.IsReady){
            	return;
            }

            
			_PB.Add((a1 - a2) * close[0] + (a2*(1 - a1) - a1 * (1 - a2))* close[1] + ((1 - a1) + (1 - a2))*_PB[1] - (1 - a1)* (1 - a2)*_PB[2]);

			Plot("PB Chart", "PB", _PB[0]);
			
            if (!Portfolio.Invested)
            {
                Console.WriteLine("TEST" + data["EURUSD"].Close);
                MarketOrder("EURUSD", 1000);
            }
            
            count++;
        }
    }
}