CBOT Error after update 4.3.9

Created at 26 Aug 2022, 08:40
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!
VE

velu130486

Joined 08.11.2019 Blocked

CBOT Error after update 4.3.9
26 Aug 2022, 08:40


Hello Team,

I have a Cbot works with Windows form which is created by a developer. This bot was working fine in Ctrader 4.1 but after the update it showed me lot of error, by searching in internet I able to fix the errors and build succeeded with .Net 6. When I run the Cbot windows form was opening immediately I get the error as below and Cbot is stopped

26/08/2022 12:25:04.102 | CBot instance [VadivelanZone_V11, XAUUSD, h1] crashed with error "Unable to invoke target method in current thread. Use `BeginInvokeOnMainThread` method to prevent this error."
26/08/2022 12:25:04.087 | Unable to invoke target method in current thread. Use `BeginInvokeOnMainThread` method to prevent this error.
26/08/2022 12:25:04.087 | timer1_Tick() is showing error
26/08/2022 12:24:57.930 | CBot instance [VadivelanZone_V11, XAUUSD, h1] started.

I am not sure which causes the error, because I am not a developer. I also don't know whether it uses .net 4.X or .net 6

Please help me to fix the error.

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using FeatureFXlib;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.IO;
using System.Windows.Forms;
using cAlgo.API.Alert;
using cAlgo.API.Alert.Utility;
using WMPLib;
using MessageBox = System.Windows.Forms.MessageBox;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class VadivelanZone_V11 : Robot
    {
        [Parameter("Remove Olverlapping", Group = "FEATURE", DefaultValue = true)]
        public bool overlapping { get; set; }
        [Parameter("Sound Alert", Group = "FEATURE", DefaultValue = true)]
        public bool soundalert { get; set; }
        [Parameter("Filter Strong Signal", Group = "FEATURE", DefaultValue = true)]
        public bool strongSignal { get; set; }
        [Parameter("Signal remove Delay", Group = "FEATURE", DefaultValue = 15, MinValue = 1)]
        public int signalRemoveDelay { get; set; }
        [Parameter("DrawUI", Group = "FEATURE", DefaultValue = true)]
        public bool drawUI { get; set; }

        [Parameter("Symbol max Trade", Group = "AUTO MODE 1st", DefaultValue = 1, MinValue = 1)]
        public int symbolMaxTrade { get; set; }
        [Parameter("Net max Trade", Group = "AUTO MODE 1st", DefaultValue = 1, MinValue = 1)]
        public int netMaxTrade { get; set; }
        [Parameter("TP", Group = "AUTO MODE 1st", DefaultValue = 1.3, MinValue = 0)]
        public double TP { get; set; }
        [Parameter("SL", Group = "AUTO MODE 1st", DefaultValue = 1, MinValue = 0)]
        public double SL { get; set; }
        [Parameter("ATR based", Group = "AUTO MODE 1st", DefaultValue = true)]
        public bool isATR { get; set; }
        [Parameter("ATR Period", Group = "AUTO MODE 1st", DefaultValue = 15, MinValue = 1)]
        public int atrPeriod { get; set; }

        [Parameter("minVolume:PF ratio ($)", Group = "AUTO MODE 2nd", DefaultValue = 0.1, MinValue = 0)]
        public double profitfactor { get; set; }
        [Parameter("EMA Period", Group = "AUTO MODE 2nd", DefaultValue = 15, MinValue = 1)]
        public int emaPeriod { get; set; }

        [Parameter("TOP", Group = "TIMEFRAME")]
        public TimeFrame toptf { get; set; }
        [Parameter("MID", Group = "TIMEFRAME")]
        public TimeFrame midtf { get; set; }
        [Parameter("LOW", Group = "TIMEFRAME")]
        public TimeFrame lowtf { get; set; }
        [Parameter("TOP back Zones", Group = "TIMEFRAME", DefaultValue = 5, MinValue = 1)]
        public int topbackZones { get; set; }
        [Parameter("MID back zones", Group = "TIMEFRAME", DefaultValue = 10, MinValue = 1)]
        public int midbackZones { get; set; }
        [Parameter("LOW back zones", Group = "TIMEFRAME", DefaultValue = 15, MinValue = 1)]
        public int lowbackZones { get; set; }

        //-----------------CUSTOM PARAMETERS
        FeatureFX API = new FeatureFX();
        BarFX bar = new BarFX();

        Dictionary<string, indicatorsFX> indicatorTop = new Dictionary<string, indicatorsFX>();
        Dictionary<string, indicatorsFX> indicatorMid = new Dictionary<string, indicatorsFX>();
        Dictionary<string, indicatorsFX> indicatorLow = new Dictionary<string, indicatorsFX>();
        Dictionary<string, VolumeROC> volumeIndicator = new Dictionary<string, VolumeROC>();
        Dictionary<string, AverageTrueRange> ATR = new Dictionary<string, AverageTrueRange>();

        Dictionary<string, Bars> topBar = new Dictionary<string, Bars>();
        Dictionary<string, Bars> midBar = new Dictionary<string, Bars>();
        Dictionary<string, Bars> lowBar = new Dictionary<string, Bars>();

        Dictionary<string, double> topGap = new Dictionary<string, double>();
        Dictionary<string, double> midGap = new Dictionary<string, double>();
        Dictionary<string, double> lowGap = new Dictionary<string, double>();

        //-----------------

        List<ChartText> textObj = new List<ChartText>();
        List<ChartRectangle> recObj = new List<ChartRectangle>();
        List<int> delindex = new List<int>();
        List<int> no_table = new List<int>();
        List<int> delay_table = new List<int>();
        List<string> symbol_table = new List<string>();

        Thread thread;
        Form1 form = new Form1();
        DataGridView table;
        ControlBase panel;
        int timeCount = 0;
        int alertCount = 0;
        int signalCount = 0;
        bool autoMode = false;
        bool autoMode2 = false;
       
    protected override void OnStart()
        {
            playDesktopAudio("FXaudio", "swiftly.mp3");
            bar.glob = MarketData;
            table = form.dataGridView1;
            bar.AddCustomListCurrencies(EURGBP, EURAUD, GBPAUD, EURNZD, GBPNZD);

            foreach (var sym in bar.customList)
            {
                topBar.Add(sym, bar.@get(toptf, sym));
                midBar.Add(sym, bar.@get(midtf, sym));
                lowBar.Add(sym, bar.@get(lowtf, sym));
                indicatorTop.Add(sym, new indicatorsFX());
                indicatorMid.Add(sym, new indicatorsFX());
                indicatorLow.Add(sym, new indicatorsFX()); 
            }

            API.drawPanelButton("Execute", Chart, panel, IndicatorStart, VerticalAlignment.Bottom, cAlgo.API.HorizontalAlignment.Right);
            Chart.DrawIcon("start", ChartIconType.Circle, Bars.OpenTimes.LastValue, Bars.ClosePrices.LastValue, Color.White);
            formINIT();
        }

        bool Execute = false;
        double gap = 0;
        void IndicatorStart()
        {
            if (!Execute)
            {
                playDesktopAudio("FXaudio", "swiftly.mp3");
                foreach (var sym in bar.customList)
                {
                    indicatorTop[sym].Zones.onStart(topBar[sym]);
                    indicatorMid[sym].Zones.onStart(midBar[sym]);
                    indicatorLow[sym].Zones.onStart(lowBar[sym]);
                }
                Execute = true;
                findGap();
                Timer.TimerTick += Timer_TimerTick;
                Timer.Start(TimeSpan.FromMinutes(1));
            }
            else
            {
                API.openForm(thread, form);
                updateTable();
            }
        }
        void IndicatorUpdate()
        {
            if (Execute)
                foreach (var sym in bar.customList)
                {
                    indicatorTop[sym].Zones.update(topBar[sym]);
                    indicatorMid[sym].Zones.update(midBar[sym]);
                    indicatorLow[sym].Zones.update(lowBar[sym]);
                }
        }
        protected override void OnTick()
        {
            try
            {
                IndicatorUpdate();
            } catch
            {
                Print("OnTick() is showing error");
            }
        }
        protected override void OnStop()
        {
            form.Close();
        }
        protected override void OnBar()
        {
        }
        private void Timer_TimerTick()
        {
            timeCount++;
            try
            {
                TopZonesFltr();
                MidZonesFltr();
                LowZonesFltr();
                TopZoneFltr_Update();
                MidZoneFltr_Update();
                LowZoneFltr_Update();
                if (drawUI)
                    drawZonesUI();
            } catch
            {
                Print("Timer_TimerTick() is showing error");
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                avgSL();
                if (TriggerScrollBTN)
                {
                    update2ndmodificationColumn();
                    updateTable();
                }
                expirePendingOrder();
            } catch
            {
                Print("timer1_Tick() is showing error");
            }
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            try
            {
                atrSL();
            } catch
            {
                Print("timer2_Tick() is showing error");
            }
        }

Above is the extract of my Cbot Code, full code is more than 2000 lines, so I can share my email or telegram. Please advice

Thanks and Regards

R. Vadivelan


Replies

PanagiotisCharalampous
26 Aug 2022, 08:50

Hi Vadivelan,

Unfortunaltely the code you sent references some external libraries therefore we won't be able to build it. If you have paid for this cBot, then the first thing you should do is to contact the developer.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

velu130486
26 Aug 2022, 09:19

RE:

PanagiotisCharalampous said:

Hi Vadivelan,

Unfortunaltely the code you sent references some external libraries therefore we won't be able to build it. If you have paid for this cBot, then the first thing you should do is to contact the developer.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi Panagiotis,

Thanks for the reply. I have the library files with me. With that is it possible to fix it. Yes I had paid lot of money, however the developer is not responding.

Can I share the library files and Cbot source code to your Telegram.

Please support to fix this error

Regards

R. Vadivelan


PanagiotisCharalampous
26 Aug 2022, 09:32

Hi Vadivelan,

Sure, if it is an easy fix, I will help.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous