how to use iBands in mql5

 

hi,

i program via mql4 before, now i am trying to create EA in mql5 but i cant use iBands in mql5, for example

in mql4 : iBands(Symbol(),0,20,2,0,PRICE_CLOSE,MODE_LOWER,2); but in mql5 i cant set mode ( MODE_LOWER or UPPER ) And cant set shift.

how can i get value of bb , for example value of upper band in last 2 candle

i test icustom for use bb indicator and i get 4802 error

thanks

Documentation on MQL5: Technical Indicators / iBands
Documentation on MQL5: Technical Indicators / iBands
  • www.mql5.com
//|                                                  Demo_iBands.mq5 | //|                        Copyright 2011, MetaQuotes Software Corp. | //|                                             https://www.mql5.com | "The method of creation of the handle is set through the 'type' parameter (function type...
 
int BandsHandle;
double Middle[], Upper[], Lower[];
void OnInit() {
        SetIndexBuffer(0, Middle, INDICATOR_DATA);
        SetIndexBuffer(1, Upper, INDICATOR_DATA);
        SetIndexBuffer(2, Lower, INDICATOR_DATA);

        BandsHandle = iBands(_Symbol, 0, BBPeriod, 0, BBDeviation, PRICE_CLOSE);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[]) {
        ...
        int to_copy;
        if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total;
        else {
                to_copy=rates_total-prev_calculated;
                if(prev_calculated>0) to_copy++;
        }
        //The buffer numbers are the following: 0 - BASE_LINE, 1 - UPPER_BAND, 2 - LOWER_BAND
        CopyBuffer(BandsHandle, 0, 0, to_copy, Middle);
        CopyBuffer(BandsHandle, 1, 0, to_copy, Upper);
        CopyBuffer(BandsHandle, 2, 0, to_copy, Lower);  
        ...
        return rates_total;
}
 
Masoud1365:

hi,

i program via mql4 before, now i am trying to create EA in mql5 but i cant use iBands in mql5, for example

in mql4 : iBands(Symbol(),0,20,2,0,PRICE_CLOSE,MODE_LOWER,2); but in mql5 i cant set mode ( MODE_LOWER or UPPER ) And cant set shift.

how can i get value of bb , for example value of upper band in last 2 candle

i test icustom for use bb indicator and i get 4802 error

thanks

An example of get values from the iBands indicator
How to start with MQL5
How to start with MQL5
  • 2020.07.05
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...