Error CS0118
Created at 31 Mar 2022, 15:01
GE
Error CS0118
31 Mar 2022, 15:01
Getting error cs0118 namespace used like a type.
Also, when adding a reference to an indicator, the source is disappearing from the editor
but the Build button is working.
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 Test40
{
[Indicator(AccessRights = AccessRights.None)]
public class Test40 : Indicator
{
[Parameter(DefaultValue = "Hello world!")]
public string Message { get; set; }
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
public Test ind;
protected override void Initialize()
{
// To learn more about cTrader Automate visit our Help Center:
// https://help.ctrader.com/ctrader-automate
ind = Indicators.GetIndicator<Test>();
Print(Message);
}
public override void Calculate(int index)
{
// Calculate value at specified index
// Result[index] =
}
}
}
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 Test
{
[Indicator(AccessRights = AccessRights.None)]
public class Test : Indicator
{
[Parameter(DefaultValue = "Hello world!")]
public string Message { get; set; }
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
protected override void Initialize()
{
// To learn more about cTrader Automate visit our Help Center:
// https://help.ctrader.com/ctrader-automate
Print(Message);
}
public override void Calculate(int index)
{
// Calculate value at specified index
// Result[index] =
}
}
}
amusleh
04 Apr 2022, 10:04 ( Updated at: 04 Apr 2022, 10:08 )
Hi,
It happens because your indicator namespace and class names are same, try this:
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 Test40 { [Indicator(AccessRights = AccessRights.None)] public class Test40 : Indicator { [Parameter(DefaultValue = "Hello world!")] public string Message { get; set; } [Output("Main")] public IndicatorDataSeries Result { get; set; } public Test.Test ind; protected override void Initialize() { // To learn more about cTrader Automate visit our Help Center: // https://help.ctrader.com/ctrader-automate ind = Indicators.GetIndicator<Test.Test>("Another Indicator"); Print(Message); } public override void Calculate(int index) { // Calculate value at specified index // Result[index] = } } }
@amusleh