cAlgo Error CS1503 with AverageTrueRange Indicator (ATR)
Created at 03 Jan 2025, 10:47
PI
cAlgo Error CS1503 with AverageTrueRange Indicator (ATR)
03 Jan 2025, 10:47
I'm encountering a CS1503 error in my cAlgo robot when trying to calculate the Average True Range (ATR) indicator. The error message indicates that I'm providing incorrect argument types to the Indicators.AverageTrueRange()
method.
Here's the relevant code snippet:
indicatorTasks.Add(Task.Run(() =>
indicators[timeframe][symbol]["ATR"] = Indicators.AverageTrueRange(
bars, config.IndicatorSettings.ATR.Period)));
Error Messages:
- CS1503: Argument 1: cannot convert from 'cAlgo.API.Bars' to 'int'
- CS1503: Argument 2: cannot convert from 'int' to 'cAlgo.API.MovingAverageType'
Context:
- I'm using cAlgo in Ctrader 5.0.50
- I'm trying to calculate the ATR indicator for multiple symbols and timeframes.
- The
bars
variable is aBars
object obtained usingMarketData.GetBars(timeframe, symbol)
. config.IndicatorSettings.ATR.Period
is an integer representing the ATR period.
Troubleshooting Steps Taken:
- I've double-checked the cAlgo API documentation to confirm the arguments for
AverageTrueRange
. - I've verified that the
bars
variable is a validBars
object and thePeriod
is an integer.
Question:
Any idea why am I getting these CS1503 errors with the AverageTrueRange
indicator? What am I doing wrong, and how can I fix this issue?
Many thanks for your help!