Edit Icon Comment free

by Capt.Z-Fort.Builder in category Other at 04/10/2022
Description

This indicator is to solve the problem ver 4.4.12 removed to access and edit the icon's comments
For problem details, please see: https://ctrader.com/forum/ctrader-support/39021
Usage:
1. Select Icon, Alt + D to popup a ChartText with the icon's comment;
2. Edit ChartText as needed;
3. Alt + D to save revised comments, hit again to hide popup ChartText;

Interested in the currency strength meter in the chart?
Get the free download link at Telegram Group: cTrader FOREX Club

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 cAlgo.API;
namespace cAlgo

//This indicator is to solve the problem ver 4.4.12 removed to access and edit the icon's comments
//Problem details see: https://ctrader.com/forum/ctrader-support/39021
//Usage:
//1. Select Icon, Alt + D to popup a ChartText with the icon's comment;
//2. Edit ChartText as needed;
//3. Alt + D to save revised comments, hit again to hide popup ChartText;
//
//Ver 1.01 Optimise : Short cut key change to only Alt + D, save and hide ChartText;
//    1.02 Optimise : Short cut key change to only Alt + D, unhide, save and hide ChartText;
//                  : Temporarily fill with 'empty...' if Icon has no comment;


{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class EditIconCmmt : Indicator
    {
        string s_objnme, s_objsve, s_objcmt;
        private ChartText tx_Cmmt;

        protected override void Initialize()
        {
            Chart.KeyDown += Chart_KeyDown;                                     //HotKeys to SaveChange;
            Chart.ObjectsSelectionChanged += Chart_ObjectsSelectionChanged;     //Select Icons to popup comments in ChartText;
        }

        private void Chart_ObjectsSelectionChanged(ChartObjectsSelectionChangedEventArgs obj)
        {
            if (obj.ObjectsAddedToSelection.Count>0)
            {   
                s_objnme = obj.ObjectsAddedToSelection[0].Name;                                         //Find LastSelect Icon
                if (obj.ObjectsAddedToSelection[0].ObjectType.ToString() == "Icon" ) 
                {
                    s_objsve = s_objnme; s_objcmt = obj.ObjectsAddedToSelection[0].Comment;             //Remember SelectIconName, Comment
                    var icons = Chart.FindAllObjects(ChartObjectType.Icon);
                    foreach (ChartIcon icon in icons) 
                    { 
                        if ( icon.Name.Equals(s_objnme) ) 
                        { 
                            tx_Cmmt = Chart.DrawText("Cmmt_Tx", " ", Bars.Count, 0, Color.Transparent); //Prepare a ChartText to display select icon comments;
                            tx_Cmmt.FontSize = 14; tx_Cmmt.Time = icon.Time; tx_Cmmt.Y = icon.Y; 
                            tx_Cmmt.Text = icon.Comment == "" ? "empty..." : icon.Comment; tx_Cmmt.Color = icon.Color;
                            tx_Cmmt.IsHidden = true; tx_Cmmt.IsInteractive = false;
                        }
                    }
                }
            }
        }

        private void Chart_KeyDown(ChartKeyboardEventArgs obj)
        {   
            if (obj.AltKey)
            {
                if (obj.Key.Equals(Key.D))  //To Show, Save revised comment in Icon, hit again to Hide ChartText
                {
                    if (tx_Cmmt.IsHidden) { tx_Cmmt.IsHidden = false; tx_Cmmt.IsInteractive = true; }   //First hit to show comment;
                    else 
                    {
                        if ( tx_Cmmt.Text != s_objcmt && tx_Cmmt.Text != "empty...")                    //Hit again to save if comment changed;
                        {
                            var icons = Chart.FindAllObjects(ChartObjectType.Icon);
                            foreach (ChartIcon icon in icons) { if ( icon.Name.Equals(s_objsve) ) { icon.Comment = tx_Cmmt.Text; s_objcmt = tx_Cmmt.Text; } }
                            Chart.DrawStaticText("S&H", string.Format("{0} comment saved...", s_objsve), VerticalAlignment.Bottom, HorizontalAlignment.Right, Color.Red);
                        }
                        else                                                                            //Hit again to hide comment TextBox;
                        {
                            tx_Cmmt.IsHidden = true; tx_Cmmt.IsInteractive = false;
                            Chart.DrawStaticText("S&H", string.Format("{0} comment hidden...", s_objnme), VerticalAlignment.Bottom, HorizontalAlignment.Right, Color.Transparent);
                        }
                    }
                }
            }
        }

        public override void Calculate(int index)
        {
        }
    }
}
Comments

run3donlineaz - October 07, 2022 @ 11:57

Your comments on the forum are very reasonable, hope you add comments to the play snake website for us to improve further, and thank you for your comments.

seboxi8126 - October 13, 2022 @ 04:50

Your sharing is very reasonable and extremely helpful. I also like how your writing is very easy to read and understand. with wordle hint to find the most correct answer yourself.

5