Topics
Replies
PanagiotisCharalampous
12 Sep 2024, 09:06
Hi there,
Please note that Spotware demo accounts are offered for demonstration purposes only and settings might not always reflect real trading conditions. If you need a demo with real trading conditions, please create a demo account with your broker.
Best regards,
@PanagiotisCharalampous
PanagiotisCharalampous
12 Sep 2024, 09:06
Hi there,
Please note that Spotware demo accounts are offered for demonstration purposes only and settings might not always reflect real trading conditions. If you need a demo with real trading conditions, please create a demo account with your broker.
Best regards,
@PanagiotisCharalampous
PanagiotisCharalampous
12 Sep 2024, 09:05
RE: RE: CTrader Web - issue with charts
Teflon said:
I added three pictures here:
No pictures posted and FxPro edge is not cTrader. If you have issues with FxPro Edge, please talk to them
@PanagiotisCharalampous
PanagiotisCharalampous
12 Sep 2024, 08:23
RE: RE: RE: RE: Bot randomly stop without any log
duongphuongtrinh92 said:
PanagiotisCharalampous said:
duongphuongtrinh92 said:
PanagiotisCharalampous said:
Hi there,
Unfortunately we cannot reproduce this issue. 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
It is still happening. Is there any work around on this, please? May be we can download an older version of cTrader?
Older versions are not available. Did you send the troubleshooting report as requested?
Yes, I did. I also attached a link to this discussion.
Hi there,
We have received your troubleshooting report. It seems you are running the cBots on three different instances that run under the same start up profile. This setup might cause conflicts between cBots. We would suggest that you create a separate profile for each instance of the cBot you are running. Read more below
https://help.ctrader.com/ctrader/interface/settings/?h=profile#startup
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Sep 2024, 05:44
Hi there,
I don't see a problem in the calculation. Please explain to us what you thing the problem is.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Sep 2024, 05:42
Hi there,
I always had a one-click trading option on, I never had a confirmation pop-up window. It was changed to my surprise.
You can set it back to one click in Settings > QuickTrade
Charts sometimes do refresh by themselves.
It can happen when there is a disconnection and reconnection
Squeezed charts. To replicate this scenario: Open CTrader Web - Google Chrome - (I had 8 charts), go to another app like Gmail - and come back after x minutes, CTrader will refresh the charts and there will be a squeeze or it will refresh all charts.
Can you please record a video demonstrating this happening?
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Sep 2024, 05:37
RE: RE: Where are all the Release Notes - cannot find any between 4.8.30 & 5.0.22 so don't know what's changed since 4.9.2
martins said:
PanagiotisCharalampous said:
You can find release notes for major releases in What's New section
Ok, thanks. I note What's New from cTrader Web has Release numbers, whereas Desktop appears not to, was that deliberate, or perhaps the Web version I'm looking at is newer than my Desktop v4.9.2 and the later versions have the numbers. Do changes & enhancements to the cBot programming API of Automate / Algo appear there too, if not where?
Also, how would I see equivalent information for a version later than the one I have?
And finally, I'm confused by the different cTrader platform names, in particular cTrader Desktop vs cTrader Automate. All the version of Desktop I've used, 3.x to 4.9, have the Automate option for coding (directly or in Visual Studio), and for running, C# automated trading cBots and Backtesting & Optimization, so are these in fact the same thing?
Hi there,
Ok, thanks. I note What's New from cTrader Web has Release numbers, whereas Desktop appears not to, was that deliberate, or perhaps the Web version I'm looking at is newer than my Desktop v4.9.2 and the later versions have the numbers.
Desktop and Web are developed by different teams hence each team, therefore there is no correspondence between versions and each team chooses their own presentation form
Do changes & enhancements to the cBot programming API of Automate / Algo appear there too, if not where?
Yes in the same place
Also, how would I see equivalent information for a version later than the one I have?
You can't see information for later versions
And finally, I'm confused by the different cTrader platform names, in particular cTrader Desktop vs cTrader Automate. All the version of Desktop I've used, 3.x to 4.9, have the Automate option for coding (directly or in Visual Studio), and for running, C# automated trading cBots and Backtesting & Optimization, so are these in fact the same thing?
cTrader Automate (now cTrader Algo) is just a part of cTrader Desktop. They are not different applications.
@PanagiotisCharalampous
PanagiotisCharalampous
10 Sep 2024, 13:23
You can find release notes for major releases in What's New section
@PanagiotisCharalampous
PanagiotisCharalampous
10 Sep 2024, 13:23
You can find release notes for major releases in What's New section
@PanagiotisCharalampous
PanagiotisCharalampous
10 Sep 2024, 11:58
Hi there,
- No there isn't. Each account can have a session opened
- It looks like an issue with your system's time, generating wrong timestamps. Please check it and make sure it's correct.
When fetching 1/2 symbols for MsgType_MarketDataRequest (V) it's fine but when I attempt more, I get that error after a period of time and I'm then forced to log out. Is there a specific way to fetch multiple symbol data? And is there a timeout before I can log back in again?
No there isn't a way to fetch multiple symbol data not there is a timeout between logouts/logins
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Sep 2024, 09:56
Hi there,
Please share some screenshots so that we can understand what you are looking at.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Sep 2024, 07:28
RE: RE: RE: RE: Timeline for future parity of the Mac version with the Windows version?
Nicolinux said:
PanagiotisCharalampous said:
[…]
Hi Stefan,
- It will be added in 5.2
- We do not have plans yet
- Can you please elaborate with examples?
Best regards,
Panagiotis
Regarding 1. 🎉🎉🎉
Regarding 2. Any way to influence it? Money, cookies, anything else? :)
Regarding 3. Apparently my media was not uploaded correctly. Here is what I mean. The layout of the mac version is fixed, in windows the layout is flexible.
Hi Stefan,
Free chart mode will be added but we do not have an ETA at the moment. It's not included in the next couple of updates.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Sep 2024, 05:59
RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: Backtesting - Incorrect TP / SL calculation
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
zytotoxiziteat said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
zytotoxiziteat said:
zytotoxiziteat said:
PanagiotisCharalampous said:
Hi there,
Please share your cBot code and make sure you are using tick data for your backtests.
Best regards,
Panagiotis
using System;using System.Collections.Generic;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo.Robots{ [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class TradingBot : Robot { [Parameter("Risk Percentage", DefaultValue = 1, MinValue = 0.1, MaxValue = 10)] public double RiskPercentage { get; set; } [Parameter("Stop Loss (Pips)", DefaultValue = 40, MinValue = 0, MaxValue = 100)] public double StopLossPips { get; set; } [Parameter("Take Profit (Pips)", DefaultValue = 20, MinValue = 0, MaxValue = 200)] public double TakeProfitPips { get; set; } private AI_101.ML101.ModelInput _modelInput; private double _lastPrediction; protected override void OnStart() { _modelInput = new AI_101.ML101.ModelInput(); } protected override void OnTick() { // Ensure only one open position per currency pair if (Positions.FindAll("ML Prediction", Symbol.Name).Length > 0) return; // Update model input with the latest close price _modelInput.ClosePrice = (float)Symbol.Bid; // Use Symbol.Bid instead of Symbol.LastTick.Bid // Get prediction var prediction = AI_101.ML101.Predict(_modelInput); // Calculate the predicted price change double predictedChange = prediction.ClosePrice[0] - _modelInput.ClosePrice; // Determine if we should open a position if (Math.Abs(predictedChange) > Symbol.PipSize) { if (predictedChange > 0 && _lastPrediction <= 0) { OpenPosition(TradeType.Buy); } else if (predictedChange < 0 && _lastPrediction >= 0) { OpenPosition(TradeType.Sell); } } _lastPrediction = predictedChange; } private void OpenPosition(TradeType tradeType) { // Calculate position size based on risk double riskAmount = Account.Balance * (RiskPercentage / 100); double volumeInUnits = riskAmount / (StopLossPips * Symbol.PipValue); // Ensure volume is within acceptable range and increments volumeInUnits = Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode.ToNearest); // Check if the volume is valid if (volumeInUnits < Symbol.VolumeInUnitsMin || volumeInUnits > Symbol.VolumeInUnitsMax) { Print("Volume is out of range: " + volumeInUnits); return; } // Open the position ExecuteMarketOrder(tradeType, Symbol.Name, volumeInUnits, "ML Prediction", StopLossPips, TakeProfitPips); } }}
My thought was:
Since I collected only m5 candle data for my Machine learning module I changed the “Data” in settings to “m5 bars from server” for backtestingand I was considering to change “protected override void OnTick()” to "protected override void OnBar()".
Is that wrong?
What is the best solution?
Thank youHi there,
If you are using fixed SL and TP, you need to use tick data to ensure accurate results in backtesting.
Best regards,
Panagiotis
Okay, my cbot code uses
protected override void OnTick()
I still get wrong TP.
You need to use tick data on your backtesting settings. OnTick() is irrelevant.
Where does the option “m5 bars from server” come from?
I thought the system provided the best possible set-up because of my csv file, which contains only m5 bars data.
I don't understand what you mean. It's just an option in a dropdown list
My friend,
I created a csv file with m5 bars only to train my module. I thought that is why I the option “M5” is available.
Can you please explain why in any of the options in Backtesting drop-down list is not triggering my predefined TP or SL .
What is the point of predefining it?
I thought the Backtesting process should prepare for the real environment. But when there are options which are not correctly executed by the system makes no sense to me.
The options have nothing to do with the data you used to generate the model. The backtesting module has no clue what your cBot is doing. Those options are there to choose the data source to be used for the backtesting. If you don't use tick data but you use SP and TP at specific price levels, your execution will be inaccurate, since m5 bars data source only uses open prices for the execution
Hi, ok I tried the optimizer with tick data from server.
The Optimizers choice of parameters : SL = 82; TP = 20
And this was the result. Again the TP was not correct: way more than 20 pips TP
I dont know mate. It seems to me there is no point of “testing” if the system doesnt TP/SL properly.
Hi there,
I cannot provide an explanation of what you are looking at since I do not have your cBot's code. If you can help me reproduce what you are looking at, I will explain what happens. But I am 100% sure that this is not related with inaccurate executions. I am using cTrader for the last 8 years, I backtest several cBots every day and I can confirm that the execution with tick data is exact.
Best regards,
Panagiotis
Bot Code:
using System;using System.Collections.Generic;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo.Robots{ [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class TradingBot : Robot { [Parameter("Risk Percentage", DefaultValue = 1, MinValue = 0.1, MaxValue = 20)] public double RiskPercentage { get; set; } [Parameter("Stop Loss (Pips)", DefaultValue = 40, MinValue = 0, MaxValue = 100)] public double StopLossPips { get; set; } [Parameter("Take Profit (Pips)", DefaultValue = 20, MinValue = 0, MaxValue = 200)] public double TakeProfitPips { get; set; } private AI_101.ML101.ModelInput _modelInput; private double _lastPrediction; protected override void OnStart() { _modelInput = new AI_101.ML101.ModelInput(); } protected override void OnTick() { // Ensure only one open position per currency pair if (Positions.FindAll("ML Prediction", Symbol.Name).Length > 0) return; // Update model input with the latest close price _modelInput.ClosePrice = (float)Symbol.Bid; // Use Symbol.Bid instead of Symbol.LastTick.Bid // Get prediction var prediction = AI_101.ML101.Predict(_modelInput); // Calculate the predicted price change double predictedChange = prediction.ClosePrice[0] - _modelInput.ClosePrice; // Determine if we should open a position if (Math.Abs(predictedChange) > Symbol.PipSize) { if (predictedChange > 0 && _lastPrediction <= 0) { OpenPosition(TradeType.Buy); } else if (predictedChange < 0 && _lastPrediction >= 0) { OpenPosition(TradeType.Sell); } } _lastPrediction = predictedChange; } private void OpenPosition(TradeType tradeType) { // Calculate position size based on risk double riskAmount = Account.Balance * (RiskPercentage / 100); double volumeInUnits = riskAmount / (StopLossPips * Symbol.PipValue); // Ensure volume is within acceptable range and increments volumeInUnits = Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode.ToNearest); // Check if the volume is valid if (volumeInUnits < Symbol.VolumeInUnitsMin || volumeInUnits > Symbol.VolumeInUnitsMax) { Print("Volume is out of range: " + volumeInUnits); return; } // Open the position ExecuteMarketOrder(tradeType, Symbol.Name, volumeInUnits, "ML Prediction", StopLossPips, TakeProfitPips); } }}
I tried to optimize AUD/USD this time.
Here is a link to my .optres file: https://file.io/JbtHJixXfPjaotherwise here is a documentation of “Report”, "Events" and “Paramaters” of my optimizer:
As you can see I used tick data, the parameters are set to SL/TP= 69/90 which are not met if I sort it by “Pips”
Unfortunately I cannot run your code without this part
_modelInput = new AI_101.ML101.ModelInput();
If you can reproduce the issue without this line of code, I am more than happy to have a look
This is the link to the Ai#101 Module and my csv file:
https://file.io/JbtHJixXfPjaI am not able to open this. In any case, if there is an issue with cTrader, this module is irrelevant. You would be able to reproduce it without it
I am not sure what you mean with reproducing?
I used it on my local machine and on an other virtual machine. In both cases I had the same wrong SL/TP results.
I mean that this should happen on other cBots as well. If you are able to provide a cBot and parameters that we can run, I will explain to you what happens. At the moment I cannot reproduce such behavior
@PanagiotisCharalampous
PanagiotisCharalampous
10 Sep 2024, 05:17
Hi there,
We do not plan to support this feature at the moment.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Sep 2024, 05:15
RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: Backtesting - Incorrect TP / SL calculation
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
zytotoxiziteat said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
zytotoxiziteat said:
zytotoxiziteat said:
PanagiotisCharalampous said:
Hi there,
Please share your cBot code and make sure you are using tick data for your backtests.
Best regards,
Panagiotis
using System;using System.Collections.Generic;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo.Robots{ [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class TradingBot : Robot { [Parameter("Risk Percentage", DefaultValue = 1, MinValue = 0.1, MaxValue = 10)] public double RiskPercentage { get; set; } [Parameter("Stop Loss (Pips)", DefaultValue = 40, MinValue = 0, MaxValue = 100)] public double StopLossPips { get; set; } [Parameter("Take Profit (Pips)", DefaultValue = 20, MinValue = 0, MaxValue = 200)] public double TakeProfitPips { get; set; } private AI_101.ML101.ModelInput _modelInput; private double _lastPrediction; protected override void OnStart() { _modelInput = new AI_101.ML101.ModelInput(); } protected override void OnTick() { // Ensure only one open position per currency pair if (Positions.FindAll("ML Prediction", Symbol.Name).Length > 0) return; // Update model input with the latest close price _modelInput.ClosePrice = (float)Symbol.Bid; // Use Symbol.Bid instead of Symbol.LastTick.Bid // Get prediction var prediction = AI_101.ML101.Predict(_modelInput); // Calculate the predicted price change double predictedChange = prediction.ClosePrice[0] - _modelInput.ClosePrice; // Determine if we should open a position if (Math.Abs(predictedChange) > Symbol.PipSize) { if (predictedChange > 0 && _lastPrediction <= 0) { OpenPosition(TradeType.Buy); } else if (predictedChange < 0 && _lastPrediction >= 0) { OpenPosition(TradeType.Sell); } } _lastPrediction = predictedChange; } private void OpenPosition(TradeType tradeType) { // Calculate position size based on risk double riskAmount = Account.Balance * (RiskPercentage / 100); double volumeInUnits = riskAmount / (StopLossPips * Symbol.PipValue); // Ensure volume is within acceptable range and increments volumeInUnits = Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode.ToNearest); // Check if the volume is valid if (volumeInUnits < Symbol.VolumeInUnitsMin || volumeInUnits > Symbol.VolumeInUnitsMax) { Print("Volume is out of range: " + volumeInUnits); return; } // Open the position ExecuteMarketOrder(tradeType, Symbol.Name, volumeInUnits, "ML Prediction", StopLossPips, TakeProfitPips); } }}
My thought was:
Since I collected only m5 candle data for my Machine learning module I changed the “Data” in settings to “m5 bars from server” for backtestingand I was considering to change “protected override void OnTick()” to "protected override void OnBar()".
Is that wrong?
What is the best solution?
Thank youHi there,
If you are using fixed SL and TP, you need to use tick data to ensure accurate results in backtesting.
Best regards,
Panagiotis
Okay, my cbot code uses
protected override void OnTick()
I still get wrong TP.
You need to use tick data on your backtesting settings. OnTick() is irrelevant.
Where does the option “m5 bars from server” come from?
I thought the system provided the best possible set-up because of my csv file, which contains only m5 bars data.
I don't understand what you mean. It's just an option in a dropdown list
My friend,
I created a csv file with m5 bars only to train my module. I thought that is why I the option “M5” is available.
Can you please explain why in any of the options in Backtesting drop-down list is not triggering my predefined TP or SL .
What is the point of predefining it?
I thought the Backtesting process should prepare for the real environment. But when there are options which are not correctly executed by the system makes no sense to me.
The options have nothing to do with the data you used to generate the model. The backtesting module has no clue what your cBot is doing. Those options are there to choose the data source to be used for the backtesting. If you don't use tick data but you use SP and TP at specific price levels, your execution will be inaccurate, since m5 bars data source only uses open prices for the execution
Hi, ok I tried the optimizer with tick data from server.
The Optimizers choice of parameters : SL = 82; TP = 20
And this was the result. Again the TP was not correct: way more than 20 pips TP
I dont know mate. It seems to me there is no point of “testing” if the system doesnt TP/SL properly.
Hi there,
I cannot provide an explanation of what you are looking at since I do not have your cBot's code. If you can help me reproduce what you are looking at, I will explain what happens. But I am 100% sure that this is not related with inaccurate executions. I am using cTrader for the last 8 years, I backtest several cBots every day and I can confirm that the execution with tick data is exact.
Best regards,
Panagiotis
Bot Code:
using System;using System.Collections.Generic;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo.Robots{ [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class TradingBot : Robot { [Parameter("Risk Percentage", DefaultValue = 1, MinValue = 0.1, MaxValue = 20)] public double RiskPercentage { get; set; } [Parameter("Stop Loss (Pips)", DefaultValue = 40, MinValue = 0, MaxValue = 100)] public double StopLossPips { get; set; } [Parameter("Take Profit (Pips)", DefaultValue = 20, MinValue = 0, MaxValue = 200)] public double TakeProfitPips { get; set; } private AI_101.ML101.ModelInput _modelInput; private double _lastPrediction; protected override void OnStart() { _modelInput = new AI_101.ML101.ModelInput(); } protected override void OnTick() { // Ensure only one open position per currency pair if (Positions.FindAll("ML Prediction", Symbol.Name).Length > 0) return; // Update model input with the latest close price _modelInput.ClosePrice = (float)Symbol.Bid; // Use Symbol.Bid instead of Symbol.LastTick.Bid // Get prediction var prediction = AI_101.ML101.Predict(_modelInput); // Calculate the predicted price change double predictedChange = prediction.ClosePrice[0] - _modelInput.ClosePrice; // Determine if we should open a position if (Math.Abs(predictedChange) > Symbol.PipSize) { if (predictedChange > 0 && _lastPrediction <= 0) { OpenPosition(TradeType.Buy); } else if (predictedChange < 0 && _lastPrediction >= 0) { OpenPosition(TradeType.Sell); } } _lastPrediction = predictedChange; } private void OpenPosition(TradeType tradeType) { // Calculate position size based on risk double riskAmount = Account.Balance * (RiskPercentage / 100); double volumeInUnits = riskAmount / (StopLossPips * Symbol.PipValue); // Ensure volume is within acceptable range and increments volumeInUnits = Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode.ToNearest); // Check if the volume is valid if (volumeInUnits < Symbol.VolumeInUnitsMin || volumeInUnits > Symbol.VolumeInUnitsMax) { Print("Volume is out of range: " + volumeInUnits); return; } // Open the position ExecuteMarketOrder(tradeType, Symbol.Name, volumeInUnits, "ML Prediction", StopLossPips, TakeProfitPips); } }}
I tried to optimize AUD/USD this time.
Here is a link to my .optres file: https://file.io/JbtHJixXfPjaotherwise here is a documentation of “Report”, "Events" and “Paramaters” of my optimizer:
As you can see I used tick data, the parameters are set to SL/TP= 69/90 which are not met if I sort it by “Pips”
Unfortunately I cannot run your code without this part
_modelInput = new AI_101.ML101.ModelInput();
If you can reproduce the issue without this line of code, I am more than happy to have a look
This is the link to the Ai#101 Module and my csv file:
https://file.io/JbtHJixXfPja
I am not able to open this. In any case, if there is an issue with cTrader, this module is irrelevant. You would be able to reproduce it without it
@PanagiotisCharalampous
PanagiotisCharalampous
09 Sep 2024, 12:36
Hi Jan,
Unfortunately caching is not available. However loading time is not affected by the increment size but by the network bandwidth.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Sep 2024, 12:34
RE: RE: RE: Where is doc for MarketSeries price data?
martins said:
martins said:
PanagiotisCharalampous said:
Hi martins,
Thanks for your suggestions but we disagree with maintaining multiple versions of documentation. Old code does not need to be maintained but needs to be updated. Obsolete methods are only supported so that developers have enough time to update their obsolete code without service interruptions. New development is not supported. Therefore we do not plan to make it easy for people not to update their code.
Best regards,
Panagiotis
OK, thank you for your replies on this. Hopefully you understand I wasn't really suggesting “maintaining” the whole old doc, as in having to review or edit it forever, I was merely suggesting either an archive area with complete as-is old doc (ie without relying on internet archive wayback), OR an easy-to-find set of migration docs, issued at the time of the change but to be considered an appendix of the current doc, on how to update from a deprecated way to a new way. Perhaps just an area with all the “what's new in release x” notes would do.
My main point was to suggest the information needed in order to comply with your assertion “Old code does not need to be maintained but needs to be updated” should be somewhere within the official current documentation, and, not only available by searching the internet or interpreting warning compile-time messages or finding old forum or blog items for items such as https://ctrader.com/forum/ctrader-blog/22440/
(My usage of the word “maintain” includes making changes for your “needs to be updated” so I wouldn't [pedantically] agree with “Old code does not need to be maintained”!)More philosophically: without official information on how old code needs to be updated, there is no support for old code, which effectively means there is no real support for current code because the customer can't trust that a current feature they've used might not become old and without migration information ‘next week’.
Hi martins,
without official information on how old code needs to be updated, there is no support for old code, which effectively means there is no real support for current code because the customer can't trust that a current feature they've used might not become old and without migration information ‘next week’.
For obsolete classes and members you should get a message indicating what you should use instead. See below
@PanagiotisCharalampous
PanagiotisCharalampous
09 Sep 2024, 12:29
RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: Backtesting - Incorrect TP / SL calculation
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
zytotoxiziteat said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
PanagiotisCharalampous said:
zytotoxiziteat said:
zytotoxiziteat said:
zytotoxiziteat said:
PanagiotisCharalampous said:
Hi there,
Please share your cBot code and make sure you are using tick data for your backtests.
Best regards,
Panagiotis
using System;using System.Collections.Generic;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo.Robots{ [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class TradingBot : Robot { [Parameter("Risk Percentage", DefaultValue = 1, MinValue = 0.1, MaxValue = 10)] public double RiskPercentage { get; set; } [Parameter("Stop Loss (Pips)", DefaultValue = 40, MinValue = 0, MaxValue = 100)] public double StopLossPips { get; set; } [Parameter("Take Profit (Pips)", DefaultValue = 20, MinValue = 0, MaxValue = 200)] public double TakeProfitPips { get; set; } private AI_101.ML101.ModelInput _modelInput; private double _lastPrediction; protected override void OnStart() { _modelInput = new AI_101.ML101.ModelInput(); } protected override void OnTick() { // Ensure only one open position per currency pair if (Positions.FindAll("ML Prediction", Symbol.Name).Length > 0) return; // Update model input with the latest close price _modelInput.ClosePrice = (float)Symbol.Bid; // Use Symbol.Bid instead of Symbol.LastTick.Bid // Get prediction var prediction = AI_101.ML101.Predict(_modelInput); // Calculate the predicted price change double predictedChange = prediction.ClosePrice[0] - _modelInput.ClosePrice; // Determine if we should open a position if (Math.Abs(predictedChange) > Symbol.PipSize) { if (predictedChange > 0 && _lastPrediction <= 0) { OpenPosition(TradeType.Buy); } else if (predictedChange < 0 && _lastPrediction >= 0) { OpenPosition(TradeType.Sell); } } _lastPrediction = predictedChange; } private void OpenPosition(TradeType tradeType) { // Calculate position size based on risk double riskAmount = Account.Balance * (RiskPercentage / 100); double volumeInUnits = riskAmount / (StopLossPips * Symbol.PipValue); // Ensure volume is within acceptable range and increments volumeInUnits = Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode.ToNearest); // Check if the volume is valid if (volumeInUnits < Symbol.VolumeInUnitsMin || volumeInUnits > Symbol.VolumeInUnitsMax) { Print("Volume is out of range: " + volumeInUnits); return; } // Open the position ExecuteMarketOrder(tradeType, Symbol.Name, volumeInUnits, "ML Prediction", StopLossPips, TakeProfitPips); } }}
My thought was:
Since I collected only m5 candle data for my Machine learning module I changed the “Data” in settings to “m5 bars from server” for backtestingand I was considering to change “protected override void OnTick()” to "protected override void OnBar()".
Is that wrong?
What is the best solution?
Thank youHi there,
If you are using fixed SL and TP, you need to use tick data to ensure accurate results in backtesting.
Best regards,
Panagiotis
Okay, my cbot code uses
protected override void OnTick()
I still get wrong TP.
You need to use tick data on your backtesting settings. OnTick() is irrelevant.
Where does the option “m5 bars from server” come from?
I thought the system provided the best possible set-up because of my csv file, which contains only m5 bars data.
I don't understand what you mean. It's just an option in a dropdown list
My friend,
I created a csv file with m5 bars only to train my module. I thought that is why I the option “M5” is available.
Can you please explain why in any of the options in Backtesting drop-down list is not triggering my predefined TP or SL .
What is the point of predefining it?
I thought the Backtesting process should prepare for the real environment. But when there are options which are not correctly executed by the system makes no sense to me.
The options have nothing to do with the data you used to generate the model. The backtesting module has no clue what your cBot is doing. Those options are there to choose the data source to be used for the backtesting. If you don't use tick data but you use SP and TP at specific price levels, your execution will be inaccurate, since m5 bars data source only uses open prices for the execution
Hi, ok I tried the optimizer with tick data from server.
The Optimizers choice of parameters : SL = 82; TP = 20
And this was the result. Again the TP was not correct: way more than 20 pips TP
I dont know mate. It seems to me there is no point of “testing” if the system doesnt TP/SL properly.
Hi there,
I cannot provide an explanation of what you are looking at since I do not have your cBot's code. If you can help me reproduce what you are looking at, I will explain what happens. But I am 100% sure that this is not related with inaccurate executions. I am using cTrader for the last 8 years, I backtest several cBots every day and I can confirm that the execution with tick data is exact.
Best regards,
Panagiotis
Bot Code:
using System;using System.Collections.Generic;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo.Robots{ [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class TradingBot : Robot { [Parameter("Risk Percentage", DefaultValue = 1, MinValue = 0.1, MaxValue = 20)] public double RiskPercentage { get; set; } [Parameter("Stop Loss (Pips)", DefaultValue = 40, MinValue = 0, MaxValue = 100)] public double StopLossPips { get; set; } [Parameter("Take Profit (Pips)", DefaultValue = 20, MinValue = 0, MaxValue = 200)] public double TakeProfitPips { get; set; } private AI_101.ML101.ModelInput _modelInput; private double _lastPrediction; protected override void OnStart() { _modelInput = new AI_101.ML101.ModelInput(); } protected override void OnTick() { // Ensure only one open position per currency pair if (Positions.FindAll("ML Prediction", Symbol.Name).Length > 0) return; // Update model input with the latest close price _modelInput.ClosePrice = (float)Symbol.Bid; // Use Symbol.Bid instead of Symbol.LastTick.Bid // Get prediction var prediction = AI_101.ML101.Predict(_modelInput); // Calculate the predicted price change double predictedChange = prediction.ClosePrice[0] - _modelInput.ClosePrice; // Determine if we should open a position if (Math.Abs(predictedChange) > Symbol.PipSize) { if (predictedChange > 0 && _lastPrediction <= 0) { OpenPosition(TradeType.Buy); } else if (predictedChange < 0 && _lastPrediction >= 0) { OpenPosition(TradeType.Sell); } } _lastPrediction = predictedChange; } private void OpenPosition(TradeType tradeType) { // Calculate position size based on risk double riskAmount = Account.Balance * (RiskPercentage / 100); double volumeInUnits = riskAmount / (StopLossPips * Symbol.PipValue); // Ensure volume is within acceptable range and increments volumeInUnits = Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode.ToNearest); // Check if the volume is valid if (volumeInUnits < Symbol.VolumeInUnitsMin || volumeInUnits > Symbol.VolumeInUnitsMax) { Print("Volume is out of range: " + volumeInUnits); return; } // Open the position ExecuteMarketOrder(tradeType, Symbol.Name, volumeInUnits, "ML Prediction", StopLossPips, TakeProfitPips); } }}
I tried to optimize AUD/USD this time.
Here is a link to my .optres file: https://file.io/JbtHJixXfPjaotherwise here is a documentation of “Report”, "Events" and “Paramaters” of my optimizer:
As you can see I used tick data, the parameters are set to SL/TP= 69/90 which are not met if I sort it by “Pips”
Unfortunately I cannot run your code without this part
_modelInput = new AI_101.ML101.ModelInput();
If you can reproduce the issue without this line of code, I am more than happy to have a look
@PanagiotisCharalampous
PanagiotisCharalampous
09 Sep 2024, 09:32
RE: RE: Timeline for future parity of the Mac version with the Windows version?
Nicolinux said:
PanagiotisCharalampous said:
Hi Steve,
This is not expected to happen anytime soon. While the Mac team is catching up, the Windows team is developing new features. So there will be differences at least for the foreseeable future.
Best regards,
Panagiotis
Hi Panagiotis,
thanks for the answer. Might I ask about a few specific features? There is not much that's missing on the Mac version:
- History Tab, realised $. This is missing on the Mac, and seems like a pretty easy feature to add.
2. Pending orders via drag-out thingie. This is missing on the Mac and super useful in the Windows version
3. Flexible Layout. This is also missing on the Mac and makes the interface harder to use because one can not resize
Thanks & best wishes,
Stefan
Hi Stefan,
- It will be added in 5.2
- We do not have plans yet
- Can you please elaborate with examples?
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
12 Sep 2024, 09:08
Hi there,
Right click on the chart, go to Viewing Options and uncheck Targets.
Best regards,
Panagiotis
@PanagiotisCharalampous