Description
Follow my cTrader Telegram group at https://t.me/cTraderCommunity; everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them. There's also a Discord Server now @ https://discord.gg/5GAPMtp and an Instagram page https://www.instagram.com/ctrader_community/
This indicator shows you another TF in the indicator area below, this is a perfect solution for those who want to scalp lower TFs while keeping an eye on bigger ones.
Of course, since it's a cTrader indicator, you can apply other indicators on it or draw any kind of level, as shown here.
For any suggestion or bug report, contact me at the links above
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class AnotherTF : Indicator
{
[Parameter()]
public TimeFrame TF { get; set; }
[Parameter("Bullish Color", Group = "Colors", DefaultValue = "Cyan")]
public string BullColorName { get; set; }
[Parameter("Bearish Color", Group = "Colors", DefaultValue = "Violet")]
public string BearColorName { get; set; }
private MarketSeries MS;
private Color BullColor, BearColor;
private int Count, PrevCount, PrevIndex;
[Output("Close", LineColor = "Black", PlotType = PlotType.Points)]
public IndicatorDataSeries Close { get; set; }
protected override void Initialize()
{
BullColor = Color.FromName(BullColorName);
BearColor = Color.FromName(BearColorName);
MS = MarketData.GetSeries(TF);
Count = MS.Close.Count;
PrevCount = MS.Close.Count;
PrevIndex = Chart.BarsTotal;
DrawHistory();
}
public override void Calculate(int index)
{
if (!IsLastBar)
return;
Count = MS.Close.Count;
if (Count != PrevCount)
{
DrawHistory();
PrevCount = Count;
}
if (PrevIndex != index)
{
DrawHistory();
PrevIndex = index;
}
int MSIndex = MS.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);
Color CandleColor = MS.Close[MS.Close.Count - 1] >= MS.Open[MS.Open.Count - 1] ? BullColor : BearColor;
IndicatorArea.DrawTrendLine("Body " + (index), index, MS.Close[MS.Close.Count - 1], index, MS.Open[MS.Open.Count - 1], CandleColor, 3);
IndicatorArea.DrawTrendLine("Tail " + (index), index, MS.Low[MS.Close.Count - 1], index, MS.High[MS.Open.Count - 1], CandleColor, 1);
Close[index] = MS.Close[MS.Close.Count - 1];
}
private void DrawHistory()
{
/*for (int i = 0; i <= Chart.BarsTotal; ++i)
{
IndicatorArea.RemoveObject("Body " + i);
IndicatorArea.RemoveObject("Tail " + i);
}*/
for (int i = 1; i < MS.Close.Count; ++i)
{
Color CandleColor = MS.Close[MS.Close.Count - i] >= MS.Open[MS.Open.Count - i] ? BullColor : BearColor;
IndicatorArea.DrawTrendLine("Body " + (Chart.BarsTotal - i), Chart.BarsTotal - i, MS.Close[MS.Close.Count - i], Chart.BarsTotal - i, MS.Open[MS.Open.Count - i], CandleColor, 3);
IndicatorArea.DrawTrendLine("Tail " + (Chart.BarsTotal - i), Chart.BarsTotal - i, MS.Low[MS.Close.Count - i], Chart.BarsTotal - i, MS.High[MS.Open.Count - i], CandleColor, 1);
Close[Chart.BarsTotal - i] = MS.Close[MS.Close.Count - i];
}
}
}
}
cysecsbin.01
Joined on 10.11.2018 Blocked
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: AnotherTF.algo
- Rating: 0
- Installs: 1283
- Modified: 13/10/2021 09:54