Replies

pozhy
26 Mar 2019, 03:13

any comment?


@pozhy

pozhy
13 Mar 2019, 02:32

RE:

Panagiotis Charalampous said:

Hi pozhy,

I offered a solution to a similar problem here.

Best Regards,

Panagiotis

protected override void Initialize()
{
 
    Chart.ZoomChanged += Chart_ZoomChanged;
}
 
private void Chart_ZoomChanged(ChartZoomEventArgs obj)
{
   //Redraw your indicator           
}

in this code you use Chart.ZommChanged , it means the only way is changing the zoom on chart to refresh the indicator?


@pozhy

pozhy
12 Mar 2019, 15:44

RE:

Panagiotis Charalampous said:

Hi pozhy,

In principle it is unless it is blocked. Paul Hayes has written a nice article about this.

Best Regards,

Panagiotis

you saved my time. thank you


@pozhy

pozhy
12 Mar 2019, 15:26

RE:

Panagiotis Charalampous said:

Hi pozhy,

I offered a solution to a similar problem here.

Best Regards,

Panagiotis

thank you


@pozhy

pozhy
11 Mar 2019, 23:36

I can not get an email. what is the reason? it is for Gmail configuration?


@pozhy

pozhy
11 Mar 2019, 03:44

is it still possible to get an email notification from Gmail? I have a problem

 

            Notifications.SendEmail("....@gmail.com", "....@gmail.com", "Email Subject", "Email body");

 


@pozhy

pozhy
23 Feb 2019, 16:44

RE:

Panagiotis Charalampous said:

Hi pozhy,

Can you elaborate a bit what do you mean when you say start hour? Do you want the indicator to start drawing on that hour?

Best Regards,

Panagiotis

for example, I want to draw a line every 5 hours. in the second step I want to draw that series from 5 pm 
 

            ChartObjects.DrawLine("left" + idx1, idx2, open, idx2, close, color, Thickness);


@pozhy

pozhy
11 Feb 2019, 03:26

RE:

pozhy said:

Hi, This indicator is written by one of the members. I wonder if we can change the beginning hour of each day by TimeShift parameter or another input that indicates start hour is 8 am for example

 

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 CustomTFCandlesticks : Indicator

    {

        [Parameter()]

        public TimeFrame Timeframe { get; set; }

         [Parameter("Time Shift ", DefaultValue = 0)]
        public int TimeShift { get; set; }

        [Parameter("Thickness", DefaultValue = 1)]

        public double Thickness { get; set; }

 

        private MarketSeries tf;

 

        protected override void Initialize()

        {

            tf = MarketData.GetSeries(Timeframe);

        }

 

        public override void Calculate(int index)

        {

            int idx1 = tf.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);

            int idx2 = MarketSeries.OpenTime.GetIndexByTime(tf.OpenTime[idx1]);

            int idx3 = idx2 + (index - idx2) / 2;

 

            double open = tf.Open[idx1];

            double high = tf.High[idx1];

            double low = tf.Low[idx1];

            double close = tf.Close[idx1];

 

            var color = open < close ? Colors.Green : Colors.Red;

 

            ChartObjects.DrawLine("top" + idx1, idx2, close, index, close, color, Thickness);

            ChartObjects.DrawLine("bottom" + idx1, idx2, open, index, open, color, Thickness);

            ChartObjects.DrawLine("left" + idx1, idx2, open, idx2, close, color, Thickness);

            ChartObjects.DrawLine("right" + idx1, index, open, index, close, color, Thickness)

 

        }

    }

}

does anyone have an Idea, for example, I want to start day based on New York


@pozhy

pozhy
31 Jan 2019, 22:52

thank you


@pozhy

pozhy
26 Jan 2019, 18:18

RE:

afhacker said:

