cBot Draw an Icon and let it stay after cBot stop?

Capt.Z-Fort.Builder's avatar

Capt.Z-Fort.Builder since: 03 Jun 2020;

  27 Jan 2022, 23:31
cBot Draw an Icon and let it stay after cBot stop?

Hi Support Team,

I have below code to draw an up arrow below the last bar lowest price. But it only exists when the Bot is running. Is there any way that I can let the UpArrow stay even the cBot stopped?

Thanks,

L

using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class DrawIcon : Robot
    {

        protected override void OnStart()
        {
            string sMessage = "Long " + Bars.LastBar.OpenTime;
            Chart.DrawIcon(sMessage, ChartIconType.UpArrow, Bars.LastBar.OpenTime, Bars.LastBar.Low * 0.999, Color.FromHex("#DDE7E7E7"));
        }

        protected override void OnTick() {}

        protected override void OnStop() {}
    }
}
amusleh's avatar

amusleh since: 01 Mar 2021;

  28 Jan 2022, 08:27

Hi,

You can set the object IsInteractive flag to True:

using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class DrawIcon : Robot
    {

        protected override void OnStart()
        {
            string sMessage = "Long " + Bars.LastBar.OpenTime;
            var icon = Chart.DrawIcon(sMessage, ChartIconType.UpArrow, Bars.LastBar.OpenTime, Bars.LastBar.Low * 0.999, Color.FromHex("#DDE7E7E7"));

            icon.IsInteractive = true;
            icon.IsLocked = true;
        }

        protected override void OnTick() {}

        protected override void OnStop() {}
    }
}

The IsLocked is an additional optional step which disables moving of object, but you can turn it on/off from object settings.

Community Developer | Spotware | Telegram: @algodeveloper
Capt.Z-Fort.Builder's avatar

Capt.Z-Fort.Builder since: 03 Jun 2020;

  28 Jan 2022, 16:16
RE:

Hi Musleh,

I've just tested the code, there are some error information when compiling. 

L

amusleh said:

Hi,

You can set the object IsInteractive flag to True:

using cAlgo.API;

namespace cAlgo.Robots
{
...    
}

The IsLocked is an additional optional step which disables moving of object, but you can turn it on/off from object settings.

Capt.Z-Fort.Builder's avatar

Capt.Z-Fort.Builder since: 03 Jun 2020;

  28 Jan 2022, 14:22
RE:

Hi Musleh,

I've just tested the code. Please advise.

 

amusleh said:

Hi,

You can set the object IsInteractive flag to True:

using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class DrawIcon : Robot
    {

        protected override void OnStart()
        {
            string sMessage = "Long " + Bars.LastBar.OpenTime;
            var icon = Chart.DrawIcon(sMessage, ChartIconType.UpArrow, Bars.LastBar.OpenTime, Bars.LastBar.Low * 0.999, Color.FromHex("#DDE7E7E7"));

            icon.IsInteractive = true;
            icon.IsLocked = true;
        }

        protected override void OnTick() {}

        protected override void OnStop() {}
    }
}

The IsLocked is an additional optional step which disables moving of object, but you can turn it on/off from object settings.

amusleh's avatar

amusleh since: 01 Mar 2021;

  31 Jan 2022, 08:04
RE: RE:

TheNiatpac said:

Hi Musleh,

I've just tested the code. Please advise.

 

Hi,

There is no such issue on my posted code, most probably you made some changes on it, the error says that the variable "icon" does not exist.

Community Developer | Spotware | Telegram: @algodeveloper
Capt.Z-Fort.Builder's avatar

Capt.Z-Fort.Builder since: 03 Jun 2020;

  31 Jan 2022, 12:22
RE: RE: RE:

Hi Musleh,

Thanks for the reply. I found the problem. 

            var icon = Chart.DrawIcon(sMessage, ChartIconType.UpArrow, Bars.LastBar.OpenTime, Bars.LastBar.Low * 0.999, Color.FromHex("#DDE7E7E7"));

I should define the icon first. So that we can set the properties for it.  

Much appreciated.

L

amusleh said:

TheNiatpac said:

Hi Musleh,

I've just tested the code. Please advise.

 

Hi,

There is no such issue on my posted code, most probably you made some changes on it, the error says that the variable "icon" does not exist.

mpaggini since: 05 Sep 2022;

  05 Sep 2022, 09:57
RE:

amusleh said:

Hi,

You can set the object IsInteractive flag to True:

using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class DrawIcon : Robot
    {

        protected override void OnStart()
        {
            string sMessage = "Long " + Bars.LastBar.OpenTime;
            var icon = Chart.DrawIcon(sMessage, ChartIconType.UpArrow, Bars.LastBar.OpenTime, Bars.LastBar.Low * 0.999, Color.FromHex("#DDE7E7E7"));

            icon.IsInteractive = true;
            icon.IsLocked = true;
        }

        protected override void OnTick() {}

        protected override void OnStop() {}
    }
}

The IsLocked is an additional optional step which disables moving of object, but you can turn it on/off from object settings.

This not work for me, when bot stop all drawed object disappar, also in backtest