struct error

Created at 18 May 2014, 22:04
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MA

mardahl

Joined 18.05.2014

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.


@mardahl
Replies

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

mardahl
19 May 2014, 19:30

RE:

Thanks, now everything is clear.

 


@mardahl