I have a problem in my EA

 

Hello to all. I have a problem in my EA: I can not pass a variable 'int' from my indicator to my EA. Here is the code, if you can make it work leave a comment. Thanks.

My EA:

#resource "\\Indicators\\Prova22b.ex5"
int var=0;

int OnInit()
  {
   var=iCustom(NULL,0,"Prova22");
   if(var==INVALID_HANDLE)
     {
      printf("Error obtaining handle");
      return(INIT_FAILED);
     }
   return(INIT_SUCCEEDED);
  }

void OnTick()
  {
      double MyVarBuffer[];
      ArraySetAsSeries(MyVarBuffer,true);
      CopyBuffer(var,0,0,1,MyVarBuffer);
      Comment (MyVarBuffer[0]);
  }

My Indicator:

#property indicator_chart_window
#property indicator_plots 1
#property indicator_buffers 1

double var1[];
int OnInit()
  {
   SetIndexBuffer(0,var1,INDICATOR_DATA);
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
   return(INIT_SUCCEEDED);
  }

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[])
  {
   var1[0]=1;
   return(rates_total);
  }
 
5025358:

I can not pass a variable 'int' from my indicator to my EA

why don't you reconstruct the indicator calculation into the EA?
as standard usage of indicator is to "Indicate" (visually, alert etc..)

 
Make it a buffer or global terminal variable or the name of a hidden chart object.
 
I can't reconstruct the indicator into the EA... This one that I sent is only an example is not the real one. It is only for understand what I did wrong. I need a buffer but probably I am doing something wrong because it does not work. If you know why please leave a comment.
 
5025358:
I can't reconstruct the indicator into the EA... This one that I sent is only an example is not the real one. It is only for understand what I did wrong. I need a buffer but probably I am doing something wrong because it does not work. If you know why please leave a comment.

buffer normally double value.
why do you need integer?

 
I also like a double. But even if it were double what is my mistake because it does not work?
 
5025358:
I can't reconstruct the indicator into the EA... This one that I sent is only an example is not the real one. It is only for understand what I did wrong. I need a buffer but probably I am doing something wrong because it does not work. If you know why please leave a comment.
   var1[rates_total-1]=1;
 
Thanks so much!
 
Mohamad Zulhairi Baba:

why don't you reconstึruct the indicator calculation into the EA?
as standard usage of indicator is to "Indicate" (visually, alert etc..)

Reason: