Topics
02 Apr 2024, 17:18
 0
 269
 0
19 May 2023, 20:44
 2
 948
 7
17 May 2023, 11:35
 1144
 14
13 Feb 2023, 12:30
 0
 481
 1
13 Feb 2023, 12:17
 0
 487
 1
09 Feb 2023, 12:18
 863
 2
25 Aug 2022, 19:12
 1
 1028
 2
Replies

Tspring
18 May 2023, 19:57

Hi, don't worry, I too disconnected from the computer shortly after the last post.
I tried replacing the string with the one you pointed out to me without success, the session opening prices keep disappearing on the H.A. chart.
This is the complete modified code in case I did something wrong:

 

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MultiSessionOpen22 : Indicator
    {
        [Parameter("London Session", DefaultValue = true)]
        public bool london { get; set; }
        [Parameter("NY Session", DefaultValue = true)]
        public bool NY { get; set; }
        [Parameter("Sydney Session", DefaultValue = true)]
        public bool sydney { get; set; }
        [Parameter("Tokyo Session", DefaultValue = true)]
        public bool tokyo { get; set; }

        [Parameter("Show Open Prices", DefaultValue = true)]
        public bool openPrices { get; set; }

        [Parameter("Show Info", DefaultValue = true)]
        public bool info { get; set; }
        
        [Parameter("MaxDays", DefaultValue = 5)]
        public int maxDays { get; set; }
        DateTime newestTime; //Track newest time

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        private MarketSeries openSeries;


        protected override void Initialize()
        {
            openSeries = MarketData.GetSeries(TimeFrame.Hour);
            newestTime = Bars[Bars.Count - 1].OpenTime;
        }

        public override void Calculate(int index)
        {
                DateTime time = Bars[index].OpenTime; //Get time of bar calculating

                if (time > newestTime) //If it's newer than the newest time
                        newestTime = time; //Update newest time

                if (time < newestTime.AddDays(-maxDays)) //Check if it's too old
                        return; //Return out of method
        
            //London Session
            string today = MarketSeries.OpenTime[index].Day.ToString() + "/" + MarketSeries.OpenTime[index].Month.ToString() + "/" + MarketSeries.OpenTime[index].Year.ToString() + " ";
            if (london)
            {
                DateTime londonOpen, londonClose;
                DateTime.TryParse(today + "07:00:00", out londonOpen);
                DateTime.TryParse(today + "15:00:00", out londonClose);
                double londonMax = 0, londonMin = double.PositiveInfinity;
                londonOpen = londonOpen.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                londonClose = londonClose.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                for (int i = MarketSeries.OpenTime.GetIndexByTime(londonOpen); i < MarketSeries.OpenTime.GetIndexByTime(londonClose); i++)
                {
                    londonMax = Math.Max(londonMax, MarketSeries.High[i]);
                    londonMin = Math.Min(londonMin, MarketSeries.Low[i]);
                }
                double londonPrice = Math.Round((MarketSeries.Close[index] - openSeries.Open[MarketSeries.OpenTime.GetIndexByTime(londonOpen)]) / Symbol.PipSize, 2);
                
                if (double.IsNormal(londonMin) && double.IsNormal(londonMax)) //Check all values are normal
                { //
                
                Chart.DrawRectangle("london session " + londonOpen, londonOpen, londonMax, londonClose, londonMin, Color.FromArgb(50, 0, 50, 255)).IsFilled = true;
                if (openPrices)
                    if (TimeFrame <= TimeFrame.Hour || TimeFrame <= TimeFrame.HeikinHour)
                        if (MarketSeries.OpenTime[index] >= londonOpen)
                            Chart.DrawTrendLine("_open london" + londonOpen, londonOpen, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(londonOpen)], londonClose, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(londonOpen)], Color.Blue);
                if (info)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= londonOpen)
                            Chart.DrawStaticText("london info", "Pips From London Open: " + londonPrice, VerticalAlignment.Top, HorizontalAlignment.Right, Color.RoyalBlue);
                        else
                            Chart.DrawStaticText("london info", "Pips From London Open: Waiting for Open", VerticalAlignment.Top, HorizontalAlignment.Right, Color.RoyalBlue);
                } //           

            }

            //NY Session
            if (NY)
            {
                DateTime nyOpen, nyClose;
                DateTime.TryParse(today + "12:00:00", out nyOpen);
                DateTime.TryParse(today + "20:00:00", out nyClose);
                double nyMax = 0, nyMin = double.PositiveInfinity;
                nyOpen = nyOpen.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                nyClose = nyClose.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                for (int i = MarketSeries.OpenTime.GetIndexByTime(nyOpen); i < MarketSeries.OpenTime.GetIndexByTime(nyClose); i++)
                {
                    nyMax = Math.Max(nyMax, MarketSeries.High[i]);
                    nyMin = Math.Min(nyMin, MarketSeries.Low[i]);
                }
                double nyPrice = Math.Round((MarketSeries.Close[index] - openSeries.Open[MarketSeries.OpenTime.GetIndexByTime(nyOpen)]) / Symbol.PipSize, 2);
                
                if (double.IsNormal(nyMin) && double.IsNormal(nyMax)) //Check all values are normal
                { //
                
                Chart.DrawRectangle("ny session " + nyOpen, nyOpen, nyMax, nyClose, nyMin, Color.FromArgb(50, 255, 50, 0)).IsFilled = true;
                if (openPrices)
                    if (TimeFrame <= TimeFrame.Hour || TimeFrame <= TimeFrame.HeikinHour)
                        if (MarketSeries.OpenTime[index] >= nyOpen)
                            Chart.DrawTrendLine("_open ny" + nyOpen, nyOpen, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(nyOpen)], nyClose, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(nyOpen)], Color.Red);
                if (info)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= nyOpen)
                            Chart.DrawStaticText("ny info", "\nPips From NY Open: " + nyPrice, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Red);
                        else
                            Chart.DrawStaticText("ny info", "\nPips From NY Open: Waiting for Open", VerticalAlignment.Top, HorizontalAlignment.Right, Color.Red);
                } //           


            }

            //Sydney Session
            string yesterday = MarketSeries.OpenTime[index].AddDays(-1).Day.ToString() + "/" + MarketSeries.OpenTime[index].AddDays(-1).Month.ToString() + "/" + MarketSeries.OpenTime[index].AddDays(-1).Year.ToString() + " ";
            string tommorow = MarketSeries.OpenTime[index].AddDays(1).Day.ToString() + "/" + MarketSeries.OpenTime[index].AddDays(1).Month.ToString() + "/" + MarketSeries.OpenTime[index].AddDays(1).Year.ToString() + " ";
            if (sydney)
            {
                DateTime sydneyOpen, sydneyClose;
                DateTime.TryParse(MarketSeries.OpenTime[index].Hour <= 6 ? yesterday + "22:00:00" : today + "22:00:00", out sydneyOpen);
                DateTime.TryParse(MarketSeries.OpenTime[index].Hour <= 6 ? today + "6:00:00" : tommorow + "6:00:00", out sydneyClose);
                double sydneyMax = 0, sydneyMin = double.PositiveInfinity;
                sydneyOpen = sydneyOpen.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                sydneyClose = sydneyClose.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                for (int i = MarketSeries.OpenTime.GetIndexByTime(sydneyOpen); i < MarketSeries.OpenTime.GetIndexByTime(sydneyClose); i++)
                {
                    sydneyMax = Math.Max(sydneyMax, MarketSeries.High[i]);
                    sydneyMin = Math.Min(sydneyMin, MarketSeries.Low[i]);
                }
                double sydneyPrice = Math.Round((MarketSeries.Close[index] - openSeries.Open[MarketSeries.OpenTime.GetIndexByTime(sydneyOpen)]) / Symbol.PipSize, 2);
                
                if (double.IsNormal(sydneyMin) && double.IsNormal(sydneyMax)) //Check all values are normal
                { //
                
                Chart.DrawRectangle("sydney session " + sydneyOpen, sydneyOpen, sydneyMax, sydneyClose, sydneyMin, Color.FromArgb(50, 50, 255, 0)).IsFilled = true;
                if (openPrices)
                    if (TimeFrame <= TimeFrame.Hour || TimeFrame <= TimeFrame.HeikinHour)
                        if (MarketSeries.OpenTime[index] >= sydneyOpen)
                            Chart.DrawTrendLine("_open sydney" + sydneyOpen, sydneyOpen, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(sydneyOpen)], sydneyClose, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(sydneyOpen)], Color.LawnGreen);
                if (info)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= sydneyOpen)
                            Chart.DrawStaticText("sydney info", "\n\nPips From Sydney Open: " + sydneyPrice, VerticalAlignment.Top, HorizontalAlignment.Right, Color.LawnGreen);
                } //            

            }

            //Tokyo Session
            if (tokyo)
            {
                DateTime tokyoOpen, tokyoClose;
                DateTime.TryParse(MarketSeries.OpenTime[index].Hour <= 7 ? yesterday + "23:00:00" : today + "23:00:00", out tokyoOpen);
                DateTime.TryParse(MarketSeries.OpenTime[index].Hour <= 7 ? today + "7:00:00" : tommorow + "7:00:00", out tokyoClose);
                double tokyoMax = 0, tokyoMin = double.PositiveInfinity;
                tokyoOpen = tokyoOpen.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                tokyoClose = tokyoClose.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                for (int i = MarketSeries.OpenTime.GetIndexByTime(tokyoOpen); i < MarketSeries.OpenTime.GetIndexByTime(tokyoClose); i++)
                {
                    tokyoMax = Math.Max(tokyoMax, MarketSeries.High[i]);
                    tokyoMin = Math.Min(tokyoMin, MarketSeries.Low[i]);
                }
                double tokyoPrice = Math.Round((MarketSeries.Close[index] - openSeries.Open[MarketSeries.OpenTime.GetIndexByTime(tokyoOpen)]) / Symbol.PipSize, 2);
                
                if (double.IsNormal(tokyoMin) && double.IsNormal(tokyoMax)) //Check all values are normal
                { //
                
                Chart.DrawRectangle("tokyo session " + tokyoOpen, tokyoOpen, tokyoMax, tokyoClose, tokyoMin, Color.FromArgb(50, 255, 255, 50)).IsFilled = true;
                if (openPrices)
                    if (TimeFrame <= TimeFrame.Hour || TimeFrame <= TimeFrame.HeikinHour)
                        if (MarketSeries.OpenTime[index] >= tokyoOpen)
                            Chart.DrawTrendLine("_open tokyo" + tokyoOpen, tokyoOpen, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(tokyoOpen)], tokyoClose, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(tokyoOpen)], Color.Yellow);
                if (info)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= tokyoOpen)
                            Chart.DrawStaticText("tokyo info", "\n\n\nPips From Tokyo Open: " + tokyoPrice, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Yellow);
                } //            

            }

        }
    }
}


