Replies

aarongeorge380
13 Jun 2023, 10:21

RE:

Hi - Have fixed it - the following code seems to work if built in the target framework .NET Framework 4x, but not under .NET 6.0 for some reason - I think maybe something to do with the BeginInvokeOnMainThread - But I haven't been able to quite figure that out to date?  I've tried it on both cTrader Desktop versions 4.6.7 and 4.7.11 

Cheers,

using cAlgo.API;
using System;
//using cAlgo.API.Internals;
//using cAlgo.API.Indicators;
//using cAlgo.Indicators;
//using System.Linq;
//using System.Threading;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    [Levels(60, 120, 180, 240, 300, 360)]
    public class TickVolatilityMeasure : Indicator
    {
       // private IndicatorDataSeries _secondsPerBar;

        private DateTime PreviousbarTime;
        private DateTime CurrentbarTime;
        private TimeSpan TimeDifference;

        [Output("Time", LineColor = "Red", IsHistogram = true,LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries TimeElapsed { get; set; }
        
        //protected override void Initialize()
        //{
        //}
       
        public override void Calculate(int index)
        {
            // Calculate value at specified index
            if (index == 0)
            {
                TimeElapsed[index] = 0;
                return;
            }
            else
            {
                PreviousbarTime = Bars.OpenTimes[index - 1];
                CurrentbarTime = Bars.OpenTimes[index];

                TimeDifference = (CurrentbarTime - PreviousbarTime);

                double secondsDifference = TimeDifference.TotalSeconds;
                
                TimeElapsed[index] = secondsDifference;
                
                RefreshData();
            }
        }
    }
}


@aarongeorge380

aarongeorge380
13 Jun 2023, 02:39

RE:

huguh said:

I tried something similar a few days ago with chatgpt.You can try yourself with your own parameters. It could work if its not too complicated. It worked fine for me

In the links below are some examples of attemps I did

 

https://chat.openai.com/c/0cad7ace-bca0-438e-b149-5c34566995fc

 

https://chat.openai.com/c/b864df40-26f1-40ca-8c2b-967915866bfc

 

https://chat.openai.com/c/0725ec34-5b3a-4fc2-8d1e-a52e05287896

 

https://chat.openai.com/c/6ffd111e-e368-48c6-9c51-f1c12cd78789

 

Hi huguh,

Thanks for response, unfortunately the links you provided don't work for me.

Regards,

 

 

 


@aarongeorge380

aarongeorge380
02 Feb 2018, 12:44

RE: Chart Error when setting IsOverlay to false

mikepecson72 said:

Dear Spotware,

 

I intentionally hide the indicator as I dont want it to be seen in the chart. I just need the chart object draw text to be displayed on the screen (not the indicator). I can display the indicator but still the same problem occurs.  What do you think is causing the issue?

Hi mikepecson72,

​You've probably worked it out by now, but I had the same problem, and have been scanning through some of the posts.  The problem solved for me if I added the following code at the start of the indicator: AutoRescale = false.

As per below:

namespace cAlgo
{
    [Indicator(IsOverlay = trueAutoRescale = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]

Hope this might work for you if your still stuck.

 


@aarongeorge380