How do I size objects in code ?

Created at 02 Mar 2014, 21:03
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!
SH

shabs19

Joined 02.03.2014

How do I size objects in code ?
02 Mar 2014, 21:03


Transferred MQ4 file intop Algo c trader, indicator build successful & shows up on chart.

How do I increase size of objects created by indicator, which line of code needs adjusting ?

Thanks for help.

 


@shabs19
Replies

shabs19
02 Mar 2014, 21:10

code attached
// ------------------------------------------------------------                   
// Paste this code into your cAlgo editor. 
// -----------------------------------------------------------
using System;
using System.Collections.Generic;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Threading;
using cAlgo.API.Requests;
// ---------------------------------------------------------------------------                   
// Converted from MQ4 to cAlgo with http://2calgo.com
// ---------------------------------------------------------------------------

namespace cAlgo.Indicators
{
    [Indicator(ScalePrecision = 5, AutoRescale = false, IsOverlay = true)]
    [Levels()]
    public class _3_Level_ZZ_Semafor_Indicator : Indicator
    {
        Mq4Double Mq4Init()
        {
            Mq4Double C = 0;
            Mq4DoubleArray Mass = new Mq4DoubleArray();
            Mq4Double CSt = 0;
            Mq4Double CDev = 0;
            if (Period1 > 0)
                F_Period = MathCeil(Period1 * Period());
            else
                F_Period = 0;
            if (Period2 > 0)
                N_Period = MathCeil(Period2 * Period());
            else
                N_Period = 0;
            if (Period3 > 0)
                H_Period = MathCeil(Period3 * Period());
            else
                H_Period = 0;

            if (Period1 > 0)
            {
                SetIndexStyle(0, DRAW_ARROW, 0, 1);
                SetIndexArrow(0, Symbol_1_Kod);
                SetIndexBuffer(0, FP_BuferUp);
                SetIndexEmptyValue(0, 0.0);

                SetIndexStyle(1, DRAW_ARROW, 0, 1);
                SetIndexArrow(1, Symbol_1_Kod);
                SetIndexBuffer(1, FP_BuferDn);
                SetIndexEmptyValue(1, 0.0);
            }

            if (Period2 > 0)
            {
                SetIndexStyle(2, DRAW_ARROW, 0, 3);
                SetIndexArrow(2, Symbol_2_Kod);
                SetIndexBuffer(2, NP_BuferUp);
                SetIndexEmptyValue(2, 0.0);

                SetIndexStyle(3, DRAW_ARROW, 0, 3);
                SetIndexArrow(3, Symbol_2_Kod);
                SetIndexBuffer(3, NP_BuferDn);
                SetIndexEmptyValue(3, 0.0);
            }
            if (Period3 > 0)
            {
                SetIndexStyle(4, DRAW_ARROW, 0, 4);
                SetIndexArrow(4, Symbol_3_Kod);
                SetIndexBuffer(4, HP_BuferUp);
                SetIndexEmptyValue(4, 0.0);

                SetIndexStyle(5, DRAW_ARROW, 0, 4);
                SetIndexArrow(5, Symbol_3_Kod);
                SetIndexBuffer(5, HP_BuferDn);
                SetIndexEmptyValue(5, 0.0);
            }
            CDev = 0;
            CSt = 0;

            C = 0;
            if (IntFromStrFunc(Dev_Step_1, ref C, Mass) == 1)
            {
                Stp1 = Mass[1];
                Dev1 = Mass[0];
            }

            if (IntFromStrFunc(Dev_Step_2, ref C, Mass) == 1)
            {
                Stp2 = Mass[1];
                Dev2 = Mass[0];
            }


            if (IntFromStrFunc(Dev_Step_3, ref C, Mass) == 1)
            {
                Stp3 = Mass[1];
                Dev3 = Mass[0];
            }
            return 0;
            return 0;
        }
        Mq4Double deinitFunc()
        {
            return 0;
            return 0;
        }
        Mq4Double Mq4Start()
        {
            if (Period1 > 0)
                CountZZFunc(FP_BuferUp, FP_BuferDn, Period1, Dev1, Stp1);
            if (Period2 > 0)
                CountZZFunc(NP_BuferUp, NP_BuferDn, Period2, Dev2, Stp2);
            if (Period3 > 0)
                CountZZFunc(HP_BuferUp, HP_BuferDn, Period3, Dev3, Stp3);
            return 0;
            return 0;
        }
        Mq4Double CountZZFunc(IMq4DoubleArray ExtMapBuffer, IMq4DoubleArray ExtMapBuffer2, Mq4Double ExtDepth, Mq4Double ExtDeviation, Mq4Double ExtBackstep)
        {
            Mq4Double lastlow = 0;
            Mq4Double lasthigh = 0;
            Mq4Double curhigh = 0;
            Mq4Double curlow = 0;
            Mq4Double res = 0;
            Mq4Double val = 0;
            Mq4Double lastlowpos = 0;
            Mq4Double lasthighpos = 0;
            Mq4Double back = 0;
            Mq4Double shift = 0;




            for (shift = Bars - ExtDepth; shift >= 0; shift--)
            {
                val = Low[Lowest(NULL, 0, MODE_LOW, ExtDepth, shift)];
                if (val == lastlow)
                    val = 0.0;
                else
                {
                    lastlow = val;
                    if ((Low[shift] - val) > (ExtDeviation * Point))
                        val = 0.0;
                    else
                    {
                        for (back = 1; back <= ExtBackstep; back++)
                        {
                            res = ExtMapBuffer[shift + back];
                            if ((res != 0) && (res > val))
                                ExtMapBuffer[shift + back] = 0.0;
                        }
                    }
                }

                ExtMapBuffer[shift] = val - (delta * Point);

                val = High[Highest(NULL, 0, MODE_HIGH, ExtDepth, shift)];
                if (val == lasthigh)
                    val = 0.0;
                else
                {
                    lasthigh = val;
                    if ((val - High[shift]) > (ExtDeviation * Point))
                        val = 0.0;
                    else
                    {
                        for (back = 1; back <= ExtBackstep; back++)
                        {
                            res = ExtMapBuffer2[shift + back];
                            if ((res != 0) && (res < val))
                                ExtMapBuffer2[shift + back] = 0.0;
                        }
                    }
                }
                ExtMapBuffer2[shift] = val + (delta * Point);
            }

            lasthigh = -1;
            lasthighpos = -1;
            lastlow = -1;
            lastlowpos = -1;

            for (shift = Bars - ExtDepth; shift >= 0; shift--)
            {
                curlow = ExtMapBuffer[shift];
                curhigh = ExtMapBuffer2[shift];
                if ((curlow == 0) && (curhigh == 0))
                    continue;

                if (curhigh != 0)
                {
                    if (lasthigh > 0)
                    {
                        if (lasthigh < curhigh)
                            ExtMapBuffer2[lasthighpos] = 0;
                        else
                            ExtMapBuffer2[shift] = 0;
                    }

                    if (lasthigh < curhigh || lasthigh < 0)
                    {
                        lasthigh = curhigh;
                        lasthighpos = shift;
                    }
                    lastlow = -1;
                }

                if (curlow != 0)
                {
                    if (lastlow > 0)
                    {
                        if (lastlow > curlow)
                            ExtMapBuffer[lastlowpos] = 0;
                        else
                            ExtMapBuffer[shift] = 0;
                    }

                    if ((curlow < lastlow) || (lastlow < 0))
                    {
                        lastlow = curlow;
                        lastlowpos = shift;
                    }
                    lasthigh = -1;
                }
            }

            for (shift = Bars - 1; shift >= 0; shift--)
            {
                if (shift >= Bars - ExtDepth)
                    ExtMapBuffer[shift] = 0.0;
                else
                {
                    res = ExtMapBuffer2[shift];
                    if (res != 0.0)
                        ExtMapBuffer2[shift] = res;
                }
            }
            return 0;
        }
        Mq4Double Str2MassiveFunc(Mq4String VStr, ref Mq4Double M_Count, IMq4DoubleArray VMass)
        {
            Mq4Double mc = 0;
            Mq4Double val = 0;
            val = StrToInteger(VStr);
            if (val > 0)
            {
                M_Count++;
                mc = ArrayResize(VMass, M_Count);
                if (mc == 0)
                    return -1;
                VMass[M_Count - 1] = val;
                return 1;
            }
            else
                return 0;
            return 0;
        }
        Mq4Double IntFromStrFunc(Mq4String ValStr, ref Mq4Double M_Count, IMq4DoubleArray VMass)
        {
            Mq4String CS = "";
            Mq4Double NP = 0;
            Mq4String SS = "";

            if (StringLen(ValStr) == 0)
                return -1;
            SS = ValStr;
            NP = 0;

            M_Count = 0;
            ArrayResize(VMass, M_Count);
            while (StringLen(SS) > 0)
            {
                NP = StringFind(SS, ",");
                if (NP > 0)
                {
                    CS = StringSubstr(SS, 0, NP);
                    SS = StringSubstr(SS, NP + 1, StringLen(SS));
                }
                else
                {
                    if (StringLen(SS) > 0)
                    {
                        CS = SS;
                        SS = "";
                    }
                }
                if (Str2MassiveFunc(CS, ref M_Count, VMass) == 0)
                {
                    return -2;
                }
            }
            return 1;
            return 0;
        }

