Description
Buy Sell signals for breakout trading.
Adjust the period as you need.
- XTick: Safe gap from break out value, e.g. if XTick = 5, a gap of 5 * TickSize is reserved for signal. Adjust it to prevent Fake out.
- Period: if = 5, then whenever there is a break thru max of 5 or min of 5 plus the gap, signal is triggered.
Do not use it alone.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Linq;
using System.Collections.Generic;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, AutoRescale = true, AccessRights = AccessRights.None)]
public class LT_Ind_OX : Indicator
{
[Parameter(DefaultValue = 5, MinValue = 1)]
public double XTick { get; set; }
[Parameter(DefaultValue = 3, MinValue = 1)]
public int Periods { get; set; }
[Parameter(DefaultValue = "Yellow", Group = "Draws")]
public Color Color { get; set; }
DonchianChannel _donchian;
protected override void Initialize()
{
_donchian = Indicators.DonchianChannel(Periods);
}
bool _curX, _curO;
public override void Calculate(int index)
{
var top = _donchian.Top[index] + Symbol.TickSize * XTick;
var bot = _donchian.Bottom[index] - Symbol.TickSize * XTick;
var key = $"Ox_{Bars.OpenTimes[index]}";
if (Bars.ClosePrices[index] > top && Math.Min(Bars.OpenPrices[index], Bars.ClosePrices[index - 1]) < top)
{
var txt = Chart.DrawText($"{key}_x", "x", index, top, Color);
txt.VerticalAlignment = VerticalAlignment.Center;
txt.HorizontalAlignment = HorizontalAlignment.Center;
_curX = true;
}
else
{
if (_curX)
{
_curX = false;
Chart.RemoveObject($"{key}_x");
}
}
if (Bars.ClosePrices[index] < bot && Math.Max(Bars.OpenPrices[index], Bars.ClosePrices[index - 1]) > bot)
{
var txt = Chart.DrawText($"{key}_o", "o", index, bot, Color);
txt.VerticalAlignment = VerticalAlignment.Center;
txt.HorizontalAlignment = HorizontalAlignment.Center;
_curO = true;
}
else
{
if (_curO)
{
_curO = false;
Chart.RemoveObject($"{key}_o");
}
}
}
}
}
dhnhuy
Joined on 03.04.2023
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: LT_Ind_OX.algo
- Rating: 0
- Installs: 802
- Modified: 22/03/2024 06:45
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.