If I changed temp[] to indicatorbuffer,then the probem will be resolved.
Changed temp[] to indicatorbuffer:
//+------------------------------------------------------------------+ //| test_2.mq4 | //| test | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "test" #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red //--- buffers double ExtMapBuffer1[]; double temp[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(2); // SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexBuffer(1,temp); // //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- for(int i=0;i<limit;i++) temp[i]= iMA(NULL,0,30,0,MODE_EMA,PRICE_CLOSE,i); for(i=0;i<limit;i++) ExtMapBuffer1[i]= iMAOnArray(temp,Bars,13,0,MODE_EMA,i);// //---- return(0); } //+------------------------------------------------------------------+
if i use buffers more than 8, how to code correctly ?
ArrayResize(temp,Bars);
bool ResizeBuffer(double& buffer[], int size){ if (ArraySize(buffer) != size){ ArraySetAsSeries(buffer, false); // Shift values B[2]=B[1]; B[1]=B[0] if (ArrayResize(buffer, size) <= 0){ trading.disabled = "ArrayResize [1] failed: "+GetLastError() + " Trading disabled."; Alert(trading.disabled); Print(trading.disabled); return(false); } ArraySetAsSeries(buffer, true); } return(true); }
Read this is should help you: https://www.mql5.com/en/articles/1456
Thank you.

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
Why I can not get the corrrect indicators value in EA testing ?
I tested the following simple indicator test_1.mq4