        [Parameter("delta", DefaultValue = 0)]
        public int delta_parameter { get; set; }
        bool _deltaGot;
        Mq4Double delta_backfield;
        Mq4Double delta
        {
            get
            {
                if (!_deltaGot)
                    delta_backfield = delta_parameter;
                return delta_backfield;
            }
            set { delta_backfield = value; }
        }

        [Parameter("Period1", DefaultValue = 7)]
        public double Period1_parameter { get; set; }
        bool _Period1Got;
        Mq4Double Period1_backfield;
        Mq4Double Period1
        {
            get
            {
                if (!_Period1Got)
                    Period1_backfield = Period1_parameter;
                return Period1_backfield;
            }
            set { Period1_backfield = value; }
        }

        [Parameter("Period2", DefaultValue = 25)]
        public double Period2_parameter { get; set; }
        bool _Period2Got;
        Mq4Double Period2_backfield;
        Mq4Double Period2
        {
            get
            {
                if (!_Period2Got)
                    Period2_backfield = Period2_parameter;
                return Period2_backfield;
            }
            set { Period2_backfield = value; }
        }

        [Parameter("Period3", DefaultValue = 77)]
        public double Period3_parameter { get; set; }
        bool _Period3Got;
        Mq4Double Period3_backfield;
        Mq4Double Period3
        {
            get
            {
                if (!_Period3Got)
                    Period3_backfield = Period3_parameter;
                return Period3_backfield;
            }
            set { Period3_backfield = value; }
        }

        [Parameter("Dev_Step_1", DefaultValue = "1,3")]
        public string Dev_Step_1_parameter { get; set; }
        bool _Dev_Step_1Got;
        Mq4String Dev_Step_1_backfield;
        Mq4String Dev_Step_1
        {
            get
            {
                if (!_Dev_Step_1Got)
                    Dev_Step_1_backfield = Dev_Step_1_parameter;
                return Dev_Step_1_backfield;
            }
            set { Dev_Step_1_backfield = value; }
        }

        [Parameter("Dev_Step_2", DefaultValue = "8,5")]
        public string Dev_Step_2_parameter { get; set; }
        bool _Dev_Step_2Got;
        Mq4String Dev_Step_2_backfield;
        Mq4String Dev_Step_2
        {
            get
            {
                if (!_Dev_Step_2Got)
                    Dev_Step_2_backfield = Dev_Step_2_parameter;
                return Dev_Step_2_backfield;
            }
            set { Dev_Step_2_backfield = value; }
        }

        [Parameter("Dev_Step_3", DefaultValue = "13,8")]
        public string Dev_Step_3_parameter { get; set; }
        bool _Dev_Step_3Got;
        Mq4String Dev_Step_3_backfield;
        Mq4String Dev_Step_3
        {
            get
            {
                if (!_Dev_Step_3Got)
                    Dev_Step_3_backfield = Dev_Step_3_parameter;
                return Dev_Step_3_backfield;
            }
            set { Dev_Step_3_backfield = value; }
        }

        [Parameter("Symbol_1_Kod", DefaultValue = 108)]
        public int Symbol_1_Kod_parameter { get; set; }
        bool _Symbol_1_KodGot;
        Mq4Double Symbol_1_Kod_backfield;
        Mq4Double Symbol_1_Kod
        {
            get
            {
                if (!_Symbol_1_KodGot)
                    Symbol_1_Kod_backfield = Symbol_1_Kod_parameter;
                return Symbol_1_Kod_backfield;
            }
            set { Symbol_1_Kod_backfield = value; }
        }

        [Parameter("Symbol_2_Kod", DefaultValue = 108)]
        public int Symbol_2_Kod_parameter { get; set; }
        bool _Symbol_2_KodGot;
        Mq4Double Symbol_2_Kod_backfield;
        Mq4Double Symbol_2_Kod
        {
            get
            {
                if (!_Symbol_2_KodGot)
                    Symbol_2_Kod_backfield = Symbol_2_Kod_parameter;
                return Symbol_2_Kod_backfield;
            }
            set { Symbol_2_Kod_backfield = value; }
        }

        [Parameter("Symbol_3_Kod", DefaultValue = 82)]
        public int Symbol_3_Kod_parameter { get; set; }
        bool _Symbol_3_KodGot;
        Mq4Double Symbol_3_Kod_backfield;
        Mq4Double Symbol_3_Kod
        {
            get
            {
                if (!_Symbol_3_KodGot)
                    Symbol_3_Kod_backfield = Symbol_3_Kod_parameter;
                return Symbol_3_Kod_backfield;
            }
            set { Symbol_3_Kod_backfield = value; }
        }



        public IndicatorDataSeries FP_BuferUp_AlgoOutputDataSeries { get; set; }
        public IndicatorDataSeries FP_BuferDn_AlgoOutputDataSeries { get; set; }
        public IndicatorDataSeries NP_BuferUp_AlgoOutputDataSeries { get; set; }
        public IndicatorDataSeries NP_BuferDn_AlgoOutputDataSeries { get; set; }
        public IndicatorDataSeries HP_BuferUp_AlgoOutputDataSeries { get; set; }
        public IndicatorDataSeries HP_BuferDn_AlgoOutputDataSeries { get; set; }


        Mq4Double Stp3;
        Mq4Double Dev3;
        Mq4Double Stp2;
        Mq4Double Dev2;
        Mq4Double Stp1;
        Mq4Double Dev1;
        Mq4Double H_Period;
        Mq4Double N_Period;
        Mq4Double F_Period;

        int indicator_buffers = 6;
        int indicator_color1 = Lime;
        int indicator_color2 = Red;
        int indicator_color3 = DodgerBlue;
        int indicator_color4 = DodgerBlue;
        int indicator_color5 = Black;
        int indicator_color6 = Black;


        Mq4Double indicator_width1 = 1;
        Mq4Double indicator_width2 = 1;
        Mq4Double indicator_width3 = 2;
        Mq4Double indicator_width4 = 2;
        Mq4Double indicator_width5 = 4;
        Mq4Double indicator_width6 = 4;
        Mq4Double indicator_width7 = 6;
        Mq4Double indicator_width8 = 6;




        private Mq4OutputDataSeries FP_BuferUp;
        private Mq4OutputDataSeries FP_BuferDn;
        private Mq4OutputDataSeries NP_BuferUp;
        private Mq4OutputDataSeries NP_BuferDn;
        private Mq4OutputDataSeries HP_BuferUp;
        private Mq4OutputDataSeries HP_BuferDn;


        List<Mq4OutputDataSeries> AllBuffers = new List<Mq4OutputDataSeries>();
        public List<DataSeries> AllOutputDataSeries = new List<DataSeries>();

