Comment() different in each chart in a multicurrency EA

 
I have an EA developed in mql5 that operates in multicurrency.
I would like to be able to program a different Comment() on the screen for each pair.
I am not able to see the solution.
Does anyone know how to do it?
Many thanks in advance,
Juan 
 
Juan Luis De Frutos Blanco:
I have an EA developed in mql5 that operates in multicurrency.
I would like to be able to program a different Comment() on the screen for each pair.
I am not able to see the solution.
Does anyone know how to do it?
Many thanks in advance,
Juan 

In its simplest form it is just a matter for detecting the currency pair and assigning the comment you want - e.g:

   string strComment = "";

   if(_Symbol == "GBPUSD")
     {
      strComment = "USD comment";
     }
   else
      if(_Symbol == "USDJPY")
        {
         strComment = "JPY comment";
        }
   Comment(strComment);     
 
R4tna C #:

In its simplest form it is just a matter for detecting the currency pair and assigning the comment you want - e.g:

Nice!

 
Thank you very much, but I have not explained myself completely well.


I have an EA in mql5 that I launch from a single graph and, from it, it operates several pairs.

The proposed option works fine on the graph where the EA is installed, but not on the other graphs on which the EA operates (It is a single EA instance that operates on several graphs).


 How can I refer to those other graphs to be able to put a Comment() on them?

Juan
 
Juan Luis De Frutos Blanco #: Thank you very much, but I have not explained myself completely well. I have an EA in mql5 that I launch from a single graph and, from it, it operates several pairs. The proposed option works fine on the graph where the EA is installed, but not on the other graphs on which the EA operates (It is a single EA instance that operates on several graphs). How can I refer to those other graphs to be able to put a Comment() on them?

Forum on trading, automated trading systems and testing trading strategies

Creating objects on multiple charts

Fernando Carreiro, 2023.10.31 01:00

To be able to add graphical objects for other symbols (i.e. other charts), you would need to ...

  1. Scan all open charts, using ChartFirst and ChartNext to find the one you wish to use (i.e. the desired symbol, time-frame, etc.). There may be more than one or none at all.
  2. If none exist, then you would have to open up a new chart for the desired symbol.
  3. Once you have identified the desired chart id, then you can add graphical objects to that chart.
However, doing this in the Strategy Tester may be tricky. I've never tested such functionality under the Strategy Tester. Also, it would only work in Visual Mode obviously.

    Forum on trading, automated trading systems and testing trading strategies

    How can I draw a simple moving average on a newly created chart?

    Fernando Carreiro, 2023.10.12 07:22

    The Comment function always applies to the current chart. As you can see from the documentation, it does not have any parameter for selecting a target chart.

    However, if you read the Comment documentation, you will notice that it instructs you to also read about ChartSetString and ChartGetString.

    So, instead of Comment, use the ChartSetString function with CHART_COMMENT property.

    ChartSetString

    Sets the string value for a corresponding property of the specified chart

    ENUM_CHART_PROPERTY_STRING

    ID

    Description

    Property Type

    CHART_COMMENT

    Text of a comment in a chart

    string

     
    Juan Luis De Frutos Blanco #:
    Thank you very much, but I have not explained myself completely well.


    I have an EA in mql5 that I launch from a single graph and, from it, it operates several pairs.

    The proposed option works fine on the graph where the EA is installed, but not on the other graphs on which the EA operates (It is a single EA instance that operates on several graphs).


     How can I refer to those other graphs to be able to put a Comment() on them?

    Juan

    An EA doesn't "operate on a graph", neither one or several, it "operates" on one symbol or several symbols and it runs on a chart.

    I guess you are talking about the Strategy Tester ?

    If yes there is no way to draw/add anything to the additional charts. If not then Fernando gives you the solution.

     

    Thank you very much Fernando, I already have it active, visualizing the comment with ChartSetString

    Juan.

    Documentación para MQL5: Operaciones con gráficos / ChartSetString
    Documentación para MQL5: Operaciones con gráficos / ChartSetString
    • www.mql5.com
    ChartSetString - Operaciones con gráficos - Manual de referencia de MQL5 - manual de usuario para el lenguaje del trading algorítmico/automático para MetaTrader 5
    Reason: