MA
struct error
18 May 2014, 22:04
Hello,
I've came upon an error while compiling a cbot.
The error(s) states that every token used in declared structure is invalid.
I've checked C# refference and i think i'm not making an error myself.
The simple code is:
public struct cena
{
poprzednia = Symbol.Bid;
obecna = Symbol.Bid;
schowek = Symbol.Bid;
}
It doesn't compile also in following version:
public struct cena
{
poprzednia;
obecna;
schowek;
}
What am i doing wrong?
Checking the code in Visual Studio did not reveal any errors.

bp2012
19 May 2014, 02:15
There are a couple things you must do to fix the issue. Please see the code below. It shows how to declare and use a struct.
using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = false)] public class TestIndicator : Indicator { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } [Output("Main")] public IndicatorDataSeries Result { get; set; } protected override void Initialize() { // Initialize and create nested indicators cena a = new cena(); a.poprzednia = Symbol.Bid; a.obecna = Symbol.Bid; a.schowek = Symbol.Bid; } public override void Calculate(int index) { // Calculate value at specified index // Result[index] = ... } } public struct cena { public double poprzednia; public double obecna; public double schowek; } }@bp2012