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);
Unfortunately we cannot help you with your issue in this forum. If you have disputes with the broker, please contact the regulator and your local authorities. Also this thread will be deleted, since broker reviewing is beyond the scope of this community and defaming is not allowed.
RE: RE: Listing all Orders, Positions where the Deal Status is Rejected
Can I programmatically list the ExecutionTime instead? My TakeProfit or LimitOrder are not executed despite the price being matched.
Not sure what do you mean here. Can you elaborate?
Also, is it normal for US500_SB to take 300ms? The LO and TP are already on cTrader - but in case it matters - the hired VPS is in New York. Importantly, the VPS provider said that Metatrader takes 1-2 ms for execution. I don't understand how this can be true.
This is the matching time, not cTrader's latency. It is the time it took for the order to be executed by the liquidity provider. This is not controlled by cTrader
PanagiotisCharalampous
22 Nov 2024, 09:04
Hi there,
Yes it is. Just add an instance and click on it. You should see the backtesting tab on the right
Best regards,
Panagiotis
@PanagiotisCharalampous