Try this:

        private void CalculateHeikenAshi(MarketSeries otherSeries, int periods = 1)
        {
            int index = MarketSeries.Close.Count - 1;

            int otherSeriesIndex = otherSeries.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);

            double barOhlcSum = otherSeries.Open[otherSeriesIndex] + otherSeries.Low[otherSeriesIndex] +
                otherSeries.High[otherSeriesIndex] + otherSeries.Close[otherSeriesIndex];

            _close[index] = Math.Round(barOhlcSum / 4, Symbol.Digits);

            if (otherSeriesIndex < periods || double.IsNaN(_open[index - 1]))
            {
                _open[index] = Math.Round((otherSeries.Open[otherSeriesIndex] + otherSeries.Close[otherSeriesIndex]) / 2, Symbol.Digits);
                _high[index] = otherSeries.High[otherSeriesIndex];
                _low[index] = otherSeries.Low[otherSeriesIndex];
            }
            else
            {
                _open[index] = Math.Round((_open[index - 1] + _close[index - 1]) / 2, Symbol.Digits);
                _high[index] = Math.Max(otherSeries.High[otherSeriesIndex], Math.Max(_open[index], _close[index]));
                _low[index] = Math.Min(otherSeries.Low[otherSeriesIndex], Math.Min(_open[index], _close[index]));
            }
        }

The _open, _high, _low, and _close are IndicatorDataSeries objects and the "otherSeries" is the other time frame market series object.

 

 

Thank you, Ahmad , Still no luck except daily chart. I put the stars in the chart to see where is the open and when is the close but when timeframe changes to less than daily the position of stars change

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 AhmadNomanMusleh : Indicator
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

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

        public IndicatorDataSeries _close;
        public IndicatorDataSeries _high;
        public IndicatorDataSeries _low;
        public IndicatorDataSeries _open;

        public IndicatorDataSeries HeikenAshiOpens;
        public IndicatorDataSeries HeikenAshiCloses;

        private MarketSeries dailySeries;

        protected override void Initialize()
        {

            HeikenAshiCloses = CreateDataSeries();
            HeikenAshiOpens = CreateDataSeries();


            _close = CreateDataSeries();
            _high = CreateDataSeries();
            _low = CreateDataSeries();
            _open = CreateDataSeries();


            dailySeries = MarketData.GetSeries(Symbol, TimeFrame.Daily);
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...
            CalculateHeikenAshi(dailySeries, 1);
        }

        private void CalculateHeikenAshi(MarketSeries otherSeries, int periods = 1)
        {
            int index = MarketSeries.Close.Count - 1;

            int idx1 = dailySeries.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);
            int idx2 = MarketSeries.OpenTime.GetIndexByTime(dailySeries.OpenTime[idx1]);
            int idx3 = idx2 + (index - idx2) / 2;

            int otherSeriesIndex = otherSeries.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);

            double barOhlcSum = otherSeries.Open[otherSeriesIndex] + otherSeries.Low[otherSeriesIndex] + otherSeries.High[otherSeriesIndex] + otherSeries.Close[otherSeriesIndex];

            _close[index] = Math.Round(barOhlcSum / 4, Symbol.Digits);

            if (otherSeriesIndex < periods || double.IsNaN(_open[index - 1]))
            {
                _open[index] = Math.Round((otherSeries.Open[otherSeriesIndex] + otherSeries.Close[otherSeriesIndex]) / 2, Symbol.Digits);
                _high[index] = otherSeries.High[otherSeriesIndex];
                _low[index] = otherSeries.Low[otherSeriesIndex];
            }
            else
            {
                _open[index] = Math.Round((_open[index - 1] + _close[index - 1]) / 2, Symbol.Digits);
                _high[index] = Math.Max(otherSeries.High[otherSeriesIndex], Math.Max(_open[index], _close[index]));
                _low[index] = Math.Min(otherSeries.Low[otherSeriesIndex], Math.Min(_open[index], _close[index]));
            }

            Chart.DrawIcon("ichac" + index, ChartIconType.Star, index, _close[idx2], Color.White);
            Chart.DrawIcon("ichao" + index, ChartIconType.Star, index, _open[idx2], Color.Yellow);
            Chart.DrawIcon("ichah" + index, ChartIconType.Star, index, _high[idx2], Color.DarkBlue);
            Chart.DrawIcon("ichal" + index, ChartIconType.Star, index, _low[idx2], Color.DarkBlue);

            Chart.DrawIcon("ichal" + index, ChartIconType.Star, index, _low[idx2], Color.DarkBlue);
            HeikenAshiCloses[index] = (_close[idx2] + _open[idx2] + _high[idx2] + _low[idx2]) / 4;
            HeikenAshiOpens[index] = (_close[idx2 - 1] + _open[idx2 - 1]) / 2;

            Chart.DrawIcon("ichach" + index, ChartIconType.Star, index, HeikenAshiCloses[index], Color.Red);
            Chart.DrawIcon("ichaoh" + index, ChartIconType.Star, index, HeikenAshiOpens[index], Color.Green);


        }

    }
}

 


