Session High And Low
Session High And Low
18 Sep 2014, 21:59
Hi, I am new here and have been coding in eaylanguage for a while. I am learning in c# now. is it possible to create an indicator that indicates the session high and low price for say for example Tokyo session or London Session or New York session.
Thanks in advance.
Abhi
Replies
Spotware
29 Sep 2014, 12:23
We recommend you to post a job in Jobs section or contact one of cAlgo consultants.
@Spotware
Abhi
01 Oct 2014, 12:13
RE:
Spotware said:
We recommend you to post a job in Jobs section or contact one of cAlgo consultants.
no worries, I guess that was a very polite hint. :-)
never mind, I sorted it out.
@Abhi
Abhi
28 Sep 2014, 15:36
Session High And Low
Hi Spotware team, I managed to do some coding but ran into some issues. My chart time settings are UTC+1 (UK time).
I could plot high and low for New York time session between 1 pm and 10 pm but for some reason I cannot plot high and low for time session between 1 pm and 1:15 pm.
Please can anybody help.
// Start of the code here
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.CentralEuropeanStandardTime, AccessRights = AccessRights.None)]
public class AbhiCharts : Indicator
{
protected DateTime today, tomorrow;
protected int ORMinute;
protected TimeSpan NewYorkStartTime, NewYorkEndTime;
protected TimeSpan NewYorkORStartTime, NewYorkOREndTime;
protected double High_NewYorkStartTime, Low_NewYorkEndTime;
protected double High_NewYorkORStartTime, Low_NewYorkOREndTime;
protected DateTime plot_NewYorkStartTime, plot_NewYorkEndTime;
protected int NewYorkStartHour, NewYorkEndHour;
protected int NewYorkORStartHour, NewYorkOREndHour;
protected override void Initialize()
{
ORMinute = 15;
NewYorkStartHour = 14;
NewYorkEndHour = 23;
NewYorkStartTime = new TimeSpan(NewYorkStartHour, 0, 0);
NewYorkEndTime = new TimeSpan(NewYorkEndHour, 0, 0);
NewYorkORStartTime = new TimeSpan(NewYorkStartHour, 0, 0);
NewYorkOREndTime = new TimeSpan(NewYorkStartHour, ORMinute, 0);
}
public override void Calculate(int index)
{
today = MarketSeries.OpenTime[index].Date;
tomorrow = today.AddDays(1);
plot_NewYorkStartTime = today.Date.AddHours(NewYorkStartHour);
plot_NewYorkEndTime = today.Date.AddHours(NewYorkEndHour);
High_NewYorkStartTime = MarketSeries.High.LastValue;
Low_NewYorkEndTime = MarketSeries.Low.LastValue;
High_NewYorkORStartTime = MarketSeries.High.LastValue;
Low_NewYorkOREndTime = MarketSeries.Low.LastValue;
for (int i = MarketSeries.Close.Count - 1; i > 0; i--)
{
if (MarketSeries.OpenTime[i].Date < today)
break;
if ((MarketSeries.OpenTime[i].TimeOfDay >= NewYorkStartTime) && (MarketSeries.OpenTime[i].TimeOfDay <= NewYorkEndTime))
{
High_NewYorkStartTime = Math.Max(High_NewYorkStartTime, MarketSeries.High[i]);
Low_NewYorkEndTime = Math.Min(Low_NewYorkEndTime, MarketSeries.Low[i]);
}
if ((MarketSeries.OpenTime[i].TimeOfDay >= NewYorkORStartTime) && (MarketSeries.OpenTime[i].TimeOfDay <= NewYorkOREndTime))
{
High_NewYorkORStartTime = Math.Max(High_NewYorkORStartTime, MarketSeries.High[i]);
Low_NewYorkOREndTime = Math.Min(Low_NewYorkOREndTime, MarketSeries.Low[i]);
}
}
ChartObjects.DrawLine("High " + today, plot_NewYorkStartTime, High_NewYorkStartTime, plot_NewYorkEndTime, High_NewYorkStartTime, Colors.Red);
ChartObjects.DrawLine("Low " + today, plot_NewYorkStartTime, Low_NewYorkEndTime, plot_NewYorkEndTime, Low_NewYorkEndTime, Colors.Green);
ChartObjects.DrawText("TextHigh " + today, string.Format("{0}", High_NewYorkStartTime), index, High_NewYorkStartTime, VerticalAlignment.Top, HorizontalAlignment.Right, Colors.Red);
ChartObjects.DrawText("TextLow " + today, string.Format("{0}", Low_NewYorkEndTime), index, Low_NewYorkEndTime, VerticalAlignment.Top, HorizontalAlignment.Right, Colors.Green);
ChartObjects.DrawLine("HighOR " + today, plot_NewYorkStartTime, High_NewYorkORStartTime, plot_NewYorkEndTime, High_NewYorkORStartTime, Colors.Yellow);
ChartObjects.DrawLine("LowOR " + today, plot_NewYorkStartTime, Low_NewYorkOREndTime, plot_NewYorkEndTime, Low_NewYorkOREndTime, Colors.Yellow);
ChartObjects.DrawText("TextHighOR " + today, string.Format("High: {0}", High_NewYorkORStartTime), index, High_NewYorkORStartTime, VerticalAlignment.Top, HorizontalAlignment.Right, Colors.Yellow);
ChartObjects.DrawText("TextLowOR " + today, string.Format("Low: {0}", Low_NewYorkOREndTime), index, Low_NewYorkOREndTime, VerticalAlignment.Top, HorizontalAlignment.Right, Colors.Yellow);
//string text = string.Format("MarketSeries.OpenTime[i].TimeOfDay : {0}", MarketSeries.OpenTime[i].TimeOfDay);
//ChartObjects.DrawText("Diff", text, StaticPosition.TopLeft, Colors.Lime);
}
}
}
@Abhi