Download MetaTrader 5

Add and indicator from a script...

To add comments, please log in or register
cyberglassed
613
cyberglassed  

Hello folks, I would like to know how do I add an indicator from a script. I wanna that when I run a script some indicators be added to the chart.


thanks in advance,

Cyberglassed.

Alain Verleyen
Moderator
32763
Alain Verleyen  
cyberglassed:

Hello folks, I would like to know how do I add an indicator from a script. I wanna that when I run a script some indicators be added to the chart.


thanks in advance,

Cyberglassed.

You have to use CharIndicatorAdd() function. Or you can use the CChart class with the method IndicatorAdd, which is equivalent.
cyberglassed
613
cyberglassed  

thank you very much angevoyageur!

cyberglassed
613
cyberglassed  

One las thing about this...

do you know how to set some indicators's parameters like: "line style" and "line width"?, I have tried with: PlotIndexSetInteger, but no success,


thank you, Cyberglassed.

Alain Verleyen
Moderator
32763
Alain Verleyen  
cyberglassed:

One las thing about this...

do you know how to set some indicators's parameters like: "line style" and "line width"?, I have tried with: PlotIndexSetInteger, but no success,


thank you, Cyberglassed.

PlotIndexSetInteger() is for use inside an indicator code.

cyberglassed
613
cyberglassed  
thank you anyway angevoyageur, so I think I'm going to implement a custom indicator with some parameters extra for style and width
Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
cyberglassed
613
cyberglassed  

yes, now with your previous post I know how to add an indicator to the chart but also I wanna change the color, style and width of it's line, so I think the only way is create a custom indicator, so, go from:

int iMA(
    string symbol, // symbol name
    ENUM_TIMEFRAMES period, // period
    int ma_period, // averaging period
    int ma_shift, // horizontal shift
    ENUM_MA_METHOD ma_method, // smoothing type
    ENUM_APPLIED_PRICE applied_price // type of price or handle
);

to a custom (and implemented by me) function:

int Custom_iMA(
    string symbol, // symbol name
    ENUM_TIMEFRAMES period, // period
    int ma_period, // averaging period
    int ma_shift, // horizontal shift
    ENUM_MA_METHOD ma_method, // smoothing type
    ENUM_APPLIED_PRICE applied_price, // type of price or handle
   
    color = clrRed, // color of indicator
    ENUM_LINE_STYLE line_style = STYLE_SOLID, // style of indicator line
    int line_width = 1 // style of indicator line
);


I think I have no option, or yes?, I'm totally new on MQL5,


thank you,

Cyberglassed.

Alain Verleyen
Moderator
32763
Alain Verleyen  
cyberglassed:

yes, now with your previous post I know how to add an indicator to the chart but also I wanna change the color, style and width of it's line, so I think the only way is create a custom indicator, so, go from:

...


I think I have no option, or yes?, I'm totally new on MQL5,


thank you,

Cyberglassed.

Yes, as far as I know this is the only way.
cyberglassed
613
cyberglassed  
thank you very much angevoyageur.
To add comments, please log in or register