Converting Indicator to EA

 

Hi,  need some help


I have converted an Indicator to EA, but it still seems to think that it is an Indicator.

"no indicator window property is defined, indicator_chart_window is applied 0 0"

I have gone through the coding and everything looks good, except I think it might be due to the Buffer, which I can't seem to figure out how to change that for the EA.

double Buy[];
double Sell[];
//---
long chartID = ChartID();
#define LabelBox "LabelBox"
#define Label1 "Label1"
#define Label2 "Label2"
#define Label3 "Label3"
#define Label4 "Label4"
string label1 = "Spread ",
       label2 = "Range";

and further down

//--- indicator buffers mapping

   SetIndexBuffer(0,Buy,INDICATOR_DATA);
   ArraySetAsSeries(Buy,true);
   PlotIndexSetString(0,PLOT_LABEL,"BuyArrow");   
   PlotIndexSetInteger(0,PLOT_ARROW,233);
   SetIndexArrow(0,233);
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
   SetIndexBuffer(1,Sell,INDICATOR_DATA);
   ArraySetAsSeries(Sell,true);
   PlotIndexSetString(1,PLOT_LABEL,"SellArrow");   
   PlotIndexSetInteger(1,PLOT_ARROW,234);
   SetIndexArrow(1,234);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0);
//---
   return(INIT_SUCCEEDED);
  }
//---
#define OP_NONE -1



 

my God you need to follow up basic programming tutorials.

your code is a mess

 

You cannot convert an indicator to an EA.

You can use iCustom to retrieve buffer values from the indicator.

 
Kristina Suh: I have converted an Indicator to EA,

Don't try to do that. There are no buffers, no IndicatorCounted() or prev_calculated. No way to know if older bars have changed or been added (history update.)

Just get the value(s) of the indicator(s) into EA/indicator (using iCustom) and do what you want with it.

You should encapsulate your iCustom calls to make your code self-documenting.
          Detailed explanation of iCustom - MQL4 programming forum #33 2017.05.23