Debugging still not working

Created at 01 May 2023, 15:35
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!
AC

acrigney

Joined 25.05.2017

Debugging still not working
01 May 2023, 15:35


Guys please for the last year now, I have been unable to attach the VS2022 debugger to any cbot. Either an old .net 4 cbot or a new .net 6 one.

Can someone please help! I am sick of putting print statements in!


@acrigney
Replies

PanagiotisChar
02 May 2023, 08:26

Hi there,

There are clear instructions here

Which step does not work for you?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

acrigney
02 May 2023, 08:40

RE:

Thanks mate, the debugger is not launched but the code says it was.

Also when I try and attach it says that no symbols have been loaded for the current document. 

As I said I have been doing this for years but ever since the upgrade to support .net 6 it has never worked.

Here is some sample code.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class DummyBot6 : Robot
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }

        [Parameter(DefaultValue = "Hello world!")]
        public string Message2 { get; set; }

        protected override void OnStart()
        {
            var result = System.Diagnostics.Debugger.Launch();

            if (result is false)
            {
                Print("Debugger launch failed");
            }
            else if (result is true)
            {
                Print("Debugger launched");
            }

            // To learn more about cTrader Automate visit our Help Center:
            // https://help.ctrader.com/ctrader-automate

            Print(Message);
            Print("onstart");
        }

        protected override void OnTick()
        {
            // Handle price updates here
        }
        
        protected override void OnBar()
        {
            double x = 0, y = 0, z = 0,p =0;
            Print("AddClose");
            for (int j = 0; j < 3; j++)
            {
                x = (float)Bars.ClosePrices.Last(j + 1);
                y = (float)Bars.OpenPrices.Last(j + 1);
                z = (float)Bars.HighPrices.Last(j + 1);
                p = (float)Bars.LowPrices.Last(j + 1);
            }
            Print(String.Format("lengths {0} {1} {2} {3}", x, y, z, p));


           

        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

PanagiotisChar said:

 

Hi there,

There are clear instructions here

Which step does not work for you?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 


@acrigney

firemyst
03 May 2023, 05:08

RE: RE:

acrigney said:

Thanks mate, the debugger is not launched but the code says it was.

Also when I try and attach it says that no symbols have been loaded for the current document. 

As I said I have been doing this for years but ever since the upgrade to support .net 6 it has never worked.

Here is some sample code.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class DummyBot6 : Robot
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }

        [Parameter(DefaultValue = "Hello world!")]
        public string Message2 { get; set; }

        protected override void OnStart()
        {
            var result = System.Diagnostics.Debugger.Launch();

            if (result is false)
            {
                Print("Debugger launch failed");
            }
            else if (result is true)
            {
                Print("Debugger launched");
            }

            // To learn more about cTrader Automate visit our Help Center:
            // https://help.ctrader.com/ctrader-automate

            Print(Message);
            Print("onstart");
        }

        protected override void OnTick()
        {
            // Handle price updates here
        }
        
        protected override void OnBar()
        {
            double x = 0, y = 0, z = 0,p =0;
            Print("AddClose");
            for (int j = 0; j < 3; j++)
            {
                x = (float)Bars.ClosePrices.Last(j + 1);
                y = (float)Bars.OpenPrices.Last(j + 1);
                z = (float)Bars.HighPrices.Last(j + 1);
                p = (float)Bars.LowPrices.Last(j + 1);
            }
            Print(String.Format("lengths {0} {1} {2} {3}", x, y, z, p));


           

        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

PanagiotisChar said:

 

Hi there,

There are clear instructions here

Which step does not work for you?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 

 

You need to follow the instructions. Your code clearly shows you haven't:

 


@firemyst

acrigney
03 May 2023, 05:52 ( Updated at: 21 Dec 2023, 09:23 )

RE: RE: RE:

So sorry gus yes it worked with FullAccess using the launch debugger but it does not work with trying to attach, that is the normal way I try and do it with my bots.

It says symbols have not been loaded. Looks like you have to specify the location of the symbols but I have never had to do that before.

firemyst said:

acrigney said:

Thanks mate, the debugger is not launched but the code says it was.

Also when I try and attach it says that no symbols have been loaded for the current document. 

As I said I have been doing this for years but ever since the upgrade to support .net 6 it has never worked.

Here is some sample code.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class DummyBot6 : Robot
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }

        [Parameter(DefaultValue = "Hello world!")]
        public string Message2 { get; set; }

        protected override void OnStart()
        {
            var result = System.Diagnostics.Debugger.Launch();

            if (result is false)
            {
                Print("Debugger launch failed");
            }
            else if (result is true)
            {
                Print("Debugger launched");
            }

            // To learn more about cTrader Automate visit our Help Center:
            // https://help.ctrader.com/ctrader-automate

            Print(Message);
            Print("onstart");
        }

        protected override void OnTick()
        {
            // Handle price updates here
        }
        
        protected override void OnBar()
        {
            double x = 0, y = 0, z = 0,p =0;
            Print("AddClose");
            for (int j = 0; j < 3; j++)
            {
                x = (float)Bars.ClosePrices.Last(j + 1);
                y = (float)Bars.OpenPrices.Last(j + 1);
                z = (float)Bars.HighPrices.Last(j + 1);
                p = (float)Bars.LowPrices.Last(j + 1);
            }
            Print(String.Format("lengths {0} {1} {2} {3}", x, y, z, p));


           

        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

PanagiotisChar said:

 

Hi there,

There are clear instructions here

Which step does not work for you?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 

 

You need to follow the instructions. Your code clearly shows you haven't:

 

 


@acrigney

firemyst
03 May 2023, 06:15

> So sorry gus yes it worked with FullAccess using the launch debugger but it does not work with trying to attach, that is the normal way I try and do it with my bots.

> It says symbols have not been loaded. Looks like you have to specify the location of the symbols but I have never had to do that before.

 

Because everything now runs under its own process, you could have literally hundreds of calgo processes running, and wouldn't know which one to attach to.

The new way of debugging automatically handles that for you. When prompted, select the VS instance you're currently working in (as per the instructions on the web page) making sure you're running it in "debug" mode, and you'll be able to step through the code as per usual.


@firemyst

acrigney
03 May 2023, 06:26

RE:

Awesome thanks heaps mate, you have really saved my bacon!! What kind of bots do you build? I build ML ones.

firemyst said:

> So sorry gus yes it worked with FullAccess using the launch debugger but it does not work with trying to attach, that is the normal way I try and do it with my bots.

> It says symbols have not been loaded. Looks like you have to specify the location of the symbols but I have never had to do that before.

 

Because everything now runs under its own process, you could have literally hundreds of calgo processes running, and wouldn't know which one to attach to.

The new way of debugging automatically handles that for you. When prompted, select the VS instance you're currently working in (as per the instructions on the web page) making sure you're running it in "debug" mode, and you'll be able to step through the code as per usual.

 


@acrigney

firemyst
03 May 2023, 09:12

RE: RE:

acrigney said:

Awesome thanks heaps mate, you have really saved my bacon!! What kind of bots do you build? I build ML ones.

 

 

I'm not sure what you mean by "ML" ones?

I write bots and a few custom indicators that do my trading for me. "Hybrid ones" where I have a basic strategy programmed up with position management, but watch the trades for divergences (and other signs) to manage them myself.

I used to focus on trading the daily time frame, but now stick more to Renko charts (with my own Renko Wicks indicator) to avoid all the noise distracting me or stimulating my emotions.

:-)

 

 


@firemyst