Download MetaTrader 5

Modifying an existing indicator "macd_histogram"

To add comments, please log in or register
Find and download Code Base apps via MetaTrader. It is fast!
MT5.2014
103
MT5.2014 2015.06.05 08:03 

Hi everybody,

I want to make two changes to an existing indicator "macd_histogram" and I would appreciate your kind help:


1- I want to show the date in alert window in "hh:mm:ss" format. By default the indicator shows the date of alerts in alert window in "yyyy:mm:dd, hh:mm:ss" format. (pls see the attached image 1.jpg.) I read that TimeToString function should be used, but I do not know how. In fact, I want to use TimeToString (datetime,TIME_SECONDS) that gets results as "hh:mm:ss" format.

2- I want to transfer the input of colors (MACD, Signal MA, Signal MA, Buy & Sell) from "colors" tab (pls see image 2.jpg) to "inputs" tab (pls see image 3.jpg). In other words, I want to have all inputs in "inputs" tab and eliminate the "Colors" tab. I know that it should be done by creating "input color..." instead of "#property..." in the indicator, but I do not know how to modify the content of the code so that it gets the colors from input color rather than #property.


Thank you so much
Files:
1.jpg 18 kb
2.jpg 51 kb
3.jpg 88 kb
Alain Verleyen
Moderator
30742
Alain Verleyen 2015.06.05 08:47  
MT5.2014:

Hi everybody,

I want to make two changes to an existing indicator "macd_histogram" and I would appreciate your kind help:


1- I want to show the date in alert window in "hh:mm:ss" format. By default the indicator shows the date of alerts in alert window in "yyyy:mm:dd, hh:mm:ss" format. (pls see the attached image 1.jpg.) I read that TimeToString function should be used, but I do not know how. In fact, I want to use TimeToString (datetime,TIME_SECONDS) that gets results as "hh:mm:ss" format.

You can't change this date format.
MT5.2014
103
MT5.2014 2015.06.05 09:18  
Alain Verleyen:
You can't change this date format.

Yes, you can, see this: https://www.mql5.com/en/docs/common/alert :

Alert

Displays a message in a separate window.

void  Alert(
   argument,     // first value
   ...           // other values
   );

Parameters

argument

[in]  Any values separated by commas. To split the information output in several lines you can use the line feed character "\n" or "\r\n". The number of parameters can not exceed 64.

Return Value

No return value.

Note

Arrays can't be passed to the Alert() function. Arrays should be output elementwise. Data of the double type are output with 8 digits after the decimal point, data of the float type are displayed with 5 digits after the decimal point. To output the real numbers with a different precision or in a scientific format, use the DoubleToString() function.

Data of the bool type is output as "true" or "false" strings. Dates are output as YYYY.MM.DD HH:MI:SS. To display a date in another format use the TimeToString() function. Data of the color type are output either as an R,G,B string or as a color name, if the color is present in a color set.

Documentation on MQL5: Common Functions / Alert
Documentation on MQL5: Common Functions / Alert
  • www.mql5.com
Common Functions / Alert - Reference on algorithmic/automated trading language for MetaTrader 5
Alain Verleyen
Moderator
30742
Alain Verleyen 2015.06.05 11:09  
No you can't. The date displayed in the Alert window is not alterable. You can add an other date to your alert message if you want.
MT5.2014
103
MT5.2014 2015.06.05 14:10  
Alain Verleyen:
No you can't. The date displayed in the Alert window is not alterable. You can add an other date to your alert message if you want.

Yes, you can!!!

Pls read the Alert command description more carefully:

Dates are output as YYYY.MM.DD HH:MI:SS. To display a date in another format use the TimeToString() function.

Alain Verleyen
Moderator
30742
Alain Verleyen 2015.06.05 15:00  
MT5.2014:

Yes, you can!!!

Pls read the Alert command description more carefully:

Dates are output as YYYY.MM.DD HH:MI:SS. To display a date in another format use the TimeToString() function.

To add comments, please log in or register