Category Other  Published on 20/03/2024

pivots

Description

pivots


// ------------------------------------------------------------                   
// 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 cAlgo.API.Requests;
// ---------------------------------------------------------------------------                   
// Converted from MQ4 to cAlgo with http://2calgo.com
// ---------------------------------------------------------------------------

namespace cAlgo.Indicators
{
    [Indicator(ScalePrecision = 5, AutoRescale = false, IsOverlay = true, AccessRights = AccessRights.None)]
    [Levels()]
    public class ConvertedIndicator : Indicator
    {
        Mq4Double Mq4Init()
        {
            return 0;
            return 0;
        }
        Mq4Double deinitFunc()
        {
            ObjectDelete("PivotLine");

            ObjectDelete("R1_Line");
            ObjectDelete("R2_Line");
            ObjectDelete("R3_Line");

            ObjectDelete("S1_Line");
            ObjectDelete("S2_Line");
            ObjectDelete("S3_Line");


            ObjectDelete("PivotLabel");

            ObjectDelete("R1_Label");
            ObjectDelete("R2_Label");
            ObjectDelete("R3_Label");

            ObjectDelete("S1_Label");
            ObjectDelete("S2_Label");
            ObjectDelete("S3_Label");


            ObjectDelete("WeekPivotLine");

            ObjectDelete("WR1_Line");
            ObjectDelete("WR2_Line");
            ObjectDelete("WR3_Line");

            ObjectDelete("WS1_Line");
            ObjectDelete("WS2_Line");
            ObjectDelete("WS3_Line");


            ObjectDelete("WeekPivotLabel");

            ObjectDelete("WR1_Label");
            ObjectDelete("WR2_Label");
            ObjectDelete("WR3_Label");

            ObjectDelete("WS1_Label");
            ObjectDelete("WS2_Label");
            ObjectDelete("WS3_Label");


            ObjectDelete("MonthPivotLine");

            ObjectDelete("MR1_Line");
            ObjectDelete("MR2_Line");
            ObjectDelete("MR3_Line");

            ObjectDelete("MS1_Line");
            ObjectDelete("MS2_Line");
            ObjectDelete("MS3_Line");


            ObjectDelete("MonthPivotLabel");

            ObjectDelete("MR1_Label");
            ObjectDelete("MR2_Label");
            ObjectDelete("MR3_Label");

            ObjectDelete("MS1_Label");
            ObjectDelete("MS2_Label");
            ObjectDelete("MS3_Label");

            return 0;
            return 0;
        }
        Mq4Double Mq4Start()
        {
            ArrayCopyRates(Day_Price, (Symbol.Code), 1440);



            YesterdayHigh = Day_Price[1][3];
            YesterdayLow = Day_Price[1][2];
            YesterdayClose = Day_Price[1][4];

            Pivot = ((YesterdayHigh + YesterdayLow + YesterdayClose) / 3);

            R1 = (2 * Pivot) - YesterdayLow;
            S1 = (2 * Pivot) - YesterdayHigh;

            R2 = Pivot + (R1 - S1);
            S2 = Pivot - (R1 - S1);

            R3 = (YesterdayHigh + (2 * (Pivot - YesterdayLow)));
            S3 = (YesterdayLow - (2 * (YesterdayHigh - Pivot)));


            if (Use_Sunday_Data == false)
            {
                while (DayOfWeek() == 1)
                {


                    YesterdayHigh = Day_Price[2][3];
                    YesterdayLow = Day_Price[2][2];
                    YesterdayClose = Day_Price[2][4];

                    Pivot = ((YesterdayHigh + YesterdayLow + YesterdayClose) / 3);

                    R1 = (2 * Pivot) - YesterdayLow;
                    S1 = (2 * Pivot) - YesterdayHigh;

                    R2 = Pivot + (R1 - S1);
                    S2 = Pivot - (R1 - S1);

                    R3 = (YesterdayHigh + (2 * (Pivot - YesterdayLow)));
                    S3 = (YesterdayLow - (2 * (YesterdayHigh - Pivot)));
                    break;
                }
            }



            ArrayCopyRates(Weekly_Price, Symbol.Code, 10080);

            WeekHigh = Weekly_Price[1][3];
            WeekLow = Weekly_Price[1][2];
            WeekClose = Weekly_Price[1][4];

            WeekPivot = ((WeekHigh + WeekLow + WeekClose) / 3);

            WR1 = (2 * WeekPivot) - WeekLow;
            WS1 = (2 * WeekPivot) - WeekHigh;

            WR2 = WeekPivot + (WR1 - WS1);
            WS2 = WeekPivot - (WR1 - WS1);

            WS3 = (WeekLow - (2 * (WeekHigh - WeekPivot)));
            WR3 = (WeekHigh + (2 * (WeekPivot - WeekLow)));



            ArrayCopyRates(Month_Price, Symbol.Code, 43200);

            MonthHigh = Month_Price[1][3];
            MonthLow = Month_Price[1][2];
            MonthClose = Month_Price[1][4];

            MonthPivot = ((MonthHigh + MonthLow + MonthClose) / 3);

            MR1 = (2 * MonthPivot) - MonthLow;
            MS1 = (2 * MonthPivot) - MonthHigh;

            MR2 = MonthPivot + (MR1 - MS1);
            MS2 = MonthPivot - (MR1 - MS1);

            MS3 = (MonthLow - (2 * (MonthHigh - MonthPivot)));
            MR3 = (MonthHigh + (2 * (MonthPivot - MonthLow)));


            if (Daily == true)
            {
                TimeToStr(CurTime());
                ObjectCreate("PivotLine", OBJ_HLINE, 0, CurTime(), Pivot);
                ObjectSet("PivotLine", OBJPROP_COLOR, Magenta);
                ObjectSet("PivotLine", OBJPROP_STYLE, STYLE_DASH);

                if (ObjectFind("PivotLabel") != 0)
                {
                    ObjectCreate("PivotLabel", OBJ_TEXT, 0, Time[20], Pivot);
                    ObjectSetText("PivotLabel", ("Daily Pivot"), 12, "Arial", Magenta);
                }
                else
                {
                    ObjectMove("PivotLabel", 0, Time[20], Pivot);
                }
                ObjectsRedraw();


                if (Daily_SR_Levels == true)
                {
                    ObjectCreate("R1_Line", OBJ_HLINE, 0, CurTime(), R1);
                    ObjectSet("R1_Line", OBJPROP_COLOR, Red);
                    ObjectSet("R1_Line", OBJPROP_STYLE, STYLE_DASH);

                    if (ObjectFind("R1_Label") != 0)
                    {
                        ObjectCreate("R1_Label", OBJ_TEXT, 0, Time[20], R1);
                        ObjectSetText("R1_Label", "Daily R1", 12, "Arial", Red);
                    }
                    else
                    {
                        ObjectMove("R1_Label", 0, Time[20], R1);
                    }


                    ObjectCreate("R2_Line", OBJ_HLINE, 0, CurTime(), R2);
                    ObjectSet("R2_Line", OBJPROP_COLOR, Red);
                    ObjectSet("R2_Line", OBJPROP_STYLE, STYLE_DASH);
                    if (ObjectFind("R2_Label") != 0)
                    {
                        ObjectCreate("R2_Label", OBJ_TEXT, 0, Time[20], R2);
                        ObjectSetText("R2_Label", "Daily R2", 12, "Arial", Red);
                    }
                    else
                    {
                        ObjectMove("R2_Label", 0, Time[20], R2);
                    }


                    ObjectCreate("R3_Line", OBJ_HLINE, 0, CurTime(), R3);
                    ObjectSet("R3_Line", OBJPROP_COLOR, Red);
                    ObjectSet("R3_Line", OBJPROP_STYLE, STYLE_DASH);
                    if (ObjectFind("R3_Label") != 0)
                    {
                        ObjectCreate("R3_Label", OBJ_TEXT, 0, Time[20], R3);
                        ObjectSetText("R3_Label", "Daily R3", 12, "Arial", Red);
                    }
                    else
                    {
                        ObjectMove("R3_Label", 0, Time[20], R3);
                    }


                    ObjectCreate("S1_Line", OBJ_HLINE, 0, CurTime(), S1);
                    ObjectSet("S1_Line", OBJPROP_COLOR, LimeGreen);
                    ObjectSet("S1_Line", OBJPROP_STYLE, STYLE_DASH);
                    if (ObjectFind("S1_Label") != 0)
                    {
                        ObjectCreate("S1_Label", OBJ_TEXT, 0, Time[20], S1);
                        ObjectSetText("S1_Label", "Daily S1", 12, "Arial", DarkBlue);
                    }
                    else
                    {
                        ObjectMove("S1_Label", 0, Time[20], S1);
                    }


                    ObjectCreate("S2_Line", OBJ_HLINE, 0, CurTime(), S2);
                    ObjectSet("S2_Line", OBJPROP_COLOR, LimeGreen);
                    ObjectSet("S2_Line", OBJPROP_STYLE, STYLE_DASH);
                    if (ObjectFind("S2_Label") != 0)
                    {
                        ObjectCreate("S2_Label", OBJ_TEXT, 0, Time[20], S2);
                        ObjectSetText("S2_Label", "Daily S2", 12, "Arial", DarkBlue);
                    }
                    else
                    {
                        ObjectMove("S2_Label", 0, Time[20], S2);
                    }


                    ObjectCreate("S3_Line", OBJ_HLINE, 0, CurTime(), S3);
                    ObjectSet("S3_Line", OBJPROP_COLOR, LimeGreen);
                    ObjectSet("S3_Line", OBJPROP_STYLE, STYLE_DASH);
                    if (ObjectFind("S3_Label") != 0)
                    {
                        ObjectCreate("S3_Label", OBJ_TEXT, 0, Time[20], S3);
                        ObjectSetText("S3_Label", "Daily S3", 12, "Arial", DarkBlue);
                    }
                    else
                    {
                        ObjectMove("S3_Label", 0, Time[20], S3);
                    }
                }
                ObjectsRedraw();
            }


            if (Weekly == true)
            {
                ObjectCreate("WeekPivotLine", OBJ_HLINE, 0, CurTime(), WeekPivot);
                ObjectSet("WeekPivotLine", OBJPROP_COLOR, Aqua);
                ObjectSet("WeekPivotLine", OBJPROP_STYLE, STYLE_DASH);
                if (ObjectFind("WeekPivotLabel") != 0)
                {
                    ObjectCreate("WeekPivotLabel", OBJ_TEXT, 0, Time[30], WeekPivot);
                    ObjectSetText("WeekPivotLabel", "WeeklyPivot", 12, "Arial", Aqua);
                }
                else
                {
                    ObjectMove("WeekPivotLabel", 0, Time[30], WeekPivot);
                }


                if (Weekly_SR_Levels == true)
                {
                    ObjectCreate("WR1_Line", OBJ_HLINE, 0, CurTime(), WR1);
                    ObjectSet("WR1_Line", OBJPROP_COLOR, Yellow);
                    ObjectSet("WR1_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("WR1_Label") != 0)
                    {
                        ObjectCreate("WR1_Label", OBJ_TEXT, 0, Time[30], WR1);
                        ObjectSetText("WR1_Label", " Weekly R1", 12, "Arial", Yellow);
                    }
                    else
                    {
                        ObjectMove("WR1_Label", 0, Time[30], WR1);
                    }


                    ObjectCreate("WR2_Line", OBJ_HLINE, 0, CurTime(), WR2);
                    ObjectSet("WR2_Line", OBJPROP_COLOR, Yellow);
                    ObjectSet("WR2_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("WR2_Label") != 0)
                    {
                        ObjectCreate("WR2_Label", OBJ_TEXT, 0, Time[30], WR2);
                        ObjectSetText("WR2_Label", " Weekly R2", 12, "Arial", Yellow);
                    }
                    else
                    {
                        ObjectMove("WR2_Label", 0, Time[30], WR2);
                    }


                    ObjectCreate("WR3_Line", OBJ_HLINE, 0, CurTime(), WR3);
                    ObjectSet("WR3_Line", OBJPROP_COLOR, Yellow);
                    ObjectSet("WR3_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("WR3_Label") != 0)
                    {
                        ObjectCreate("WR3_Label", OBJ_TEXT, 0, Time[30], WR3);
                        ObjectSetText("WR3_Label", " Weekly R3", 12, "Arial", Yellow);
                    }
                    else
                    {
                        ObjectMove("WR3_Label", 0, Time[30], WR3);
                    }


                    ObjectCreate("WS1_Line", OBJ_HLINE, 0, CurTime(), WS1);
                    ObjectSet("WS1_Line", OBJPROP_COLOR, SteelBlue);
                    ObjectSet("WS1_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("WS1_Label") != 0)
                    {
                        ObjectCreate("WS1_Label", OBJ_TEXT, 0, Time[30], WS1);
                        ObjectSetText("WS1_Label", "Weekly S1", 12, "Arial", SteelBlue);
                    }
                    else
                    {
                        ObjectMove("WS1_Label", 0, Time[30], WS1);
                    }


                    ObjectCreate("WS2_Line", OBJ_HLINE, 0, CurTime(), WS2);
                    ObjectSet("WS2_Line", OBJPROP_COLOR, SteelBlue);
                    ObjectSet("WS2_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("WS2_Label") != 0)
                    {
                        ObjectCreate("WS2_Label", OBJ_TEXT, 0, Time[30], WS2);
                        ObjectSetText("WS2_Label", "Weekly S2", 12, "Arial", SteelBlue);
                    }
                    else
                    {
                        ObjectMove("WS2_Label", 0, Time[30], WS2);
                    }


                    ObjectCreate("WS3_Line", OBJ_HLINE, 0, CurTime(), WS3);
                    ObjectSet("WS3_Line", OBJPROP_COLOR, SteelBlue);
                    ObjectSet("WS3_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("WS3_Label") != 0)
                    {
                        ObjectCreate("WS3_Label", OBJ_TEXT, 0, Time[30], WS3);
                        ObjectSetText("WS3_Label", "Weekly S3", 12, "Arial", SteelBlue);
                    }
                    else
                    {
                        ObjectMove("WS3_Label", 0, Time[30], WS3);
                    }
                }
            }


            if (Monthly == true)
            {
                ObjectCreate("MonthPivotLine", OBJ_HLINE, 0, CurTime(), MonthPivot);
                ObjectSet("MonthPivotLine", OBJPROP_COLOR, Black);
                ObjectSet("MonthPivotLine", OBJPROP_STYLE, STYLE_DASH);
                if (ObjectFind("MonthPivotLabel") != 0)
                {
                    ObjectCreate("MonthPivotLabel", OBJ_TEXT, 0, Time[40], MonthPivot);
                    ObjectSetText("MonthPivotLabel", "MonthlyPivot", 12, "Arial", Black);
                }
                else
                {
                    ObjectMove("MonthPivotLabel", 0, Time[40], MonthPivot);
                }


                if (Monthly_SR_Levels == true)
                {
                    ObjectCreate("MR1_Line", OBJ_HLINE, 0, CurTime(), MR1);
                    ObjectSet("MR1_Line", OBJPROP_COLOR, Blue);
                    ObjectSet("MR1_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("MR1_Label") != 0)
                    {
                        ObjectCreate("MR1_Label", OBJ_TEXT, 0, Time[40], MR1);
                        ObjectSetText("MR1_Label", " Monthly R1", 12, "Arial", Blue);
                    }
                    else
                    {
                        ObjectMove("MR1_Label", 0, Time[40], MR1);
                    }


                    ObjectCreate("MR2_Line", OBJ_HLINE, 0, CurTime(), MR2);
                    ObjectSet("MR2_Line", OBJPROP_COLOR, Blue);
                    ObjectSet("MR2_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("MR2_Label") != 0)
                    {
                        ObjectCreate("MR2_Label", OBJ_TEXT, 0, Time[40], MR2);
                        ObjectSetText("MR2_Label", " Monthly R2", 12, "Arial", Blue);
                    }
                    else
                    {
                        ObjectMove("MR2_Label", 0, Time[40], MR2);
                    }


                    ObjectCreate("MR3_Line", OBJ_HLINE, 0, CurTime(), MR3);
                    ObjectSet("MR3_Line", OBJPROP_COLOR, Blue);
                    ObjectSet("MR3_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("MR3_Label") != 0)
                    {
                        ObjectCreate("MR3_Label", OBJ_TEXT, 0, Time[40], MR3);
                        ObjectSetText("MR3_Label", " Monthly R3", 12, "Arial", Blue);
                    }
                    else
                    {
                        ObjectMove("MR3_Label", 0, Time[40], MR3);
                    }


                    ObjectCreate("MS1_Line", OBJ_HLINE, 0, CurTime(), MS1);
                    ObjectSet("MS1_Line", OBJPROP_COLOR, Silver);
                    ObjectSet("MS1_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("MS1_Label") != 0)
                    {
                        ObjectCreate("MS1_Label", OBJ_TEXT, 0, Time[40], MS1);
                        ObjectSetText("MS1_Label", "Monthly S1", 12, "Arial", Silver);
                    }
                    else
                    {
                        ObjectMove("MS1_Label", 0, Time[40], MS1);
                    }


                    ObjectCreate("MS2_Line", OBJ_HLINE, 0, CurTime(), MS2);
                    ObjectSet("MS2_Line", OBJPROP_COLOR, Silver);
                    ObjectSet("MS2_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("MS2_Label") != 0)
                    {
                        ObjectCreate("MS2_Label", OBJ_TEXT, 0, Time[40], MS2);
                        ObjectSetText("MS2_Label", "Monthly S2", 12, "Arial", Silver);
                    }
                    else
                    {
                        ObjectMove("MS2_Label", 0, Time[40], MS2);
                    }


                    ObjectCreate("MS3_Line", OBJ_HLINE, 0, CurTime(), MS3);
                    ObjectSet("MS3_Line", OBJPROP_COLOR, Silver);
                    ObjectSet("MS3_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
                    if (ObjectFind("MS3_Label") != 0)
                    {
                        ObjectCreate("MS3_Label", OBJ_TEXT, 0, Time[40], MS3);
                        ObjectSetText("MS3_Label", "Monthly S3", 12, "Arial", Silver);
                    }
                    else
                    {
                        ObjectMove("MS3_Label", 0, Time[40], MS3);
                    }
                }
            }

            ObjectsRedraw();

            return 0;
            return 0;
        }

        [Parameter("Use_Sunday_Data", DefaultValue = True)]
        public bool Use_Sunday_Data_parameter { get; set; }
        bool _Use_Sunday_DataGot;
        Mq4Double Use_Sunday_Data_backfield;
        Mq4Double Use_Sunday_Data
        {
            get
            {
                if (!_Use_Sunday_DataGot)
                    Use_Sunday_Data_backfield = Use_Sunday_Data_parameter;
                return Use_Sunday_Data_backfield;
            }
            set { Use_Sunday_Data_backfield = value; }
        }

        [Parameter("Daily", DefaultValue = True)]
        public bool Daily_parameter { get; set; }
        bool _DailyGot;
        Mq4Double Daily_backfield;
        Mq4Double Daily
        {
            get
            {
                if (!_DailyGot)
                    Daily_backfield = Daily_parameter;
                return Daily_backfield;
            }
            set { Daily_backfield = value; }
        }

        [Parameter("Daily_SR_Levels", DefaultValue = True)]
        public bool Daily_SR_Levels_parameter { get; set; }
        bool _Daily_SR_LevelsGot;
        Mq4Double Daily_SR_Levels_backfield;
        Mq4Double Daily_SR_Levels
        {
            get
            {
                if (!_Daily_SR_LevelsGot)
                    Daily_SR_Levels_backfield = Daily_SR_Levels_parameter;
                return Daily_SR_Levels_backfield;
            }
            set { Daily_SR_Levels_backfield = value; }
        }

        [Parameter("Weekly", DefaultValue = True)]
        public bool Weekly_parameter { get; set; }
        bool _WeeklyGot;
        Mq4Double Weekly_backfield;
        Mq4Double Weekly
        {
            get
            {
                if (!_WeeklyGot)
                    Weekly_backfield = Weekly_parameter;
                return Weekly_backfield;
            }
            set { Weekly_backfield = value; }
        }

        [Parameter("Weekly_SR_Levels", DefaultValue = False)]
        public bool Weekly_SR_Levels_parameter { get; set; }
        bool _Weekly_SR_LevelsGot;
        Mq4Double Weekly_SR_Levels_backfield;
        Mq4Double Weekly_SR_Levels
        {
            get
            {
                if (!_Weekly_SR_LevelsGot)
                    Weekly_SR_Levels_backfield = Weekly_SR_Levels_parameter;
                return Weekly_SR_Levels_backfield;
            }
            set { Weekly_SR_Levels_backfield = value; }
        }

        [Parameter("Monthly", DefaultValue = True)]
        public bool Monthly_parameter { get; set; }
        bool _MonthlyGot;
        Mq4Double Monthly_backfield;
        Mq4Double Monthly
        {
            get
            {
                if (!_MonthlyGot)
                    Monthly_backfield = Monthly_parameter;
                return Monthly_backfield;
            }
            set { Monthly_backfield = value; }
        }

        [Parameter("Monthly_SR_Levels", DefaultValue = False)]
        public bool Monthly_SR_Levels_parameter { get; set; }
        bool _Monthly_SR_LevelsGot;
        Mq4Double Monthly_SR_Levels_backfield;
        Mq4Double Monthly_SR_Levels
        {
            get
            {
                if (!_Monthly_SR_LevelsGot)
                    Monthly_SR_Levels_backfield = Monthly_SR_Levels_parameter;
                return Monthly_SR_Levels_backfield;
            }
            set { Monthly_SR_Levels_backfield = value; }
        }





        Mq4Double MR3;
        Mq4Double MR2;
        Mq4Double MR1;
        Mq4Double MS3;
        Mq4Double MS2;
        Mq4Double MS1;
        Mq4Double MonthPivot;
        Mq4DoubleTwoDimensionalArray Month_Price = new Mq4DoubleTwoDimensionalArray(6);
        Mq4Double MonthClose;
        Mq4Double MonthLow;
        Mq4Double MonthHigh;
        Mq4Double WR3;
        Mq4Double WR2;
        Mq4Double WR1;
        Mq4Double WS3;
        Mq4Double WS2;
        Mq4Double WS1;
        Mq4Double WeekPivot;
        Mq4DoubleTwoDimensionalArray Weekly_Price = new Mq4DoubleTwoDimensionalArray(6);
        Mq4Double WeekClose;
        Mq4Double WeekLow;
        Mq4Double WeekHigh;
        Mq4Double R3;
        Mq4Double R2;
        Mq4Double R1;
        Mq4Double S3;
        Mq4Double S2;
        Mq4Double S1;
        Mq4Double Pivot;
        Mq4DoubleTwoDimensionalArray Day_Price = new Mq4DoubleTwoDimensionalArray(6);
        Mq4Double YesterdayClose;
        Mq4Double YesterdayLow;
        Mq4Double YesterdayHigh;

        int indicator_buffers = 0;


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






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

        protected override void Initialize()
        {



            CommonInitialize();

        }

        private bool _initialized;
        public override void Calculate(int index)
        {
            try
            {
                _currentIndex = 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; }
        }

        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));
            }
        }























        Mq4String TimeToStr(int value, int mode = TIME_DATE | TIME_MINUTES)
        {
            var formatString = "";
            if ((mode & TIME_DATE) != 0)
                formatString += "yyyy.MM.dd ";
            if ((mode & TIME_SECONDS) != 0)
                formatString += "HH:mm:ss";
            else if ((mode & TIME_MINUTES) != 0)
                formatString += "HH:mm";
            formatString = formatString.Trim();

            return Mq4TimeSeries.ToDateTime(value).ToString(formatString);
        }


        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;
            }
        }


        void ObjectsRedraw()
        {
        }












        int DayOfWeek()
        {
            return (int)Server.Time.DayOfWeek;
        }






        int TimeCurrent()
        {
            return Mq4TimeSeries.ToInteger(Server.Time);
        }

        int CurTime()
        {
            return TimeCurrent();
        }












        const string NotSupportedMaShift = "Converter supports only ma_shift = 0";





































        Mq4Double ArrayCopyRates(Mq4DoubleTwoDimensionalArray array, Mq4String symbol = null, int timeframe = 0)
        {
            var marketSeries = GetSeries(symbol, timeframe);

            for (var i = 0; i < MarketSeries.Open.Count; i++)
            {
                array[i][0] = Mq4TimeSeries.ToInteger(marketSeries.OpenTime.Last(i));
                array[i][1] = marketSeries.Open.Last(i);
                array[i][2] = marketSeries.Low.Last(i);
                array[i][3] = marketSeries.High.Last(i);
                array[i][4] = marketSeries.Close.Last(i);
                array[i][5] = marketSeries.TickVolume.Last(i);
            }

            return MarketSeries.Open.Count;
        }


        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 "➔";
                case 233:
                case 199:
                case 200:
                case 217:
                case 221:
                case 225:
                    return "◭";
                case 234:
                case 201:
                case 202:
                case 218:
                case 222:
                case 226:
                    return "⧨";
                case 239:
                    return "⇦";
                case 240:
                    return "⇨";
                case 241:
                    return "◭";
                case 242:
                    return "⧨";
                case 243:
                    return "⬄";
                case 244:
                    return "⇳";
                case 245:
                case 227:
                case 235:
                    return "↖";
                case 246:
                case 228:
                case 236:
                    return "↗";
                case 247:
                case 229:
                case 237:
                    return "↙";
                case 248:
                case 230:
                case 238:
                    return "↘";
                case 249:
                    return "▭";
                case 250:
                    return "▫";
                case 251:
                    return "✗";
                case 252:
                    return "✓";
                case 253:
                    return "☒";
                case 254:
                    return "☑";
                default:
                    return xArrow;
            }
        }
        class Mq4OutputDataSeries : IMq4DoubleArray
        {
            public IndicatorDataSeries OutputDataSeries { get; private set; }
            private readonly IndicatorDataSeries _originalValues;
            private int _currentIndex;
            private int _shift;
            private double _emptyValue = EMPTY_VALUE;
            private readonly ChartObjects _chartObjects;
            private readonly int _style;
            private readonly int _bufferIndex;
            private readonly ConvertedIndicator _indicator;

            public Mq4OutputDataSeries(ConvertedIndicator indicator, IndicatorDataSeries outputDataSeries, ChartObjects chartObjects, int style, int bufferIndex, Func<IndicatorDataSeries> dataSeriesFactory, int lineWidth, Colors? color = null)
            {
                OutputDataSeries = outputDataSeries;
                _chartObjects = chartObjects;
                _style = style;
                _bufferIndex = bufferIndex;
                _indicator = indicator;
                Color = color;
                _originalValues = dataSeriesFactory();
                LineWidth = lineWidth;
            }

            public int LineWidth { get; private set; }
            public Colors? Color { get; private set; }

            public int Length
            {
                get { return OutputDataSeries.Count; }
            }

            public void Resize(int newSize)
            {
            }

            public void SetCurrentIndex(int index)
            {
                _currentIndex = index;
            }

            public void SetShift(int shift)
            {
                _shift = shift;
            }

            public void SetEmptyValue(double emptyValue)
            {
                _emptyValue = emptyValue;
            }

            public Mq4Double this[int index]
            {
                get
                {
                    var indexToGetFrom = _currentIndex - index + _shift;
                    if (indexToGetFrom < 0 || indexToGetFrom > _currentIndex)
                        return 0;
                    if (indexToGetFrom >= _originalValues.Count)
                        return _emptyValue;

                    return _originalValues[indexToGetFrom];
                }
                set
                {
                    var indexToSet = _currentIndex - index + _shift;
                    if (indexToSet < 0)
                        return;

                    _originalValues[indexToSet] = value;

                    var valueToSet = value;
                    if (valueToSet == _emptyValue)
                        valueToSet = double.NaN;

                    if (indexToSet < 0)
                        return;

                    OutputDataSeries[indexToSet] = valueToSet;

                    switch (_style)
                    {
                        case DRAW_ARROW:
                            var arrowName = GetArrowName(indexToSet);
                            if (double.IsNaN(valueToSet))
                                _chartObjects.RemoveObject(arrowName);
                            else
                            {
                                var color = Color.HasValue ? Color.Value : Colors.Red;
                                _chartObjects.DrawText(arrowName, _indicator.ArrowByIndex[_bufferIndex], indexToSet, valueToSet, VerticalAlignment.Center, HorizontalAlignment.Center, color);
                            }
                            break;
                        case DRAW_HISTOGRAM:
                            if (true)
                            {
                                var anotherLine = _indicator.AllBuffers.FirstOrDefault(b => b.LineWidth == LineWidth && b != this);
                                if (anotherLine != null)
                                {
                                    var name = GetNameOfHistogramLineOnChartWindow(indexToSet);
                                    Colors color;
                                    if (this[index] > anotherLine[index])
                                        color = Color ?? Colors.Green;
                                    else
                                        color = anotherLine.Color ?? Colors.Green;
                                    var lineWidth = LineWidth;
                                    if (lineWidth != 1 && lineWidth < 5)
                                        lineWidth = 5;

                                    _chartObjects.DrawLine(name, indexToSet, this[index], indexToSet, anotherLine[index], color, lineWidth);
                                }
                            }
                            break;
                    }
                }
            }

            private string GetNameOfHistogramLineOnChartWindow(int index)
            {
                return string.Format("Histogram on chart window {0} {1}", LineWidth, index);
            }

            private string GetArrowName(int index)
            {
                return string.Format("Arrow {0} {1}", GetHashCode(), index);
            }
        }
















        public Dictionary<int, string> ArrowByIndex = new Dictionary<int, string> 
        {
            {
                0,
                xArrow
            },
            {
                1,
                xArrow
            },
            {
                2,
                xArrow
            },
            {
                3,
                xArrow
            },
            {
                4,
                xArrow
            },
            {
                5,
                xArrow
            },
            {
                6,
                xArrow
            },
            {
                7,
                xArrow
            }
        };
        void SetIndexArrow(int index, int code)
        {
            ArrowByIndex[index] = GetArrowByCode(code);
        }

        private int _indicatorCounted;
        int FILE_READ = 1;
        int FILE_WRITE = 2;
//int FILE_BIN = 8;
        int FILE_CSV = 8;

        int SEEK_END = 2;

        class FileInfo
        {
            public int Mode { get; set; }
            public int Handle { get; set; }
            public char Separator { get; set; }
            public string FileName { get; set; }
            public List<string> PendingParts { get; set; }
            public StreamWriter StreamWriter { get; set; }
            public StreamReader StreamReader { get; set; }
        }

        private Dictionary<int, FileInfo> _openedFiles = new Dictionary<int, FileInfo>();
        private int _handleCounter = 1000;







        class FolderPaths
        {
            public static string _2calgoAppDataFolder
            {
                get
                {
                    var result = Path.Combine(SystemAppData, "2calgo");
                    if (!Directory.Exists(result))
                        Directory.CreateDirectory(result);
                    return result;
                }
            }

            public static string _2calgoDesktopFolder
            {
                get
                {
                    var result = Path.Combine(Desktop, "2calgo");
                    if (!Directory.Exists(result))
                        Directory.CreateDirectory(result);
                    return result;
                }
            }

            static string SystemAppData
            {
                get { return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); }
            }

            static string Desktop
            {
                get { return Environment.GetFolderPath(Environment.SpecialFolder.Desktop); }
            }
        }
        const int MODE_TRADES = 0;
        const int MODE_HISTORY = 1;
        const int SELECT_BY_POS = 0;
        const int SELECT_BY_TICKET = 1;

        T GetPropertyValue<T>(Func<Position, T> getFromPosition, Func<PendingOrder, T> getFromPendingOrder, Func<HistoricalTrade, T> getFromHistory)
        {
            if (_currentOrder == null)
                return default(T);

            return GetPropertyValue<T>(_currentOrder, getFromPosition, getFromPendingOrder, getFromHistory);
        }

        T GetPropertyValue<T>(object obj, Func<Position, T> getFromPosition, Func<PendingOrder, T> getFromPendingOrder, Func<HistoricalTrade, T> getFromHistory)
        {
            if (obj is Position)
                return getFromPosition((Position)obj);
            if (obj is PendingOrder)
                return getFromPendingOrder((PendingOrder)obj);

            return getFromHistory((HistoricalTrade)obj);
        }

        private Mq4Double GetTicket(object trade)
        {
            return new Mq4Double(GetPropertyValue<int>(trade, _ => _.Id, _ => _.Id, _ => _.ClosingDealId));
        }
        private int GetMagicNumber(string label)
        {
            int magicNumber;
            if (int.TryParse(label, out magicNumber))
                return magicNumber;

            return 0;
        }

        private int GetMagicNumber(object order)
        {
            var label = GetPropertyValue<string>(order, _ => _.Label, _ => _.Label, _ => _.Label);
            return GetMagicNumber(label);
        }




        object _currentOrder;
        double GetLots(object order)
        {
            var volume = GetPropertyValue<long>(order, _ => _.Volume, _ => _.Volume, _ => _.Volume);
            var symbolCode = GetPropertyValue<string>(order, _ => _.SymbolCode, _ => _.SymbolCode, _ => _.SymbolCode);
            var symbolObject = MarketData.GetSymbol(symbolCode);

            return symbolObject.ToLotsVolume(volume);
        }

        object GetOrderByTicket(int ticket)
        {
            var allOrders = Positions.OfType<object>().Concat(PendingOrders.OfType<object>()).ToArray();

            return allOrders.FirstOrDefault(_ => GetTicket(_) == ticket);
        }


        double GetOpenPrice(object order)
        {
            return GetPropertyValue<double>(order, _ => _.EntryPrice, _ => _.TargetPrice, _ => _.EntryPrice);
        }


        private double GetStopLoss(object order)
        {
            var nullableValue = GetPropertyValue<double?>(order, _ => _.StopLoss, _ => _.StopLoss, _ => 0);
            return nullableValue ?? 0;
        }

        private double GetTakeProfit(object order)
        {
            var nullableValue = GetPropertyValue<double?>(order, _ => _.TakeProfit, _ => _.TakeProfit, _ => 0);
            return nullableValue ?? 0;
        }























        class ParametersKey
        {
            private readonly object[] _parameters;

            public ParametersKey(params object[] parameters)
            {
                _parameters = parameters;
            }

            public override bool Equals(object obj)
            {
                var other = (ParametersKey)obj;
                for (var i = 0; i < _parameters.Length; i++)
                {
                    if (!_parameters[i].Equals(other._parameters[i]))
                        return false;
                }
                return true;
            }

            public override int GetHashCode()
            {
                unchecked
                {
                    var hashCode = 0;
                    foreach (var parameter in _parameters)
                    {
                        hashCode = (hashCode * 397) ^ parameter.GetHashCode();
                    }
                    return hashCode;
                }
            }
        }

        class Cache<TValue>
        {
            private Dictionary<ParametersKey, TValue> _dictionary = new Dictionary<ParametersKey, TValue>();

            public bool TryGetValue(out TValue value, params object[] parameters)
            {
                var key = new ParametersKey(parameters);
                return _dictionary.TryGetValue(key, out value);
            }

            public void Add(TValue value, params object[] parameters)
            {
                var key = new ParametersKey(parameters);
                _dictionary.Add(key, value);
            }
        }


        private static MovingAverageType ToMaType(int constant)
        {
            switch (constant)
            {
                case MODE_SMA:
                    return MovingAverageType.Simple;
                case MODE_EMA:
                    return MovingAverageType.Exponential;
                case MODE_LWMA:
                    return MovingAverageType.Weighted;
                default:
                    throw new ArgumentOutOfRangeException("Not supported moving average type");
            }
        }


























        class CachedStandardIndicators
        {
            private readonly IIndicatorsAccessor _indicatorsAccessor;

            public CachedStandardIndicators(IIndicatorsAccessor indicatorsAccessor)
            {
                _indicatorsAccessor = indicatorsAccessor;
            }

        }
        const bool True = true;
        const bool False = false;
        const bool TRUE = true;
        const bool FALSE = false;
        Mq4Null NULL;
        const int EMPTY = -1;
        const double EMPTY_VALUE = 2147483647;
        public const int WHOLE_ARRAY = 0;

        const int MODE_SMA = 0;
        //Simple moving average
        const int MODE_EMA = 1;
        //Exponential moving average,
        const int MODE_SMMA = 2;
        //Smoothed moving average,
        const int MODE_LWMA = 3;
        //Linear weighted moving average. 
        const int PRICE_CLOSE = 0;
        //Close price. 
        const int PRICE_OPEN = 1;
        //Open price. 
        const int PRICE_HIGH = 2;
        //High price. 
        const int PRICE_LOW = 3;
        //Low price. 
        const int PRICE_MEDIAN = 4;
        //Median price, (high+low)/2. 
        const int PRICE_TYPICAL = 5;
        //Typical price, (high+low+close)/3. 
        const int PRICE_WEIGHTED = 6;
        //Weighted close price, (high+low+close+close)/4. 
        const int DRAW_LINE = 0;
        const int DRAW_SECTION = 1;
        const int DRAW_HISTOGRAM = 2;
        const int DRAW_ARROW = 3;
        const int DRAW_ZIGZAG = 4;
        const int DRAW_NONE = 12;

        const int STYLE_SOLID = 0;
        const int STYLE_DASH = 1;
        const int STYLE_DOT = 2;
        const int STYLE_DASHDOT = 3;
        const int STYLE_DASHDOTDOT = 4;

        const int MODE_OPEN = 0;
        const int MODE_LOW = 1;
        const int MODE_HIGH = 2;
        const int MODE_CLOSE = 3;
        const int MODE_VOLUME = 4;
        const int MODE_TIME = 5;
        const int MODE_BID = 9;
        const int MODE_ASK = 10;
        const int MODE_POINT = 11;
        const int MODE_DIGITS = 12;
        const int MODE_SPREAD = 13;
        const int MODE_TRADEALLOWED = 22;
        const int MODE_PROFITCALCMODE = 27;
        const int MODE_MARGINCALCMODE = 28;
        const int MODE_SWAPTYPE = 26;
        const int MODE_TICKSIZE = 17;
        const int MODE_FREEZELEVEL = 33;
        const int MODE_STOPLEVEL = 14;
        const int MODE_LOTSIZE = 15;
        const int MODE_TICKVALUE = 16;
        /*const int MODE_SWAPLONG = 18;
const int MODE_SWAPSHORT = 19;
const int MODE_STARTING = 20;
const int MODE_EXPIRATION = 21;    
*/
        const int MODE_MINLOT = 23;
        const int MODE_LOTSTEP = 24;
        const int MODE_MAXLOT = 25;
        /*const int MODE_MARGININIT = 29;
const int MODE_MARGINMAINTENANCE = 30;
const int MODE_MARGINHEDGED = 31;*/
        const int MODE_MARGINREQUIRED = 32;

        const int OBJ_VLINE = 0;
        const int OBJ_HLINE = 1;
        const int OBJ_TREND = 2;
        const int OBJ_FIBO = 10;

        /*const int OBJ_TRENDBYANGLE = 3;
    const int OBJ_REGRESSION = 4;
    const int OBJ_CHANNEL = 5;
    const int OBJ_STDDEVCHANNEL = 6;
    const int OBJ_GANNLINE = 7;
    const int OBJ_GANNFAN = 8;
    const int OBJ_GANNGRID = 9;
    const int OBJ_FIBOTIMES = 11;
    const int OBJ_FIBOFAN = 12;
    const int OBJ_FIBOARC = 13;
    const int OBJ_EXPANSION = 14;
    const int OBJ_FIBOCHANNEL = 15;*/
        const int OBJ_RECTANGLE = 16;
        /*const int OBJ_TRIANGLE = 17;
    const int OBJ_ELLIPSE = 18;
    const int OBJ_PITCHFORK = 19;
    const int OBJ_CYCLES = 20;*/
        const int OBJ_TEXT = 21;
        const int OBJ_ARROW = 22;
        const int OBJ_LABEL = 23;

        const int OBJPROP_TIME1 = 0;
        const int OBJPROP_PRICE1 = 1;
        const int OBJPROP_TIME2 = 2;
        const int OBJPROP_PRICE2 = 3;
        const int OBJPROP_TIME3 = 4;
        const int OBJPROP_PRICE3 = 5;
        const int OBJPROP_COLOR = 6;
        const int OBJPROP_STYLE = 7;
        const int OBJPROP_WIDTH = 8;
        const int OBJPROP_BACK = 9;
        const int OBJPROP_RAY = 10;
        const int OBJPROP_ELLIPSE = 11;
        //const int OBJPROP_SCALE = 12;
        const int OBJPROP_ANGLE = 13;
        //angle for text rotation
        const int OBJPROP_ARROWCODE = 14;
        const int OBJPROP_TIMEFRAMES = 15;
        //const int OBJPROP_DEVIATION = 16;
        const int OBJPROP_FONTSIZE = 100;
        const int OBJPROP_CORNER = 101;
        const int OBJPROP_XDISTANCE = 102;
        const int OBJPROP_YDISTANCE = 103;
        const int OBJPROP_FIBOLEVELS = 200;
        const int OBJPROP_LEVELCOLOR = 201;
        const int OBJPROP_LEVELSTYLE = 202;
        const int OBJPROP_LEVELWIDTH = 203;
        const int OBJPROP_FIRSTLEVEL = 210;

        const int PERIOD_M1 = 1;
        const int PERIOD_M5 = 5;
        const int PERIOD_M15 = 15;
        const int PERIOD_M30 = 30;
        const int PERIOD_H1 = 60;
        const int PERIOD_H4 = 240;
        const int PERIOD_D1 = 1440;
        const int PERIOD_W1 = 10080;
        const int PERIOD_MN1 = 43200;

        const int TIME_DATE = 1;
        const int TIME_MINUTES = 2;
        const int TIME_SECONDS = 4;

        const int MODE_MAIN = 0;
        const int MODE_BASE = 0;
        const int MODE_PLUSDI = 1;
        const int MODE_MINUSDI = 2;
        const int MODE_SIGNAL = 1;

        const int MODE_UPPER = 1;
        const int MODE_LOWER = 2;

        const int MODE_GATORLIPS = 3;
        const int MODE_GATORJAW = 1;
        const int MODE_GATORTEETH = 2;

        const int CLR_NONE = 32768;

        const int White = 16777215;
        const int Snow = 16448255;
        const int MintCream = 16449525;
        const int LavenderBlush = 16118015;
        const int AliceBlue = 16775408;
        const int Honeydew = 15794160;
        const int Ivory = 15794175;
        const int Seashell = 15660543;
        const int WhiteSmoke = 16119285;
        const int OldLace = 15136253;
        const int MistyRose = 14804223;
        const int Lavender = 16443110;
        const int Linen = 15134970;
        const int LightCyan = 16777184;
        const int LightYellow = 14745599;
        const int Cornsilk = 14481663;
        const int PapayaWhip = 14020607;
        const int AntiqueWhite = 14150650;
        const int Beige = 14480885;
        const int LemonChiffon = 13499135;
        const int BlanchedAlmond = 13495295;
        const int LightGoldenrod = 13826810;
        const int Bisque = 12903679;
        const int Pink = 13353215;
        const int PeachPuff = 12180223;
        const int Gainsboro = 14474460;
        const int LightPink = 12695295;
        const int Moccasin = 11920639;
        const int NavajoWhite = 11394815;
        const int Wheat = 11788021;
        const int LightGray = 13882323;
        const int PaleTurquoise = 15658671;
        const int PaleGoldenrod = 11200750;
        const int PowderBlue = 15130800;
        const int Thistle = 14204888;
        const int PaleGreen = 10025880;
        const int LightBlue = 15128749;
        const int LightSteelBlue = 14599344;
        const int LightSkyBlue = 16436871;
        const int Silver = 12632256;
        const int Aquamarine = 13959039;
        const int LightGreen = 9498256;
        const int Khaki = 9234160;
        const int Plum = 14524637;
        const int LightSalmon = 8036607;
        const int SkyBlue = 15453831;
        const int LightCoral = 8421616;
        const int Violet = 15631086;
        const int Salmon = 7504122;
        const int HotPink = 11823615;
        const int BurlyWood = 8894686;
        const int DarkSalmon = 8034025;
        const int Tan = 9221330;
        const int MediumSlateBlue = 15624315;
        const int SandyBrown = 6333684;
        const int DarkGray = 11119017;
        const int CornflowerBlue = 15570276;
        const int Coral = 5275647;
        const int PaleVioletRed = 9662683;
        const int MediumPurple = 14381203;
        const int Orchid = 14053594;
        const int RosyBrown = 9408444;
        const int Tomato = 4678655;
        const int DarkSeaGreen = 9419919;
        const int Cyan = 16776960;
        const int MediumAquamarine = 11193702;
        const int GreenYellow = 3145645;
        const int MediumOrchid = 13850042;
        const int IndianRed = 6053069;
        const int DarkKhaki = 7059389;
        const int SlateBlue = 13458026;
        const int RoyalBlue = 14772545;
        const int Turquoise = 13688896;
        const int DodgerBlue = 16748574;
        const int MediumTurquoise = 13422920;
        const int DeepPink = 9639167;
        const int LightSlateGray = 10061943;
        const int BlueViolet = 14822282;
        const int Peru = 4163021;
        const int SlateGray = 9470064;
        const int Gray = 8421504;
        const int Red = 255;
        const int Magenta = 16711935;
        const int Blue = 16711680;
        const int DeepSkyBlue = 16760576;
        const int Aqua = 16776960;
        const int SpringGreen = 8388352;
        const int Lime = 65280;
        const int Chartreuse = 65407;
        const int Yellow = 65535;
        const int Gold = 55295;
        const int Orange = 42495;
        const int DarkOrange = 36095;
        const int OrangeRed = 17919;
        const int LimeGreen = 3329330;
        const int YellowGreen = 3329434;
        const int DarkOrchid = 13382297;
        const int CadetBlue = 10526303;
        const int LawnGreen = 64636;
        const int MediumSpringGreen = 10156544;
        const int Goldenrod = 2139610;
        const int SteelBlue = 11829830;
        const int Crimson = 3937500;
        const int Chocolate = 1993170;
        const int MediumSeaGreen = 7451452;
        const int MediumVioletRed = 8721863;
        const int FireBrick = 2237106;
        const int DarkViolet = 13828244;
        const int LightSeaGree

AR
arturo.bedolla

Joined on 20.03.2024

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Auto Pivot Points (1).algo
  • Rating: 0
  • Installs: 336
Comments
Log in to add a comment.
AR
arturo.bedolla · 3 months ago

pivots point