the optimization results - are these credible enough?
the optimization results - are these credible enough?
27 Nov 2024, 10:29
And... I can see that my tests do not give the right results when I subsequently do backtests based on the optimization results. normally I use tick data but can see that the broker's commission destroys the overall result, for example down to a 1-minute chart. Can I have the commission included so that I get a 100% correct picture of the value of the strategy?
Replies
jcr1818
01 Dec 2024, 16:59
( Updated at: 01 Dec 2024, 17:34 )
RE: the optimization results - are these credible enough?
PanagiotisCharalampous said:
Hi there,
Please provide us with more information on how to reproduce this problem. Share your cBot code, cBot parameters, dates and broker and explain to us what you expected to see and what you see instead.
Best regards,
Panagiotis
In this example I use following from the c-trader cbot system: SAMPLE RSI CBOT.
Data ticks: EURUSD 1 HOUR: Optimisation settings: TF 1 hour. Quantity: 1 lot. Source: Close. Periods: min: 5 max 20 and step 1.
Optimisation Criteria: Standard. Max netto profit. Min equity DD (%) and Max winnings trades.
Test period: 30.10.24 - 30.11.24
The system shows: AUTOSELECT THE BEST PASS: = 14. Netto profit: = 2773,72. Trades 27 etc.
Then I import the result and backtest it without changing nothing. Now the netto results shows me just 380,75 + 1 open position = 225,33 (euro)
What do I wrong?
Code:
// -------------------------------------------------------------------------------------------------
//
// 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, AddIndicators = true)]
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");
}
}
}
@jcr1818
PanagiotisCharalampous
02 Dec 2024, 07:56
RE: RE: the optimization results - are these credible enough?
jcr1818 said:
PanagiotisCharalampous said:
Hi there,
Please provide us with more information on how to reproduce this problem. Share your cBot code, cBot parameters, dates and broker and explain to us what you expected to see and what you see instead.
Best regards,
Panagiotis
In this example I use following from the c-trader cbot system: SAMPLE RSI CBOT.
Data ticks: EURUSD 1 HOUR: Optimisation settings: TF 1 hour. Quantity: 1 lot. Source: Close. Periods: min: 5 max 20 and step 1.
Optimisation Criteria: Standard. Max netto profit. Min equity DD (%) and Max winnings trades.
Test period: 30.10.24 - 30.11.24
The system shows: AUTOSELECT THE BEST PASS: = 14. Netto profit: = 2773,72. Trades 27 etc.
Then I import the result and backtest it without changing nothing. Now the netto results shows me just 380,75 + 1 open position = 225,33 (euro)
What do I wrong?
Code:
// -------------------------------------------------------------------------------------------------
//
// 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, AddIndicators = true)]
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");
}
}
}
Are the backtesting settings the same (dates, source, commissions etc)?
@PanagiotisCharalampous
jcr1818
02 Dec 2024, 12:55
RE: RE: RE: the optimization results - are these credible enough?
PanagiotisCharalampous said:
jcr1818 said:
PanagiotisCharalampous said:
Hi there,
Please provide us with more information on how to reproduce this problem. Share your cBot code, cBot parameters, dates and broker and explain to us what you expected to see and what you see instead.
Best regards,
Panagiotis
In this example I use following from the c-trader cbot system: SAMPLE RSI CBOT.
Data ticks: EURUSD 1 HOUR: Optimisation settings: TF 1 hour. Quantity: 1 lot. Source: Close. Periods: min: 5 max 20 and step 1.
Optimisation Criteria: Standard. Max netto profit. Min equity DD (%) and Max winnings trades.
Test period: 30.10.24 - 30.11.24
The system shows: AUTOSELECT THE BEST PASS: = 14. Netto profit: = 2773,72. Trades 27 etc.
Then I import the result and backtest it without changing nothing. Now the netto results shows me just 380,75 + 1 open position = 225,33 (euro)
What do I wrong?
Code:
// -------------------------------------------------------------------------------------------------
//
// 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, AddIndicators = true)]
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");
}
}
}
Are the backtesting settings the same (dates, source, commissions
@jcr1818
jcr1818
02 Dec 2024, 12:56
( Updated at: 02 Dec 2024, 13:25 )
RE: RE: RE: RE: the optimization results - are these credible enough?
jcr1818 said:
PanagiotisCharalampous said:
jcr1818 said:
PanagiotisCharalampous said:
Hi there,
Please provide us with more information on how to reproduce this problem. Share your cBot code, cBot parameters, dates and broker and explain to us what you expected to see and what you see instead.
Best regards,
Panagiotis
In this example I use following from the c-trader cbot system: SAMPLE RSI CBOT.
Data ticks: EURUSD 1 HOUR: Optimisation settings: TF 1 hour. Quantity: 1 lot. Source: Close. Periods: min: 5 max 20 and step 1.
Optimisation Criteria: Standard. Max netto profit. Min equity DD (%) and Max winnings trades.
Test period: 30.10.24 - 30.11.24
The system shows: AUTOSELECT THE BEST PASS: = 14. Netto profit: = 2773,72. Trades 27 etc.
Then I import the result and backtest it without changing nothing. Now the netto results shows me just 380,75 + 1 open position = 225,33 (euro)
What do I wrong?
Code:
// -------------------------------------------------------------------------------------------------
//
// 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, AddIndicators = true)]
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");
}
}
}
Are the backtesting settings the same (dates, source, commissions
Yes 100%. I am very careful about consistent data. However, In my backtests and optimizations, I can choose live spread but not swap. If the ticks option covers commission, swap, etc. then there should be no difference at all. ??
@jcr1818
PanagiotisCharalampous
03 Dec 2024, 08:10
Hi there,
I just tested it and the results are identical
There is probably something wrong in your configuration that we cannot see. Please check a bit more.
Best regards,
Panagiotis
@PanagiotisCharalampous
jcr1818
03 Dec 2024, 12:13
RE: the optimization results - are these credible enough?
PanagiotisCharalampous said:
Hi there,
I just tested it and the results are identical
There is probably something wrong in your configuration that we cannot see. Please check a bit more.
Best regards,
Panagiotis
Over the past year, I have done well over 3,000 optimizations, and it’s definitely not always been clear to me what the logic behind the results is, as the optimization and backtest results should match, which they don’t at all. I can’t see where a potential error could be in my configuration. Maybe I can get a more precise hint? We agree that the results should be the same when I import the optimization result into the parameters, right? Once this is done, I click on backtest and, of course, check the data from the optimization and the backtest parameters, including the date. What I can’t see is whether the import of the backtest includes things like wrap and other criteria, but logically, these things should be included when importing the optimization data. I am trying to perform another simple test based on one of your robots from your system.
@jcr1818
PanagiotisCharalampous
03 Dec 2024, 13:01
RE: RE: the optimization results - are these credible enough?
jcr1818 said:
PanagiotisCharalampous said:
Hi there,
I just tested it and the results are identical
There is probably something wrong in your configuration that we cannot see. Please check a bit more.
Best regards,
Panagiotis
Over the past year, I have done well over 3,000 optimizations, and it’s definitely not always been clear to me what the logic behind the results is, as the optimization and backtest results should match, which they don’t at all. I can’t see where a potential error could be in my configuration. Maybe I can get a more precise hint? We agree that the results should be the same when I import the optimization result into the parameters, right? Once this is done, I click on backtest and, of course, check the data from the optimization and the backtest parameters, including the date. What I can’t see is whether the import of the backtest includes things like wrap and other criteria, but logically, these things should be included when importing the optimization data. I am trying to perform another simple test based on one of your robots from your system.
Hi there,
I can't give another hint since it works fine on my side. Can you record a video with the all steps you take to reproduce this issue? Maybe we are missing something. I am also doing optimizations over the last 8 years and any time I encounter a discrepancy, 99% is some kind of an oversight on my side.
Best regards,
Panagiotis
@PanagiotisCharalampous
jcr1818
03 Dec 2024, 17:03
RE: RE: RE: the optimization results - are these credible enough?
PanagiotisCharalampous said:
jcr1818 said:
PanagiotisCharalampous said:
Hi there,
I just tested it and the results are identical
There is probably something wrong in your configuration that we cannot see. Please check a bit more.
Best regards,
Panagiotis
Over the past year, I have done well over 3,000 optimizations, and it’s definitely not always been clear to me what the logic behind the results is, as the optimization and backtest results should match, which they don’t at all. I can’t see where a potential error could be in my configuration. Maybe I can get a more precise hint? We agree that the results should be the same when I import the optimization result into the parameters, right? Once this is done, I click on backtest and, of course, check the data from the optimization and the backtest parameters, including the date. What I can’t see is whether the import of the backtest includes things like wrap and other criteria, but logically, these things should be included when importing the optimization data. I am trying to perform another simple test based on one of your robots from your system.
Hi there,
I can't give another hint since it works fine on my side. Can you record a video with the all steps you take to reproduce this issue? Maybe we are missing something. I am also doing optimizations over the last 8 years and any time I encounter a discrepancy, 99% is some kind of an oversight on my side.
Best regards,
Panagiotis
I will record a video soon.
@jcr1818
PanagiotisCharalampous
27 Nov 2024, 12:05
Hi there,
Please provide us with more information on how to reproduce this problem. Share your cBot code, cBot parameters, dates and broker and explain to us what you expected to see and what you see instead.
Best regards,
Panagiotis
@PanagiotisCharalampous