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
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
23 Feb 2017, 05:43
The previous name of the cBot was "A Robot", now I changed to "ARobot" and this came out...
"A Bot".. class ABot.. error..
Ahm.. well... I changed to "something"...
I will recreate the bot, but I'm just reporting the bug..
@fermjy