Order failed with Error "Technical Error" ?

13 Jun 2019, 07:30Order failed with Error "Technical Error" ?#1
FireMystposts: 92since: 26 Mar 2019

Hi everyone:

See screen captures below from cTrader and VS debugging on EURAUD M15 chart.

1) The SL line is 1 pip above the order line. 

2) In the VS watch window, the code and values are there (most are rounded to 4 decimal places). The entry price was 1.63386; the new SL is to be 1.6339; it says the current SL is 1.6338

3) When the code goes to place the trade, there's the error message.

4) The LOG says, "FAILED with 'Technical Error', Position PID32394943"

What is the 'technical error'? Are orders not allowed to be placed that change the SL by 0.00004 to a nice, 4-decimal-place number?

Thank you.

13 Jun 2019, 10:02#2
Panagiotis Charalampousposts: 2868since: 13 Jan 2017

Hi FireMyst,

If you can share the cBot code and cBot parameters we can investigate further.

Best Regards,

Panagiotis


Head of Community Management at cTrader
14 Jun 2019, 04:12#3
FireMystposts: 92since: 26 Mar 2019

HI @Panagiotis:

Before sharing code, since the PID was given in the log output from cTrader, is your team able to look it up in any "transaction logs" to see what, if anything, was logged on the server?

Or is that something I can pass along to Pepperstone, and then they would contact Spotware to find out more?

Thank you,

 

14 Jun 2019, 06:21RE:#4
FireMystposts: 92since: 26 Mar 2019

Panagiotis Charalampous said:

Hi FireMyst,

If you can share the cBot code and cBot parameters we can investigate further.

Best Regards,

Panagiotis

Here is the bot code for that particular section:

{
                            pipAdjustment = Symbol.PipSize * 1;

                            if (p.TradeType == TradeType.Buy)
                                newSL = RoundPips(Symbol, p.EntryPrice + pipAdjustment);
                            else
                                newSL = RoundPips(Symbol, p.EntryPrice - pipAdjustment);

                            if (DebugLogMode)
                                Print("MP11: Position \"{0} {1}\" is in profit by at least {2} pips. Setting new SL to {3} from {4}.", p.Id, p.Label, _minPipProfitPastEntryPriceThreshold, newSL, _prevStopLossLocation);

                            TradeResult r = p.ModifyStopLossPrice(newSL);
                            if (r.IsSuccessful)
                            {
                                _prevStopLossLocation = newSL;
                                Print("MP11: Successfully set stoploss to \"{0}\" for position \"{1} {2}\".", newSL, p.Id, p.Label);
                            }
                            else
                            {
                                Print("MP11: Problem! Could not set stoploss to \"{0}\" for position \"{1} {2}\".", newSL, p.Id, p.Label);
                                Stop();
                                return;
                            }
                        }

Here is the function "RoundPips":

/// <summary>
        /// JPY currency in pips only goes to 2 decimal places. If the symbol contains JPY, round pips value to 2 places; otherwise 4.
        /// </summary>
        /// <param name="s">The Symbol</param>
        /// <param name="pips">The Pip value</param>
        /// <returns>The rounded pip value to either 2 or 4 places if symbol s contains JPY.</returns>
        private double RoundPips(Symbol s, double pips)
        {
            if (s.Code.ToUpper().Contains("JPY"))
            {
                return ((int)(pips * 100)) / 100.0;
            }
            else
            {
                return ((int)(pips * 10000)) / 10000.0;
            }
        }

The variable "p" is just the current position:

Position p = Positions.Find(_positionLabel, Symbol);

This is coded with cTrader v 3.3.

14 Jun 2019, 09:24RE:#5
Panagiotis Charalampousposts: 2868since: 13 Jan 2017

FireMyst said:

HI @Panagiotis:

Before sharing code, since the PID was given in the log output from cTrader, is your team able to look it up in any "transaction logs" to see what, if anything, was logged on the server?

Or is that something I can pass along to Pepperstone, and then they would contact Spotware to find out more?

Thank you,

 

Hi FireMyst,

To investigate the reasons for the specific position you need to go through Pepperstone. They are in charge of their execution. Regarding the code sample, I will need the complete cBot and steps to reproduce. Since I do not see any obvious reason for a technical error, I might need to forward to the QA team for further investigation. Btw a more proper way to round prices is the following

Math.Round(price, Symbol.Digits)

Best Regards,

Panagiotis


Head of Community Management at cTrader
14 Jun 2019, 09:41RE: RE:#6
FireMystposts: 92since: 26 Mar 2019

Panagiotis Charalampous said:

Hi FireMyst,

To investigate the reasons for the specific position you need to go through Pepperstone. They are in charge of their execution. Regarding the code sample, I will need the complete cBot and steps to reproduce. Since I do not see any obvious reason for a technical error, I might need to forward to the QA team for further investigation. Btw a more proper way to round prices is the following

Math.Round(price, Symbol.Digits)

Best Regards,

Panagiotis

