Replies

couscousmckoy
25 May 2023, 16:09

Thanks Pick - I'll give that a try. Part of the problem was length of time it took to scroll through all historical bars to colour code certain bars.  I've managed to irradicate this half of the issue by only updating bar colour on visible bars. Still leaves the 10seconds it takes to calculate which bars should be colour coded and unfortunately to work that out it has to work through a lot of bars from the start.  I'll give threads a go though. Thank you for the help.

couscous


@couscousmckoy

couscousmckoy
25 May 2023, 11:53

Thanks firemyst

Its just a simple one bot instance.

This example exhibits the same behaviour. My question:  why does the static text show after the fake pause and not before it?

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 DrawStaticTextExample : Robot
    {

        protected override void OnStart()
        {
            Print("Starting long job");
            Chart.DrawStaticText("LongJobWarning", "Warning: Long Job. Wait until this message disappears!!", VerticalAlignment.Center, HorizontalAlignment.Center,Color.Red);
            
            var WakeUpTime = Server.Time.AddSeconds(10);
            while (WakeUpTime > Server.Time)
            {
            //waste some time
            }
          
            Print("Finished Long Job");
        }
    }
}

 


@couscousmckoy

couscousmckoy
26 May 2022, 10:03

RE: RE: RE:

Hi

Ctrader version:  4.1.19.50832

Live Data

Thanks

 

 


@couscousmckoy

couscousmckoy
25 May 2022, 10:13

RE:

Hi amusleh

Thanks for the prompt response. The entire data set was 434 records long for my test so I removed all the valid BarOpened event logs (even those where there was subsequently a later refire of the same bar).  I've still removed the records that were correct with no subsequent erroneous refire, but here are those records with the original correct event logged plus the subsequent erroneous entry. Look at the log entry times for each pair.

Thanks


@couscousmckoy

couscousmckoy
20 May 2022, 13:57

RE:

Thank you Amusleh. I appreciate you taking the time to reply. I actually decided just to forward the emails on to the second address from Outlook with a rule. But I can see your solution would be successful too.

Marcus

 

amusleh said:

Hi,

It depends on your email server that how many emails it allows you to send on a unit of time (seconds/milliseconds).

To avoid this issue you can place a delay after sending the first email, use Thread.Sleep, example:

            try
            {
                Notifications.SendEmail(EmailAddress1, EmailAddress1, "cTrader 5 Wick Alert", emailmsg);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Invalid email address", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (EmailAddress2 != "")
            {
                // 2 seconds delay
                Thread.Sleep(2000);
                // Call refresh data is required after suspending the main thread
                RefreshData();
                
                try
                {
                    Notifications.SendEmail(EmailAddress1, EmailAddress2, "cTrader 5 Wick Alert", emailmsg);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Invalid email address", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

 

 


@couscousmckoy

couscousmckoy
23 Mar 2021, 17:44

RE:

Hi amusleh

Thank you for your response.  Works well. You also made me realise I could also just add "\r\n" into my text string to drop the second number down a line.

Cheers

 

 

amusleh said:

Hi,

Try StringBuilder:

using cAlgo.API;
using System.Text;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Blank : Indicator
    {
        protected override void Initialize()
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("First Text");
            stringBuilder.AppendLine("Second Text");

            var text = stringBuilder.ToString();

            Chart.DrawText("text", text, Chart.LastVisibleBarIndex, Bars.HighPrices[Chart.LastVisibleBarIndex], Color.Red);
        }

        public override void Calculate(int index)
        {
        }
    }
}

With string builder you can easily add as many line as you want to, and then you just have to call the DrawText once.

You can't use font size, that's for chart controls not chart objects.

 


@couscousmckoy

couscousmckoy
19 Mar 2021, 13:06 ( Updated at: 21 Dec 2023, 09:22 )

RE:

Hi Panagiotis

Maybe its due to monitor resolution? Mine is 1920x1080.

This is with interface scale set to 100%

and to 110%

and to 90%

PanagiotisCharalampous said:

Hi couscousmckoy,

Thanks for your feedback.

 The timeframe label on the tabs of the non selected chart are clipped and not displaying the number part fully.  Can be corrected by setting font zoom / interface scale to 110% in settings - but seems a little strange that zoom=100% (i.e. default) doesn't display correctly. Strangely, setting Zoom to less than 100% also displays fine!

Can you please post some screenshots so that we can see what you are looking at?

Best Regards,

Panagiotis 

Join us on Telegram

 


@couscousmckoy