- How to become a signal provider and receive monthly fees
- When MetaTrader 5 Web Terminal is indispensable
- MetaTrader 5 for your investors
Hello everyone.
It's simple. An example based on the Two Rivers Alert custom indicator. The indicator has two buffers ("Up" and "Down") - when an signal appears in the buffer, an arrow appears. How to check: is there a signal or not? Very simple:
- if there is a signal "arrow" - then the price is in the indicator buffer
- if there is no signal, then the value “0.0” is in the indicator buffer. The value "0.0" is used in this indicator, for this you need to look
at the indicator code:
for(int i=limit; i<rates_total; i++) { //Если есть сигнал к покупке(Свеча пересекла полностью) - поставим синюю стрелку вверх if(open[i]<=iMALowBuffer[i] && close[i]>iMAHighBuffer[i] && close[i]>open[i]) { UpBuffer[i]=high[i];//запомним цену синей стрелки if(prev_calculated!=0) { if(time[i]!=m_last_notifications) { m_last_notifications=time[i]; Alert("Up Alert"); } } } else UpBuffer[i]=0.0; //Если есть сигнал к продаже - поставим красную стрелку вниз if(open[i]>=iMAHighBuffer[i] && close[i]<iMALowBuffer[i] && close[i]<open[i]) { DownBuffer[i]=low[i];//запомним цену красной стрелки if(prev_calculated!=0) { if(time[i]!=m_last_notifications) { m_last_notifications=time[i]; Alert("Down Alert"); } } } else DownBuffer[i]=0.0; } //--- return value of prev_calculated for next call return(rates_total); }
Advisor example:
//+------------------------------------------------------------------+ //| Two Rivers Alert.mq5 | //| Copyright © 2019, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2019, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.00" //--- input parameters input int Inp_MA_ma_period = 20; // MA's: averaging period input int Inp_MA_ma_shift = 0; // MA's: horizontal shift input ENUM_MA_METHOD Inp_MA_ma_method = MODE_LWMA; // MA's: smoothing type //--- int handle_iCustom; // variable for storing the handle of the iCustom indicator //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create handle of the indicator iCustom handle_iCustom=iCustom(Symbol(),Period(),"Two Rivers Alert",Inp_MA_ma_period,Inp_MA_ma_shift,Inp_MA_ma_method); //--- if the handle is not created if(handle_iCustom==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iCustom indicator for the symbol %s/%s, error code %d", Symbol(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- double up[],down[]; ArraySetAsSeries(up,true); ArraySetAsSeries(down,true); int start_pos=0,count=3; if(!iGetArray(handle_iCustom,0,start_pos,count,up) || !iGetArray(handle_iCustom,1,start_pos,count,down)) { return; } //--- if(up[0]!=0.0) { //--- signal "Up" in bar #0 int d=0; } if(up[1]!=0.0) { //--- signal "Up" in bar #1 int d=0; } if(down[0]!=0.0) { //--- signal "Down" in bar #0 int d=0; } if(down[1]!=0.0) { //--- signal "Down" in bar #1 int d=0; } } //+------------------------------------------------------------------+ //| Get value of buffers | //+------------------------------------------------------------------+ bool iGetArray(const int handle,const int buffer,const int start_pos, const int count,double &arr_buffer[]) { bool result=true; if(!ArrayIsDynamic(arr_buffer)) { PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__); return(false); } ArrayFree(arr_buffer); //--- reset error code ResetLastError(); //--- fill a part of the iBands array with values from the indicator buffer int copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer); if(copied!=count) { //--- if the copying fails, tell the error code PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d", __FILE__,__FUNCTION__,count,copied,GetLastError()); //--- quit with zero result - it means that the indicator is considered as not calculated return(false); } return(result); } //+------------------------------------------------------------------+
It's simple. An example based on the Two Rivers Alert custom indicator. The indicator has two buffers ("Up" and "Down") - when an signal appears in the buffer, an arrow appears. How to check: is there a signal or not? Very simple:
- if there is a signal "arrow" - then the price is in the indicator buffer
- if there is no signal, then the value “0.0” is in the indicator buffer. The value "0.0" is used in this indicator, for this you need to look
at the indicator code:
Advisor example:
For Indicators I don't have source code for
Thank you. I work with mt5 only. I found a work around for working with iCustom, thanks to Vlamidir Kaputov. Been practicing with different Indicators and using comments to figure out the output of each buffer. I'm learning great!
It's simple. An example based on the Two Rivers Alert custom indicator. The indicator has two buffers ("Up" and "Down") - when an signal appears in the buffer, an arrow appears. How to check: is there a signal or not? Very simple:
- if there is a signal "arrow" - then the price is in the indicator buffer
- if there is no signal, then the value “0.0” is in the indicator buffer. The value "0.0" is used in this indicator, for this you need to look at the indicator code:
Advisor example:
OMG, THANK YOU!!!! FINALLY SOMEONE WHO HELPED INSTEAD OF JUST STANDING OUT THE DOCUMENTATION LINK! THANK YOU SO MUCH SAVED MY LIFE! =)
It's simple. An example based on the Two Rivers Alert custom indicator. The indicator has two buffers ("Up" and "Down") - when an signal appears in the buffer, an arrow appears. How to check: is there a signal or not? Very simple:
- if there is a signal "arrow" - then the price is in the indicator buffer
- if there is no signal, then the value “0.0” is in the indicator buffer. The value "0.0" is used in this indicator, for this you need to look at the indicator code:
Advisor example:
It's simple. An example based on the Two Rivers Alert custom indicator. The indicator has two buffers ("Up" and "Down") - when an signal appears in the buffer, an arrow appears. How to check: is there a signal or not? Very simple:
- if there is a signal "arrow" - then the price is in the indicator buffer
- if there is no signal, then the value “0.0” is in the indicator buffer. The value "0.0" is used in this indicator, for this you need to look at the indicator code:
Advisor example:
Thanks a lot, i really appreciate. i used the above example of iCustom EA to call my custom indicator but its failing to execute trades. May i kindly have solution in execution if possible thanks
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem
We can't see your broken code.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem
We can't see your broken code.
/+------------------------------------------------------------------+ #property copyright "" #property link "" #property version "1.00" #include <Trade/Trade.mqh> #include <Trade/OrderInfo.mqh> #include <Trade/PositionInfo.mqh> //--- input parameters //--- int handle_iCustom; // variable for storing the handle of the iCustom indicator CTrade trade; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create handle of the indicator iCustom handle_iCustom=iCustom(Symbol(),Period(),"Any Custom Indicator with Arrow"); //--- if the handle is not created if(handle_iCustom==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iCustom indicator for the symbol %s/%s, error code %d", Symbol(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- double up[],down[]; ArraySetAsSeries(up,true); ArraySetAsSeries(down,true); int start_pos=0,count=3; if(!iGetArray(handle_iCustom,0,start_pos,count,up) || !iGetArray(handle_iCustom,1,start_pos,count,down)) { return; } //--- if(up[0]!=0.0) { //--- signal "Up" in bar #0 int d=0; trade.PositionClose(_Symbol); trade.Buy(1); } if(up[1]!=0.0) { //--- signal "Up" in bar #1 int d=0; } if(down[0]!=0.0) { //--- signal "Down" in bar #0 int d=0; trade.PositionClose(_Symbol); trade.Sell(1); } if(down[1]!=0.0) { //--- signal "Down" in bar #1 int d=0; } } //+------------------------------------------------------------------+ //| Get value of buffers | //+------------------------------------------------------------------+ bool iGetArray(const int handle,const int buffer,const int start_pos, const int count,double &arr_buffer[]) { bool result=true; if(!ArrayIsDynamic(arr_buffer)) { PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__); return(false); } ArrayFree(arr_buffer); //--- reset error code ResetLastError(); //--- fill a part of the iBands array with values from the indicator buffer int copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer); if(copied!=count) { //--- if the copying fails, tell the error code PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d", __FILE__,__FUNCTION__,count,copied,GetLastError()); //--- quit with zero result - it means that the indicator is considered as not calculated return(false); } return(result); } //+------------------------------------------------------------------+
if(up[1]!=0.0)
You are testing against zero. Does the indicator use zero for empty instead of EMPTY_VALUE?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use