@Tspring

Tspring
17 May 2023, 20:38

Great, I was able to successfully modify the indicator thanks to your help! Once it is perfected I will post the code so anyone who wants can download it.
I have one more question: the indicator draws horizontal opening session lines on the traditional candlestick chart, but when I change to heiken ashi candlesticks, the opening price lines disappear.
I assume this is because heiken ashi candles have a different calculation method to regular candles, so there is probably nothing to do about it.

Do you think this is the problem, or is it possible to fix this?


@Tspring

Tspring
17 May 2023, 19:54

Even though you didn't realise what I wanted, the indicator has improved a lot thanks to your advice!
I have now tried to add the code you told me, trying to be as precise as possible, but I get errors...


@Tspring

Tspring
17 May 2023, 18:51

Thanks, it's a real blessing to find helpful people like you!
I also made the last change you made, and it seems to work fine now. It has improved considerably, the first version was constantly causing cTrader to freeze every time I changed timeframe, and I always had to force close it and restart it.
I think the problem is due to the fact that the sessions drawn on the chart by the indicator are infinite! The person who created the indicator did not provide a parameter for setting a customised number of sessions. In fact, although it is much better now, it always seems a bit cumbersome for the platform to have to calculate infinite sessions backwards in time, when it could calculate three or four at most.
So going back to the title of my first post, what would it take to reduce that infinite value and be able to enter a custom value of sessions, so that everything runs smoother?
For example, I have a pivot point indicator that has a parameter to select the number of days back in time on which to calculate pivots (see image). Could I copy and paste that part of the code from the pivot indicator to the forex session indicator?

 


