cTrader 5, wrong backtesting result, when not using Visual Mode. m1 Bars.
cTrader 5, wrong backtesting result, when not using Visual Mode. m1 Bars.
10 Nov 2024, 14:40
Hello cTrader team.
Please fix the cTrader 5 version. Optimization and backtesting with m1 Bars.
I'm using cTrader 4.92 (from ICM) and cTrader 5.0.44.
The backtesting results when NOT using Visual mode and when using Visual Mode are totally different in cTrader 5.
When I use Visual Mode in backtesting I get the same results / equity curve on cTrader 4.92 and on cTrader 5.
This means that optimization and backtesting when not using Visual mode in cTrader 4.92 are correct. In cTrader 5 the results are not correct and are different.
This is because when I use Visual Mode in backtesting I get the same results / equity curve in both cTrader versions. cTrader version 4.92 and version 5.0.44.
Backtesting in Visual Mode gives accurate results. This means I have to optimize my cBots on the cTrader 4.92 to get accurate optimization results.
YouTube video: https://youtu.be/6b7uyPiow-k
Here are some examples (Telegram screenshots on your cTrader Official group):
Thank you,
Mark
Replies
algorithmic.trading.eu_gmail.com
11 Nov 2024, 15:08
( Updated at: 12 Nov 2024, 06:20 )
RE: cTrader 5, wrong backtesting result, when not using Visual Mode. m1 Bars.
Hi,
It happens on any cBot in cTrader 5. Also, with the already built in “Sample RSI cBot”.
I am experiencing an issue with cTrader 5 when conducting a backtest using m1 bars in Visual Mode compared to non-Visual Mode, which produces vastly different outcomes. The results obtained in Visual Mode are accurate, and this discrepancy needs resolution. The optimization result using m1 bars is also inaccurate just like the backtesting result when not using visual mode.
Video=
@algorithmic.trading.eu_gmail.com
algorithmic.trading.eu_gmail.com
24 Nov 2024, 10:02
RE: RE: cTrader 5, wrong backtesting result, when not using Visual Mode. m1 Bars.
Hi,
You asked for the source code.
This is the source code. Default parameter settings were used.
// -------------------------------------------------------------------------------------------------
//
// This code is a cTrader Automate API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
//
// All changes to this file might be lost on the next application update.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// The "Sample RSI cBot" will create a buy order when the Relative Strength Index indicator crosses the level 30,
// and a Sell order when the RSI indicator crosses the level 70. The order is closed be either a Stop Loss, defined in
// the "Stop Loss" parameter, or by the opposite RSI crossing signal (buy orders close when RSI crosses the 70 level
// and sell orders are closed when RSI crosses the 30 level).
//
// The cBot can generate only one Buy or Sell order at any given time.
//
// -------------------------------------------------------------------------------------------------
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SampleRSIcBot : Robot
{
[Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double Quantity { get; set; }
[Parameter("Source", Group = "RSI")]
public DataSeries Source { get; set; }
[Parameter("Periods", Group = "RSI", DefaultValue = 14)]
public int Periods { get; set; }
private RelativeStrengthIndex rsi;
protected override void OnStart()
{
rsi = Indicators.RelativeStrengthIndex(Source, Periods);
}
protected override void OnTick()
{
if (rsi.Result.LastValue < 30)
{
Close(TradeType.Sell);
Open(TradeType.Buy);
}
else if (rsi.Result.LastValue > 70)
{
Close(TradeType.Buy);
Open(TradeType.Sell);
}
}
private void Close(TradeType tradeType)
{
foreach (var position in Positions.FindAll("SampleRSI", SymbolName, tradeType))
ClosePosition(position);
}
private void Open(TradeType tradeType)
{
var position = Positions.Find("SampleRSI", SymbolName, tradeType);
var volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);
if (position == null)
ExecuteMarketOrder(tradeType, SymbolName, volumeInUnits, "SampleRSI");
}
}
}
@algorithmic.trading.eu_gmail.com
PanagiotisCharalampous
25 Nov 2024, 06:46
RE: RE: RE: cTrader 5, wrong backtesting result, when not using Visual Mode. m1 Bars.
Algo_robot said:
Hi,
You asked for the source code.
This is the source code. Default parameter settings were used.
// -------------------------------------------------------------------------------------------------
//
// This code is a cTrader Automate API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
//
// All changes to this file might be lost on the next application update.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// The "Sample RSI cBot" will create a buy order when the Relative Strength Index indicator crosses the level 30,
// and a Sell order when the RSI indicator crosses the level 70. The order is closed be either a Stop Loss, defined in
// the "Stop Loss" parameter, or by the opposite RSI crossing signal (buy orders close when RSI crosses the 70 level
// and sell orders are closed when RSI crosses the 30 level).
//
// The cBot can generate only one Buy or Sell order at any given time.
//
// -------------------------------------------------------------------------------------------------
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SampleRSIcBot : Robot
{
[Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double Quantity { get; set; }
[Parameter("Source", Group = "RSI")]
public DataSeries Source { get; set; }
[Parameter("Periods", Group = "RSI", DefaultValue = 14)]
public int Periods { get; set; }
private RelativeStrengthIndex rsi;
protected override void OnStart()
{
rsi = Indicators.RelativeStrengthIndex(Source, Periods);
}
protected override void OnTick()
{
if (rsi.Result.LastValue < 30)
{
Close(TradeType.Sell);
Open(TradeType.Buy);
}
else if (rsi.Result.LastValue > 70)
{
Close(TradeType.Buy);
Open(TradeType.Sell);
}
}
private void Close(TradeType tradeType)
{
foreach (var position in Positions.FindAll("SampleRSI", SymbolName, tradeType))
ClosePosition(position);
}
private void Open(TradeType tradeType)
{
var position = Positions.Find("SampleRSI", SymbolName, tradeType);
var volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);
if (position == null)
ExecuteMarketOrder(tradeType, SymbolName, volumeInUnits, "SampleRSI");
}
}
}
Hi there,
This issue will be solved in 5.0.47
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Nov 2024, 06:54
Hi Mark,
Please share your cBot code and backtesting parameters and settings that will allow us to reproduce this problem.
Best regards,
Panagiotis
@PanagiotisCharalampous