Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
using System;
namespace QuantConnect.Algorithm.CSharp
{
    /// <summary>
    /// Basic template algorithm simply initializes the date range and cash. This is a skeleton
    /// framework you can use for designing an algorithm.
    /// </summary>

	public class BasicTemplateAlgorithm : QCAlgorithm 
	{ 
	 
	   private int barcount = 0; 
	   private decimal barclose = 0; 
	   private decimal barlow = 0; 
	   private decimal barhigh = 0; 
	   private decimal barlowest = (decimal)999999.0; 
	   private decimal barhighest = (decimal)0.0; 
	   private decimal HH1 = 0; 
	   private decimal HH2 = 0; 
	   private decimal LL1 = 0; 
	   private decimal LL2 = 0; 
	   private bool is_high = true; 
	   private bool is_low = false; 
	   private int HLbarcount = 0; 
	 
	   DateTime barlowestDateTime; 
	   DateTime barhighestDateTime; 
	   
	   private RollingWindow<TradeBar> Bars ;
	 
	 //  TimeSeries HL; 
	         TradeBars prices = new TradeBars();
	private String symbol = "EURUSD";
	 
	   public override void Initialize() 
	   { 
	   	            SetStartDate(2017, 10, 3);
	            SetEndDate(2017, 10, 5);
	                 AddSecurity(SecurityType.Forex, "EURUSD", resolution: Resolution.Minute);
	   	var chart = new Chart("Plotter");
	chart.AddSeries(new Series("HH",SeriesType.Line));
	chart.AddSeries(new Series(symbol+"H",SeriesType.Line));
	chart.AddSeries(new Series(symbol+"L",SeriesType.Line));
				AddChart(chart);
				Bars = new RollingWindow<TradeBar>(4);
		//					PlotIndicator("EURUSD", spyClose, emaFast, emaSlow);
	     // HL = new TimeSeries("High-Low", Color.White); 
	     // Draw(HL, 0); 
	
	   } 
	 
	   public void OnData(TradeBars bar) 
	   { 
	   	Bars.Add(bar[symbol]);
	   	Plot("Plotter", symbol+"H", bar[symbol].High);
	   	Plot("Plotter", symbol+"L", bar[symbol].Low);
	      if ((bar[symbol].Close > 0) && (bar[symbol].High > 0) && (bar[symbol].Low > 0) && (bar[symbol].Open > 0)) 
	      {  
	      	/*
	         if (Mode != StrategyMode.Simulation) 
	         { 
	            DataManager.Add(Instrument, bar); 
	         } 
	         */
	         barcount++; 
	         HLbarcount++; 
	         barclose = bar[symbol].Close; 
	         barhigh = bar[symbol].High; 
	         barlow = bar[symbol].Low; 
	 
	 
	         if (barcount > 1) 
	         { 
	            if ((barlow) < barlowest) 
	            { 
	               barlowest = barlow; 
	               barlowestDateTime = bar[symbol].EndTime; 
	            } 
	 
	            if ((barhigh) > barhighest) 
	            { 
	               barhighest = barhigh; 
	               barhighestDateTime = bar[symbol].EndTime; 
	            }          
	         }       
	 
	         if (Bars.IsReady) 
	         { 
	            if ((HLbarcount > 3) && (is_low) && (Bars[0].High > Bars[3].High) && (Bars[0].Low > Bars[1].Low) && (Bars[0].Low > barlowest)) 
	            { 
	               LL2 = LL1; 
	               LL1 = barlowest; 
	               if (LL1 != LL2) 
	               { 
	                  is_high = true; 
	                  is_low = false; 
	                  //prices.Add(symbol, bar[symbol]);
	                  //HL.Add(barlowestDateTime, barlowest);    
	                  Plot("Plotter", "HH", barlowest);
	
	                  barhighest = Math.Max(Math.Max(Math.Max(Bars[0].High,Bars[1].High),Bars[2].High),Bars[3].High);    
	                  barhighestDateTime = bar[symbol].EndTime; 
	                  HLbarcount = 0; 
	                  HH1 = 0; 
	                  HH2 = 0; 
	   //               Log("{0}     LL1 = {1}     barhighest = {2}", barlowestDateTime, LL1, barhighest);                                  
	               } 
	            } 
	 
	            if ((HLbarcount > 3) && (is_high) && (Bars[0].Low < Bars[3].Low)&& (Bars[0].High < Bars[1].High) && (Bars[0].High < barhighest)) 
	            { 
	               HH2 = HH1; 
	               HH1 = barhighest; 
	               if (HH1 != HH2) 
	               { 
	                  is_low = true; 
	                  is_high = false; 
	                 // HL.Add(barhighestDateTime, barhighest);  
	                                  	Plot("Plotter", "HH", barhighest);
	                  //barlowest =  Bars.LowestLow(4); 
	                  barlowest = Math.Min(Math.Min(Math.Min(Bars[0].High,Bars[1].High),Bars[2].High),Bars[3].High);    
	
	                  barlowestDateTime = bar[symbol].EndTime; 
	                  HLbarcount = 0; 
	                  LL1 = 0; 
	                  LL2 = 0; 
	             //     Log("{0}     HH1 = {1}     barlowest = {2}", barhighestDateTime, HH1, barlowest);                                     
	               } 
	            } 
	 
	         }       
	 
	      }     
	      else 
	      { 
	     //    Log("Instrument:    {0},       Date/Time:     {1}", Instrument, bar.DateTime); 
	      } 
	   } 
	}
}