Indicator Print in cBot
Indicator Print in cBot
05 Apr 2021, 20:36
Hi all,
I developed an indicator, and it Print messages in the Log tab.
For some unknown reason, it doesn't display the same way when I add it to a chart of a cBot backtest, so I would like to see the logs of my indicator to understand why some Outputs are not displayed on the chart.
Is there a way to display logs (or get a file somewhere) of an indicator when it is instanciated elsewhere than the Indicator tab?
Thanks for your answers,
Cheers,
Jerry
Replies
JerryTrader
06 Apr 2021, 10:38
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
The indicator should print the messages if you are in the cTrader Automate section.
I can't get the indicator logs displayed anywhere else than the Indicator instance itself.
If not, please share the source code to check.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class TestPrintMessages : Indicator
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
[Output("Moving Average")]
public IndicatorDataSeries ResultMtfMa { get; set; }
private Bars _mtfBars;
private MovingAverage _mtfMa;
protected override void Initialize()
{
_mtfBars = MarketData.GetBars(TimeFrame.Daily);
_mtfMa = Indicators.MovingAverage(_mtfBars.ClosePrices, 100, MovingAverageType.Exponential);
}
public override void Calculate(int index)
{
var mtfMaIndex = _mtfBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
if (mtfMaIndex != -1)
{
Print(string.Format("Index is {0}. Mtf Index is {1}", index, mtfMaIndex));
ResultMtfMa[index] = _mtfMa.Result[mtfMaIndex];
}
}
}
}
Given the code above :
OK : cTrader Automate section -> Indicators -> Test Print Messages instance
NOK : cTrader Automate section -> cBot -> Basic cBot that does nothing else than printing a message on start
NOK : cTrader Automate section -> cBot -> Backtesting the basic cBot that does nothing else than printing a message on start
@JerryTrader
PanagiotisCharalampous
06 Apr 2021, 10:53
Hi JerryTrader,
You haven't shared your cBot code.
Best Regards,
Panagiotis
@PanagiotisCharalampous
JerryTrader
06 Apr 2021, 11:05
RE: RE:
JerryTrader said:
NOK : cTrader Automate section -> cBot -> Basic cBot that does nothing else than printing a message on start
using cAlgo.API;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FileSystem)]
public class PrintMessagesTests : Robot
{
protected override void OnStart()
{
base.OnStart();
Print("Print Messages test bot started");
}
protected override void OnStop()
{
base.OnStop();
Print("Print Messages test bot stopped");
}
}
}
@JerryTrader
PanagiotisCharalampous
06 Apr 2021, 11:09
Hi JerryTrader,
Your cBot does not use the indicator in any way. Why do you expect to see any messages?
Best Regards,
Panagiotis
@PanagiotisCharalampous
JerryTrader
06 Apr 2021, 11:22
RE:
Hi PanagiotisCharalampous,
As I said, my chart does, not my cBot.
JerryTrader said:
For some unknown reason, it doesn't display the same way when I add it to a chart of a cBot backtest, so I would like to see the logs of my indicator to understand why some Outputs are not displayed on the chart.
I have a complex indicator that works fine in the Indicators tab, the cBot live instance and in cTrader Trade, but when I add it to a chart of a cBot backtest, it doesn't behave the same way.
I have no idea why an indicator would be displayed differently when used with the same settings, so I want to debug this by writing some messages and see what's going on.
Hence my question:
JerryTrader said:
Is there a way to display logs (or get a file somewhere) of an indicator when it is instanciated elsewhere than the Indicator tab?
@JerryTrader
PanagiotisCharalampous
06 Apr 2021, 12:24
Hi JerryTrader,
Indicators added to the backtesting chart cannot use the backtesting log to print messages. Maybe try calling the indicator from a cBot. In this case, you should be able to see the messages.
Best Regards,
Panagiotis
@PanagiotisCharalampous
JerryTrader
06 Apr 2021, 16:47
RE:
PanagiotisCharalampous said:
Hi JerryTrader,
Indicators added to the backtesting chart cannot use the backtesting log to print messages. Maybe try calling the indicator from a cBot. In this case, you should be able to see the messages.
Best Regards,
Panagiotis
Hmmm ok.
I will try that. I can also log indicator messages to a file so that I don't have to create a cBot just to get logs from an indicator.
As long as I have workarounds, I'm fine ;)
But I think it could be handy to add a feature to let the user choose the log sources in the Log tab.
While you're there (sorry, this is off-topic but I can't find any answer...):
For 2-3 weeks now, I don't receive any notifications about the topics I am subscribed to. For example, if I don't visit/refresh this page, I'm not able to see if you answered to it.
I checked my settings and everything seems fine to me. I posted a message in the cTrader Web section, and I reported an issue through Pepperstone cTrader. I really have no idea where to report this so it can be fixed...
Can you please redirect me to the right place, or report this to the right team ?
@JerryTrader
PanagiotisCharalampous
06 Apr 2021, 08:45
Hi JerryTrader,
The indicator should print the messages if you are in the cTrader Automate section. If not, please share the source code to check. Alternatively, you can export your messages in a csv file.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous