Hi,
I am trying to code a multi time frame bollinger band. The code below compiles successfully (part of an EA). However during EA running the M30's code section does not get looked at (higher time frame's code does no work as intended). Can you please have a look at the code below if code is written correctly for the intended job.
Intended Job:
Buy - once the lower Bollinger Band has pierced in both CURRENT and M30 time frames.
Sell - once the upper Bollinger Band has pierced in both CURRENT and M30 time frames.
// Input variables for Bollinger Band Indicator
extern ENUM_TIMEFRAMES bb_lower_TF = PERIOD_CURRENT;
extern int BBPeriod = 20;
extern double BBDeviation = 2.0;
extern ENUM_APPLIED_PRICE BBApplied = PRICE_CLOSE;
extern ENUM_TIMEFRAMES higher_TF = PERIOD_M30;
// Bollinger Band Indicator for both current time frame and 30 minute time frame
double bbup1 = iBands(NULL, bb_lower_TF, BBPeriod, BBDeviation, 0, BBApplied, MODE_UPPER, 0);
double bbdn1 = iBands(NULL, bb_lower_TF, BBPeriod, BBDeviation, 0, BBApplied, MODE_LOWER, 0);
double bbup2 = iBands(NULL, higher_TF, BBPeriod, BBDeviation, 0, BBApplied, MODE_UPPER, 0);
double bbdn2 = iBands(NULL, higher_TF, BBPeriod, BBDeviation, 0, BBApplied, MODE_LOWER, 0);
// Sell - once the upper BB is pierced in both CURRENT and H4 time frames.
if (type==OP_BUY && ((NormalizeDouble(Bid, _Digits)>NormalizeDouble(bbdn1, _Digits)) && (NormalizeDouble(Bid, _Digits)>NormalizeDouble(bbdn2, _Digits)))) return (false);
//Buy - once the lower BB is pierced in both CURRENT and H4 time frames.
if (type==OP_SELL && ((NormalizeDouble(Bid, _Digits)<NormalizeDouble(bbup1, _Digits)) && (NormalizeDouble(Bid, _Digits)<NormalizeDouble(bbup2, _Digits)))) return (false);
Any help would be appreciated. Thank you.
I am trying to code a multi time frame bollinger band. The code below compiles successfully (part of an EA). However during EA running the M30's code section does not get looked at (higher time frame's code does no work as intended). Can you please have a look at the code below if code is written correctly for the intended job.
Intended Job:
Buy - once the lower Bollinger Band has pierced in both CURRENT and M30 time frames.
Sell - once the upper Bollinger Band has pierced in both CURRENT and M30 time frames.
// Input variables for Bollinger Band Indicator
extern ENUM_TIMEFRAMES bb_lower_TF = PERIOD_CURRENT;
extern int BBPeriod = 20;
extern double BBDeviation = 2.0;
extern ENUM_APPLIED_PRICE BBApplied = PRICE_CLOSE;
extern ENUM_TIMEFRAMES higher_TF = PERIOD_M30;
// Bollinger Band Indicator for both current time frame and 30 minute time frame
double bbup1 = iBands(NULL, bb_lower_TF, BBPeriod, BBDeviation, 0, BBApplied, MODE_UPPER, 0);
double bbdn1 = iBands(NULL, bb_lower_TF, BBPeriod, BBDeviation, 0, BBApplied, MODE_LOWER, 0);
double bbup2 = iBands(NULL, higher_TF, BBPeriod, BBDeviation, 0, BBApplied, MODE_UPPER, 0);
double bbdn2 = iBands(NULL, higher_TF, BBPeriod, BBDeviation, 0, BBApplied, MODE_LOWER, 0);
// Sell - once the upper BB is pierced in both CURRENT and H4 time frames.
if (type==OP_BUY && ((NormalizeDouble(Bid, _Digits)>NormalizeDouble(bbdn1, _Digits)) && (NormalizeDouble(Bid, _Digits)>NormalizeDouble(bbdn2, _Digits)))) return (false);
//Buy - once the lower BB is pierced in both CURRENT and H4 time frames.
if (type==OP_SELL && ((NormalizeDouble(Bid, _Digits)<NormalizeDouble(bbup1, _Digits)) && (NormalizeDouble(Bid, _Digits)<NormalizeDouble(bbup2, _Digits)))) return (false);
Any help would be appreciated. Thank you.