Description
Follow my cTrader Telegram group at https://t.me/cTraderCommunity; it's a new community but it will grow fast, plus everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them.
This must be used on Daily TF!
This indicator shows Hosoda's cyclic days; press ctrl and move the mouse to set the starting date.
If you are new to hosoda techniques, you must know that this must be used with ichimoku and Hosoda Waves, which will be the next indicator uploaded.
Please note that you must set you TimeZone to use this correctly. To set the TimeZone, open cTrader's code editor and change it at line 10 of this indicator.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Collections.Generic;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class Cicli_Hosoda : Indicator
{
[Parameter("Show Starting Date", DefaultValue = true)]
public bool st_date { get; set; }
[Parameter("Show Cycles Dates", DefaultValue = true)]
public bool cy_date { get; set; }
public DateTime dt;
public int init_index;
public bool error = false;
public string calendar = "";
protected override void Initialize()
{
if (MarketSeries.TimeFrame != TimeFrame.Daily)
{
ChartObjects.DrawText("Error", "\nTimeFrame must be Daily", StaticPosition.TopCenter, Colors.Red);
error = true;
Print("error 4");
}
Chart.MouseMove += OnChartMouseMove;
}
void OnChartMouseMove(ChartMouseEventArgs obj)
{
if (obj.CtrlKey && !obj.AltKey && !obj.ShiftKey)
{
dt = MarketSeries.OpenTime[(int)obj.BarIndex];
init_index = (int)obj.BarIndex;
Calculate_();
}
}
public int paragone = 0;
public override void Calculate(int index)
{
}
public void Calculate_()
{
if (error)
return;
if (st_date)
ChartObjects.DrawText("start date", "Starting Date: " + dt.Day.ToString() + "/" + dt.Month.ToString() + "/" + dt.Year.ToString(), StaticPosition.TopRight, Colors.Yellow);
int count = 1;
double quote = MarketSeries.High[init_index];
ChartObjects.DrawVerticalLine("cycle" + count, dt, Colors.Yellow, 1, LineStyle.Solid);
int added_days = 1;
int paragone = count;
while (added_days < 365)
{
if (dt.AddDays(added_days).DayOfWeek != DayOfWeek.Sunday && dt.AddDays(added_days).DayOfWeek != DayOfWeek.Saturday && !(dt.AddDays(added_days).Day == 25 && dt.AddDays(added_days).Month == 12) && !(dt.AddDays(added_days).Day == 1 && dt.AddDays(added_days).Month == 1))
count++;
DrawLine(count, dt.AddDays(added_days), quote);
added_days++;
}
if (cy_date)
{
ChartObjects.DrawText("calendar", calendar, StaticPosition.TopRight, Colors.Yellow);
calendar = "";
}
}
public List<int> Days = new List<int>
{
9,
13,
17,
26,
33,
42,
51,
65,
76
};
private void DrawLine(int count, DateTime i, double quote)
{
if (count == paragone)
return;
bool checker = false;
foreach (int day in Days)
{
if (count == day)
checker = true;
}
if (checker)
{
Chart.DrawVerticalLine(count.ToString() + " day", i, Color.Red);
Chart.DrawText(count.ToString(), count.ToString(), i, quote, Color.White);
calendar = calendar + ("\n" + count.ToString() + ": " + i.Day.ToString() + '/' + i.Month.ToString() + '/' + i.Year.ToString());
paragone = count;
}
}
}
}
cysecsbin.01
Joined on 10.11.2018 Blocked
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: HosodaCycles.algo
- Rating: 0
- Installs: 1554
- Modified: 13/10/2021 09:54