@pozhy

pozhy
26 Jan 2019, 15:28

RE:

Thank you, Ahmad, but I need this code to go forward, what is the problem? is it from the index or open calculation?

 

afhacker said:

I'm building a free multi time frame Heiken Ashi indicator that will plot another time frame Heiken Ashi bars on top of your chart, it will be available for download on our site in the next few days as an update to our current Heiken Ashi MTF indicator (the indicator current version isn't free but the new version will be free).

Check out our Custom Period Candles indicator, it will look like it with an alerting feature on bar color change.

 


@pozhy

pozhy
26 Jan 2019, 06:59

I can't make open based on Heiken-Ashi which is Open[index] = (open the last candle + close the last candle )/2

and my chart in daily won't work correctly, is there anyone that has a solution when we want to draw daily Heiken Ashi in a smaller chart like hourly? 

 

 

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using System.Collections.Generic;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.EEuropeStandardTime, AccessRights = AccessRights.None)]
    public class AHeikenashi3 : Indicator
    {
        public List<double> dailyIndexesOpensList = new List<double>();
        private MarketSeries dailySeries;
        public IndicatorDataSeries MyPreviousClose;
        public IndicatorDataSeries CurrentOpens;
        public IndicatorDataSeries xClose;
        public IndicatorDataSeries xHigh;
        public IndicatorDataSeries xLow;
        public IndicatorDataSeries xOpen;

        private IndicatorDataSeries _haOpen;
        private IndicatorDataSeries _haClose;
        private IndicatorDataSeries _haOpenD;
        private IndicatorDataSeries _haCloseD;

        public double prviousClose;
        protected override void Initialize()
        {
            MyPreviousClose = CreateDataSeries();
            CurrentOpens = CreateDataSeries();

            xClose = CreateDataSeries();
            xHigh = CreateDataSeries();
            xLow = CreateDataSeries();
            xOpen = CreateDataSeries();
            dailySeries = MarketData.GetSeries(Symbol, TimeFrame.Daily);

            _haOpen = CreateDataSeries();
            _haClose = CreateDataSeries();
            _haOpenD = CreateDataSeries();
            _haCloseD = CreateDataSeries();

        }

        public override void Calculate(int index)
        {

            int dailyIndex = GetIndexByDate(dailySeries, MarketSeries.OpenTime[index]);
            if (dailyIndex < 0)
            {
                dailyIndex = GetClosestIndexByDate(dailySeries, MarketSeries.OpenTime[index]);

            }

            int idx1 = dailySeries.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);
            int idx2 = MarketSeries.OpenTime.GetIndexByTime(dailySeries.OpenTime[idx1]);
            int idx3 = idx2 + (index - idx2) / 2;

            double open = dailySeries.Open[idx1];
            double high = dailySeries.High[idx1];
            double low = dailySeries.Low[idx1];
            double close = dailySeries.Close[idx1];

            var haClose = (open + high + low + close) / 4;
            double haOpen;
            if (index > 0)
            {
                //haOpen = (MarketData.GetSeries(TimeFrame.Daily).Open[idx1 - 1] + MarketData.GetSeries(TimeFrame.Daily).Close[idx1 - 1]) / 2;
                haOpen = (_haOpen[index - 1] + _haClose[index - 1]) / 2;
                //haOpen = (dailySeries.Open[idx1 - 1] + dailySeries.Close[idx1 - 1]) / 2;
            }
            else
                haOpen = (open + close) / 2;
            var haCloseD = (open + high + low + close) / 4;

            double haOpenD;
            if (idx1 > 0)
            {
                haOpenD = (_haOpenD[idx1 - 1] + _haCloseD[idx1 - 1]) / 2;
            }
            else
            {
                haOpenD = (open + close) / 2;
            }

            _haOpen[index] = haOpen;
            _haClose[index] = haClose;
            _haOpenD[idx1] = haOpen;
            _haCloseD[idx1] = haClose;

            var haHigh = Math.Max(Math.Max(high, haOpenD), haCloseD);
            var haLow = Math.Min(Math.Min(low, haOpenD), haCloseD);


            dailyIndexesOpensList.Add((haCloseD + haOpenD) / 2);
            MyPreviousClose[idx1] = (haCloseD + haOpenD) / 2;

            prviousClose = ((dailySeries.Open[idx1 - 1] + dailySeries.High[idx1 - 1] + dailySeries.Low[idx1 - 1] + dailySeries.Close[idx1 - 1]) / 4);

            var mDcolor = haOpenD > haCloseD ? Color.Red : Color.Blue;

            Chart.DrawRectangle("recHeiken " + idx2, idx2, (MyPreviousClose[idx1 - 2] + prviousClose) / 2, index, haCloseD, mDcolor, 7);
            Chart.DrawTrendLine("lineHUP " + idx2, idx3, haHigh, idx3, haLow, mDcolor, 3);
        }

        private int GetIndexByDate(MarketSeries series, DateTime time)
        {
            var lastBar = series.Close.Count - 1;
            for (int i = lastBar; i > 0; i--)
            {
                if (time == series.OpenTime[i])
                    return i;
            }
            return -1;
        }

        private int GetClosestIndexByDate(MarketSeries series, DateTime time)
        {
            var lastIndex = series.Close.Count - 1;

            if (time >= series.OpenTime[lastIndex])
                return lastIndex;

            var timeDifference = time.Subtract(series.OpenTime[0]);

            int index = 0;

            for (int i = 0; i < lastIndex - 1; i++)
            {
                if (time < series.OpenTime[i])
                    break;
                var currDiff = time.Subtract(series.OpenTime[i]);

                if (currDiff < timeDifference)
                {
                    timeDifference = currDiff;
                    index = i;
                }
            }

            return index;
        }
    }
}

 


@pozhy

pozhy
19 Jan 2019, 06:40

I have done it but it is weird

                if (MarketSeries.OpenTime[index].Hour == StartHour)
                {
                    DrawRectangle(index);
                } 

-------------------------------------

         public void DrawRectangle(int index)
        {
            int idx1 = tf.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);
            int idx2 = MarketSeries.OpenTime.GetIndexByTime(tf.OpenTime[idx1]);

            double open = tf.Open[idx1];
            high = tf.High[idx1];
            low = tf.Low[idx1];
            double close = tf.Close[idx1];

            Chart.DrawRectangle("Rectangel" + index, index, high, idx2, low, open < close ? Color.Yellow : Color.Pink);

}


@pozhy

pozhy
04 Apr 2018, 11:14

RE:

Panagiotis Charalampous said:

Hi pozhy,

Thanks for posting in our forum. It is not clear what you mean to import forex data in visual studio. Do you mean to read a file using C#? Please elaborate so that we can help you more.

Best Regards,

Panagiotis

Hi Panagiotis
For example I need realtime data of XAUUASD such as: ask ,bid ,close ,open ,high ,low , inorder to save on Database and doing some culculations in C# language. Then I will excuate some orders in Visual studio.  


@pozhy