Drawing lines from robots and indicators

Chistabo's avatar

Chistabo since: 01 May 2015;

  13 Dec 2015, 20:28
Drawing lines from robots and indicators

magforex said:

cAlgo_Fanatic said:

Daily High and Low Indicator. Displays horizontal lines that correspond to the daily high and low.

Source Code:

using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true)]
    public class DailyHighLow : Indicator
    {
        public override void Calculate(int index)
        {
            DateTime today = MarketSeries.OpenTime[index].Date;
            DateTime tomorrow = today.AddDays(1);

            double high = MarketSeries.High.LastValue;
            double low = MarketSeries.Low.LastValue;

            for (int i = MarketSeries.Close.Count - 1; i > 0; i--)
            {
                if (MarketSeries.OpenTime[i].Date < today)
                    break;

                high = Math.Max(high, MarketSeries.High[i]);
                low = Math.Min(low, MarketSeries.Low[i]);
            }

            ChartObjects.DrawLine("high " + today, today, high, tomorrow, high, Colors.Pink);
            ChartObjects.DrawLine("low " + today, today, low, tomorrow, low, Colors.Pink);
        }
    }
}


 

Hi Spotware, how do I control if I only want the current day or maybe only 2 days high and low only? Can you give me a hint? thanks!

for (int i = MarketSeries.Close.Count - 1; i > 0; i--)
            {
                if (MarketSeries.OpenTime[i].Date < today)
                    break;

                high = Math.Max(high, MarketSeries.High[i]);
                low = Math.Min(low, MarketSeries.Low[i]);
            }

In this case 'int i = MarketSeries.Close.Count - 1' defines a number of iritations that equals all 'close' values found on chart = back to the beginning of available chart data. So, setting this to i.e. 2 would do.

I guess. Have not tried.

Simon

huupie_heijntje since: 11 Jul 2016;

  11 Jul 2016, 23:24

Why is it that if I draw objects from a custom indicator they do show up on the chart, but when drawing them from a robot they don't? I tied to run the robot in a backtest as well as on a live chart.

Vitali Gajdabrus since: 20 Aug 2015;

  16 Jan 2017, 22:06
RE:
2. Horizontal line:
ChartObjects.DrawHorizontalLine(objectName, y, color, [optional] thickness, [optional] style)

How to set the color:

Color FromArgb(	int alpha,	int red,	int green,	int blue)  ?

First of all I am interested in transparency -  int alpha.

I can draw a band  msdn "StripLine Class"?

I want to develop an indicator for cTrader:

This can be done on cAlgo?

Sorry for my English is not Oxford.

Извините за мой слегка шершавый английский. Поэтому если что - то можно по русски.

Vitali Gajdabrus since: 20 Aug 2015;

  18 Jan 2017, 15:00
RE: RE:

Vitali Gajdabrus said:

How to set the color:
Color FromArgb(	int alpha,	int red,	int green,	int blue)  ?

First of all I am interested in transparency -  int alpha.

I can draw a band  msdn "StripLine Class"?

I want to develop an indicator for cTrader:

This can be done on cAlgo?

Can I get the coordinates of the cursor in the processing of events MouseClick, MouseDoubleClick, MouseDown, MoseLeave, MuseTove, the MouseUp, and the like to the program trading robots draw on the chart.

Vitali Gajdabrus since: 20 Aug 2015;

  20 Jan 2017, 21:43
RE: RE: RE:

Can I get the coordinates of the cursor in the processing of events MouseClick, MouseDoubleClick, MouseDown, MoseLeave, MuseTove, the MouseUp, and the like to the program trading robots draw on the chart.

On the issue of transparency, color and found the answer. Please excuse me for my carelessness.

Interested in response to the second question.

Vitali Gajdabrus since: 20 Aug 2015;

  23 Jan 2017, 09:03
RE: RE: RE: RE:

Vitali Gajdabrus said:

Can I get the coordinates of the cursor in the processing of events MouseClick, MouseDoubleClick, MouseDown, MoseLeave, MuseTove, the MouseUp, and the like to the program trading robots draw on the chart.

Regrettable very poor support cAlgo... :(

akhizhniy since: 13 Feb 2017;

  20 Feb 2017, 11:05
RE: RE: test

Vitali Gajdabrus said:

test

test

akhizhniy since: 13 Feb 2017;

  20 Feb 2017, 14:42
RE: RE: RE: test

akhizhniy said:

Vitali Gajdabrus said:

test

test

johnreygalax8 since: 21 Jul 2018;

  23 Jul 2018, 18:30
RE:

hi is there a way to highlight the corresponding whole number???

so it will look like this cAlgo_Fanatic said:

Indicator showing Round Numbers based on input step pips calculated between the chart High and Low.

Source Code:

using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true)]
    public class RoundNumbers : Indicator
    {
        [Parameter(DefaultValue = 100)]
        public int StepPips { get; set; }

        protected override void Initialize()
        {
            double max = MarketSeries.High.Maximum(MarketSeries.High.Count);
            double min = MarketSeries.Low.Minimum(MarketSeries.Low.Count);

            double step = Symbol.PipSize*StepPips;
            double start = Math.Floor(min/step)*step;

            for (double level = start; level <= max + step; level += step)
            {
                ChartObjects.DrawHorizontalLine("line_" + level, level, Colors.Gray);
            }
        }

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


 

einrel.lernie since: 13 Apr 2020;

  29 Apr 2020, 19:41
RE: RE:

I'm looking for this highlight as well. Is there any property for this? Even if its not related to the lines will do.

Or maybe some tooltips?

Thanks.

johnreygalax8 said:

hi is there a way to highlight the corresponding whole number???

so it will look like this cAlgo_Fanatic said:

Indicator showing Round Numbers based on input step pips calculated between the chart High and Low.

Source Code:

using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true)]
    public class RoundNumbers : Indicator
    {
        [Parameter(DefaultValue = 100)]
        public int StepPips { get; set; }

        protected override void Initialize()
        {
            double max = MarketSeries.High.Maximum(MarketSeries.High.Count);
            double min = MarketSeries.Low.Minimum(MarketSeries.Low.Count);

            double step = Symbol.PipSize*StepPips;
            double start = Math.Floor(min/step)*step;

            for (double level = start; level <= max + step; level += step)
            {
                ChartObjects.DrawHorizontalLine("line_" + level, level, Colors.Gray);
            }
        }

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