Category Trend  Published on 12/09/2022

AW Symbol Watermark ctrader

Description

Adds a watermark to the chart background displaying symol name and description and timeframe with options( color, font, alignment, opacity, show description)

 

watermark


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    //V 1.0 
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false,AccessRights = AccessRights.None)]
    public class AWSymbolWatermarkctrader : Indicator
    {
        //[Parameter(DefaultValue = "Hello world!")]
        //public string Message { get; set; }
        
        //symbol watermark parameter
        [Parameter("Font size", DefaultValue = 18, MinValue = 1, MaxValue = 999)]
        public int FontSize { get; set; }
 
        [Parameter("Font weight", DefaultValue = 7)]
        public FontWeight FontWeight { get; set; }
 
        [Parameter("color", DefaultValue = "#FF7F50")]
        public string ForegroundColor { get; set; }
        
        [Parameter("VerticalAlignment", DefaultValue = VerticalAlignment.Top)]
        public VerticalAlignment  VerticalAlignment { get; set; }
        
        [Parameter("HorizontalAlignment", DefaultValue = HorizontalAlignment.Center)]
        public HorizontalAlignment  HorizontalAlignment { get; set; }
        
        [Parameter("Opacity", DefaultValue = 1)]
        public double  TextOpacity { get; set; }
        
        [Parameter("Show Description", DefaultValue = true)]
        public bool IsDescription { get; set; }
        //[Output("Main")]
       // public IndicatorDataSeries Result { get; set; }

        protected override void Initialize()
        {
            // To learn more about cTrader Automate visit our Help Center:
            // https://help.ctrader.com/ctrader-automate

            DrawWatermark();
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = 
        }
        
        private void DrawWatermark()
        {
            var symbol = Symbols.GetSymbol(SymbolName);
            var text = string.Format("{0}, {1}",Symbol.Name+'('+symbol.Description+')', TimeFrame);
            if(!IsDescription)
            {
                text = string.Format("{0}, {1}",Symbol.Name, TimeFrame);
            }
            var textBlock = new TextBlock 
            {
                VerticalAlignment = VerticalAlignment,
                HorizontalAlignment = HorizontalAlignment,
                Text = text,
                ForegroundColor = ForegroundColor,
                FontSize = FontSize,
                FontWeight = FontWeight,
                Opacity = TextOpacity,
                IsHitTestVisible = false
            };
            Chart.AddControl(textBlock);
        }
    }
}

MA
ma.norouzifar

Joined on 12.09.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: AW Symbol Watermark ctrader.algo
  • Rating: 0
  • Installs: 1000
  • Modified: 12/09/2022 06:22
Comments
Log in to add a comment.
No comments found.