How to obtain data from indicator in EA?

 
Hi guys,

I've made a breakout indicator, recorded the highest and lowest valuea, let's say x and y, of the box,
is it possible to use a EA to obtain those values? could anyone please show me the script?
Thanks very much

lmyyyks
 
I
Get the output values from any indicator with this EA
//+------------------------------------------------------------------+
//|                                            IndicatorTesterEA.mq4 |
//|                                         http://www.selectfx.net/ |
//+------------------------------------------------------------------+

#property link      "http://www.selectfx.net"

//+------------------------------------------------------------------+


extern string IndicatorName = "Your Indicator Name";


/*
An EA to read any custom indicator, just put the exact indi name in the value above

Run a backtest with this EA or attach it to a chart (if the market is open) and look in the Journal tab for the results

You dont have to know how many outputs there are for this to work
An output of zero as an integer means that there is no output buffer to read

If you get a huge integer value as an output (often repeated) that can mean the buffer is empty at that point


*/

//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {


// Check each tick section START

// Read all 7 possible outputs for the current bar
double signal0_0=iCustom(NULL, 0, IndicatorName,0,0); 
double signal1_0=iCustom(NULL, 0, IndicatorName,1,0);
double signal2_0=iCustom(NULL, 0, IndicatorName,2,0);
double signal3_0=iCustom(NULL, 0, IndicatorName,3,0);
double signal4_0=iCustom(NULL, 0, IndicatorName,4,0);
double signal5_0=iCustom(NULL, 0, IndicatorName,5,0);
double signal6_0=iCustom(NULL, 0, IndicatorName,6,0);

// Notes
// In the code IndicatorName, 0, 0) the final 0 means this is reading the indicator position during the current Bar
// The next to last 0 means you are reading the first buffer
// An indicator can have up to 7 outputs (aka 'output buffers'), confusingly numbered 0-6 (aka 'zero based')

// Output the values to the Journal tab
Print("signal0_0: ", signal0_0, " signal1_0: ", signal1_0, " signal2_0: ", signal2_0, " signal3_0: ", signal3_0, " signal4_0: ", signal4_0, " signal5_0: ", signal5_0, " signal6_0: ", signal6_0);



// Read all 7 possible outputs for the last closed bar
double signal0_1=iCustom(NULL, 0, IndicatorName,0,1); 
double signal1_1=iCustom(NULL, 0, IndicatorName,1,1);
double signal2_1=iCustom(NULL, 0, IndicatorName,2,1);
double signal3_1=iCustom(NULL, 0, IndicatorName,3,1);
double signal4_1=iCustom(NULL, 0, IndicatorName,4,1);
double signal5_1=iCustom(NULL, 0, IndicatorName,5,1);
double signal6_1=iCustom(NULL, 0, IndicatorName,6,1);

// Notes
// In the code IndicatorName, 0, 1) the 1 means this is reading the indicator position in the last closed bar

// Output the values to the Journal tab
Print("signal0_1: ", signal0_1, " signal1_1: ", signal1_1, " signal2_1: ", signal2_1, " signal3_1: ", signal3_1, " signal4_1: ", signal4_1, " signal5_1: ", signal5_1, " signal6_1: ", signal6_1);



// Read all 7 possible outputs for two bars ago bar
double signal0_2=iCustom(NULL, 0, IndicatorName,0,2); 
double signal1_2=iCustom(NULL, 0, IndicatorName,1,2);
double signal2_2=iCustom(NULL, 0, IndicatorName,2,2);
double signal3_2=iCustom(NULL, 0, IndicatorName,3,2);
double signal4_2=iCustom(NULL, 0, IndicatorName,4,2);
double signal5_2=iCustom(NULL, 0, IndicatorName,5,2);
double signal6_2=iCustom(NULL, 0, IndicatorName,6,2);

// Notes
// In the code IndicatorName, 0, 2) the 2 means this is reading the indicator position in the bar before last closed bar

// Output the values to the Journal tab
Print("signal0_2: ", signal0_2, " signal1_2: ", signal1_2, " signal2_2: ", signal2_2, " signal3_2: ", signal3_2, " signal4_2: ", signal4_2, " signal5_2: ", signal5_2, " signal6_2: ", signal6_2);


return (0);

}








Good Luck
-BB-
 
thanks joetrader and BarrowBoy,
but i'm using a breakout box, like the panca-eagle breakout,
which doesn't seem to be using any buffer

what i want is to obtain the values of dPriceHigh and dPriceLow from the indicator

dPriceHigh = High[Highest(NULL, 0, MODE_HIGH, iBarBegin-iBarEnd, iBarEnd)];
dPriceLow = Low [Lowest (NULL, 0, MODE_LOW, iBarBegin-iBarEnd, iBarEnd)];

//+------------------------------------------------------------------+
//| BreakOutPANCA-EAGLE.mq4 |
//| hapalkos |
//| 2007.11.20 |
//| ++ modified so that rectangles do not overlay |
//| ++ this makes color selection more versatile |
//| ++ code consolidated |
//+------------------------------------------------------------------+
#property copyright "hapalkos"
#property link ""

#property indicator_chart_window

extern int NumberOfDays = 50;
extern string periodBegin = "00:00";
extern string periodEnd = "05:30";
extern string BoxEnd = "23:00";
extern int BoxBreakOut_Offset = 10;
extern color BoxHLColor = MidnightBlue;
extern color BoxBreakOutColor = LimeGreen;
extern color BoxPeriodColor = OrangeRed;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init() {
DeleteObjects();
}

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
void deinit() {
DeleteObjects();
return(0);
}

