Topics
22 Jan 2016, 11:53
 92
 1402
 4
Replies

magforex
30 Oct 2015, 15:54

RE:

cAlgo_Fanatic said:

Daily High and Low Indicator. Displays horizontal lines that correspond to the daily high and low.

 

Source Code:

using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true)]
    public class DailyHighLow : Indicator
    {
        public override void Calculate(int index)
        {
            DateTime today = MarketSeries.OpenTime[index].Date;
            DateTime tomorrow = today.AddDays(1);

            double high = MarketSeries.High.LastValue;
            double low = MarketSeries.Low.LastValue;

            for (int i = MarketSeries.Close.Count - 1; i > 0; i--)
            {
                if (MarketSeries.OpenTime[i].Date < today)
                    break;

                high = Math.Max(high, MarketSeries.High[i]);
                low = Math.Min(low, MarketSeries.Low[i]);
            }

            ChartObjects.DrawLine("high " + today, today, high, tomorrow, high, Colors.Pink);
            ChartObjects.DrawLine("low " + today, today, low, tomorrow, low, Colors.Pink);
        }
    }
}


 

Hi Spotware, how do I control if I only want the current day or maybe only 2 days high and low only? Can you give me a hint? thanks!


@magforex