indichandle[i][0]=iCCI … indichandle[i][1]=iATR … indichandle[i][2]=iATR … indichandle[i][3]=iBan … ⋮ CopyBuffer(indichandle[topair][3],2,1,2,BOLL_L);
You should never do that as constants are not self-documenting and error prone.enum INDI {ICCI, IATR_D1, IATR_TF, IBANDS}; indichandle[i][ICCI ]=iCCI … indichandle[i][IATR_D1]=iATR … indichandle[i][IATR_TF]=iATR … indichandle[i][IBANDS ]=iBan … ⋮ CopyBuffer(indichandle[topair][IBANDS],UPPER_BAND,1,2,BOLL_L);
Replacing constants with an enumeration is better. Using predefined constants is also better.- Best is a structure and simplifying methods.
struct Indi{ string symbol; int hCCI, hATR_D1, hATR_TF, hBB; int get_BB(int iBuf, int iBeg, int n, double &a[]){ int r=CopyBuffer(hBB,iBuf,iBeg,n,a); if(r < n) PrintFormat("%s:CB-BB(%i,%n) failed: %i", __FUNCTION__, hBB, _LastError); return r; ⋮ }; Indi indi[28]; ⋮ indi[i].symbol = … indi[i].hCCI =iCCI( indi[i].symbol,PERIOD_D1,14,PRICE_TYPICAL); indi[i].hATR_D1=iATR( indi[i].symbol,PERIOD_D1,12); indi[i].hATR_TF=iATR( indi[i].symbol,TFrame,12); indi[i].hBB =iBands(indi[i].symbol,TFrame,20,2,0,PRICE_LOW); ⋮ void OnTick(){ ⋮ indi[topair].get_BB(UPPER_BAND,1,2,BOLL_L);
-
stanislass: What did I not understand?You would know why, if you check your return codes for errors, and report them including GLE/LE. Don't look at it unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after. -
On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum
William Roeder:
- You should never do that as constants are not self-documenting and error prone.
- Replacing constants with an enumeration is better. Using predefined constants is also better.
- Best is a structure and simplifying methods.
-
You would know why, if you check your return codes for errors, and report them including GLE/LE.
Don't look at it unless you have an error.
Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after. -
On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum
Terminal and server are synchronized.
There is no error return.
In a visual backtest, on the topair / TFrame graph only the average of the bollinger is traced. There are no upper and lower bands.(?)
Ps. I do not see any error or you report it.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
With this code I always get in BOLL_U and BOLL_L the values of the average of the Bollinger, buffer 0 according to the doc, whereas I specify that I want upper, buffer 1 according to the doc, and lower, buffer 2 according to the doc.
What did I not understand?