        protected override void Initialize()
        {
            if (FP_BuferUp_AlgoOutputDataSeries == null)
                FP_BuferUp_AlgoOutputDataSeries = CreateDataSeries();
            FP_BuferUp = new Mq4OutputDataSeries(this, FP_BuferUp_AlgoOutputDataSeries, ChartObjects, 3, 0, () => CreateDataSeries(), 1, Colors.Lime);
            AllBuffers.Add(FP_BuferUp);
            if (FP_BuferDn_AlgoOutputDataSeries == null)
                FP_BuferDn_AlgoOutputDataSeries = CreateDataSeries();
            FP_BuferDn = new Mq4OutputDataSeries(this, FP_BuferDn_AlgoOutputDataSeries, ChartObjects, 3, 1, () => CreateDataSeries(), 1, Colors.Red);
            AllBuffers.Add(FP_BuferDn);
            if (NP_BuferUp_AlgoOutputDataSeries == null)
                NP_BuferUp_AlgoOutputDataSeries = CreateDataSeries();
            NP_BuferUp = new Mq4OutputDataSeries(this, NP_BuferUp_AlgoOutputDataSeries, ChartObjects, 3, 2, () => CreateDataSeries(), 2, Colors.DodgerBlue);
            AllBuffers.Add(NP_BuferUp);
            if (NP_BuferDn_AlgoOutputDataSeries == null)
                NP_BuferDn_AlgoOutputDataSeries = CreateDataSeries();
            NP_BuferDn = new Mq4OutputDataSeries(this, NP_BuferDn_AlgoOutputDataSeries, ChartObjects, 3, 3, () => CreateDataSeries(), 2, Colors.DodgerBlue);
            AllBuffers.Add(NP_BuferDn);
            if (HP_BuferUp_AlgoOutputDataSeries == null)
                HP_BuferUp_AlgoOutputDataSeries = CreateDataSeries();
            HP_BuferUp = new Mq4OutputDataSeries(this, HP_BuferUp_AlgoOutputDataSeries, ChartObjects, 3, 4, () => CreateDataSeries(), 4, Colors.Black);
            AllBuffers.Add(HP_BuferUp);
            if (HP_BuferDn_AlgoOutputDataSeries == null)
                HP_BuferDn_AlgoOutputDataSeries = CreateDataSeries();
            HP_BuferDn = new Mq4OutputDataSeries(this, HP_BuferDn_AlgoOutputDataSeries, ChartObjects, 3, 5, () => CreateDataSeries(), 4, Colors.Black);
            AllBuffers.Add(HP_BuferDn);

            AllOutputDataSeries.Add(FP_BuferUp_AlgoOutputDataSeries);
            AllOutputDataSeries.Add(FP_BuferDn_AlgoOutputDataSeries);
            AllOutputDataSeries.Add(NP_BuferUp_AlgoOutputDataSeries);
            AllOutputDataSeries.Add(NP_BuferDn_AlgoOutputDataSeries);
            AllOutputDataSeries.Add(HP_BuferUp_AlgoOutputDataSeries);
            AllOutputDataSeries.Add(HP_BuferDn_AlgoOutputDataSeries);


            CommonInitialize();

        }

        private bool _initialized;
        public override void Calculate(int index)
        {
            try
            {
                _currentIndex = index;
                FP_BuferUp.SetCurrentIndex(index);
                FP_BuferDn.SetCurrentIndex(index);
                NP_BuferUp.SetCurrentIndex(index);
                NP_BuferDn.SetCurrentIndex(index);
                HP_BuferUp.SetCurrentIndex(index);
                HP_BuferDn.SetCurrentIndex(index);


                if (IsLastBar)
                {
                    if (!_initialized)
                    {
                        Mq4Init();
                        _initialized = true;
                    }

                    Mq4Start();
                    _indicatorCounted = index;
                }
            } catch (Exception e)
            {

                throw;
            }
        }

        int _currentIndex;
        CachedStandardIndicators _cachedStandardIndicators;
        Mq4ChartObjects _mq4ChartObjects;
        Mq4ArrayToDataSeriesConverterFactory _mq4ArrayToDataSeriesConverterFactory;
        Mq4MarketDataSeries Open;
        Mq4MarketDataSeries High;
        Mq4MarketDataSeries Low;
        Mq4MarketDataSeries Close;
        Mq4MarketDataSeries Median;
        Mq4MarketDataSeries Volume;
        Mq4TimeSeries Time;

