mql4 bollingers bands always give the same value
mql4 bollingers bands always give the same value
Loading saved threads...
z0diac · External communityPost link
External question — Stack Overflow Stack Exchange
Author: z0diac
Original post: https://stackoverflow.com/questions/78135317
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
bollingers bands always give the same value and give the same value in each symbol there is no error in the code sequence but there is a logical error can you help
property copyright "Copyright 2024, MetaQuotes Ltd."
property link "https://www.mql5.com"
property version "1.00"
property strict
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
double bb_degeri = iBands(NULL,PERIOD_CURRENT,21,0,2,PRICE_CLOSE);
Alert("");
Alert(bb_degeri);
it needs to give a different value for each symbol and the forex bot I will write will open and close trades according to these values
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: PaulB
Original post: https://stackoverflow.com/a/78141322
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Your question states MQL4, your code looks more like MQL5, you need to clarify which language you are using as they are distinctly different.
MQL4 is relitevly straight forward, check the documentation:
iBands
Values are retrieved using the following code
double value=iBands(NULL,0,20,2,0,PRICE_LOW,MODE_LOWER,0);
MQL5 requires a handler. Again check the documentation:
iBands
Example:
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
handle_iBands = iBands(_Symbol, PERIOD_CURRENT, 20, 0, 0.21, PRICE_OPEN);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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 max=rates_total; //rates_total;
CopyBuffer(handle_iBands, 0, 0, max, Upper);
CopyBuffer(handle_iBands, 0, 0, max, Lower);
double value1=Upper[0];
double value2=Lower[0];
return(rates_total);
}
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: z0diac Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/78135317 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. bollingers bands always give the same value and give the same value in each symbol there is no error in the code sequence but there is a logical error can you help property copyright "Copyright 2024, MetaQuotes Ltd." property link "https://www.mql5.com" property version "1.00" property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { double bb_degeri = iBands(NULL,PERIOD_CURRENT,21,0,2,PRICE_CLOSE); Alert(""); Alert(bb_degeri); it needs to give a different value for each symbol and the forex bot I will write will open and close trades according to these values
Checking account access…