Topics
Replies
PanagiotisCharalampous
26 Jul 2024, 05:47
Hi there,
Try installing the .Net 6.0 SDK from the link below
https://dotnet.microsoft.com/en-us/download/visual-studio-sdks
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Jul 2024, 05:41
Hi there,
Probably your broker does not offer cTrader Copy. Reach out to them for more information.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Jul 2024, 05:47
Hi there,
There is no such option at the moment. The R/R tool will be added in the rest of the applications in future releases.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Jul 2024, 05:46
As explained in your other thread, this is an issue of your cBot, you need to handle this situation inside your cBot code
@PanagiotisCharalampous
PanagiotisCharalampous
25 Jul 2024, 05:44
RE: Found the problem
patrickandrade2 said:
The thing is, the actual bot is misbehaving, it occurs when the bot is trying to set a stop loss and a sudden movement happens. It happened live just some moments ago. I have the setup for max 15 pips of stop loss on this strategy. When buying there was a massive movement to go down. Stop loss wasn't setted and now I'm in a huge loss. This is severe, please fix.
Hi there,
The stop loss is ignored when it falls within the spread since it is invalid. You need to handle this situation within your cBot code and detect when stop losses are not set due to invalid values.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Jul 2024, 05:40
Hi there,
Accounts can be removed by the brokers. Please contact your broker regarding this.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Jul 2024, 05:39
Hi there,
An obvious problem in your code is that you are using the current open bar's value for your checks. This value can change by the time the bar closes therefore this can lead to false or missing signals. You should only check closed bar values. Try the below instead
double shortMAValue = shortMA.Result[lastIndex - 1];
double longMAValue = longMA.Result[lastIndex - 1];
double prevShortMAValue = shortMA.Result[lastIndex - 2];
double prevLongMAValue = longMA.Result[lastIndex - 2];
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Jul 2024, 05:36
Hi there,
As per the message, your cBot crashes. Please share your cBot code so that we can check.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Jul 2024, 05:34
RE: Custom Indicator Values Controlled by cBot in cTrader
cortes.br said:
I want to plot on the chart points that represent quantities calculated during the execution of the robot, such as limit and stop prices. I need the ability to draw values on the chart for debugging and visualization purposes. Specifically, I am looking for a function equivalent to PlotTimeSeries found in WealthLab.
PlotTimeSeries
public void PlotTimeSeries(TimeSeries ts, string name, string paneTag, WLColor color = default(WLColor), PlotStyles plotStyle = PlotStyle.Line, bool suppressLabels = false)
Plots a TimeSeries on the chart. The ts parameter is a TimeSeries instance. PlotTimeSeries is useful when plotting the results of mathematical operations on indicators and other TimeSeries. These operations always return instances of the TimeSeries class.
The name parameter should be a descriptive name of the data being plotted. This appears in the pane label.
The paneTag specifies which chart pane to plot the data in. You can specify Price for the price pane, Volume for the volume pane, or some other string value for a custom pane.
The color parameter is optional. If not provided, WealthLab will use a default color.
The plotStyle parameter is also optional, and is a member of the PlotStyle enum. If not specified, WealthLab will use PlotStyle.Line.
The suppressLabels parameter lets you disable to indicator pane labels and the value markers along the chart's right margin for this plot.
Why don't you do all of this in an indicator?
@PanagiotisCharalampous
PanagiotisCharalampous
25 Jul 2024, 05:30
RE: RE: RE: RE: RE: RE: how to extend trendline to right?
tuuguu177 said:
PanagiotisCharalampous said:
tuuguu177 said:
PanagiotisCharalampous said:
tuuguu177 said:
PanagiotisCharalampous said:
Hi there,
I added the indicator on a chart but I see no error. Can you please explain what error do you get and how we can reproduce it?
Best regards,
Panagiotis
are you there?
You did not answer my question therefore I am not able to help you further at the moment.
This error occurred. I only want extend trend lines. That is all. I can not find right structure of extended trend line codes.
Please share the code that reproduces these error messages
Code is:
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Collections.Generic;
#pragma warning disable
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class LinearRegressionChannel : Indicator
{
[Parameter("Projection Length", DefaultValue = 0)]
public int ProjLength { get; set; }
[Parameter("Center", DefaultValue = true)]
public bool ShowCenter { get; set; }
[Parameter("Channel", DefaultValue = true)]
public bool ShowChannel { get; set; }
[Parameter("Standard deviation", DefaultValue = true)]
public bool ShowDeviantion { get; set; }
public Dictionary<string, LR> LRs = new Dictionary<string, LR>();
protected override void Initialize()
{
///Add the button in the topleft corner
Border border = new Border
{
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Right,
Margin = "20 40 20 20",
Width = 50,
Child = new Toolbar(this)
};
Chart.AddControl(border);
///Events for calculating and drawing
Chart.ObjectUpdated += OnChartObjectUpdated;
Chart.ObjectRemoved += OnChartObjectRemoved;
foreach (ChartObject o in Chart.Objects)
if (o.Name.Length > 24 && o.Name.Substring(0, 24) == "LinearRegressionChannel " && o.IsInteractive && o.ObjectType == ChartObjectType.TrendLine)
{
LRs.Add(o.Name, new LR((ChartTrendLine)o));
o.IsInteractive = false;
o.IsInteractive = true;
}
}
void OnChartObjectRemoved(ChartObjectRemovedEventArgs obj)
{
try
{
if (IsCleaning)
return;
RemoveAllObjectsConnectedWith(obj.ChartObject);
if (LRs.ContainsKey(obj.ChartObject.Name))
LRs.Remove(obj.ChartObject.Name);
} catch (Exception e)
{
Print(e);
Print("Errore nella rimozione dell'oggetto");
}
}
bool IsCleaning = false;
void RemoveAllObjectsConnectedWith(ChartObject o)
{
if (LRs.ContainsKey(o.Name))
{
IsCleaning = true;
for (int i = 0; i < LRs[o.Name].Children.Count; ++i)
{
try
{
Chart.RemoveObject(LRs[o.Name].Children[i].Name);
} catch (Exception e)
{
Print(e);
continue;
}
}
}
LRs[o.Name].Children.Clear();
IsCleaning = false;
}
public override void Calculate(int index)
{
}
void OnChartObjectUpdated(ChartObjectUpdatedEventArgs obj)
{
try
{
RemoveAllObjectsConnectedWith(obj.ChartObject);
///Check if object is a rectangle and if it's part of this indicator
if (!LRs.ContainsKey(obj.ChartObject.Name))
return;
ChartTrendLine lr = (ChartTrendLine)obj.ChartObject;
// Linear regresion
double sum_x = 0, sum_x2 = 0, sum_y = 0, sum_xy = 0, x_avg=0, x=0,x_sum_squared=0,stdDeviation=0;
int start = Bars.OpenTimes.GetIndexByTime(lr.Time1);
int end = Bars.OpenTimes.GetIndexByTime(lr.Time2);
int length = Math.Abs(end - start);
if (start > end)
{
start = Bars.OpenTimes.GetIndexByTime(lr.Time2);
end = Bars.OpenTimes.GetIndexByTime(lr.Time1);
}
for (int i = start; i < end; i++)
{
sum_x += 1.0 * i;
sum_x2 += 1.0 * i * i;
sum_y += Bars[i].Close;
sum_xy += Bars[i].Close * i;
}
double a = (length * sum_xy - sum_x * sum_y) / (length * sum_x2 - sum_x * sum_x);
double b = (sum_y - a * sum_x) / length;
// Calculate maximum and standard devaitions
double maxUpperDeviation = 0, maxLowerDeviation = 0;
double sumDevation = 0;
for (int i = start; i < end; i++)
{
double price = a * i + b;
x = Math.Abs(Bars[i].Close - price);
x_avg=(x_avg+x)/i;
x_sum_squared += (x - x_avg) * (x - x_avg);
maxUpperDeviation = Math.Max(Bars[i].Close - price, maxUpperDeviation);
maxLowerDeviation = Math.Min(Bars[i].Close - price, maxLowerDeviation);
stdDeviation=Math.Sqrt(x_sum_squared/(length - 1));
}
//double stdDeviation = Math.Sqrt(sumDevation / (length - 1));
// draw in future
//end += (int)(length * 0.01 * ProjLength);
double pr1 = a * start + b;
double pr2 = a * end + b;
if (ShowCenter)
{
//LRs[lr.Name].Children.Add(Chart.DrawTrendLine("Center " + lr.Name, start, pr1, end, pr2, Color.Blue, 1, LineStyle.DotsRare));
var line LRs[lr.Name].Children.Add(Chart.DrawTrendLine("Center " + lr.Name, start, pr1, end, pr2, Color.Blue, 1, LineStyle.DotsRare));
line .ExtendToInfinity = true;
}
if (ShowChannel)
{
LRs[lr.Name].Children.Add(Chart.DrawTrendLine("Top " + lr.Name, start, pr1 + stdDeviation*2, end, pr2 + stdDeviation*2, Color.Blue, 1, LineStyle.DotsRare));
LRs[lr.Name].Children.Add(Chart.DrawTrendLine("Bottom " + lr.Name, start, pr1 - stdDeviation*2, end, pr2 - stdDeviation*2, Color.Blue, 1, LineStyle.DotsRare));
}
if (ShowDeviantion)
{
LRs[lr.Name].Children.Add(Chart.DrawTrendLine("Dev-Top " + lr.Name, start, pr1 + stdDeviation, end, pr2 + stdDeviation, Color.Blue, 1, LineStyle.DotsRare));
LRs[lr.Name].Children.Add(Chart.DrawTrendLine("Dev-Bottom " + lr.Name, start, pr1 - stdDeviation, end, pr2 - stdDeviation, Color.Blue, 1, LineStyle.DotsRare));
}
} catch (Exception)
{
}
}
}
public class Toolbar : CustomControl
{
LinearRegressionChannel LR;
public Toolbar(LinearRegressionChannel lr)
{
LR = lr;
var AddButton = new Button
{
Text = "Add",
Style = new Style(DefaultStyles.ButtonStyle),
Height = 25
};
AddButton.Click += AddArea;
AddChild(AddButton);
}
void AddArea(ButtonClickEventArgs e)
{
double Y = (LR.Chart.TopY - LR.Chart.BottomY) * 0.6 + LR.Chart.BottomY;
string name = "LinearRegressionChannel " + LR.Time;
LR.LRs.Add(name, new LR(LR.Chart.DrawTrendLine(name, LR.Chart.LastVisibleBarIndex - 2, Y, (int)(LR.Chart.LastVisibleBarIndex - (LR.Chart.LastVisibleBarIndex - LR.Chart.FirstVisibleBarIndex) * 0.2), Y, Color.DarkSlateGray)));
LR.LRs[name].Parent.IsInteractive = true;
}
}
public class LR
{
public ChartTrendLine Parent;
public List<ChartTrendLine> Children = new List<ChartTrendLine>();
public LR(ChartTrendLine cr)
{
Parent = cr;
}
}
}
Your problem is this line of code. This is not correct C#
var line LRs[lr.Name].Children.Add(Chart.DrawTrendLine("Center " + lr.Name, start, pr1, end, pr2, Color.Blue, 1, LineStyle.DotsRare));
Maybe you are trying to do this?
var line = Chart.DrawTrendLine("Center " + lr.Name, start, pr1, end, pr2, Color.Blue, 1, LineStyle.DotsRare);
line .ExtendToInfinity = true;
LRs[lr.Name].Children.Add(line);
@PanagiotisCharalampous
PanagiotisCharalampous
25 Jul 2024, 05:23
RE: RE: RE: RE: Cache data not available or corrupted
Dharaksa.pokpong said:
PanagiotisCharalampous said:
Dharaksa.pokpong said:
PanagiotisCharalampous said:
Hi there,
Which version of cTrader do you use?
Best regards,
Panagiotis
Hi Panagiotis
it's the latest version so 5.0.28
Best,
Dha
Hi Dha,
Thank you. Could you please send us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.
Best regards,
Panagiotis
Hi Panagiotis,
First of all, thank you for your attention. I have already submitted the form with a link to this forum. However, I saw that there is a link to download a older version of ctrader, thus, I downloaded yet it says this broker has been suspended. Is there any way for me to use the older version for now?
Best,
Dha
Hi Dha,
No you cannot use an older version of cTrader at the moment.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Jul 2024, 10:37
RE: RE: RE: RE: how to extend trendline to right?
tuuguu177 said:
PanagiotisCharalampous said:
tuuguu177 said:
PanagiotisCharalampous said:
Hi there,
I added the indicator on a chart but I see no error. Can you please explain what error do you get and how we can reproduce it?
Best regards,
Panagiotis
are you there?
You did not answer my question therefore I am not able to help you further at the moment.
This error occurred. I only want extend trend lines. That is all. I can not find right structure of extended trend line codes.
Please share the code that reproduces these error messages
@PanagiotisCharalampous
PanagiotisCharalampous
24 Jul 2024, 07:59
RE: RE: Cache data not available or corrupted
Dharaksa.pokpong said:
PanagiotisCharalampous said:
Hi there,
Which version of cTrader do you use?
Best regards,
Panagiotis
Hi Panagiotis
it's the latest version so 5.0.28
Best,
Dha
Hi Dha,
Thank you. Could you please send us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Jul 2024, 06:51
Hi there,
This tool is not available on cTrader Desktop at the moment. You can use a third party one like the below
https://clickalgo.com/free-risk-reward-indicator
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Jul 2024, 06:49
Hi there,
Talk to your broker about this matter.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Jul 2024, 06:45
Hi there,
The idea is that the cBot will determine and set the indicator values during each
OnBar
event, and these values will then be plotted on the chart by the indicator.
Can you please explain to us why this design is necessary?
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Jul 2024, 06:41
RE: RE: RE: RE: RE: Load more History on Backtest
eynt said:
Hello, anything new?
Thanks
Hi eynt,
It seems it has not been released yet. It will be released in v5.2
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Jul 2024, 06:32
Hi there,
The result of the method is units, which is what you need as an input for all the order methods of the API. There is no reason to convert it to lots and then back to units. But if you need to convert it to Lots, you can use the Symbol.VolumeToQuantity() method.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Jul 2024, 06:26
Hi there,
Which version of cTrader do you use?
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Jul 2024, 05:52
RE: RE: RE: Found the problem
patrickandrade2 said:
Hi there,
You can check if a position has a stop loss using the Position.Opened event. See below an example
Best regards,
Panagiotis
@PanagiotisCharalampous