Chart.DrawText error. please help.
Created at 16 Feb 2020, 19:13
TR
Chart.DrawText error. please help.
16 Feb 2020, 19:13
please help me fix the error code. i dont know how to code.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
//using cAlgo.Lib;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class LEXtrend : Indicator
{
[Parameter("LEX Period", DefaultValue = 14, MinValue = 1, MaxValue = 25)]
public int Period { get; set; }
[Parameter("LEX Threshold", DefaultValue = 20, MinValue = 20, MaxValue = 60)]
public int Threshold { get; set; }
[Parameter("Arrow Offset", DefaultValue = 5, MinValue = 1, Step = 1)]
public double arrowOffset { get; set; }
private string upArrow = "▲";
private string downArrow = "▼";
private IchimokuKinkoHyo Ichimoku;
private DirectionalMovementSystem dms;
protected override void Initialize()
{
Ichimoku= Indicators.IchimokuKinkoHyo(9, 26, 52);
dms = Indicators.DirectionalMovementSystem (Period);
arrowOffset = Symbol.PipSize * arrowOffset;
}
public override void Calculate(int index)
{
double high = Bars.HighPrices[index];
double low = Bars.LowPrices[index];
if (BuySignal())
Chart.DrawText(string.Format("Buy {0}", index), upArrow, index - 1, low - arrowOffset, VerticalAlignment.Top, HorizontalAlignment.Center, Color.Lime);
if (SellSignal())
Chart.DrawText(string.Format("Sell {0}", index), downArrow, index - 1, high + arrowOffset, VerticalAlignment.Top, HorizontalAlignment.Center, Color.Red);
}
#region Predicate
public bool BuySignal()
{
return
Bars.ClosePrices.Last(1) > Bars.OpenPrices.Last(1) && Bars.ClosePrices.Last(1) > Ichimoku.KijunSen.Last(1) && dms.DIPlus.Last(1) > dms.DIMinus.Last(1) &&
dms.DIPlus.Last(1) > Threshold &&
(Bars.ClosePrices.Last(2) < Bars.OpenPrices.Last(2) || Bars.ClosePrices.Last(2) < Ichimoku.KijunSen.Last(2) || dms.DIPlus.Last(2) < dms.DIMinus.Last(2) || dms.DIPlus.Last(2) <= Threshold);
}
public bool SellSignal()
{
return
Bars.ClosePrices.Last(1) < Bars.OpenPrices.Last(1) && Bars.ClosePrices.Last(1) < Ichimoku.KijunSen.Last(1) && dms.DIPlus.Last(1) < dms.DIMinus.Last(1) &&
dms.DIMinus.Last(1) > Threshold &&
(Bars.ClosePrices.Last(2) > Bars.OpenPrices.Last(2) || Bars.ClosePrices.Last(2) > Ichimoku.KijunSen.Last(2) || dms.DIPlus.Last(2) > dms.DIMinus.Last(2) || dms.DIMinus.Last(2) <= Threshold);
}
#endregion
}
}
PanagiotisCharalampous
17 Feb 2020, 09:50
Hi traderfxmaster007,
See below
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous