Topics
04 Nov 2024, 17:12
 158
 5
22 Oct 2024, 06:29
 0
 65
 0
20 Oct 2024, 04:36
 85
 1
11 Oct 2024, 06:30
 0
 75
 0
11 Oct 2024, 06:30
 0
 76
 0
10 Oct 2024, 12:37
 83
 2
13 Sep 2024, 07:14
 1
 104
 0
21 Aug 2024, 16:28
 0
 107
 0
12 Aug 2024, 08:14
 0
 150
 1
06 Aug 2024, 06:38
 182
 1
22 Jul 2024, 08:13
 0
 174
 0
22 Jul 2024, 08:13
 0
 150
 0
08 Jul 2024, 08:24
 0
 269
 1
08 Jul 2024, 08:19
 1
 173
 0
Replies

eynt
21 Sep 2022, 08:47

RE:

Hello

 

Is there anything new on the subject? This issue is SUPER important, my entire project is stuck until this problem is solved


@eynt

eynt
20 Sep 2022, 14:41 ( Updated at: 20 Sep 2022, 14:45 )

RE:

Hi

 

Yes, I can navigate to the folder, however:

1. On my computer there are only version 6.0.8 and up, no 6.0.0

2. More importantly, I don't know how to change the version of the framework. It seems the framework properties is read only, there is no edit/add/remove option.

 


@eynt

eynt
20 Sep 2022, 14:12

RE: RE:

I also don't understand how can I upgrade the version on the cbot or downgrade the version on the Utils project


@eynt

eynt
20 Sep 2022, 13:38

RE:

Hi

 

I understand that. I also updated the original post and uploaded screenshots of the versions of the references. It seems that when a new cBot is created it uses version 6.0.0.0 which is old. Is there a way to make a new cBot to automatically use the highest version available?

 

 

 


@eynt

eynt
20 Sep 2022, 13:16 ( Updated at: 21 Dec 2023, 09:22 )

RE:

Thank you,

 

I've done the changes described in the link you provided so now I can use Winforms on my cBot. However, when I added a reference to my old dll which is called utils I got the following error:

I also added a screenshot of Windows.Forms refereces both from the cBot and the utils. I can see there's a difference but I'm not sure how to fix it without making a problem. It's also prefered that the cBot will use the newer version inseatd of Utils to use the loder one.

 

 

Severity    Code    Description    Project    File    Line    Suppression State
Error    CS1705    Assembly 'Utils' with identity 'Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Windows.Forms, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' which has a higher version than referenced assembly 'System.Windows.Forms' with identity 'System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'    New cBot (2)    C:\Users\yuval\Documents\cAlgo\Sources\Robots\New cBot (2)\New cBot (2)\CSC    1    Active
 

 

cbot:

 

 

utiils


@eynt

eynt
14 Sep 2022, 01:02

RE:

Some of my indicators were upgraded to .net 6 successfully however on one how them i get the error:

Severity    Code    Description    Project    File    Line    Suppression State
Error    CT0121    Output type "System.String" is not supported.    SummaryInd    C:\Users\yuval\.nuget\packages\ctrader.automate\1.0.2\build\cTrader.Automate.targets    41    

 

Line 41 on the targets file is:

<ExtractMetadataTask AssemblyPath="$(TargetPath)"

 

 

Thanks

 


@eynt

eynt
05 May 2022, 16:36

RE:

Is there a new feature in which you are working on?

 


@eynt

eynt
10 Mar 2022, 16:10

RE:

Hello and thank you for your reply.

 

I was able to solve the issue by making a few small changes in the ScrollChart method. I tried to apply it to your version of the indicator however there were sync issues when 2 charts are changed at the same time so I let it go. I am uploading my fixed version of the indicator, feel free to use/improve/share it with the community. If there are any updates or improvements on the subject please let me know.

 

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;


namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.IsraelStandardTime, AccessRights = AccessRights.FileSystem)]
    public class SyncObjectsInstance : Indicator
    {
        protected override void Initialize()
        {
            Synchronizer.Instance.Register(this);
            Timer.Start(Synchronizer.HeartbeatRate);
        }

        protected override void OnTimer()
        {
            Synchronizer.Instance.Heartbeat(this);
        }

        public override void Calculate(int index)
        {
            // do nothing
        }
    }

    public class Synchronizer
    {
        public static readonly TimeSpan HeartbeatTimeout = TimeSpan.FromSeconds(5);
        public static readonly TimeSpan HeartbeatRate = TimeSpan.FromSeconds(4);

        private static readonly object _sync = new object();
        private static Synchronizer _instance = null;

        public static Synchronizer Instance
        {
            get
            {
                if (_instance != null)
                    return _instance;

                lock (_sync)
                {
                    if (_instance != null)
                        return _instance;

                    _instance = new Synchronizer();
                }

                return _instance;
            }
        }

        private readonly Dictionary<string, HashSet<SyncObjectsInstance>> _instances;
        private readonly Dictionary<SyncObjectsInstance, DateTime> _instanceHeartbeats;

        public Synchronizer()
        {
            _instances = new Dictionary<string, HashSet<SyncObjectsInstance>>(StringComparer.OrdinalIgnoreCase);
            _instanceHeartbeats = new Dictionary<SyncObjectsInstance, DateTime>();
        }

        public void Register(SyncObjectsInstance instance)
        {
            // instance.Print("Register");

            lock (_sync)
            {
                Restore(instance);
            }
        }

        public void Heartbeat(SyncObjectsInstance instance)
        {
            //   instance.Print("Heartbeat");

            lock (_sync)
            {
                var now = DateTime.Now;

                _instanceHeartbeats[instance] = now;

                var expiredInstances = _instanceHeartbeats.Where(hb => now - hb.Value > HeartbeatTimeout).Select(hb => hb.Key).ToArray();

                foreach (var expiredInstance in expiredInstances)
                {
                    expiredInstance.Chart.MouseUp -= OnMouseUp;
                    _instanceHeartbeats.Remove(expiredInstance);
                    _instances[expiredInstance.SymbolName].Remove(expiredInstance);
                }
            }
        }
        private void OnMouseUp(ChartMouseEventArgs args)
        {
            lock (_sync)
            {
                HashSet<SyncObjectsInstance> symbolInstances;

                if (!_instances.TryGetValue(args.Chart.SymbolName, out symbolInstances))
                    return;

                foreach (var instance in symbolInstances)
                {
                    if (instance.Chart == args.Chart)
                        continue;

                    instance.BeginInvokeOnMainThread(() => ScrollChart(instance, args.TimeValue));
                }
            }
        }

        private void ScrollChart(SyncObjectsInstance targetInstance, DateTime targetTime)
        {
            //p("ScrollChart " + targetTime);
            //targetInstance.Chart.ScrollXTo(targetTime);

            int leftBar = targetInstance.Chart.FirstVisibleBarIndex;
            int rightBar = targetInstance.Chart.LastVisibleBarIndex;
            int middleBar = leftBar + ((rightBar - leftBar) / 2);
            DateTime midDate = targetInstance.Bars.OpenTimes[middleBar];
            bool crossDate = false;
            int crossDir = midDate < targetTime ? 1 : -1;
            int scrolledBars = 0;

            while (midDate != targetTime && !crossDate)
            {
                //p("midDate= " + midDate + " targetTime= " + targetTime + " middleBar= " + middleBar + " midDate= " + midDate);
                //p("FirstVisibleBarIndex= " + targetInstance.Chart.FirstVisibleBarIndex + " LastVisibleBarIndex= " + targetInstance.Chart.LastVisibleBarIndex);
                //targetInstance.Chart.ScrollXBy(crossDir);
                leftBar += crossDir;
                rightBar += crossDir;
                scrolledBars += crossDir;
                //middleBar = targetInstance.Chart.FirstVisibleBarIndex + ((targetInstance.Chart.LastVisibleBarIndex - targetInstance.Chart.FirstVisibleBarIndex) / 2);
                middleBar = leftBar + ((rightBar - leftBar) / 2);
                midDate = targetInstance.Bars.OpenTimes[middleBar];
                crossDate = crossDir == 1 ? midDate > targetTime : midDate < targetTime;
            }

            targetInstance.Chart.ScrollXBy(scrolledBars);
        }

        private void p(string text)
        {
            File.AppendAllText("d:\\temp\\a.log", text + Environment.NewLine);
        }

        //p("a targetTime= " + targetTime + 
        // " targetInstance.Chart.TimeFrame.ToString()= " + targetInstance.Chart.TimeFrame.ToString() +
        // " FirstVisibleBarIndex= " + targetInstance.Chart.FirstVisibleBarIndex +
        // );


        //targetInstance.Chart.ScrollXBy(100);
        //targetInstance.Chart.ScrollXTo(targetTime);
        //Thread.Sleep(300);
        //targetInstance.Chart.ScrollXBy((targetInstance.Chart.FirstVisibleBarIndex - targetInstance.Chart.LastVisibleBarIndex) / 2);

        //p("diff= " + ((targetInstance.Chart.FirstVisibleBarIndex - targetInstance.Chart.LastVisibleBarIndex) / 2));

        //p("f" + " TimeFrame= " + targetInstance.Chart.TimeFrame + " args.targetTime= " + targetTime + " LastVisibleBarIndex= " +
        //  targetInstance.Chart.LastVisibleBarIndex + " lastTime= " + targetInstance.Bars.OpenTimes[targetInstance.Chart.LastVisibleBarIndex] +
        //  " FirstVisibleBarIndex= " + targetInstance.Chart.FirstVisibleBarIndex + " firstTime= " +
        //  targetInstance.Bars.OpenTimes[targetInstance.Chart.FirstVisibleBarIndex] +
        //  " middleIdx= " + middleBar +
        //  " middleDate= " + targetInstance.Bars.OpenTimes[middleBar] +
        //  "-2Bars= " + ((targetInstance.Chart.LastVisibleBarIndex - targetInstance.Chart.FirstVisibleBarIndex) / -2).ToString()
        //  );

        //p("crossDir= " + crossDir);
        //p("a FirstVisibleBarIndex= " + targetInstance.Chart.FirstVisibleBarIndex + " LastVisibleBarIndex= " + targetInstance.Chart.LastVisibleBarIndex);

        //for (int i = 0; i < 100; i++)
        //{
        //    //p("FirstVisibleBarIndex= " + targetInstance.Chart.FirstVisibleBarIndex + " LastVisibleBarIndex= " + targetInstance.Chart.LastVisibleBarIndex);
        //    targetInstance.Chart.ScrollXBy(-1);
        //    targetInstance.Chart.
        //    //Thread.Sleep(300);
        //}

        //p("b FirstVisibleBarIndex= " + targetInstance.Chart.FirstVisibleBarIndex + " LastVisibleBarIndex= " + targetInstance.Chart.LastVisibleBarIndex);


        private void Restore(SyncObjectsInstance sender)
        {
            HashSet<SyncObjectsInstance> symbolInstances;

            if (!_instances.TryGetValue(sender.SymbolName, out symbolInstances))
            {
                symbolInstances = new HashSet<SyncObjectsInstance>();
                _instances.Add(sender.SymbolName, symbolInstances);
            }

            sender.Chart.MouseUp += OnMouseUp;

            symbolInstances.Add(sender);
            _instanceHeartbeats[sender] = DateTime.Now;
        }
    }
}
 


@eynt

eynt
14 Dec 2021, 13:03

RE:

Hello

 

I understand that, however this issue is more of a bug than a feature and therefor should be treated as such priority

 

Thanks

 


@eynt

eynt
07 Dec 2021, 10:58

RE:

Starting at an earlier date solves the problem but it's far from being an easy solution as described above.

A low priority means it will never be solved, it's open for a year and a half already. I don't see why this issue cannot be solved sooner, the feature already exists on a live run.

 

Thanks

 

 


@eynt

eynt
07 Dec 2021, 08:56

RE: RE:

Hello

 

Anything new on the subject?


@eynt

eynt
02 Dec 2021, 10:09

RE:

Does a workspace is auto save when I change its symbol?

 

thanks

 


@eynt

eynt
02 Dec 2021, 09:19

RE: RE: RE: RE: RE: RE: RE:

OK so how can I prevent from running code inside OnTick after disconnection?

 


@eynt

eynt
01 Dec 2021, 13:58

RE: RE: RE: RE: RE:

 

Please view the "DISCONNECTED" errors I got below. I can upload the entire logf but i'm not sure how to upload files to the forum.

They happened during a simple 'ModifyStopLossPrice' which always works fine, including on the day of the errors, until the errors occured.

 

2021.11.30 16:02:17.920 | Request to amend position PID64902077 (SL: 1.49319) is sent to server
2021.11.30 16:02:19.186 | Request to amend position PID64919920 (SL: 1577.54) is sent to server
2021.11.30 16:02:21.202 | Request to Buy 0.01 Lots SpotCrude is sent to server
2021.11.30 16:02:22.137 | → Request to amend position PID64902077 (SL: 1.49319) is REJECTED with error "DISCONNECTED"
2021.11.30 16:02:22.146 | → Request to amend position PID64919920 (SL: 1577.54) is REJECTED with error "DISCONNECTED"
2021.11.30 16:02:22.211 | → Order OID0 is REJECTED with error "DISCONNECTED"
2021.11.30 16:02:22.315 | Request to close position PID64902077 is sent to server
2021.11.30 16:02:22.362 | → Failed to close position PID64902077 with error "DISCONNECTED"
2021.11.30 16:02:22.365 | Request to close position PID64919920 is sent to server
2021.11.30 16:02:22.376 | → Failed to close position PID64919920 with error "DISCONNECTED"
2021.11.30 16:02:23.651 | cBot "Main" was stopped for SpotCrude, Ra1.
2021.11.30 16:02:28.941 | Request to close position PID64902077 is sent to server
2021.11.30 16:02:29.109 | → Request to close position PID64902077 is ACCEPTED, order OID101746508 created (30/11/2021 16:02:29.028 UTC+0)
2021.11.30 16:02:29.420 | → Order OID101746508 is FILLED at 1.48182, position PID64902077 closed (30/11/2021 16:02:29.059 UTC+0)
2021.11.30 16:02:29.597 | cBot "Main" was stopped for CHFSGD, Ra1.
2021.11.30 16:12:40.758 | cBot "Main" was stopped for XAUEUR, Ra1.
2021.11.30 16:38:17.105 | cTrader started

 

 


