Another bug with logging? Are you kidding me Spotware?
Another bug with logging? Are you kidding me Spotware?
15 May 2025, 01:56
Logs writes to all running cTrader instances of same bot, regardless of accounts.
With a broker, create two demo accounts. Let's say “A” and “B”.
Launch cTrader, create a bot instance of AUDCAD against demo account “A”.
Start another instance of cTrader against account “B” and make sure the AUDCAD bot instance appears.
In cTrader account “A” start bot against the AUDCAD instance that just prints something to the log. Then stop the bot.
Now switch to the other cTrader, which is against account “B”. Look in the logs for the bot instance against AUDCAD, You should see the output from the bot running against account “A” in the logs for cTrader that is set against account “B”!
There's no way the log file from the bot instance running under demo account “A” should be showing under the other cTrader running against account “B”!
Sample code. :
using System;
using System.Linq;
using System.Xml.Linq;
using cAlgo.API;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None, AddIndicators = true)]
public class BugBot : Robot
{
private int _currentIndex = 0;
private int _previousIndex = 0;
private int _tickCount = 0;
private Bars _marketSeries;
protected override void OnStart()
{
_tickCount = 0;
_marketSeries = MarketData.GetBars(TimeFrame.Hour, Chart.SymbolName);
_currentIndex = _marketSeries.OpenTimes.Count;
_previousIndex = _currentIndex;
}
protected override void OnTick()
{
_tickCount += 1;
_currentIndex = _marketSeries.OpenTimes.Count;
if (_currentIndex != _previousIndex)
{
Print("OT05: Calling OnBar from OnTick {0}, {1}, {2}", _currentIndex, _previousIndex, _tickCount);
OnBarForBot();
_previousIndex = _currentIndex;
if (Server.Time.Minute <= 5)
{
if (_marketSeries.TimeFrame == TimeFrame.Hour)
{
Print("OT08: Starting sleeping 3,060,000 ms / 51 minutes.");
Sleep(3060000); //51 minutes
Print("OT08: Sleep over.");
}
}
}
}
private void OnBarForBot()
{
Print("In OnBarForBot. You should only see this message on the hour! Sometimes it doesn't happen that way!");
_currentIndex = _marketSeries.OpenTimes.Count;
Print("End On Bar");
}
protected override void OnStop()
{
// Handle cBot stop here
}
}
}