        private void CommonInitialize()
        {
            Open = new Mq4MarketDataSeries(MarketSeries.Open);
            High = new Mq4MarketDataSeries(MarketSeries.High);
            Low = new Mq4MarketDataSeries(MarketSeries.Low);
            Close = new Mq4MarketDataSeries(MarketSeries.Close);
            Volume = new Mq4MarketDataSeries(MarketSeries.TickVolume);
            Median = new Mq4MarketDataSeries(MarketSeries.Median);
            Time = new Mq4TimeSeries(MarketSeries.OpenTime);

            _cachedStandardIndicators = new CachedStandardIndicators(Indicators);
            _mq4ChartObjects = new Mq4ChartObjects(ChartObjects, MarketSeries.OpenTime);
            _mq4ArrayToDataSeriesConverterFactory = new Mq4ArrayToDataSeriesConverterFactory(() => CreateDataSeries());
        }
        private int Bars
        {
            get { return MarketSeries.Close.Count; }
        }

        Mq4Double Point
        {
            get
            {
                if (Symbol == null)
                    return 1E-05;

                return Symbol.TickSize;
            }
        }
        private int Period()
        {
            if (TimeFrame == TimeFrame.Minute)
                return 1;
            if (TimeFrame == TimeFrame.Minute2)
                return 2;
            if (TimeFrame == TimeFrame.Minute3)
                return 3;
            if (TimeFrame == TimeFrame.Minute4)
                return 4;
            if (TimeFrame == TimeFrame.Minute5)
                return 5;
            if (TimeFrame == TimeFrame.Minute10)
                return 10;
            if (TimeFrame == TimeFrame.Minute15)
                return 15;
            if (TimeFrame == TimeFrame.Minute30)
                return 30;
            if (TimeFrame == TimeFrame.Hour)
                return 60;
            if (TimeFrame == TimeFrame.Hour4)
                return 240;
            if (TimeFrame == TimeFrame.Hour12)
                return 720;
            if (TimeFrame == TimeFrame.Daily)
                return 1440;
            if (TimeFrame == TimeFrame.Weekly)
                return 10080;

            return 43200;
        }

        public TimeFrame PeriodToTimeFrame(int period)
        {
            switch (period)
            {
                case 0:
                    return TimeFrame;
                case 1:
                    return TimeFrame.Minute;
                case 2:
                    return TimeFrame.Minute2;
                case 3:
                    return TimeFrame.Minute3;
                case 4:
                    return TimeFrame.Minute4;
                case 5:
                    return TimeFrame.Minute5;
                case 10:
                    return TimeFrame.Minute10;
                case 15:
                    return TimeFrame.Minute15;
                case 30:
                    return TimeFrame.Minute30;
                case 60:
                    return TimeFrame.Hour;
                case 240:
                    return TimeFrame.Hour4;
                case 720:
                    return TimeFrame.Hour12;
                case 1440:
                    return TimeFrame.Daily;
                case 10080:
                    return TimeFrame.Weekly;
                case 43200:
                    return TimeFrame.Monthly;
                default:
                    throw new NotSupportedException(string.Format("TimeFrame {0} minutes isn't supported by cAlgo", period));
            }
        }








        Mq4Double MathCeil(double x)
        {
            return Math.Ceiling(x);
        }














        Mq4Double StrToInteger(Mq4String value)
        {
            return int.Parse(value);
        }



        int ToMq4ErrorCode(ErrorCode errorCode)
        {
            switch (errorCode)
            {
                case ErrorCode.BadVolume:
                    return ERR_INVALID_TRADE_VOLUME;
                case ErrorCode.NoMoney:
                    return ERR_NOT_ENOUGH_MONEY;
                case ErrorCode.MarketClosed:
                    return ERR_MARKET_CLOSED;
                case ErrorCode.Disconnected:
                    return ERR_NO_CONNECTION;
                case ErrorCode.Timeout:
                    return ERR_TRADE_TIMEOUT;
                default:
                    return ERR_COMMON_ERROR;
            }
        }







        int StringFind(Mq4String text, string matched_text, int start = 0)
        {
            return ((string)text).IndexOf(matched_text, start);
        }

        int StringLen(Mq4String text)
        {
            return ((string)text).Length;
        }

        Mq4String StringSubstr(Mq4String text, int start, int length = 0)
        {
            if (length == 0 || length > ((string)text).Length - start)
                return ((string)text).Substring(start, ((string)text).Length - start);

            return ((string)text).Substring(start, length);
        }
