@eynt

eynt
01 Dec 2021, 11:12

RE: RE: RE:

I want to show you the error. Does the journal is saved to somewhere?

 


@eynt

eynt
01 Dec 2021, 09:40

RE:

OK but how is it possible that the OnTick method was even running while the cBot is disconnected?

 

Thanks

 


@eynt

eynt
26 Nov 2021, 09:45

RE:

just to be clear, when I say "changed" on question 1, I mean switched to a different workspace. yes?

 

Thanks


@eynt

eynt
03 Nov 2021, 10:14 ( Updated at: 03 Nov 2021, 10:31 )

RE: RE: RE:

A. What does the Stop method does?

B. If I have several instances of the same cBot and one of them calls the Stop, does it effect the other instances?

 

 

Thanks

 


@eynt

eynt
02 Nov 2021, 10:42

RE:

Is there any way to determine it using some sort of a parameter or via the app's GUI?

 

Thanks

 


@eynt

eynt
28 Oct 2021, 10:04

RE: RE: RE: RE: RE: RE: RE:

My original single symbol cBot has dozens of private members (strings, integers, etc.). All those members were designed for a single symbol. Now that there are many symbols, each of them should have a different value per symbol. Is there an easy straight forward way to convert all the members from single to multi symbol?

 

Thanks

 


@eynt