Converting Indicator to EA

To add comments, please log in or register
Kristina Suh
394
Kristina Suh  

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



Jean Francois Le Bas
1248
Jean Francois Le Bas  

my God you need to follow up basic programming tutorials.

your code is a mess

Keith Watford
Moderator
24159
Keith Watford  

You cannot convert an indicator to an EA.

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

William Roeder
22318
William Roeder  
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

To add comments, please log in or register