The backtesting function should be at the same place as on the cTrader Windows application. Just click on the instance and you should get the tab on the right.
Could you pleasesend us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.
Could you pleasesend us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.
We are not aware of any specific issue with optimization performance. If you can share more information with us like the cBot code and the optimization parameters and settings, we are happy to have a look.
This info needs to be kept on the client side. The whole concept of Async execution is to proceed with your code execution while you expect a response from the server. There is no pending state on the server side. The server receives the order and responds.
Ok so at least you get a response and a message. I will suggest to the team to enhance the message.
I suppose the question for the team to consider is - should it even throw an error message if there's nothing to change? As opposed to, say, a warning? (depending on how the server side captures/responds to different severity levels)
There are no severity levels. There are only messages in the Error field when the modification is not successful.
Nor does it seem to be returned when checking a TradeResult object for error messages (unless I'm doing that wrong).
Can you share the code you are using so that we can see what you are doing? The below should work
Print("Error: {0}", TradeResult.Error);
Best regards,
Panagiotgis
Below is some sample code you can run on a forex symbol like EURJPY to demonstrate the lack of information.
The output from the log is:
Note that it doesn't say, “Nothing to Change” in the error reported, the symbol name, or anything. Just says, “invalid request”, which to me makes no sense when someone's looking for the actual error message in log files. “invalid request” can happen for any number of reasons, and means we have to keep bothering our broker to find out what and why was an “invalid request”.
Code to reproduce:
using System;using cAlgo.API;namespace cAlgo{ [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class TokyoSessionStrategy : Robot { private Position _p; private int _tickCount; protected override void OnStart() { _p = null; _tickCount = 0; } protected override void OnTick() { TradeResult r; if (_p == null) { r = ExecuteMarketOrder(TradeType.Buy, SymbolName, 1000, "TESTBOT"); if (!r.IsSuccessful) { Print("Order not successful. Please restart bot. Error message {0}", r.Error.Value.ToString()); } else { _p = Positions.Find("TESTBOT"); } } Print("TICK COUNT {0}", _tickCount.ToString()); if (_tickCount % 5 == 0 && _p != null) { Print("Modifying order"); r = _p.ModifyStopLossPrice(_p.StopLoss.GetValueOrDefault()); if (!r.IsSuccessful) { Print("Order not successful. Error message:"); Print("1 {0}", r.Error); Print("2 {0}", r.Error.Value.ToString()); } } _tickCount++; } protected override void OnStop() { if (_p != null) { _p.Close(); } base.OnStop(); } }}
Ok so at least you get a response and a message. I will suggest to the team to enhance the message.
// Si condition haussière if (bullishCondition) { // Ferme d'abord toutes les positions vendeuses foreach (var position in positions) { if (position.TradeType == TradeType.Sell) ClosePosition(position); }
// Vérifie s'il n'y a pas de positions acheteuses ouvertes if (!HasOpenPositions(TradeType.Buy)) { ExecuteMarketOrder(TradeType.Buy, SymbolName, lotSize, "Buy Signal"); } } // Si condition baissière else if (bearishCondition) { // Ferme d'abord toutes les positions acheteuses foreach (var position in positions) { if (position.TradeType == TradeType.Buy) ClosePosition(position); }
// Vérifie s'il n'y a pas de positions vendeuses ouvertes if (!HasOpenPositions(TradeType.Sell)) { ExecuteMarketOrder(TradeType.Sell, SymbolName, lotSize, "Sell Signal"); } } }
private bool HasOpenPositions(TradeType tradeType) { foreach (var position in Positions) { if (position.TradeType == tradeType) return true; } return false; } } }
Les paramètres de mon backtest : Capital initial 1 000 dollars avec les graphiques renko de 500 pips.
je n'ai pas connecté un courtier
Hi there,
Can you please also share screenshots from your log?
This happens because you are printing the values at the opening of the bar. The indicator value might change by the time the bar closes. Try printing values for closed bars i.e.
var openTime = Bars.OpenTimes.Last(1);
var _rsi = rsi.Result.Last(1);
PanagiotisCharalampous
25 Nov 2024, 06:33
Hi there,
The backtesting function should be at the same place as on the cTrader Windows application. Just click on the instance and you should get the tab on the right.
Best regards,
Panagiotis
@PanagiotisCharalampous