In OnInit:
//+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- indicator buffers mapping *** //--- set levels IndicatorSetInteger(INDICATOR_LEVELS,2); IndicatorSetDouble(INDICATOR_LEVELVALUE,0,InpLevelDown); IndicatorSetDouble(INDICATOR_LEVELVALUE,1,InpLevelUp);
Indicator Input
- Averaging period - indicator averaging period;
- Level UP - the UP level value;
- Level DOWN - the DOWN level value.
The UP and DOWN levels will be immediately shown in the indicator sub-window:
- www.mql5.com
In OnInit:
Hi Vladimir,
First of all, thank you for taking time to help!
The methods "IndicatorSet"... cannot be used from Experts, only at Indicators - they are in this list of "Prohibited" functions as stated in this article : https://www.mql5.com/en/docs/runtime/running
All functions designed for indicators are prohibited in Expert Advisors and scripts:
- SetIndexBuffer();
- IndicatorSetDouble();
- IndicatorSetInteger();
- IndicatorSetString();
- PlotIndexSetDouble();
- PlotIndexSetInteger();
- PlotIndexSetString();
- PlotIndexGetInteger.
Any other way to do this ?
- www.mql5.com
int OnInit() { hRsi = new CiRSI; hRsi.Create(Symbol(), Period(), 14, PRICE_CLOSE); ChartIndicatorAdd(0,1,hRsi.Handle()); ObjectCreate(0, "LimiteSup", OBJ_HLINE, 1, 0, gatilhoSuperior); ObjectCreate(0, "LimiteInf", OBJ_HLINE, 1, 0, gatilhoInferior); hRsi.Redrawer(true); ChartRedraw(); //--- return(INIT_SUCCEEDED); }
Just adding some information, I managed to add "lines" to the indicator window, but they are separated objects and they don't show up on backtesting, only running the expert on an actual chart.
This is not what I wanted...
Just adding some information, I managed to add "lines" to the indicator window, but they are separated objects and they don't show up on backtesting , only running the expert on an actual chart.
This is not what I wanted...
You did not understand. The algorithm is as follows: You write your custom indicator (the indicator in which you add levels - an example in the code CCI Color Levels). And then, in the Expert Advisor, you create the indicator handle (the handle must be created in OnInit) and using the 'ChartIndicatorAdd' add the indicator to the chart.
- www.mql5.com
An example of a custom indicator with custom levels and an example of an Expert Advisor that works with this indicator
Custom indicator based on iRSI (Relative Strength Index, RSI) - added two custom levels
Custom indicator based on iRSI (Relative Strength Index, RSI) - added two custom levels
You did not understand. The algorithm is as follows: You write your custom indicator (the indicator in which you add levels - an example in the code CCI Color Levels). And then, in the Expert Advisor, you create the indicator handle (the handle must be created in OnInit) and using the 'ChartIndicatorAdd' add the indicator to the chart.
I really appreciate your help Vladimir !
Never crossed my mind that we actually have to create ANOTHER indicator just to change two levels that already exist in the "base" one... That sounds kind of silly to someone that works with software development. It would make sense if I was trying to add more levels or change the behavior of the indicator, but this is not the case :-) So I guess that this limitation is based on the fact that the included RSI indicator is bases on the "de facto" standard and so they assume we woudn't change levels...
Anyways, I'm very happy that you helped me with this, and as I saw, you had this same problem in the past - thank's for sharing !
Best regards from Brasil !
You did not understand. The algorithm is as follows: You write your custom indicator (the indicator in which you add levels - an example in the code CCI Color Levels). And then, in the Expert Advisor, you create the indicator handle (the handle must be created in OnInit) and using the 'ChartIndicatorAdd' add the indicator to the chart.
Humm, let me say: first I need to create a custom indicator that contein all level that i need (RSI indicator with 4 or more levels); finaly, Create an EA where i will use my custom indicator. That is all???
I really appreciate your help Vladimir !
Never crossed my mind that we actually have to create ANOTHER indicator just to change two levels that already exist in the "base" one... That sounds kind of silly to someone that works with software development. It would make sense if I was trying to add more levels or change the behavior of the indicator, but this is not the case :-) So I guess that this limitation is based on the fact that the included RSI indicator is bases on the "de facto" standard and so they assume we woudn't change levels...
Anyways, I'm very happy that you helped me with this, and as I saw, you had this same problem in the past - thank's for sharing !
Best regards from Brasil !
I have the same situation, can you help me with the code
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Could anyone help me to set the levels for a RSI indicator that I'm creating/adding during EA OnInit() event ?
Just to be clear, I want to do this during the EXPERT execution, not during Indicator initialization, as I'm getting those limits as parameters from my EA.
I can add the RSI indicator using code below, but it always starts with the default values 70/30 - didn't find a way to change this from the EA. I found many articles explaining how to do this on an indicator code, but not on how to change the values from the Expert Advisor...