Here's sample code which reproduces the issue every time for me on Pepperstone. Use on EURAUD 15-minute chart:

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TestBot : Robot
    {
        private string _positionLabel = String.Empty;
        private MarketSeries _marketSeries;
        private int _counter = 0;
        double _prevStopLossLocation = 0;

        protected override void OnStart()
        {
            _marketSeries = MarketData.GetSeries(Symbol, MarketSeries.TimeFrame);
            DataSeries series = _marketSeries.Close;
            _positionLabel = (MarketSeries.TimeFrame) + " " + Symbol.Code + " Test Bot";
            ExecuteMarketOrder(TradeType.Buy,Symbol,1000,_positionLabel,30,null);
            _prevStopLossLocation = 0;
        }

        protected override void OnTick()
        {
            Print("Tick! {0}", _counter);
            Position p = Positions.Find(_positionLabel, Symbol);

            double pipAdjustment = Symbol.PipSize * 10;
            double newSL = RoundPips(Symbol, p.EntryPrice - pipAdjustment);

            if (_prevStopLossLocation != 0)
                newSL += _prevStopLossLocation;

            Print("MP10: Position \"{0} {1}\" is in profit. Setting new SL to {2} from {3}.", p.Id, p.Label, newSL, _prevStopLossLocation);

            TradeResult r = p.ModifyStopLossPrice(newSL);
            if (r.IsSuccessful)
            {
                _prevStopLossLocation = newSL + 0.00004;
                Print("MP10: Successfully set stoploss to \"{0}\" for position \"{1} {2}\".", newSL, p.Id, p.Label);
            }
            else
            {
                Print("MP10: Problem! Could not set stoploss to \"{0}\" for position \"{1} {2}\".", newSL, p.Id, p.Label);
                Stop();
                return;
            }
        }

        private double RoundPips(Symbol s, double pips)
        {
                return ((int)(pips * Math.Pow(10, 4))) / Math.Pow(10, 4);
        }

    }
}

It typically bombs out the second or 3rd time through for me after I add the "0.00004" to the newSL value.

14 Jun 2019, 09:41RE: RE:#7
FireMystposts: 92since: 26 Mar 2019

Panagiotis Charalampous said:

Hi FireMyst,

To investigate the reasons for the specific position you need to go through Pepperstone. They are in charge of their execution. Regarding the code sample, I will need the complete cBot and steps to reproduce. Since I do not see any obvious reason for a technical error, I might need to forward to the QA team for further investigation. Btw a more proper way to round prices is the following

Math.Round(price, Symbol.Digits)

Best Regards,

Panagiotis

Here's sample code which reproduces the issue every time for me on Pepperstone. Use on EURAUD 15-minute chart:

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TestBot : Robot
    {
        private string _positionLabel = String.Empty;
        private MarketSeries _marketSeries;
        private int _counter = 0;
        double _prevStopLossLocation = 0;

        protected override void OnStart()
        {
            _marketSeries = MarketData.GetSeries(Symbol, MarketSeries.TimeFrame);
            DataSeries series = _marketSeries.Close;
            _positionLabel = (MarketSeries.TimeFrame) + " " + Symbol.Code + " Test Bot";
            ExecuteMarketOrder(TradeType.Buy,Symbol,1000,_positionLabel,30,null);
            _prevStopLossLocation = 0;
        }

        protected override void OnTick()
        {
            Print("Tick! {0}", _counter);
            Position p = Positions.Find(_positionLabel, Symbol);

            double pipAdjustment = Symbol.PipSize * 10;
            double newSL = RoundPips(Symbol, p.EntryPrice - pipAdjustment);

            if (_prevStopLossLocation != 0)
                newSL += _prevStopLossLocation;

            Print("MP10: Position \"{0} {1}\" is in profit. Setting new SL to {2} from {3}.", p.Id, p.Label, newSL, _prevStopLossLocation);

            TradeResult r = p.ModifyStopLossPrice(newSL);
            if (r.IsSuccessful)
            {
                _prevStopLossLocation = newSL + 0.00004;
                Print("MP10: Successfully set stoploss to \"{0}\" for position \"{1} {2}\".", newSL, p.Id, p.Label);
            }
            else
            {
                Print("MP10: Problem! Could not set stoploss to \"{0}\" for position \"{1} {2}\".", newSL, p.Id, p.Label);
                Stop();
                return;
            }
        }

        private double RoundPips(Symbol s, double pips)
        {
                return ((int)(pips * Math.Pow(10, 4))) / Math.Pow(10, 4);
        }

    }
}

It typically bombs out the second or 3rd time through for me after I add the "0.00004" to the newSL value.

14 Jun 2019, 09:53#8
Panagiotis Charalampousposts: 2868since: 13 Jan 2017

Hi FireMyst,

Here is your problem

Best Regards,

Panagiotis


Head of Community Management at cTrader
14 Jun 2019, 10:13RE:#9
FireMystposts: 92since: 26 Mar 2019

Panagiotis Charalampous said:

Hi FireMyst,

Here is your problem

Best Regards,

Panagiotis

 

Thank you! Debugging in VS i didn't see those -- only what's written in the log. I appreciate your time.:-)