Sunday dailyOpen is missing...
Sunday dailyOpen is missing...
31 Jan 2016, 19:36
Does somebody know why the sunday dailyOpen is missing? (Fat Blue line.) See chart examples and indicator-link below.
/algos/indicators/show/1104
Detail
Replies
MaVe
31 Jan 2016, 22:19
- Time set at UTC +0
- Indicator TimeZone = TimeZones.UTC
- First bar on sunday 22:05, second bar, 22:06, ... 22:07, ,...
- First bar on monday 00:00, second bar, 00:01, ... 00:02, ...
Time settings are correct.
My question is: what do I have to change at the code, to get it right?
@MaVe
MaVe
01 Feb 2016, 08:54
The problem is:
- at the Metals and Currencies, the dailyOpen is missing on Sunday
- at the Energies, the dailyOpen is missing on Monday
So it seems to me that the dailyOpen is skipping the first day of the week.
How do I correct that?
// This indicator displays the daily OHLC. // The daily High/Low horizontal lines are extended two days into the future. (Colors: red and green.) // The dailyClose is only on the next day visible (as the previousClose) and extended one extra day into the future. (Color: blue.) // The dailyOpen for each day is a solid, fat line. (Color: mediumblue.) // // The logic of the LineStyle: // // Daily: solid line // Previous(p): ---- dashed line // prePrevious(pp): .... dotted line // // // Daily Result: Occurred at: Color: // Open --------- Today ---------------- MediumBlue(Fat) // High/Low ----- Today ---------------- Yellow // pHigh/pLow --- Yesterday ------------ Red/Green // ppHigh/ppLow - Day before Yesterday - Red/Green // pClose ------- Yesterday ------------ Blue // ppClose ------ Day before Yesterday - Blue // // // It is possible to change: - Daily Open on/off // - Daily Open color // - Daily High/Low color // // -- Free to use -- // MaVe // ---- Version: Sunday31Jan201 // using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, AutoRescale = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class MaVeTripleDailyOHLC : Indicator { [Parameter("Daily High/Low Color", DefaultValue = "Yellow")] public string DailyHighLowColor { get; set; } [Parameter("Show Daily Open", DefaultValue = false)] public bool ShowDailyOpen { get; set; } private Colors dailyHLcolor; // ------------------------------------------------------ protected override void Initialize() { Enum.TryParse(DailyHighLowColor, out dailyHLcolor); } // ------------------------------------------------------ public override void Calculate(int index) { DateTime today = MarketSeries.OpenTime[index].Date; DateTime today1 = today.AddDays(1); DateTime today2 = today.AddDays(2); DateTime today3 = today.AddDays(3); double high = MarketSeries.High.Last(0); double low = MarketSeries.Low.Last(0); double open = MarketSeries.Open[index + 1]; double close = MarketSeries.Close[index]; 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]); } // ----- Triple DailyHighLow ChartObjects.DrawLine("High" + today, today, high, today1, high, dailyHLcolor, 1); ChartObjects.DrawLine("Low" + today, today, low, today1, low, dailyHLcolor, 1); ChartObjects.DrawText("High-text", "High", index, high, VerticalAlignment.Bottom, HorizontalAlignment.Right, dailyHLcolor); ChartObjects.DrawText("Low-Text", "Low", index, low, VerticalAlignment.Top, HorizontalAlignment.Right, dailyHLcolor); ChartObjects.DrawLine("pHigh" + today, today1, high, today2, high, Colors.Green, 1, LineStyle.Lines); ChartObjects.DrawLine("pLow" + today, today1, low, today2, low, Colors.Red, 1, LineStyle.Lines); ChartObjects.DrawLine("ppHigh" + today, today2, high, today3, high, Colors.Green, 1, LineStyle.DotsRare); ChartObjects.DrawLine("ppLow" + today, today2, low, today3, low, Colors.Red, 1, LineStyle.DotsRare); // ----- PreviousClose ChartObjects.DrawLine("pClose" + today, today1, close, today2, close, Colors.Blue, 1, LineStyle.Lines); ChartObjects.DrawLine("ppClose" + today, today2, close, today3, close, Colors.Blue, 1, LineStyle.DotsRare); // ----- DailyOpen if (!ShowDailyOpen) return; ChartObjects.DrawLine("Open" + today, today1, open, today2, open, Colors.MediumBlue, 2); } } }
@MaVe
ctid253839
07 Feb 2017, 15:27
hi there mave, congratulation for your C# code. till now it is the best indicator i have found here;)
i m tring to add inside this code the daily pivot too, couse that one is a very important point.
hope this will not offend you. i m telling just to let you know and just to say i m using your code to learn;) my first steps, couse it is quet clear
are you learning coding in calgo?
i think you already are a coder, couse it is not easy, at least for me....but i m tring the same.
in the future i d like develping a cbot....working on my trading system....
so for now thanks!
mat
@ctid253839
galafrin
31 Jan 2016, 21:58
You may adjust cTrader time shift right bottom to have time separators coincide with date.
@galafrin