        const string NotSupportedMaShift = "Converter supports only ma_shift = 0";
        int GetHighestIndex(DataSeries dataSeries, int count, int invertedStart)
        {
            var start = invertedStart;
            var maxIndex = start;
            var endIndex = count == WHOLE_ARRAY ? (dataSeries.Count - 1) : (count + start - 1);
            for (var i = start; i <= endIndex; i++)
            {
                if (dataSeries.Last(i) > dataSeries.Last(maxIndex))
                    maxIndex = i;
            }
            return maxIndex;
        }

        int GetLowestIndex(DataSeries dataSeries, int count, int invertedStart)
        {
            var start = invertedStart;
            var minIndex = start;
            var endIndex = count == WHOLE_ARRAY ? (dataSeries.Count - 1) : (count + start - 1);
            for (var i = start; i <= endIndex; i++)
            {
                if (dataSeries.Last(i) < dataSeries.Last(minIndex))
                    minIndex = i;
            }
            return minIndex;
        }

        int GetExtremeIndex(Func<DataSeries, intintint> extremeFunc, string symbol, int timeframe, int type, int count, int start)
        {
            var marketSeries = GetSeries(symbol, timeframe);
            switch (type)
            {
                case MODE_OPEN:
                    return extremeFunc(marketSeries.Open, count, start);
                case MODE_HIGH:
                    return extremeFunc(marketSeries.High, count, start);
                case MODE_LOW:
                    return extremeFunc(marketSeries.Low, count, start);
                case MODE_CLOSE:
                    return extremeFunc(marketSeries.Close, count, start);
                case MODE_VOLUME:
                    return extremeFunc(marketSeries.TickVolume, count, start);
                case MODE_TIME:
                    return start;
                default:
                    throw new ArgumentOutOfRangeException("wrong type for GetExtremeIndex");
            }
        }

//{
        int iHighest(Mq4String symbol, int timeframe, int type, int count = WHOLE_ARRAY, int start = 0)
        {
            return GetExtremeIndex(GetHighestIndex, symbol, timeframe, type, count, start);
        }

        int Highest(Mq4String symbol, int timeframe, int type, int count = WHOLE_ARRAY, int start = 0)
        {
            return iHighest(symbol, timeframe, type, count, start);
        }
        //}

//{
        int iLowest(Mq4String symbol, int timeframe, int type, int count = WHOLE_ARRAY, int start = 0)
        {
            return GetExtremeIndex(GetLowestIndex, symbol, timeframe, type, count, start);
        }

        int Lowest(Mq4String symbol, int timeframe, int type, int count = WHOLE_ARRAY, int start = 0)
        {
            return iLowest(symbol, timeframe, type, count, start);
        }
        //}






















//{
        int ArrayResize(IMq4DoubleArray array, int new_size)
        {
            array.Resize(new_size);
            return new_size;
        }

        int ArrayResize(Mq4DoubleTwoDimensionalArray array, int new_size)
        {
            return 0;
        }
//}

        int ArrayResize(Mq4StringArray array, int new_size)
        {
            array.Resize(new_size);
            return new_size;
        }









        private int _lastError;












        const string GlobalVariablesPath = "Software\\2calgo\\Global Variables\\";






        Symbol GetSymbol(string symbolCode)
        {
            if (symbolCode == "0" || string.IsNullOrEmpty(symbolCode))
            {
                return Symbol;
            }
            return MarketData.GetSymbol(symbolCode);
        }

        MarketSeries GetSeries(string symbol, int period)
        {
            var timeFrame = PeriodToTimeFrame(period);
            var symbolObject = GetSymbol(symbol);

            if (symbolObject == Symbol && timeFrame == TimeFrame)
                return MarketSeries;

            return MarketData.GetSeries(symbolObject.Code, timeFrame);
        }

        private DataSeries ToAppliedPrice(string symbol, int timeframe, int constant)
        {
            var series = GetSeries(symbol, timeframe);
            switch (constant)
            {
                case PRICE_OPEN:
                    return series.Open;
                case PRICE_HIGH:
                    return series.High;
                case PRICE_LOW:
                    return series.Low;
                case PRICE_CLOSE:
                    return series.Close;
                case PRICE_MEDIAN:
                    return series.Median;
                case PRICE_TYPICAL:
                    return series.Typical;
                case PRICE_WEIGHTED:
                    return series.WeightedClose;
            }
            throw new NotImplementedException("Converter doesn't support working with this type of AppliedPrice");
        }
        const string xArrow = "✖";