//+------------------------------------------------------------------+
//| Remove all Rectangles |
//+------------------------------------------------------------------+
void DeleteObjects() {
ObjectsDeleteAll(0,OBJ_RECTANGLE);
return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void start() {
datetime dtTradeDate=TimeCurrent();

for (int i=0; i<NumberOfDays; i++) {

DrawObjects(dtTradeDate, "BoxHL " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxHLColor, 0, 1);
DrawObjects(dtTradeDate, "BoxBreakOut_High " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,2);
DrawObjects(dtTradeDate, "BoxBreakOut_Low " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,3);
DrawObjects(dtTradeDate, "BoxPeriod " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, periodEnd, BoxPeriodColor, BoxBreakOut_Offset,4);

dtTradeDate=decrementTradeDate(dtTradeDate);
while (TimeDayOfWeek(dtTradeDate) > 5) dtTradeDate = decrementTradeDate(dtTradeDate);
}
}

//+------------------------------------------------------------------+
//| Create Rectangles |
//+------------------------------------------------------------------+

void DrawObjects(datetime dtTradeDate, string sObjName, string sTimeBegin, string sTimeEnd, string sTimeObjEnd, color cObjColor, int iOffSet, int iForm) {
datetime dtTimeBegin, dtTimeEnd, dtTimeObjEnd;
double dPriceHigh, dPriceLow;
int iBarBegin, iBarEnd;

dtTimeBegin = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + sTimeBegin);
dtTimeEnd = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + sTimeEnd);
dtTimeObjEnd = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + sTimeObjEnd);

iBarBegin = iBarShift(NULL, 0, dtTimeBegin);
iBarEnd = iBarShift(NULL, 0, dtTimeEnd);
dPriceHigh = High[Highest(NULL, 0, MODE_HIGH, iBarBegin-iBarEnd, iBarEnd)];
dPriceLow = Low [Lowest (NULL, 0, MODE_LOW, iBarBegin-iBarEnd, iBarEnd)];

ObjectCreate(sObjName, OBJ_RECTANGLE, 0, 0, 0, 0, 0);

ObjectSet(sObjName, OBJPROP_TIME1, dtTimeBegin);
ObjectSet(sObjName, OBJPROP_TIME2, dtTimeObjEnd);

//---- High-Low Rectangle
if(iForm==1){
ObjectSet(sObjName, OBJPROP_PRICE1, dPriceHigh);
ObjectSet(sObjName, OBJPROP_PRICE2, dPriceLow);
ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(sObjName, OBJPROP_COLOR, cObjColor);
ObjectSet(sObjName, OBJPROP_BACK, True);
}

//---- Upper Rectangle
if(iForm==2){
ObjectSet(sObjName, OBJPROP_PRICE1, dPriceHigh);
ObjectSet(sObjName, OBJPROP_PRICE2, dPriceHigh + iOffSet*Point);
ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(sObjName, OBJPROP_COLOR, cObjColor);
ObjectSet(sObjName, OBJPROP_BACK, True);
}

//---- Lower Rectangle
if(iForm==3){
ObjectSet(sObjName, OBJPROP_PRICE1, dPriceLow - iOffSet*Point);
ObjectSet(sObjName, OBJPROP_PRICE2, dPriceLow);
ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(sObjName, OBJPROP_COLOR, cObjColor);
ObjectSet(sObjName, OBJPROP_BACK, True);
}

//---- Period Rectangle
if(iForm==4){
ObjectSet(sObjName, OBJPROP_PRICE1, dPriceHigh + iOffSet*Point);
ObjectSet(sObjName, OBJPROP_PRICE2, dPriceLow - iOffSet*Point);
ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(sObjName, OBJPROP_COLOR, cObjColor);
ObjectSet(sObjName, OBJPROP_WIDTH, 2);
ObjectSet(sObjName, OBJPROP_BACK, False);
}
string sObjDesc = StringConcatenate("High: ",dPriceHigh," Low: ", dPriceLow, " OffSet: ",iOffSet);
ObjectSetText(sObjName, sObjDesc,10,"Times New Roman",Black);
}

//+------------------------------------------------------------------+
//| Decrement Date to draw objects in the past |
//+------------------------------------------------------------------+

datetime decrementTradeDate (datetime dtTimeDate) {
int iTimeYear=TimeYear(dtTimeDate);
int iTimeMonth=TimeMonth(dtTimeDate);
int iTimeDay=TimeDay(dtTimeDate);
int iTimeHour=TimeHour(dtTimeDate);
int iTimeMinute=TimeMinute(dtTimeDate);

iTimeDay--;
if (iTimeDay==0) {
iTimeMonth--;
if (iTimeMonth==0) {
iTimeYear--;
iTimeMonth=12;
}

// Thirty days hath September...
if (iTimeMonth==4 || iTimeMonth==6 || iTimeMonth==9 || iTimeMonth==11) iTimeDay=30;
// ...all the rest have thirty-one...
if (iTimeMonth==1 || iTimeMonth==3 || iTimeMonth==5 || iTimeMonth==7 || iTimeMonth==8 || iTimeMonth==10 || iTimeMonth==12) iTimeDay=31;
// ...except...
if (iTimeMonth==2) if (MathMod(iTimeYear, 4)==0) iTimeDay=29; else iTimeDay=28;
}
return(StrToTime(iTimeYear + "." + iTimeMonth + "." + iTimeDay + " " + iTimeHour + ":" + iTimeMinute));
}

//+------------------------------------------------------------------+