Overall Statistics
Total Trades
301
Average Win
0.19%
Average Loss
-0.11%
Annual Return
0.556%
Drawdown
4.100%
Expectancy
0.027
Net Profit
0.806%
Sharpe Ratio
0.2
Loss Rate
63%
Win Rate
37%
Profit-Loss Ratio
1.78
Trade Frequency
Daily trades
using System;
using System.Collections;
using System.Collections.Generic; 

namespace QuantConnect 
{
    using QuantConnect.Securities;
    using QuantConnect.Models; 

    public partial class BasicTemplateAlgorithm : QCAlgorithm, IAlgorithm 
    { 

        string symbol = "EURUSD";
        decimal brickSize = .001m;
        decimal greed = .5m;
        decimal renkoPrice;
        int trendConfirm = 4;
        int[] sign;
        
        bool initialized = false;

        //Initialize the data and resolution you require for your strategy:
        public override void Initialize() 
        {            
            //Initialize the start, end dates for simulation; cash and data required.
            SetStartDate(2013, 01, 01);
            SetEndDate(2014, 01, 01);
            SetCash(30000); //Starting Cash in USD.
            AddSecurity(SecurityType.Forex, symbol, Resolution.Tick); //Minute, Second or Tick
            SetRunMode(RunMode.Series); //Series or Parallel for intraday strategies.
        }
        
        //Handle Tick Events - Only when you're requesting tick data
        public override void OnTick(Dictionary<string, List<Tick>> ticks) 
        {
            foreach (Tick tick in ticks[symbol]) {
                if (initialized) {
                    if (tick.Price > renkoPrice + brickSize) {
                        while (renkoPrice < tick.Price - brickSize) {
                            renkoPrice += brickSize;
                            for (int i = 0; i < trendConfirm - 1; i++) {
                                sign[i] = sign[i+1];
                            }
                            sign[trendConfirm - 1] = 1;
                        }
                    } else if (tick.Price < renkoPrice - brickSize) {
                        while (renkoPrice > tick.Price + brickSize) {
                            renkoPrice -= brickSize;
                            for (int i = 0; i < trendConfirm - 1; i++) {
                                sign[i] = sign[i+1];
                            }
                            sign[trendConfirm - 1] = -1;
                        }
                    }
                    bool allNegative = true;
                    bool allPositive = true;
                    for (int i = 0; i < trendConfirm; i++) {
                        if (sign[i] != -1) {
                            allNegative = false;
                        } else if (sign[i] != 1) {
                            allPositive = false;
                        }
                    }
                    if (allPositive && tick.Price < renkoPrice - greed * brickSize) {
                        if (Portfolio[symbol].HoldStock && Portfolio[symbol].Quantity < 0) {
                            Order(symbol, -2*Portfolio[symbol].Quantity);
                        } else if (!Portfolio[symbol].HoldStock) {
                            Order(symbol, 10000);
                        }
                    } else if (allNegative && tick.Price > renkoPrice + greed * brickSize) {
                        if (Portfolio[symbol].HoldStock && Portfolio[symbol].Quantity > 0) {
                            Order(symbol, -2*Portfolio[symbol].Quantity);
                        } else if (!Portfolio[symbol].HoldStock) {
                            Order(symbol, -10000);
                        }
                    }
                } else {
                    renkoPrice = tick.Price;
                    sign = new int[trendConfirm];
                    initialized = true;
                }
            }
        }
    }
}