@Tspring

Tspring
17 May 2023, 16:03

Thank you, I succeeded. Now cTrader no longer gives me the error.
However, now it does not always draw the most recent sessions, as you can see in the picture.

And besides that it has a couple of other things to fix.
I don't think I'll be able to fix it completely even with your help, also because it doesn't seem fair to me to monopolize your time.

Do you happen to do programming work in exchange for payment?

 


@Tspring

Tspring
17 May 2023, 14:42

Hi, thanks for your help.

This is my first attempt to modify a code without knowing anything about programming at all.
Comparing the original code with the one you sent me, it seems to me that the only difference is this additional string:

if (double.IsNormal(londonMin) && double.IsNormal(londonMax) && double.IsNormal(londonPrice)) //Check all values are normal
{ //

So following your instructions I took the string in question and copied and pasted it to all the other sessions, replacing only the name of each session.
At the end I clicked on build but some errors came up.


This is the complete modified code:

 

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MultiSessionOpen2 : Indicator
    {
        [Parameter("London Session", DefaultValue = true)]
        public bool london { get; set; }
        [Parameter("NY Session", DefaultValue = true)]
        public bool NY { get; set; }
        [Parameter("Sydney Session", DefaultValue = true)]
        public bool sydney { get; set; }
        [Parameter("Tokyo Session", DefaultValue = true)]
        public bool tokyo { get; set; }

        [Parameter("Show Open Prices", DefaultValue = true)]
        public bool openPrices { get; set; }

        [Parameter("Show Info", DefaultValue = true)]
        public bool info { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        private MarketSeries openSeries;


        protected override void Initialize()
        {
            openSeries = MarketData.GetSeries(TimeFrame.Hour);
        }

        public override void Calculate(int index)
        {
            //London Session
            string today = MarketSeries.OpenTime[index].Day.ToString() + "/" + MarketSeries.OpenTime[index].Month.ToString() + "/" + MarketSeries.OpenTime[index].Year.ToString() + " ";
            if (london)
            {
                DateTime londonOpen, londonClose;
                DateTime.TryParse(today + "07:00:00", out londonOpen);
                DateTime.TryParse(today + "15:00:00", out londonClose);
                double londonMax = 0, londonMin = double.PositiveInfinity;
                londonOpen = londonOpen.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                londonClose = londonClose.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                for (int i = MarketSeries.OpenTime.GetIndexByTime(londonOpen); i < MarketSeries.OpenTime.GetIndexByTime(londonClose); i++)
                {
                    londonMax = Math.Max(londonMax, MarketSeries.High[i]);
                    londonMin = Math.Min(londonMin, MarketSeries.Low[i]);
                }
                double londonPrice = Math.Round((MarketSeries.Close[index] - openSeries.Open[MarketSeries.OpenTime.GetIndexByTime(londonOpen)]) / Symbol.PipSize, 2);
                
                if (double.IsNormal(londonMin) && double.IsNormal(londonMax) && double.IsNormal(londonPrice)) //Check all values are normal
                { //
                
                Chart.DrawRectangle("london session " + londonOpen, londonOpen, londonMax, londonClose, londonMin, Color.FromArgb(50, 0, 50, 255)).IsFilled = true;
                if (openPrices)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= londonOpen)
                            Chart.DrawTrendLine("_open london" + londonOpen, londonOpen, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(londonOpen)], londonClose, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(londonOpen)], Color.Blue);
                if (info)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= londonOpen)
                            Chart.DrawStaticText("london info", "Pips From London Open: " + londonPrice, VerticalAlignment.Top, HorizontalAlignment.Right, Color.RoyalBlue);
                        else
                            Chart.DrawStaticText("london info", "Pips From London Open: Waiting for Open", VerticalAlignment.Top, HorizontalAlignment.Right, Color.RoyalBlue);

            }

            //NY Session
            if (NY)
            {
                DateTime nyOpen, nyClose;
                DateTime.TryParse(today + "12:00:00", out nyOpen);
                DateTime.TryParse(today + "20:00:00", out nyClose);
                double nyMax = 0, nyMin = double.PositiveInfinity;
                nyOpen = nyOpen.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                nyClose = nyClose.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                for (int i = MarketSeries.OpenTime.GetIndexByTime(nyOpen); i < MarketSeries.OpenTime.GetIndexByTime(nyClose); i++)
                {
                    nyMax = Math.Max(nyMax, MarketSeries.High[i]);
                    nyMin = Math.Min(nyMin, MarketSeries.Low[i]);
                }
                double nyPrice = Math.Round((MarketSeries.Close[index] - openSeries.Open[MarketSeries.OpenTime.GetIndexByTime(nyOpen)]) / Symbol.PipSize, 2);
                
                if (double.IsNormal(nyMin) && double.IsNormal(nyMax) && double.IsNormal(nyPrice)) //Check all values are normal
                { //
                
                Chart.DrawRectangle("ny session " + nyOpen, nyOpen, nyMax, nyClose, nyMin, Color.FromArgb(50, 255, 50, 0)).IsFilled = true;
                if (openPrices)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= nyOpen)
                            Chart.DrawTrendLine("_open ny" + nyOpen, nyOpen, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(nyOpen)], nyClose, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(nyOpen)], Color.Red);
                if (info)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= nyOpen)
                            Chart.DrawStaticText("ny info", "\nPips From NY Open: " + nyPrice, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Red);
                        else
                            Chart.DrawStaticText("ny info", "\nPips From NY Open: Waiting for Open", VerticalAlignment.Top, HorizontalAlignment.Right, Color.Red);


            }

            //Sydney Session
            string yesterday = MarketSeries.OpenTime[index].AddDays(-1).Day.ToString() + "/" + MarketSeries.OpenTime[index].AddDays(-1).Month.ToString() + "/" + MarketSeries.OpenTime[index].AddDays(-1).Year.ToString() + " ";
            string tommorow = MarketSeries.OpenTime[index].AddDays(1).Day.ToString() + "/" + MarketSeries.OpenTime[index].AddDays(1).Month.ToString() + "/" + MarketSeries.OpenTime[index].AddDays(1).Year.ToString() + " ";
            if (sydney)
            {
                DateTime sydneyOpen, sydneyClose;
                DateTime.TryParse(MarketSeries.OpenTime[index].Hour <= 6 ? yesterday + "22:00:00" : today + "22:00:00", out sydneyOpen);
                DateTime.TryParse(MarketSeries.OpenTime[index].Hour <= 6 ? today + "6:00:00" : tommorow + "6:00:00", out sydneyClose);
                double sydneyMax = 0, sydneyMin = double.PositiveInfinity;
                sydneyOpen = sydneyOpen.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                sydneyClose = sydneyClose.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                for (int i = MarketSeries.OpenTime.GetIndexByTime(sydneyOpen); i < MarketSeries.OpenTime.GetIndexByTime(sydneyClose); i++)
                {
                    sydneyMax = Math.Max(sydneyMax, MarketSeries.High[i]);
                    sydneyMin = Math.Min(sydneyMin, MarketSeries.Low[i]);
                }
                double sydneyPrice = Math.Round((MarketSeries.Close[index] - openSeries.Open[MarketSeries.OpenTime.GetIndexByTime(sydneyOpen)]) / Symbol.PipSize, 2);
                
                if (double.IsNormal(sydneyMin) && double.IsNormal(sydneyMax) && double.IsNormal(sydneyPrice)) //Check all values are normal
                { //
                
                Chart.DrawRectangle("sydney session " + sydneyOpen, sydneyOpen, sydneyMax, sydneyClose, sydneyMin, Color.FromArgb(50, 50, 255, 0)).IsFilled = true;
                if (openPrices)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= sydneyOpen)
                            Chart.DrawTrendLine("_open sydney" + sydneyOpen, sydneyOpen, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(sydneyOpen)], sydneyClose, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(sydneyOpen)], Color.LawnGreen);
                if (info)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= sydneyOpen)
                            Chart.DrawStaticText("sydney info", "\n\nPips From Sydney Open: " + sydneyPrice, VerticalAlignment.Top, HorizontalAlignment.Right, Color.LawnGreen);

            }

            //Tokyo Session
            if (tokyo)
            {
                DateTime tokyoOpen, tokyoClose;
                DateTime.TryParse(MarketSeries.OpenTime[index].Hour <= 7 ? yesterday + "23:00:00" : today + "23:00:00", out tokyoOpen);
                DateTime.TryParse(MarketSeries.OpenTime[index].Hour <= 7 ? today + "7:00:00" : tommorow + "7:00:00", out tokyoClose);
                double tokyoMax = 0, tokyoMin = double.PositiveInfinity;
                tokyoOpen = tokyoOpen.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                tokyoClose = tokyoClose.AddHours(MarketSeries.OpenTime[index].IsDaylightSavingTime() ? 1 : 0);
                for (int i = MarketSeries.OpenTime.GetIndexByTime(tokyoOpen); i < MarketSeries.OpenTime.GetIndexByTime(tokyoClose); i++)
                {
                    tokyoMax = Math.Max(tokyoMax, MarketSeries.High[i]);
                    tokyoMin = Math.Min(tokyoMin, MarketSeries.Low[i]);
                }
                double tokyoPrice = Math.Round((MarketSeries.Close[index] - openSeries.Open[MarketSeries.OpenTime.GetIndexByTime(tokyoOpen)]) / Symbol.PipSize, 2);
                
                if (double.IsNormal(tokyoMin) && double.IsNormal(tokyoMax) && double.IsNormal(tokyoPrice)) //Check all values are normal
                { //
                
                Chart.DrawRectangle("tokyo session " + tokyoOpen, tokyoOpen, tokyoMax, tokyoClose, tokyoMin, Color.FromArgb(50, 255, 255, 50)).IsFilled = true;
                if (openPrices)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= tokyoOpen)
                            Chart.DrawTrendLine("_open tokyo" + tokyoOpen, tokyoOpen, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(tokyoOpen)], tokyoClose, MarketSeries.Open[MarketSeries.OpenTime.GetIndexByTime(tokyoOpen)], Color.Yellow);
                if (info)
                    if (TimeFrame <= TimeFrame.Hour)
                        if (MarketSeries.OpenTime[index] >= tokyoOpen)
                            Chart.DrawStaticText("tokyo info", "\n\n\nPips From Tokyo Open: " + tokyoPrice, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Yellow);

            }

        }
    }
}

 


@Tspring

Tspring
11 May 2023, 13:35

Ciao, io avevo la necessità di cambiare rapidamente da un symbol all'altro ed ho trovato un indicatore gratuito che mi permette di farlo.

Se ti interessa questo è l'indicatore: https://ctrader.com/algos/indicators/show/2054

Questa è la versione con i timeframe: https://ctrader.com/algos/indicators/show/2562


@Tspring

Tspring
11 May 2023, 13:12

I asked a similar thing a while ago. It would be very convenient to insert the automatic breakeven on a pending order, for example to straddle the news release.


@Tspring