Topics
Replies
Algorithmic_Robot
22 Jul 2023, 19:51
RE: RE:
fx.pro said:
Did You solve this problem ? I have identical.
Best Regards,
P.
No. The problem is still there. The data is loading each time for the same time period while backtesting.
If I want to backtest for more than 3 years, it won't even load the data. And I should be able to backtest on tick data since 2016.
I have enough ram and enough virtual ram on my computer.
@Algorithmic_Robot
Algorithmic_Robot
15 Jun 2023, 17:20
( Updated at: 15 Jun 2023, 23:02 )
RE:
Spotware said:
Dear Automated_Trading,
We managed to reproduce this issue and we will fix in in an upcoming update.
Best regards,
cTrader Team
EDIT. 1.6.2023. I installed Windows 10, logged in with my Microsoft account. cTrader desktop backtesting and optimization now works well. Problem solved.
(All I did was going to settings / General and 'reset local data to default'. I didn't know It will have to load the data now each time I want to run the backtesting.)
I see you updated the cTrader desktop to 4.7.12 but the problem stays the same. The data is loading every time I run the optimization.
@Algorithmic_Robot
Algorithmic_Robot
05 Jun 2023, 10:37
RE:
Spotware said:
Dear Automated_Trading,
We managed to reproduce this issue and we will fix in in an upcoming update.
Best regards,
cTrader Team
Thank you. I'm looking forward to it.
(I tried reinstalling the cTrader 4.7.9, but it didn't solve the problem. It loads the data every time I backtest a bot)
Best regards
@Algorithmic_Robot
Algorithmic_Robot
29 May 2023, 09:32
( Updated at: 21 Dec 2023, 09:23 )
RE: RE:
Automated_Trading said:
firemyst said:
Read this thread and do what's suggested:
Now the cTrader is loading the data each time I want to optimize or backtest the bot. I ran the backtesting letting the data load. I tried again using the same history, but it loads the data again. It is not saving the data. I closed the cTrader and restarted my computer several times, but the problem persists.
Do you maybe know how to fix this?
Another thing I noticed:
The data is probably saved, because my disk space is getting smaller when I run the optimization/backtesting, but the cTrader 4.7.9 is not using the already saved data. Maybe this is the problem?
All I did was going to settings / General and 'reset local data to default'. I didn't know It will have to load the data now each time I want to run the backtesting.
You think I'll have to reinstall the cTrader 4.7.9 or is there a better solution? I already have my bots running. Too bad it's not a weekend.
I would run my bots on ICM cTrader 4.6 but it keeps freezing.
Can someone help me fix the problem I'm having? I run the backtesting almost every day, and I'm running the optimization all the time. Loading the data each time is very time-consuming.
@Algorithmic_Robot
Algorithmic_Robot
28 May 2023, 22:30
( Updated at: 28 May 2023, 22:32 )
RE:
firemyst said:
Read this thread and do what's suggested:
Now the cTrader is loading the data each time I want to optimize or backtest the bot. I ran the backtesting letting the data load. I tried again using the same history, but it loads the data again. It is not saving the data. I closed the cTrader and restarted my computer several times, but the problem persists.
Do you maybe know how to fix this?
@Algorithmic_Robot
Algorithmic_Robot
28 May 2023, 22:01
RE:
firemyst said:
Read this thread and do what's suggested:
Thank you. That worked. Problem solved.
((I noticed the cTrader icons from my 'Multiple Profiles' disappeared. I deleted all profiles and created new ones, but the problem persists, so I just used icons from %SystemRoot%\System32\SHELL32.dll .
When optimizing my cBot the cTrader has to load the data again. No biggie))
Thanks firemyst
@Algorithmic_Robot
Algorithmic_Robot
09 Sep 2022, 07:04
RE:
PanagiotisCharalampous said:
Hi swingfish,
We were not able to reproduce this behavior. Can you please provide us with the following?
- Troubleshooting information with a link to this page.
- Your GPU.
- Please advise what exactly do you do at 0:22 of the video.
Best Regards,
Panagiotis
I also have this problem.
@Algorithmic_Robot
Algorithmic_Robot
09 Aug 2022, 12:49
RE:
PanagiotisCharalampous said:
Hi Professional,
We need you to provide us with the code of all the custom indicators you have on the chart at the moment this issue happens.
Best Regards,
Panagiotis
Here is also a video of the problem:
I would upload it here but it doesn't support any formats I have on windows 10. I even tried to save the video with different formats.
LINK:
@Algorithmic_Robot
Algorithmic_Robot
09 Aug 2022, 12:30
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi Professional,
We need you to provide us with the code of all the custom indicators you have on the chart at the moment this issue happens.
Best Regards,
Panagiotis
I removed all drawings and indicators and I only used one window and then tried to use and draw a trend line. The trend line follows my mouse movement for a second and then just stops. I will try to make a quick video and attach it here.
@Algorithmic_Robot
Algorithmic_Robot
09 Aug 2022, 12:20
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi Professional,
It seems that you are using some custom indicators which might cause the problem. Can you please provide them to us?
Best Regards,
Panagiotis
I'm having problems with drawing trend lines, using the ray, horizontal line and vertical line:
(The problem also appears with Fibonacci Retracement,.. It is all standard tools in cTrader)
My included indicators right now on the chart:
All my installed Indicators:
@Algorithmic_Robot
Algorithmic_Robot
02 Aug 2023, 12:41 ( Updated at: 02 Aug 2023, 12:49 )
RE: Someone please fix this indicator
PanagiotisChar said:
Hi. Someone uploaded this cBot again: https://ctrader.com/algos/cbots/show/3150
I want to fix this cBot. It is originally from a person who uploaded it here in 2013. This person just disappeared after 2014. I tried to find him on Facebook to help me fix it, but there is no response.
The problem is it uses two custom indicators. FibbonacciBands and Velocidade (velocityIndicator). These two indicators have errors and warnings. The robot won't work as it should because these two custom indicators must be fixed.
These are the indicators the cBot uses;
VelocityIndicator https://ctrader.com/algos/indicators/show/906
FibonacciBands (the source code is hidden now. It wasn't before) https://ctrader.com/algos/indicators/show/190
If any of you guys who see this post can fix the errors and some warnings would be great, because as I see it is a really good robot. Even with errors I managed to runu the backtest and it performs great.
Here are all 3 source codes (robot, fibonaccibands, velocityindicator)
Robot:
//#reference: ..\Indicators\FibonacciBands.algo
//#reference: ..\Indicators\Velocidade.algo
// -------------------------------------------------------------------------------
//
// This is a Template used as a guideline to build your own Robot.
//
// -------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Requests;
using cAlgo.Indicators;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Globalization;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC)]
public class SR_Fibo : Robot
{
[Parameter(DefaultValue = 100000)]
public int Volume { get; set; }
[Parameter(DefaultValue = 21)]
public int AtrPeriod { get; set; }
[Parameter(DefaultValue = 55)]
public int EmaPeriod { get; set; }
[Parameter(DefaultValue = 10)]
public int VelPeriod { get; set; }
List<double> fibo;
int idx;
Velocidade tendencia;
FibonacciBands fbands;
double stop, gain, price;
PendingOrder ordemc, ordemv;
Position posicao;
private void Seta_variaveis(TradeType oper)
{
Carregar_fibo();
if (oper == TradeType.Buy)
price =Precos(fibo, Symbol.Ask, oper);
else
price = Precos(fibo, Symbol.Bid, oper);
stop = Stopcalc(oper, fibo);
gain = Gaincalc(oper, fibo);
}
protected override void OnPendingOrderCreated(PendingOrder newPendingOrder)
{
if (newPendingOrder.TradeType == TradeType.Sell)
ordemv = newPendingOrder;
else
ordemc = newPendingOrder;
}
protected override void OnBar()
{
Carregar_fibo();
Trade.DeletePendingOrder(ordemv);
Trade.DeletePendingOrder(ordemc);
if (tendencia.velocidade.LastValue > 0 && Functions.IsRising(tendencia.velocidade))
Abreposicoes(TradeType.Buy);
if (tendencia.velocidade.LastValue < 0 && Functions.IsFalling(tendencia.velocidade))
Abreposicoes(TradeType.Sell);
}
protected override void OnStart()
{
tendencia = Indicators.GetIndicator<Velocidade>(MarketSeries.Close, VelPeriod);
fbands = Indicators.GetIndicator<FibonacciBands>(EmaPeriod, AtrPeriod);
fibo = new List<double>();
Carregar_fibo();
OrganizarVetores();
Abreposicoes(TradeType.Buy);
Abreposicoes(TradeType.Sell);
Print("OK!!!");
}
protected override void OnTick()
{
}
private void OrganizarVetores()
{
fibo.Sort();
fibo.Reverse();
}
private void Carregar_fibo()
{
fibo.Clear();
fibo.Add(fbands.UpperBand4.LastValue);
fibo.Add(fbands.UpperBand3.LastValue);
fibo.Add(fbands.UpperBand2.LastValue);
fibo.Add(fbands.UpperBand1.LastValue);
fibo.Add(fbands.LowerBand1.LastValue);
fibo.Add(fbands.LowerBand2.LastValue);
fibo.Add(fbands.LowerBand3.LastValue);
fibo.Add(fbands.LowerBand4.LastValue);
}
private void Abreposicoes(TradeType oper)
{
Seta_variaveis(oper);
if (oper == TradeType.Buy)
Trade.CreateBuyLimitOrder(Symbol, Volume, price, stop, gain, null);
if (oper == TradeType.Sell)
{
Trade.CreateSellLimitOrder(Symbol, Volume, price, stop, gain, null);
}
}
private double Stopcalc(TradeType oper, List<double> sr)
{
OrganizarVetores();
if (oper == TradeType.Sell)
sr.Sort();
if (idx < sr.Count - 1 && Math.Abs(sr[idx] - Symbol.Bid) / Symbol.PipSize > 5)
return sr[idx + 1];
else if (oper == TradeType.Buy)
return sr[idx] - 20 * Symbol.PipSize;
else if (oper == TradeType.Sell)
return sr[idx] + 20 * Symbol.PipSize;
return 0;
}
private double Gaincalc(TradeType oper, List<double> sr)
{
OrganizarVetores();
if (oper == TradeType.Sell)
sr.Sort();
return sr[idx - 1];
}
private double Precos(List<double> sr, double price, TradeType oper)
{
OrganizarVetores();
if (oper == TradeType.Buy)
{
for (var i = 1; i < sr.Count() - 1; i++)
{
if (tendencia.velocidade.LastValue > 0 && price - sr[i] > 10 * Symbol.PipSize)
if (sr[i] < price)
{
idx = i;
return sr[i];
break;
}
if (tendencia.velocidade.LastValue < 0 && price - sr[i] > 10 * Symbol.PipSize)
if (sr[i] < price)
{
idx = i + 1;
return sr[i + 1];
break;
}
}
}
if (oper == TradeType.Sell)
{
sr.Sort();
for (var i = 1; i < sr.Count() - 1; i++)
{
if (tendencia.velocidade.LastValue < 0 && sr[i] - price > 10 * Symbol.PipSize)
{
if (sr[i] > price)
{
idx = i;
return sr[i];
break;
}
}
if (tendencia.velocidade.LastValue > 0 && sr[i] - price > 10 * Symbol.PipSize)
if (sr[i] > price)
{
idx = i + 1;
return sr[i + 1];
break;
}
}
}
return 0;
}
protected override void OnPositionOpened(Position posicaoaberta)
{
posicao = posicaoaberta;
Print("Nova posição aberta\n");
}
protected override void OnPositionClosed(Position posicaoaberta)
{
posicao = null;
}
protected override void OnStop()
{
Trade.DeletePendingOrder(ordemv);
Trade.DeletePendingOrder(ordemc);
}
}
}
FibonacciBands indicator:
//#reference: ..\Indicators\AverageTrueRange.algo
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true)]
public class FibonacciBandsOriginal : Indicator
{
private AverageTrueRange _averageTrueRange;
private ExponentialMovingAverage _exponentialMovingAverage;
[Parameter(DefaultValue = 55)]
public int PeriodEma { get; set; }
[Parameter(DefaultValue = 21)]
public int PeriodAtr { get; set; }
[Output("Upper Band 1", Color = Colors.DarkCyan)]
public IndicatorDataSeries UpperBand1 { get; set; }
[Output("Upper Band 2", Color = Colors.DarkCyan)]
public IndicatorDataSeries UpperBand2 { get; set; }
[Output("Upper Band 3", Color = Colors.DarkCyan)]
public IndicatorDataSeries UpperBand3 { get; set; }
[Output("Upper Band 4", Color = Colors.DarkCyan)]
public IndicatorDataSeries UpperBand4 { get; set; }
[Output("Lower Band 1", Color = Colors.DarkGreen)]
public IndicatorDataSeries LowerBand1 { get; set; }
[Output("Lower Band 2", Color = Colors.DarkGreen)]
public IndicatorDataSeries LowerBand2 { get; set; }
[Output("Lower Band 3", Color = Colors.DarkGreen)]
public IndicatorDataSeries LowerBand3 { get; set; }
[Output("Lower Band 4", Color = Colors.DarkGreen)]
public IndicatorDataSeries LowerBand4 { get; set; }
[Output("EMA", Color = Colors.Blue)]
public IndicatorDataSeries Ema { get; set; }
protected override void Initialize()
{
_averageTrueRange = Indicators.GetIndicator<AverageTrueRange>(PeriodAtr);
_exponentialMovingAverage = Indicators.ExponentialMovingAverage(MarketSeries.Close, PeriodEma);
}
public override void Calculate(int index)
{
double ema = _exponentialMovingAverage.Result[index];
double atr = _averageTrueRange.Result[index];
UpperBand1[index] = ema + 1.62 * atr;
UpperBand2[index] = ema + 2.62 * atr;
UpperBand3[index] = ema + 4.23 * atr;
UpperBand4[index] = ema + 1 * atr;
LowerBand1[index] = ema - 1.62 * atr;
LowerBand2[index] = ema - 2.62 * atr;
LowerBand3[index] = ema - 4.23 * atr;
LowerBand4[index] = ema - 1 * atr;
Ema[index] = ema;
}
}
}
VelocityIndicator:
//The MIT License (MIT)
//Copyright (c) 2014 abdallah HACID, https://www.facebook.com/ab.hacid
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software
//and associated documentation files (the "Software"), to deal in the Software without restriction,
//including without limitation the rights to use, copy, modify, merge, publish, distribute,
//sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
//is furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in all copies or
//substantial portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Project Hosting for Open Source Software on Github : https://github.com/abhacid/cAlgoBot
// -------------------------------------------------------------------------------------------------
//
// Leonardo Hermoso, modifié par https://www.facebook.com/ab.hacid
//
// leonardo.hermoso arroba hotmail.com
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// -------------------------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(TimeZone = TimeZones.UTC, IsOverlay = false, AccessRights = AccessRights.None)]
[Levels(-5, -3, -2, -1, -0.75, -0.5, -0.25, 0, 0.25, 0.5,
0.75, 1, 2, 3, 5)]
public class VelocityIndicator : Indicator
{
#region cIndicators Parammeters
[Parameter("Number Of Candle", DefaultValue = 5, MinValue = 1)]
public int NumberOfCandle { get; set; }
[Parameter("Moving Average", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MovingAverageType { get; set; }
[Parameter("MA Period", DefaultValue = 14, MinValue = 2)]
public int Period { get; set; }
[Output("High Acceleration", Color = Colors.Green, Thickness = 1)]
public IndicatorDataSeries HighAccelerationSeries { get; set; }
[Output("Low Acceleration", Color = Colors.Red, Thickness = 1)]
public IndicatorDataSeries LowAccelerationSeries { get; set; }
[Output("Moving Average", Color = Colors.Blue, Thickness = 2)]
public IndicatorDataSeries MovingAverageSeries { get; set; }
#endregion
MovingAverage _movingAverage;
double _elapsedTime;
protected override void Initialize()
{
_movingAverage = Indicators.MovingAverage(HighAccelerationSeries, Period, MovingAverageType);
long elapsedTicks = (long)Math.Ceiling((NumberOfCandle + 0.5) * MarketSeries.TimeFrame.ToTimeSpan().Ticks);
TimeSpan elapsedSpan = new TimeSpan(elapsedTicks);
_elapsedTime = elapsedSpan.TotalSeconds;
}
/// <summary>
/// S = S0 + V0t +(at^2)/2 a = (2*(S-S0))/t^2.
/// v = v0 +at
/// </summary>
/// <param name="index"></param>
public override void Calculate(int index)
{
double high = MarketSeries.High[index];
double previewHigh = MarketSeries.High[index - NumberOfCandle];
double actualPriceOrHigh = (MarketSeries.Bars() - 1) == index ? Symbol.Mid() : high;
double low = MarketSeries.Low[index];
double previewLow = MarketSeries.Low[index - NumberOfCandle];
double actualPriceOrLow = (MarketSeries.Bars() - 1) == index ? Symbol.Mid() : low;
double highAcceleration = (2 * (high - previewHigh) / Math.Pow(_elapsedTime, 2)) * Math.Pow(10, 2 * Symbol.Digits);
double lowAcceleration = (2 * (low - previewLow) / Math.Pow(_elapsedTime, 2)) * Math.Pow(10, 2 * Symbol.Digits);
HighAccelerationSeries[index] = highAcceleration;
LowAccelerationSeries[index] = lowAcceleration;
MovingAverageSeries[index] = _movingAverage.Result[index];
// Print("{0} {1} {2} {3} {4}",highAcceleration, lowAcceleration, elapsedTime, MarketSeries.Bars()-1, index);
}
}
}
and the same indicator but the name is Velocidade:
//The MIT License (MIT)
//Copyright (c) 2014 abdallah HACID, https://www.facebook.com/ab.hacid
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software
//and associated documentation files (the "Software"), to deal in the Software without restriction,
//including without limitation the rights to use, copy, modify, merge, publish, distribute,
//sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
//is furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in all copies or
//substantial portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Project Hosting for Open Source Software on Github : https://github.com/abhacid/cAlgoBot
// -------------------------------------------------------------------------------------------------
//
// Leonardo Hermoso, modifié par https://www.facebook.com/ab.hacid
//
// leonardo.hermoso arroba hotmail.com
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// -------------------------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.Lib;
namespace cAlgo.Indicators
{
[Indicator(TimeZone = TimeZones.UTC, IsOverlay = false, AccessRights = AccessRights.None)]
[Levels(-5, -3, -2, -1, -0.75, -0.5, -0.25, 0, 0.25, 0.5,
0.75, 1, 2, 3, 5)]
public class VelocityIndicator : Indicator
{
#region cIndicators Parammeters
[Parameter("Number Of Candle", DefaultValue = 5, MinValue = 1)]
public int NumberOfCandle { get; set; }
[Parameter("Moving Average", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MovingAverageType { get; set; }
[Parameter("MA Period", DefaultValue = 14, MinValue = 2)]
public int Period { get; set; }
[Output("High Acceleration", Color = Colors.Green, Thickness = 1)]
public IndicatorDataSeries HighAccelerationSeries { get; set; }
[Output("Low Acceleration", Color = Colors.Red, Thickness = 1)]
public IndicatorDataSeries LowAccelerationSeries { get; set; }
[Output("Moving Average", Color = Colors.Blue, Thickness = 2)]
public IndicatorDataSeries MovingAverageSeries { get; set; }
#endregion
MovingAverage _movingAverage;
double _elapsedTime;
protected override void Initialize()
{
_movingAverage = Indicators.MovingAverage(HighAccelerationSeries, Period, MovingAverageType);
long elapsedTicks = (long)Math.Ceiling((NumberOfCandle + 0.5) * MarketSeries.TimeFrame.ToTimeSpan().Ticks);
TimeSpan elapsedSpan = new TimeSpan(elapsedTicks);
_elapsedTime = elapsedSpan.TotalSeconds;
}
/// <summary>
/// S = S0 + V0t +(at^2)/2 a = (2*(S-S0))/t^2.
/// v = v0 +at
/// </summary>
/// <param name="index"></param>
public override void Calculate(int index)
{
double high = MarketSeries.High[index];
double previewHigh = MarketSeries.High[index - NumberOfCandle];
double actualPriceOrHigh = (MarketSeries.Bars() - 1) == index ? Symbol.Mid() : high;
double low = MarketSeries.Low[index];
double previewLow = MarketSeries.Low[index - NumberOfCandle];
double actualPriceOrLow = (MarketSeries.Bars() - 1) == index ? Symbol.Mid() : low;
double highAcceleration = (2 * (high - previewHigh) / Math.Pow(_elapsedTime, 2)) * Math.Pow(10, 2 * Symbol.Digits);
double lowAcceleration = (2 * (low - previewLow) / Math.Pow(_elapsedTime, 2)) * Math.Pow(10, 2 * Symbol.Digits);
HighAccelerationSeries[index] = highAcceleration;
LowAccelerationSeries[index] = lowAcceleration;
MovingAverageSeries[index] = _movingAverage.Result[index];
// Print("{0} {1} {2} {3} {4}",highAcceleration, lowAcceleration, elapsedTime, MarketSeries.Bars()-1, index);
}
}
}
@Algorithmic_Robot