iCustom not working.

 

hello.

actually i'm almost new to mql4 programming.

i have a angle indicator which is using MA and inside other EA i want to call this angle indicator and want to read angle value so i tried iCustom but every i tried all failed.

following is ma_angle source.

and this is icustom code what i tried.

    double xx = iCustom(NULL, 0, "ma_angle",10,3,AliceBlue,21,0,0 ,0,  0);

    Print("aaa "+xx);

anyone help much appreciate!

//+------------------------------------------------------------------+
//|                                                     ma_angle.mq4 |
//|                                                        DimDimych |
//|                                                     dm34@mail.ru |
//|                                         http://dimdimych.ucoz.ru |
//+------------------------------------------------------------------+
#property copyright "DimDimych"
#property link      "http://dimdimych.ucoz.ru"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 CLR_NONE



extern int             ma_per = 10;
extern int             ma_met = 3;
extern color          col_ang = AliceBlue;
extern int           ExtDepth = 21;
extern int                ext = 0;
extern int           Complect = 0;
double varMA[],value;

int init()
  {
   IndicatorBuffers(1);   
   IndicatorDigits(Digits+1);   
   SetIndexBuffer(0,varMA);
   SetIndexStyle(0,DRAW_LINE);
   return(0);
  }
int deinit()
  {
   ObjectDelete("AngleA "+Complect);
   ObjectDelete("AngleText "+Complect);
   Comment("");
   return(0);
  }
  
int start()
  {
   int i, limit, counted_bars=IndicatorCounted();
   limit = Bars-counted_bars-1; 
   double varMALast, varMACurrent;
   //Print(value);
   for(i=limit; i>=0; i--)
   {
      varMA[i] = iMA(NULL,0,ma_per,0,ma_met,PRICE_CLOSE,i);
      int nb_0 = GetExtremumZZBar(NULL, 0, ext);
      
      varMALast= varMA[i+nb_0];
      varMACurrent=varMA[i+1];
 
      if (ObjectFind("AngleA "+Complect)<0)
      {
        ObjectCreate("AngleA "+Complect,OBJ_TRENDBYANGLE,0,Time[i+nb_0],varMALast,Time[i+1],varMACurrent);
        ObjectSet("AngleA "+Complect,OBJPROP_STYLE,2);
      }
      
      if (ObjectFind("AngleText "+Complect)==-1)
          ObjectCreate("AngleText "+Complect,OBJ_TEXT,0,0,0);

      ObjectSet("AngleA "+Complect,OBJPROP_TIME2,Time[i+1]);
      ObjectSet("AngleA "+Complect,OBJPROP_PRICE2,varMACurrent);
      ObjectSet("AngleA "+Complect,OBJPROP_TIME1,Time[i+nb_0]);
      ObjectSet("AngleA "+Complect,OBJPROP_PRICE1,varMALast);
      ObjectSet("AngleA "+Complect,OBJPROP_COLOR,col_ang);
      value=ObjectGet("AngleA "+Complect,OBJPROP_ANGLE);
      color warna;
      if(value>90)
        value = value-360;
        //Print(value);
      ObjectSetText("AngleText "+Complect,DoubleToStr(value,2),8,"Verdana",col_ang);
      ObjectMove("AngleText "+Complect,0,Time[0]+5*Period()*60,ObjectGetValueByShift("AngleA "+Complect,i)); 
   }
   return(0);
  }

int GetExtremumZZBar(string sy="", int tf=0, int ne=0) {
  if (sy=="" || sy=="0") sy=Symbol();
  double zz;
  int    i, k=iBars(sy, tf), ke=0;

  for (i=1; i<k; i++) {
    zz=iCustom(sy, tf, "ZigZag", ExtDepth,5,3, 0,i);
    if (zz!=0) {
      ke++;
      if (ke>ne) return(i);
    }
  }
  Print("GetExtremumZZBar(): ");
  return(-1);
}
 
james272: want … so i tried … all failed.
  1. Define "failed"

    "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
         How To Ask Questions The Smart Way. 2004
              When asking about code

    Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  2. Your indicator only has one buffer. It only puts a MA there. What do you expect to read? Define "failed"

  3. It also creates a trendline by angle which is useless.
    1. There is no angle from 2 anchor points. An angle requires distance divided by distance; a unit-less number. A chart has price and time. What is the angle of going 30 miles in 45 minutes? Meaningless!

    2. You can get the slope from a trendline: m=ΔPrice÷ΔTime. Changing the price scale, bar width, or window size, changes the apparent angle, the slope is constant. Angle is meaningless.

    3. You can create an angled line using one point and setting the angle (Object Properties - Objects Constants - Standard Constants, Enumerations and Structures - MQL4 Reference.) The line is drawn that angle in pixels. Changing the axes scales does NOT change the angle (and thus is meaningless.)

    4. If you insist, take the two price/time coordinates, convert them to pixel coordinates and then to apparent angle with arctan.
                How to get the angle of a trendline and place a text object to it? - Trend Indicators - MQL4 programming forum - Page 2

 
William Roeder:
  1. Define "failed"

    "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
         How To Ask Questions The Smart Way. 2004
              When asking about code

    Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  2. Your indicator only has one buffer. It only puts a MA there. What do you expect to read? Define "failed"

  3. It also creates a trendline by angle which is useless.
    1. There is no angle from 2 anchor points. An angle requires distance divided by distance; a unit-less number. A chart has price and time. What is the angle of going 30 miles in 45 minutes? Meaningless!

    2. You can get the slope from a trendline: m=ΔPrice÷ΔTime. Changing the price scale, bar width, or window size, changes the apparent angle, the slope is constant. Angle is meaningless.

    3. You can create an angled line using one point and setting the angle (Object Properties - Objects Constants - Standard Constants, Enumerations and Structures - MQL4 Reference.) The line is drawn that angle in pixels. Changing the axes scales does NOT change the angle (and thus is meaningless.)

    4. If you insist, take the two price/time coordinates, convert them to pixel coordinates and then to apparent angle with arctan.
                How to get the angle of a trendline and place a text object to it? - Trend Indicators - MQL4 programming forum - Page 2

thanks for advice!

finally i edited icustom side source but still couldn't read value from ma_angle indicator.

please check

Files:
test2.mq4  2 kb
 
james272:

thanks for advice!

finally i edited icustom side source but still couldn't read value from ma_angle indicator.

please check

resolved

 iCustom(NULL, 0, "Angle", 10, 3, clrBlue, 21, 0, 0, 1, 0)
 
james272: resolved iCustom(NULL, 0, "Angle", 10, 3, clrBlue, 21, 0, 0, 1, 0)

Good like reading the second buffer from an indicator with only one.

Reason: