What are Discontinuous Lines in cTrader.

Created at 19 May 2022, 15:56
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!
GE

genappsforex

Joined 25.11.2019

What are Discontinuous Lines in cTrader.
19 May 2022, 15:56


hi,

Cannot figure out why these lines are not discontinuous.Or do i have a wrong understanding of discontinuous

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 TestDiscontinue : Indicator
    {
        [Output("Main1", PlotType = PlotType.DiscontinuousLine)]
        public IndicatorDataSeries Result1 { get; set; }
        [Output("Main2", PlotType = PlotType.DiscontinuousLine)]
        public IndicatorDataSeries Result2 { get; set; }
        int Switch = 1;
        int PrevIndex = -1;

        protected override void Initialize()
        {
        }

        public override void Calculate(int index)
        {
            if(PrevIndex==index) return;
            if(
               ((double)index)/3 == index/3  ||
               ((double)index)/4 == index/4  
            )
                Switch *= -1;
           
            if(Switch>0) 
                Result1[index] = Bars[index].High;
            else
                Result2[index] = Bars[index].High;
              
            Print(index + "\t"+ Result1[index],"\t",Result2[index]);
            PrevIndex=index;
        }
    }
}

Any Idea?

 


@genappsforex
Replies

amusleh
20 May 2022, 10:20 ( Updated at: 21 Dec 2023, 09:22 )

Hi,

The lines are discontinuous:

Discontinuous outputs can have empty or NAN values, and those NAN values will not be displayed on the chart.


@amusleh

genappsforex
21 May 2022, 09:24 ( Updated at: 23 May 2022, 12:21 )

RE: Discontinuous outputs

amusleh said:

Hi,

The lines are discontinuous:

 

Discontinuous outputs can have empty or NAN values, and those NAN values will not be displayed on the chart.

Well that was my understanding also.
So Why does my little progam above NOT generate discontinuous Lines?


@genappsforex

firemyst
22 May 2022, 13:36

RE: RE: Discontinuous outputs

genappsforex said:

amusleh said:

Hi,

The lines are discontinuous:

 

Discontinuous outputs can have empty or NAN values, and those NAN values will not be displayed on the chart.

Well that was my understanding also.
So Why does not my little progam above generate discontinuous Lines?

Because both

((double)index)/3 == index/3

is false and

((double)index)/4 == index/4

is false.

So it always has a value in Result1 and not Result2 because Switch is always > 0:

if(Switch>0) Result1[index] = Bars[index].High;

@firemyst

genappsforex
23 May 2022, 12:19

RE: RE: RE: Discontinuous outputs

firemyst said:

Because both

((double)index)/3 == index/3

is false and

((double)index)/4 == index/4

is false.

So it always has a value in Result1 and not Result2 because Switch is always > 0:

if(Switch>0) Result1[index] = Bars[index].High;

Sorry to tell you but you're wrong.
Just run the indicator code i've posted and see for yourself.


@genappsforex

firemyst
23 May 2022, 12:42 ( Updated at: 24 May 2022, 03:36 )

RE: RE: RE: RE: Discontinuous outputs

genappsforex said:

firemyst said:

Because both

((double)index)/3 == index/3

is false and

((double)index)/4 == index/4

is false.

So it always has a value in Result1 and not Result2 because Switch is always > 0:

if(Switch>0) Result1[index] = Bars[index].High;

Sorry to tell you but you're wrong.
Just run the indicator code i've posted and see for yourself.

 

Perhaps you have some Windows or .Net updates that haven't taken affect yet in cTrader? Reboot?

 


@firemyst

genappsforex
23 May 2022, 17:41

RE: RE: RE: RE: RE: Discontinuous outputs

@firemyst 

My Last message to you about this!
Print statement 

            Print(
                "index = " + index +" => " + 
                (((double)index)/3).ToString("F1") +" =?= "+
                (index/3).ToString("F1") +" || " +
                (((double)index)/4).ToString("F1") +" =?= "+
                (index/4).ToString("F1") + " => " + 
                (((double)index)/3 == index/3  || ((double)index)/4 == index/4)
            );

Output:

23/05/2022 14:38:33.156 | index = 0 => 0.0 =?= 0.0 || 0.0 =?= 0.0 => True
23/05/2022 14:38:33.156 | index = 1 => 0.3 =?= 0.0 || 0.3 =?= 0.0 => False
23/05/2022 14:38:33.156 | index = 2 => 0.7 =?= 0.0 || 0.5 =?= 0.0 => False
23/05/2022 14:38:33.156 | index = 3 => 1.0 =?= 1.0 || 0.8 =?= 0.0 => True
23/05/2022 14:38:33.156 | index = 4 => 1.3 =?= 1.0 || 1.0 =?= 1.0 => True
23/05/2022 14:38:33.156 | index = 5 => 1.7 =?= 1.0 || 1.3 =?= 1.0 => False
23/05/2022 14:38:33.156 | index = 6 => 2.0 =?= 2.0 || 1.5 =?= 1.0 => True
23/05/2022 14:38:33.156 | index = 7 => 2.3 =?= 2.0 || 1.8 =?= 1.0 => False
23/05/2022 14:38:33.156 | index = 8 => 2.7 =?= 2.0 || 2.0 =?= 2.0 => True
23/05/2022 14:38:33.156 | index = 9 => 3.0 =?= 3.0 || 2.3 =?= 2.0 => True


So please next time do not answer without beign 100% sure when you're rebuttled. but try the provided indicator code first. If you did you'd seen you were wrong!
 


@genappsforex

genappsforex
23 May 2022, 17:47

problem solved bij reinstalling cTrader

amusleh said:

Hi,

The lines are discontinuous:

After closing all copies of cTrader  and reinstalling cTrader  it It now gives the discontinuous lines as it should.


@genappsforex

amusleh
24 May 2022, 10:14

RE: problem solved bij reinstalling cTrader

genappsforex said:

amusleh said:

Hi,

The lines are discontinuous:

After closing all copies of cTrader  and reinstalling cTrader  it It now gives the discontinuous lines as it should.

Hi,

The image I posted is from your own indicator and as you can see it was working fine on my system.


@amusleh