        public static string GetArrowByCode(int code)
        {
            switch (code)
            {
                case 0:
                    return string.Empty;
                case 32:
                    return " ";
                case 33:
                    return "✏";
                case 34:
                    return "✂";
                case 35:
                    return "✁";
                case 40:
                    return "☎";
                case 41:
                    return "✆";
                case 42:
                    return "✉";
                case 54:
                    return "⌛";
                case 55:
                    return "⌨";
                case 62:
                    return "✇";
                case 63:
                    return "✍";
                case 65:
                    return "✌";
                case 69:
                    return "☜";
                case 70:
                    return "☞";
                case 71:
                    return "☝";
                case 72:
                    return "☟";
                case 74:
                    return "☺";
                case 76:
                    return "☹";
                case 78:
                    return "☠";
                case 79:
                    return "⚐";
                case 81:
                    return "✈";
                case 82:
                    return "☼";
                case 84:
                    return "❄";
                case 86:
                    return "✞";
                case 88:
                    return "✠";
                case 89:
                    return "✡";
                case 90:
                    return "☪";
                case 91:
                    return "☯";
                case 92:
                    return "ॐ";
                case 93:
                    return "☸";
                case 94:
                    return "♈";
                case 95:
                    return "♉";
                case 96:
                    return "♊";
                case 97:
                    return "♋";
                case 98:
                    return "♌";
                case 99:
                    return "♍";
                case 100:
                    return "♎";
                case 101:
                    return "♏";
                case 102:
                    return "♐";
                case 103:
                    return "♑";
                case 104:
                    return "♒";
                case 105:
                    return "♓";
                case 106:
                    return "&";
                case 107:
                    return "&";
                case 108:
                    return "●";
                case 109:
                    return "❍";
                case 110:
                    return "■";
                case 111:
                case 112:
                    return "□";
                case 113:
                    return "❑";
                case 114:
                    return "❒";
                case 115:
                case 116:
                    return "⧫";
                case 117:
                case 119:
                    return "◆";
                case 118:
                    return "❖";
                case 120:
                    return "⌧";
                case 121:
                    return "⍓";
                case 122:
                    return "⌘";
                case 123:
                    return "❀";
                case 124:
                    return "✿";
                case 125:
                    return "❝";
                case 126:
                    return "❞";
                case 127:
                    return "▯";
                case 128:
                    return "⓪";
                case 129:
                    return "①";
                case 130:
                    return "②";
                case 131:
                    return "③";
                case 132:
                    return "④";
                case 133:
                    return "⑤";
                case 134:
                    return "⑥";
                case 135:
                    return "⑦";
                case 136:
                    return "⑧";
                case 137:
                    return "⑨";
                case 138:
                    return "⑩";
                case 139:
                    return "⓿";
                case 140:
                    return "❶";
                case 141:
                    return "❷";
                case 142:
                    return "❸";
                case 143:
                    return "❹";
                case 144:
                    return "❺";
                case 145:
                    return "❻";
                case 146:
                    return "❼";
                case 147:
                    return "❽";
                case 148:
                    return "❾";
                case 149:
                    return "❿";
                case 158:
                    return "·";
                case 159:
                    return "•";
                case 160:
                case 166:
                    return "▪";
                case 161:
                    return "○";
                case 162:
                case 164:
                    return "⭕";
                case 165:
                    return "◎";
                case 167:
                    return "✖";
                case 168:
                    return "◻";
                case 170:
                    return "✦";
                case 171:
                    return "★";
                case 172:
                    return "✶";
                case 173:
                    return "✴";
                case 174:
                    return "✹";
                case 175:
                    return "✵";
                case 177:
                    return "⌖";
                case 178:
                    return "⟡";
                case 179:
                    return "⌑";
                case 181:
                    return "✪";
                case 182:
                    return "✰";
                case 195:
                case 197:
                case 215:
                case 219:
                case 223:
                case 231:
                    return "◀";
                case 196:
                case 198:
                case 224:
                    return "▶";
                case 213:
                    return "⌫";
                case 214:
                    return "⌦";
                case 216:
                    return "➢";
                case 220:
                    return "➲";
                case 232:
                    return "➔";
                

@shabs19