Error : Error occured during parsing project file: ''Robotul' is an unexpected token. The expected token is '='. Line 2, position 34.'

Created at 23 Feb 2017, 05:36
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!
fermjy's avatar

fermjy

Joined 23.07.2016

Error : Error occured during parsing project file: ''Robotul' is an unexpected token. The expected token is '='. Line 2, position 34.'
23 Feb 2017, 05:36


Hey, this error came out...


Error : Error occured during parsing project file: ''Robotul' is an unexpected token. The expected token is '='. Line 2, position 34.'

I created a new bot.. and I pasted this code which is from my first test bot.....
Important: I THINK, that the problem It's related with the name of the cBot.. "ARobot"

 

using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

using System;
using System.Linq;


namespace cAlgo
{


    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ARobot : Robot
    {


        private const string cBotLabel = "A Robot";


        [Parameter("Buy", DefaultValue = true)]
        public bool Direction { get; set; }

        [Parameter("Lots", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
        public double Lots { get; set; }

        [Parameter("Trailing Stop", DefaultValue = 2, MinValue = 0, Step = 0.01)]
        public double TSL { get; set; }


        protected override void OnStart()
        {

            if (Positions.Count != 0)
                return;

            Positions.Opened += OnPositionsOpened;
            Positions.Closed += OnPositionsClosed;

            TradeType TradeDirection = (Direction == true) ? TradeType.Buy : TradeType.Sell;
            long volume = Symbol.QuantityToVolume(Lots);

            ExecuteMarketOrder(TradeDirection, Symbol, volume, cBotLabel);

        }

        protected override void OnBar()
        {

        }

        protected override void OnTick()
        {

            if (Positions.Find(cBotLabel) == null)
                return;

            TrailingStop(TSL);

        }

        protected void OnPositionsOpened(PositionOpenedEventArgs obj)
        {

            Position position = obj.Position;

            TrailingStop(TSL, position);

        }

        protected void OnPositionsClosed(PositionClosedEventArgs obj)
        {

            Position position = obj.Position;

        }

        protected override void OnStop()
        {
            if (Positions.Find(cBotLabel) != null)
                ClosePosition(Positions.Find(cBotLabel));

        }


        private void TrailingStop(double pips, Position position = null)
        {

            if (pips == 0)
                return;
            else
                pips = Math.Abs(pips);

            if (position == null)
            {

                if (Positions.Count == 0)
                    return;

                position = Positions.First();

            }


            double TrailingStop = pips * Symbol.PipSize;

            if (position.TradeType == TradeType.Buy)
                TrailingStop = Symbol.Bid - TrailingStop;
            else
                TrailingStop = Symbol.Ask + TrailingStop;

            bool updateTrailing = false;

            if (position.TradeType == TradeType.Buy)
                updateTrailing = TrailingStop > position.StopLoss;
            else
                updateTrailing = TrailingStop < position.StopLoss;

            if (updateTrailing || position.StopLoss == null)
                ModifyPosition(position, TrailingStop, null);

        }


    }

}


Greetings.


@fermjy
Replies

fermjy
23 Feb 2017, 05:43

The previous name of the cBot was "A Robot", now I changed to "ARobot" and this came out...

Error : Error occured during parsing project file: 'Unrecognized Guid format.'


"A Bot".. class ABot.. error..

Error : Error occured during parsing project file: ''BotultT' is an unexpected token. The expected token is '='. Line 2, position 34.'

 
Ahm.. well... I changed to "something"...

Error : Error occured during parsing project file: 'Unrecognized Guid format.'


I will recreate the bot, but I'm just reporting the bug..


@fermjy

fermjy
23 Feb 2017, 05:46

I recreated as "A Robot", I changed the name as soon as I created, not like before(anyways.. I didn't compiled before). And now It works just fine...


@fermjy