Comment Function

Overview

Outputs user-defined comments to the top-left corner of a chart.

Signature

void Comment(argument, ...);

Parameters

  • argument: Any values, separated by commas.
  • * To delimit output into several lines, use \n or \r\n. * Maximum number of parameters: 64. * Total length of the input comment (including invisible symbols): 2045 characters (excess symbols will be cut out).

    Return Value

    None.

    Notes

  • Arrays cannot be passed directly; pass elements individually.
  • **Data Formatting:**
  • * double: Up to 16 decimal places, traditional or scientific format (whichever is more compact). * float: 5 digits after the decimal point. * bool: Output as "true" or "false". * Dates: Output as YYYY.MM.DD HH:MI:SS. Use TimeToString() for custom formats. * color: Output as R,G,B string or a recognized color name.
  • For custom real number formatting, use DoubleToString().
  • Example

    void OnTick()
      {
    //--- 
       double Ask,Bid;
       int Spread;
       Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
       Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
       Spread=SymbolInfoInteger(Symbol(),SYMBOL_SPREAD);
    //--- Output values in three lines
       Comment(StringFormat("Show prices\nAsk = %G\nBid = %G\nSpread = %d",Ask,Bid,Spread));
      }
    

    Related Functions

  • Alert()
  • Print()