Error CT0002: ASSEMBLY MUST COINTAIN ALGO TYPE.
Error CT0002: ASSEMBLY MUST COINTAIN ALGO TYPE.
30 Aug 2023, 14:47
Hello
I'm creating an indicator from scratch I'm not a programmer but I make an effort. The code of my program has no errors, but at compile time I get the following error.
Error CT0002: Assembly must contain something type.
Please someone knowledgeable help me.
Replies
ricardos274
31 Aug 2023, 15:45
( Updated at: 01 Sep 2023, 04:18 )
RE: Error CT0002: ASSEMBLY MUST COINTAIN ALGO TYPE.
PanagiotisChar said:
Hi there,
Your code does not look like an indicator code. Can you share the complete code of your indicator?
using System;
namespace cAlgo.API
{
public enum TimeZones
{
UTC
}
public class Color
{
// Define propiedades y métodos de la clase Color aquí
}
public class HorizontalLine
{
// Define propiedades y métodos de la clase HorizontalLine aquí
public double Price { get; internal set; }
public bool IsDeleted { get; internal set; }
public object LineColor { get; internal set; }
}
}
namespace cAlgo
{
using cAlgo.API; // Importar el espacio de nombres cAlgo.API
using HorizontalLineAPI = cAlgo.API.HorizontalLine; // Alias para evitar conflicto de nombres
[AttributeUsage(AttributeTargets.Class)]
public class IndicatorAttribute : Attribute
{
public bool IsOverlay { get; set; }
public TimeZones TimeZone { get; set; }
}
public abstract class Indicator
{
// Define las propiedades y métodos de tu clase Indicator aquí
public abstract void Calculate(int index);
}
public class MarketSeries
{
public double[] High { get; set; }
public double[] Low { get; set; }
public double[] Close { get; set; }
}
public class InstitutionalLevels : Indicator
{
private double sensitivity = 0.1;
private double testTolerance = 5.0;
private readonly Color testedColor = new Color();
private readonly double[] fiboRetracements1 = new double[0]; // Inicializa el arreglo con el tamaño adecuado
public HorizontalLineAPI ResistanceLine1 { get; private set; } // Usar el alias aquí
public HorizontalLineAPI SupportLine { get; private set; } // Usar el alias aquí
public MarketSeries MarketSeries { get; set; }
public InstitutionalLevels(HorizontalLineAPI supportLine)
{
SupportLine = supportLine;
ResistanceLine1 = new HorizontalLineAPI();
}
public override void Calculate(int index)
{
if (MarketSeries == null || MarketSeries.Close == null || index >= MarketSeries.Close.Length - 1)
{
return;
}
double high = MarketSeries.High[index];
double low = MarketSeries.Low[index];
double close = MarketSeries.Close[index];
double range = high - low;
double upperLevel = close + range * sensitivity;
double lowerLevel = close - range * sensitivity;
double nearestResistance = FindNearestLevel(fiboRetracements1, upperLevel);
double nearestSupport = FindNearestLevel(fiboRetracements1, lowerLevel);
ResistanceLine1.Price = nearestResistance;
SupportLine.Price = nearestSupport;
CheckAndChangeColor(ResistanceLine1, high);
CheckAndChangeColor(SupportLine, low);
}
private double FindNearestLevel(double[] levels, double target)
{
if (levels == null || levels.Length == 0)
{
throw new ArgumentException("Levels array cannot be null or empty.");
}
double nearestLevel = levels[0];
double smallestDifference = Math.Abs(levels[0] - target);
foreach (double level in levels)
{
double difference = Math.Abs(level - target);
if (difference < smallestDifference)
{
nearestLevel = level;
smallestDifference = difference;
}
}
return nearestLevel;
}
private void CheckAndChangeColor(HorizontalLineAPI line, double price)
{
bool isTested = Math.Abs(price - line.Price) <= testTolerance;
if (price > line.Price && !isTested)
{
line.IsDeleted = true;
return;
}
line.LineColor = isTested ? testedColor : line.LineColor;
}
}
public class Program
{
public static void Main(string[] args)
{
// Crear una instancia de InstitutionalLevels
HorizontalLineAPI supportLine = new HorizontalLineAPI();
InstitutionalLevels institutionalLevels = new InstitutionalLevels(supportLine);
// Crear una instancia de MarketSeries y asignar valores de ejemplo
MarketSeries marketSeries = new MarketSeries
{
High = new double[] { 10.0, 15.0, 12.0, 18.0 },
Low = new double[] { 5.0, 8.0, 7.0, 10.0 },
Close = new double[] { 8.0, 12.0, 9.0, 15.0 }
};
// Asignar el MarketSeries a InstitutionalLevels
institutionalLevels.MarketSeries = marketSeries;
// Calcular los niveles institucionales para cada índice
for (int i = 0; i < marketSeries.Close.Length; i++)
{
institutionalLevels.Calculate(i);
Console.WriteLine("Resistance Level: " + institutionalLevels.ResistanceLine1.Price);
Console.WriteLine("Support Level: " + institutionalLevels.SupportLine.Price);
}
// Modificar el valor de la línea de soporte y recalcular los niveles institucionales
supportLine.Price = 7.5;
institutionalLevels.Calculate(marketSeries.Close.Length - 1);
Console.WriteLine("Resistance Level (after modification): " + institutionalLevels.ResistanceLine1.Price);
Console.WriteLine("Support Level (after modification): " + institutionalLevels.SupportLine.Price);
// Agregar más lógica de prueba o manipulación de datos según sea necesario
}
}
}hello thank you for your help
@ricardos274
ricardos274
31 Aug 2023, 16:01
( Updated at: 01 Sep 2023, 04:18 )
RE: Error CT0002: ASSEMBLY MUST COINTAIN ALGO TYPE.
PanagiotisChar said:
Hi there,
Hello, this would be a version of the NCATRSD indicator that is currently used in the Ninjatrader platform. Adapted to the ctrader platform If you know of one that is already on the ctrader platform and that complies with the ncatrsd characteristics, you would be so kind as to share it. In any case, we continue with my code to see what comes out lolz.
@ricardos274
PanagiotisChar
01 Sep 2023, 05:21
Hi there,
I am not sure where did you get this code from but it is definitely not a cTrader indicator.
@PanagiotisChar
PanagiotisChar
31 Aug 2023, 05:20
Hi there,
Your code does not look like an indicator code. Can you share the complete code of your indicator?
@PanagiotisChar