Draw Pips free

by yomm0401 in category Other at 25/06/2020
Description
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None, AutoRescale = false)]

    public class DrawPips : Indicator
    {
        public enum calbase
        {
            Bid,
            Ask
        }

        [Parameter("Base Calculate", DefaultValue = "Ask")]
        public calbase Calbase { get; set; }

        [Parameter("Line Offset Minus", DefaultValue = 1, MinValue = 0)]
        public int mOffset { get; set; }

        [Parameter("Label Color", DefaultValue = "Black")]
        public string tColor { get; set; }

        [Parameter("Show", Group = "Stop 1", DefaultValue = true)]
        public bool _show1 { get; set; }

        [Parameter("Show", Group = "Stop 2", DefaultValue = true)]
        public bool _show2 { get; set; }

        [Parameter("Stop 1 pips", Group = "Stop 1", DefaultValue = 20, MinValue = 1)]
        public int stop1Pips { get; set; }

        [Parameter("Stop 2 pips", Group = "Stop 2", DefaultValue = 30, MinValue = 1)]
        public int stop2Pips { get; set; }

        [Parameter("Label", Group = "Stop 1", DefaultValue = true)]
        public bool _showl1 { get; set; }

        [Parameter("Label", Group = "Stop 2", DefaultValue = true)]
        public bool _showl2 { get; set; }

        [Parameter("Label Offset", Group = "Stop 1", DefaultValue = 0)]
        public int lOffset1 { get; set; }

        [Parameter("Label Offset", Group = "Stop 2", DefaultValue = 0)]
        public int lOffset2 { get; set; }

        [Parameter("Line Offset", Group = "Stop 1", DefaultValue = 3, MinValue = 0)]
        public int Offset1 { get; set; }

        [Parameter("Line Offset", Group = "Stop 2", DefaultValue = 5, MinValue = 0)]
        public int Offset2 { get; set; }

        [Parameter("Linestyle", Group = "Stop 1", DefaultValue = LineStyle.Dots)]
        public LineStyle LineStyle1 { get; set; }

        [Parameter("Linestyle", Group = "Stop 2", DefaultValue = LineStyle.Solid)]
        public LineStyle LineStyle2 { get; set; }

        [Parameter("Line Color", Group = "Stop 1", DefaultValue = "Black")]
        public string lColor1 { get; set; }

        [Parameter("Line Color", Group = "Stop 2", DefaultValue = "Red")]
        public string lColor2 { get; set; }

        [Parameter("Line thickness", Group = "Stop 1", DefaultValue = 1, MinValue = 0)]
        public int thickness1 { get; set; }

        [Parameter("Line thickness", Group = "Stop 2", DefaultValue = 1, MinValue = 0)]
        public int thickness2 { get; set; }

        public double currentPriceLevel, currentPriceAboveLevel1, currentPriceBelowLevel1, currentPriceAboveLevel2, currentPriceBelowLevel2;

        public override void Calculate(int index)
        {
            if (IsLastBar)
            {
                switch (Calbase)
                {
                    case calbase.Ask:
                        currentPriceLevel = Symbol.Ask;
                        break;
                    case calbase.Bid:
                        currentPriceLevel = Symbol.Bid;
                        break;
                }
                if (_show1)
                {
                    //draw pips1
                    currentPriceAboveLevel1 = currentPriceLevel + (Symbol.PipSize * stop1Pips);
                    currentPriceBelowLevel1 = currentPriceLevel - (Symbol.PipSize * stop1Pips);

                    Chart.DrawTrendLine("stopLevel1Above", index, currentPriceAboveLevel1, index + (-1 * Offset1), currentPriceAboveLevel1, lColor1, thickness1, LineStyle1);
                    Chart.DrawTrendLine("stopLevel1Above2", index, currentPriceAboveLevel1, index + mOffset, currentPriceAboveLevel1, lColor1, thickness1, LineStyle1);
                    Chart.DrawTrendLine("stopLevel1Below", index, currentPriceBelowLevel1, index + (-1 * Offset1), currentPriceBelowLevel1, lColor1, thickness1, LineStyle1);
                    Chart.DrawTrendLine("stopLevel1Below2", index, currentPriceBelowLevel1, index + mOffset, currentPriceBelowLevel1, lColor1, thickness1, LineStyle1);

                    if (_showl1)
                    {
                        var stopLevel1BelowLabel = Chart.DrawText("stopLevel1BelowLabel", stop1Pips.ToString("N0"), index + lOffset1, currentPriceBelowLevel1, tColor);
                        stopLevel1BelowLabel.VerticalAlignment = VerticalAlignment.Bottom;
                        stopLevel1BelowLabel.HorizontalAlignment = HorizontalAlignment.Right;
                        var stopLevel1AboveLabel = Chart.DrawText("stopLevel1AboveLabel", stop1Pips.ToString("N0"), index + lOffset1, currentPriceAboveLevel1, tColor);
                        stopLevel1AboveLabel.VerticalAlignment = VerticalAlignment.Top;
                        stopLevel1AboveLabel.HorizontalAlignment = HorizontalAlignment.Right;
                    }
                }
                if (_show2)
                {
                    //draw pips2
                    currentPriceAboveLevel2 = currentPriceLevel + (Symbol.PipSize * stop2Pips);
                    currentPriceBelowLevel2 = currentPriceLevel - (Symbol.PipSize * stop2Pips);

                    Chart.DrawTrendLine("stopLevel2Above", index, currentPriceAboveLevel2, index + (-1 * Offset2), currentPriceAboveLevel2, lColor2, thickness2, LineStyle2);
                    Chart.DrawTrendLine("stopLevel2Above2", index, currentPriceAboveLevel2, index + mOffset, currentPriceAboveLevel2, lColor2, thickness2, LineStyle2);
                    Chart.DrawTrendLine("stopLevel2Below", index, currentPriceBelowLevel2, index + (-1 * Offset2), currentPriceBelowLevel2, lColor2, thickness2, LineStyle2);
                    Chart.DrawTrendLine("stopLevel2Below2", index, currentPriceBelowLevel2, index + mOffset, currentPriceBelowLevel2, lColor2, thickness2, LineStyle2);

                    if (_showl2)
                    {
                        var stopLevel2AboveLabel = Chart.DrawText("stopLevel2AboveLabel", stop2Pips.ToString("N0"), index + lOffset2, currentPriceAboveLevel2, tColor);
                        stopLevel2AboveLabel.VerticalAlignment = VerticalAlignment.Top;
                        stopLevel2AboveLabel.HorizontalAlignment = HorizontalAlignment.Right;
                        var stopLevel2BelowLabel = Chart.DrawText("stopLevel2BelowLabel", stop2Pips.ToString("N0"), index + lOffset2, currentPriceBelowLevel2, tColor);
                        stopLevel2BelowLabel.VerticalAlignment = VerticalAlignment.Bottom;
                        stopLevel2BelowLabel.HorizontalAlignment = HorizontalAlignment.Right;
                    }
                }
            }
        }
    }
}
Comments
0