Topics
Replies
Abstract
31 Aug 2021, 00:34
( Updated at: 21 Dec 2023, 09:22 )
RE: RE: RE:
Hello,
I've had the following error message trying to find the bug:
The last version of my robot is "naked" -shown below- but still with the same problem: an error is thrown for high steps in parameters. Maybe my Ctrader is corrupted... I would appreciate an answer to resolve this problem. Thank you.
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class TAGLAXerrr : Robot
{
[Parameter("Dx", Group = "Ind21", DefaultValue = 10, MinValue = 0)]
public double Dx { get; set; }
protected override void OnStart()
{
}
//se ejecuta cada inicio de vela
protected override void OnBar()
{
}
}
}
@Abstract
Abstract
29 Aug 2021, 03:03
RE: RE:
The last version is still with the same error. If Dx Step is 5 works fine. It DX Step is 10 works wrong:
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class TAGLAXerrr : Robot
{
[Parameter("Bot Name", Group = "Configuration", DefaultValue = "TAGLAX")]
public String BotName { get; set; }
[Parameter("Label Suffix", Group = "Configuration", DefaultValue = DEFAULT_LABEL)]
public String Label { get; set; }
[Parameter("Config File", Group = "Configuration", DefaultValue = DEFAULT_CONFIGFILENAME)]
public String ConfigFile { get; set; }
[Parameter("Stop Loss VUD", Group = "Finance", DefaultValue = 2.8)]
public double StopLossFactor { get; set; }
[Parameter("Profit/Risk Factor", Group = "Finance", DefaultValue = 1.0)]
public double ProfitRiskFactor { get; set; }
[Parameter("Max Spread", Group = "Finance", DefaultValue = 1.0)]
public double MaxSpread { get; set; }
//------------------Params. Indicadores-----------------------
[Parameter("Ax", Group = "Ind", DefaultValue = 0.6, MinValue = 0)]
public double Ax { get; set; }
[Parameter("Bx", Group = "Ind", DefaultValue = 0.2, MinValue = 0)]
public double Bx { get; set; }
[Parameter("Cx", Group = "Ind", DefaultValue = 1.0, MinValue = 0)]
public double Cx { get; set; }
[Parameter("Dx", Group = "Ind21", DefaultValue = 10, MinValue = 0)]
public double Dx { get; set; }
[Parameter("Ex", Group = "Ind21", DefaultValue = 0.1, MinValue = 0)]
public double Ex { get; set; }
//--------------------Time Indicadores------------------------
[Parameter("Start Hour", Group = "Time", DefaultValue = 0, MinValue = 0, MaxValue = 24)]
public int StartHour { get; set; }
[Parameter("End Hour", Group = "Time", DefaultValue = 24, MinValue = 0, MaxValue = 24)]
public int EndHour { get; set; }
private const string DEFAULT_LABEL = "Default";
private const string DEFAULT_CONFIGFILENAME = "config";
private const int VUD_PERIOD = 50;
private AverageTrueRange atr;
private SimpleMovingAverage smaATR;
protected override void OnStart()
{
atr = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
smaATR = Indicators.SimpleMovingAverage(atr.Result, VUD_PERIOD);
}
//se ejecuta cada inicio de vela
protected override void OnBar()
{
}
}
}
@Abstract
Abstract
28 Aug 2021, 15:41
( Updated at: 29 Aug 2021, 03:06 )
RE:
I've deleted many lines in order to find the bug, even I've replaced my class TradeException -using only the class Exception- but nothing changes. I've found the solution but it's so strange: when the value of the step in the parameter Dx is 5 then the bot works fine. I cannot understand this behaviour, maybe my Ctrader is corrupted and I need to install it again...
I show the last version of my bot -with the same problem-
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System.IO;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class TAGLAXerrr : Robot
{
[Parameter("Bot Name", Group = "Configuration", DefaultValue = "TAGLAX")]
public String BotName { get; set; }
[Parameter("Label Suffix", Group = "Configuration", DefaultValue = DEFAULT_LABEL)]
public String Label { get; set; }
[Parameter("Config File", Group = "Configuration", DefaultValue = DEFAULT_CONFIGFILENAME)]
public String ConfigFile { get; set; }
[Parameter("Stop Loss VUD", Group = "Finance", DefaultValue = 2.8)]
public double StopLossFactor { get; set; }
[Parameter("Profit/Risk Factor", Group = "Finance", DefaultValue = 1.0)]
public double ProfitRiskFactor { get; set; }
[Parameter("Max Spread", Group = "Finance", DefaultValue = 1.0)]
public double MaxSpread { get; set; }
//------------------Params. Indicadores-----------------------
[Parameter("Ax", Group = "Ind", DefaultValue = 0.6, MinValue = 0)]
public double Ax { get; set; }
[Parameter("Bx", Group = "Ind", DefaultValue = 0.2, MinValue = 0)]
public double Bx { get; set; }
[Parameter("Cx", Group = "Ind", DefaultValue = 1.0, MinValue = 0)]
public double Cx { get; set; }
[Parameter("Dx", Group = "Ind21", DefaultValue = 10, MinValue = 0)]
public double Dx { get; set; }
[Parameter("Ex", Group = "Ind21", DefaultValue = 0.1, MinValue = 0)]
public double Ex { get; set; }
//--------------------Time Indicadores------------------------
[Parameter("Start Hour", Group = "Time", DefaultValue = 0, MinValue = 0, MaxValue = 24)]
public int StartHour { get; set; }
[Parameter("End Hour", Group = "Time", DefaultValue = 24, MinValue = 0, MaxValue = 24)]
public int EndHour { get; set; }
private const string PATH = "c:\\Trading\\";
private const string DEFAULT_LABEL = "Default";
private const string DEFAULT_CONFIGFILENAME = "config";
private const int VUD_PERIOD = 50;
private string label;
private string configFile = "";
private AverageTrueRange atr;
private SimpleMovingAverage smaATR;
protected override void OnStart()
{
try
{
if (StopLossFactor == 0)
closeBot();
atr = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
smaATR = Indicators.SimpleMovingAverage(atr.Result, VUD_PERIOD);
initialize();
} catch (Exception e)
{
log(e);
}
}
//se ejecuta cada inicio de vela
protected override void OnBar()
{
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
//==========================================================================
// UTILIDADES
//==========================================================================
private void initialize()
{
try
{
if ((Label == null) || (string.Compare(Label, "Default") == 0) || (Label.Length == 0))
{
label = BotName + Symbol.Name + TimeFrame.ToString();
}
else
label = Label;
configFile = PATH + ConfigFile + ".txt";
} catch (Exception e)
{
throw new Exception("Error al inicializar variables", e);
}
}
private void log(Exception ex)
{
string message = "";
if (ex.InnerException != null)
message = ex.Message + ". " + ex.InnerException.Message;
else
message = ex.Message;
using (StreamWriter w = File.AppendText(PATH + "log.txt"))
{
w.Write("\r\n" + BotName + ";" + Label + ";" + Symbol.Name + ";" + TimeFrame.ToString() + ";" + DateTime.Now.ToLongDateString() + ";" + DateTime.Now.ToLongTimeString() + ";" + "" + ";" + message);
}
}
private void closeBot()
{
Stop();
}
private bool isOperationAllowed()
{
bool ret = false;
try
{
int h = Bars.OpenTimes.LastValue.Hour;
if (isNumber(h))
{
if ((h >= StartHour) && (h <= EndHour))
ret = true;
}
} catch (Exception e)
{
throw new Exception("Error en la lectura de fecha y hora de las barras", e);
}
return ret;
}
private bool isNumber(double val)
{
return !double.IsNaN(val);
}
}
}
Any advice would be appreciated. Thank you.
@Abstract
Abstract
12 Aug 2021, 16:02
RE:
PanagiotisCharalampous said:
Hi Abstract,
Can you please provide us with the cBot source code and the optimization settings so that we are able to reproduce this problem?
Best Regards,
Panagiotis
Hello, Panagiotis.
It was my fault. There were some divisions by zero in some situations. I've fixed this issue and now it's working fine.
Thanks a lot.
@Abstract
Abstract
29 Nov 2024, 07:09
Synchronization problem
The problem is synchronization.
The main indicator uses other indicators with AccessRights=AccessRights.None, so the cloud of the indicator is in red with message “This algorithm is available only locally because it requires full access rights”. But the bot is running locally.
Other indicators do the same (use other indicators with no access rights) and are synchronized, I mean no red clouds. These indicators were only built with the last version, not this one.
Also other bots have the red cloud but run fine. They are running locally.
All bots are running locally.
But I don't wish to be synchronized, how can I be desynchronized?
Thanks
@Abstract