how to reference a custom indicator
how to reference a custom indicator
25 Aug 2020, 17:17
Hi Panagiotis, how are you, brother I'm having trouble making reference to a custom indicator in my Cbot. How could I solve this problem? Below is my model. thanks man, you are the best
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.ESouthAmericaStandardTime, AccessRights = AccessRights.None)]
public class bot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter("Periods", DefaultValue = 14)]
public int Periods { get; set; }
[Parameter("Stop Loss (pips)", DefaultValue = 40, MinValue = 10)]
public double StopLoss { get; set; }
[Parameter("Volume", DefaultValue = 10000, MinValue = 1000)]
public int Volume { get; set; }
[Parameter("Take_Profit", DefaultValue = 100, MinValue = 10)]
public double TakeProfit { get; set; }
[Output("Referenced 61.8retracement Output")]
public IndicatorDataSeries refretracement { get; set; }
private 61.8retracement _retra;
protected override void Initialize()
{
_retra = Indicators.GetIndicator<Sample61.retracement>(Source);
}
However I have received this error message. ( Error : Project C:\Users\Samuel\Documents\cAlgo\Sources\Indicators\ZigZag\ZigZag\ZigZag.csproj doesn't exist. )
And yes, I already used the reference manager. But it is still impossible to use the indicator on my bot.
Replies
samuel.jus.cornelio
26 Aug 2020, 14:10
RE:
PanagiotisCharalampous said:
Hi Sam,
Did you build the indicator before referencing it? Does it build without problems?
Best Regards,
Panagiotis
The indicator has been used normally in live trades. In case the indicator was downloaded from the Ctrader website
@samuel.jus.cornelio
PanagiotisCharalampous
26 Aug 2020, 14:12
( Updated at: 21 Dec 2023, 09:22 )
Hi Sam,
Thanks but you did not reply to my question :) Did you try to build the indicator? Does it compile without problems?
Best Regards,
Panagiotis
@PanagiotisCharalampous
samuel.jus.cornelio
26 Aug 2020, 14:17
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi Sam,
Thanks but you did not reply to my question :) Did you try to build the indicator? Does it compile without problems?
Best Regards,
Panagiotis
Sorry man, I will try this method right now. Thank you
@samuel.jus.cornelio
samuel.jus.cornelio
26 Aug 2020, 14:22
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi Sam,
Thanks but you did not reply to my question :) Did you try to build the indicator? Does it compile without problems?
Best Regards,
Panagiotis
And we have an answer. No it doesn't build normally, I get this error message
Error : Project C:\Users\Samuel\Documents\cAlgo\Sources\Indicators\ZigZag\ZigZag\ZigZag.csproj doesn't exist.
follow the indicator code below
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewIndicator : Indicator
{
[Parameter(DefaultValue = 0.5)]
public double Deviation { get; set; }
[Parameter("% Retracement", DefaultValue = 38.2)]
public double per { get; set; }
[Output("_forIndicators", Color = Colors.Gray, PlotType = PlotType.DiscontinuousLine)]
public IndicatorDataSeries sign { get; set; }
[Output("UpTrend", PlotType = PlotType.DiscontinuousLine)]
public IndicatorDataSeries up { get; set; }
[Output("DownTrend", Color = Colors.Red, PlotType = PlotType.DiscontinuousLine)]
public IndicatorDataSeries down { get; set; }
private ZigZagAndFiboLevels zz;
protected override void Initialize()
{
zz = Indicators.GetIndicator<ZigZagAndFiboLevels>(Deviation, false, false, false);
}
public override void Calculate(int index)
{
int i = index;
while (double.IsNaN(zz.Value[i]) && i > 0)
{
i--;
}
double A = zz.Value[i];
i--;
while (double.IsNaN(zz.Value[i]) && i > 0)
{
i--;
}
double B = zz.Value[i];
sign[index] = A < B ? B - (1 - per / 100) * (B - A) : A > B ? A - per / 100 * (A - B) : double.NaN;
down[index] = A < B ? B - (1 - per / 100) * (B - A) : double.NaN;
up[index] = A > B ? A - per / 100 * (A - B) : double.NaN;
}
}
}
@samuel.jus.cornelio
PanagiotisCharalampous
26 Aug 2020, 14:31
Hi Sam,
It seems this indicator is using another indicator (ZigZagAndFiboLevels). Did you download this indicator?
Best Regards,
Panagiotis
@PanagiotisCharalampous
samuel.jus.cornelio
26 Aug 2020, 14:44
RE:
PanagiotisCharalampous said:
Hi Sam,
It seems this indicator is using another indicator (ZigZagAndFiboLevels). Did you download this indicator?
Best Regards,
Panagiotis
now the indicator is being built normally :))
is there any example of making the reference? Thanks man
@samuel.jus.cornelio
PanagiotisCharalampous
26 Aug 2020, 14:50
Hi Sam,
I am not sure what kind of an example do you need. Can you please explain?
Best Regards,
Panagiotis
@PanagiotisCharalampous
samuel.jus.cornelio
26 Aug 2020, 15:01
RE:
PanagiotisCharalampous said:
Hi Sam,
I am not sure what kind of an example do you need. Can you please explain?
Best Regards,
Panagiotis
I need an example of how to put this Indicator (61.8 retracement) in my Cbot
@samuel.jus.cornelio
PanagiotisCharalampous
26 Aug 2020, 15:11
Hi Sam,
But you already do this above
_retra = Indicators.GetIndicator<Sample61.retracement>(Source);
Best Regards,
Panagiotis
@PanagiotisCharalampous
samuel.jus.cornelio
26 Aug 2020, 15:23
RE:
PanagiotisCharalampous said:
Hi Sam,
But you already do this above
_retra = Indicators.GetIndicator<Sample61.retracement>(Source);
Best Regards,
Panagiotis
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.ESouthAmericaStandardTime, AccessRights = AccessRights.None)]
public class bot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter("Periods", DefaultValue = 14)]
public int Periods { get; set; }
[Parameter("Stop Loss (pips)", DefaultValue = 40, MinValue = 10)]
public double StopLoss { get; set; }
[Parameter("Volume", DefaultValue = 10000, MinValue = 1000)]
public int Volume { get; set; }
[Parameter("Take_Profit", DefaultValue = 100, MinValue = 10)]
public double TakeProfit { get; set; }
[Output("Referenced 61.8retracement Output")]
public IndicatorDataSeries refretracement { get; set; }
private 61.retracement _retra;
protected override void OnTick()
{
_retra = Indicators.GetIndicator<Sample61.retracement>(Source);
...
error messages :
Error CS1519: Token '61' invalid in class, struct or interface member declaration
Error CS1031: Expected type
:(
@samuel.jus.cornelio
PanagiotisCharalampous
26 Aug 2020, 15:36
Hi Sam,
In general your code does not make much sense.
You are declaring this
private 61.retracement _retra;
But then you are calling an indicator of another type
_retra = Indicators.GetIndicator<Sample61.retracement>(Source);
Finally the class for the indicator you posted is something else
public class NewIndicator : Indicator
Best Regards,
Panagiotis
@PanagiotisCharalampous
samuel.jus.cornelio
26 Aug 2020, 19:38
RE:
PanagiotisCharalampous said:
Hi Sam,
In general your code does not make much sense.
You are declaring this
private 61.retracement _retra;
But then you are calling an indicator of another type
_retra = Indicators.GetIndicator<Sample61.retracement>(Source);
Finally the class for the indicator you posted is something else
public class NewIndicator : Indicator
Best Regards,
Panagiotis
now I tried it that way. and still not working :(((
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.ESouthAmericaStandardTime, AccessRights = AccessRights.None)]
public class bot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter("Periods", DefaultValue = 14)]
public int Periods { get; set; }
[Parameter("Stop Loss (pips)", DefaultValue = 40, MinValue = 10)]
public double StopLoss { get; set; }
[Parameter("Volume", DefaultValue = 10000, MinValue = 1000)]
public int Volume { get; set; }
[Parameter("Take_Profit", DefaultValue = 100, MinValue = 10)]
public double TakeProfit { get; set; }
[Output("Referenced 61.8retracement Output")]
public IndicatorDataSeries ref61.8retracement { get; set; }
private 61.8retracement _retra;
protected override void OnTick()
{
_retra = Indicators.GetIndicator<61.8retracement>(0.5, 30);
...
@samuel.jus.cornelio
PanagiotisCharalampous
27 Aug 2020, 07:46
Hi Sam,
How about your indicator's Class name? It's named NewIndicator and not 61.8retracement.
Best Regards,
Panagiotis
@PanagiotisCharalampous
samuel.jus.cornelio
27 Aug 2020, 16:21
RE:
PanagiotisCharalampous said:
Hi Sam,
How about your indicator's Class name? It's named NewIndicator and not 61.8retracement.
Best Regards,
Panagiotis
sorry, man. I couldn't understand / implement your idea. Could you please give me a concrete example?
@samuel.jus.cornelio
PanagiotisCharalampous
27 Aug 2020, 16:27
Hi Sam,
It's you who needs to explain what you are doing in order to help you. You are trying to declare an indicator with a class name of 61.8retracement but you have not posted such an indicator here. What indicator is this? Can you share it with us?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Aug 2020, 08:07
Hi Sam,
Did you build the indicator before referencing it? Does it build without problems?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous