Order Execution Error : Nothing to change

Created at 21 Nov 2024, 06:53
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
FI

firemyst

Joined 26.03.2019

Order Execution Error : Nothing to change
21 Nov 2024, 06:53


How do we capture in logs what's causing this error?

I'm running bots with multiple instances, and I haven't found this error in any of the logs. 

Nor does it seem to be returned when checking a TradeResult object for error messages (unless I'm doing that wrong).

Is this error captured anywhere so we can analyze or at least see what values and bot instances are causing it?

I saw this thread:

https://ctrader.com/forum/cbot-support/13607/

and I understand it could be a rounding issue. But again, I need to be able to log and find out where it's happening as I have lots of places in code where price/position could be updated/modified.

Thank you.


@firemyst
Replies

PanagiotisCharalampous
21 Nov 2024, 08:50

Hi firemyst,

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


@PanagiotisCharalampous

firemyst
22 Nov 2024, 02:11 ( Updated at: 22 Nov 2024, 05:59 )

RE: Order Execution Error : Nothing to change

PanagiotisCharalampous said: 

Hi firemyst,

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();
        }
    }
}

 

 


@firemyst

PanagiotisCharalampous
22 Nov 2024, 06:11

RE: RE: Order Execution Error : Nothing to change

firemyst said: 

PanagiotisCharalampous said: 

Hi firemyst,

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.


@PanagiotisCharalampous

firemyst
22 Nov 2024, 06:16

RE: RE: RE: Order Execution Error : Nothing to change

Panagio

 

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)

 


@firemyst

PanagiotisCharalampous
22 Nov 2024, 08:51

RE: RE: RE: RE: Order Execution Error : Nothing to change

firemyst said: 

Panagio

 

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.

Best regards,

Panagiotis


@PanagiotisCharalampous

firemyst
23 Nov 2024, 09:39

RE: RE: RE: Order Execution Error : Nothing to change

PanagiotisCharalampous said: 

firemyst said: 

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”.

 

Ok so at least you get a response and a message. I will suggest to the team to enhance the message.

 

Would you be able to suggest to them they enhance this message too in addition to the one “Nothing to change”? 

This is an example where I had to write the broker because “invalid request” in the logs didn't match with what's actually happening. In this message, it says, “Nothing to amend”, but “nothing to amend” isn't printed out in the error message returned in the calgo logs. 

 

 


@firemyst