Custom indicator recognition problem
Custom indicator recognition problem
15 Jul 2023, 20:40
Hey Guys,
I cant for the life of me get cAlgo to recognise my custom indicator RateOfChange.
Here is the code snippet plus the indicator code maybe someone can see what I am doing wrong?
I get the error code Cs2046: The type or namespace name RateOfChange could not be found
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.UTC, AccessRights = AccessRights.None)]
public class FxBotPro : Robot
{
[Parameter("Volume in Units (Default) ", DefaultValue = 10000)]
public int DefaultVolumeInUnits { get; set; }
[Parameter("Stop Loss in Pips", DefaultValue = 5)]
public int StopLossInPips { get; set; }
[Parameter("Take Profit in Pips", DefaultValue = 5)]
public int TakeProfitInPips { get; set; }
[Parameter("Max Risk Per Trade (%)", DefaultValue = 2.0)]
public double MaxRiskPerTrade { get; set; }
[Parameter("SMA Short Period", DefaultValue = 5)]
public int ShortPeriod { get; set; }
[Parameter("SMA Medium Period", DefaultValue = 8)]
public int MediumPeriod { get; set; }
[Parameter("SMA Long Period", DefaultValue = 13)]
public int LongPeriod { get; set; }
[Parameter("RSI Period", DefaultValue = 14)]
public int RsiPeriod { get; set; }
[Parameter("Upper Bollinger Band Period", DefaultValue = 20)]
public int UpperBBPeriod { get; set; }
[Parameter("Lower Bollinger Band Period", DefaultValue = 20)]
public int LowerBBPeriod { get; set; }
[Parameter("Trailing Stop in Pips", DefaultValue = 20)]
public int TrailingStopInPips { get; set; }
[Parameter("Lorentzian x0", DefaultValue = 0.0)]
public double LorentzianX0 { get; set; }
[Parameter("Lorentzian γ", DefaultValue = 1.0)]
public double LorentzianGamma { get; set; }
[Parameter("Lorentzian Period", DefaultValue = 14)]
public int LorentzianPeriod { get; set; }
[Parameter("Volatility Threshold", DefaultValue = 0.5)]
public double VolatilityThreshold { get; set; }
[Parameter("Deviation Threshold", DefaultValue = 0.5)]
public double DeviationThreshold { get; set; }
private SimpleMovingAverage smaShort;
private SimpleMovingAverage smaMedium;
private SimpleMovingAverage smaLong;
private RelativeStrengthIndex rsi;
private BollingerBands bb;
private RateOfChange roc;
protected override void OnStart()
{
smaShort = Indicators.SimpleMovingAverage(Bars.ClosePrices, ShortPeriod);
smaMedium = Indicators.SimpleMovingAverage(Bars.ClosePrices, MediumPeriod);
smaLong = Indicators.SimpleMovingAverage(Bars.ClosePrices, LongPeriod);
rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, RsiPeriod);
bb = Indicators.BollingerBands(Bars.ClosePrices, UpperBBPeriod, 2, MovingAverageType.Simple);
roc = Indicators.GetIndicator<RateOfChange>(LorentzianPeriod);
Indicator
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class RateOfChange : Indicator
{
[Parameter(DefaultValue = 14)]
public int Periods { get; set; }
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
public override void Calculate(int index)
{
if (index < Periods)
{
Result[index] = 0;
}
else
{
double diff = Bars.ClosePrices[index] - Bars.ClosePrices[index - Periods];
Result[index] = (diff / Bars.ClosePrices[index - Periods]) * 100;
}
}
}
}
Thanks Peeps
Replies
jamesgoodman
17 Jul 2023, 14:38
RE:
firemyst said:
Did you add your Rate of Change as a "reference" to your bot?
No I have created the RateOfChange in the indicator class and then used the Indicators.GetIndicators function in main bot. Are you saying I need to create it in an external library?
@jamesgoodman
firemyst
21 Jul 2023, 00:04
RE: RE:
jamesgoodman said:
firemyst said:
Did you add your Rate of Change as a "reference" to your bot?
No I have created the RateOfChange in the indicator class and then used the Indicators.GetIndicators function in main bot. Are you saying I need to create it in an external library?
Read this:
https://clickalgo.com/ctrader-assembly-reference
@firemyst
firemyst
17 Jul 2023, 09:47
Did you add your Rate of Change as a "reference" to your bot?
@firemyst