Custom Indicators in EA

 

Can anyone shed some light on how I can incorporate a custom indicator into my order send functions in my EA? I have the custom indicator and want to call on it with the EA.....any help would be greatly appreciated! Custom indicator resembles... ...

//+------------------------------------------------------------------+
//|                                          Support and Resistance  |
//|                                 Copyright © 2004  Barry Stander  |
//|                          http://myweb.absa.co.za/stander/4meta/  |
//+------------------------------------------------------------------+
#property copyright "Click here: Barry Stander"
#property link      "http://myweb.absa.co.za/stander/4meta/"
 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- buffers
double v1[];
double v2[];
double val1;
double val2;
int i;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+  
int init()
  {
//---- drawing settings
   SetIndexArrow(0, 119);
   SetIndexArrow(1, 119);
//----  
   SetIndexStyle(0, DRAW_ARROW, STYLE_DOT, 1);
   SetIndexDrawBegin(0, i-1);
   SetIndexBuffer(0, v1);
   SetIndexLabel(0,"Resistance");
//----    
   SetIndexStyle(1,DRAW_ARROW,STYLE_DOT,1);
   SetIndexDrawBegin(1,i-1);
   SetIndexBuffer(1, v2);
   SetIndexLabel(1,"Support");
//---- 
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  { 
   i = Bars;
   while(i >= 0)
     {   
       val1 = iFractals(NULL, 0, MODE_UPPER, i);
       //----
       if(val1 > 0) 
           v1[i] = High[i];
       else
           v1[i] = v1[i+1];
       val2 = iFractals(NULL, 0, MODE_LOWER, i);
       //----
       if(val2 > 0) 
           v2[i] = Low[i];
       else
           v2[i] = v2[i+1];
       i--;
     }   
   return(0);
  }
//+------------------------------------------------------------------+
need this to return a value for the support and a value for the resistance...... .thanks!!!!!
 

See iCustom()

 
Do I call val 1 and val 2 for the actual values or is it v1 and v2? I noticed the support and resistance values show up after a few bars......
 

iCustom requests the value of an indicator index, numbered 0 through 7.

Look at indicator code and request the value of the index you are interested in obtaining

double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

mode - Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions.
 
phy:

iCustom requests the value of an indicator index, numbered 0 through 7.

Look at indicator code and request the value of the index you are interested in obtaining

double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

mode - Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions.


Phy,

What would this look like for the indicator I put up above? Sorry, I am a little confused on what needs to go into all the places for the iCustom funciton. I understand we need to use this function, but I cannot decipher what needs to be done from there. Also is this put in as Normalizedouble or double? Please help.....

 

"Can anyone shed some light on how I can incorporate a custom indicator into my order send functions in my EA? I have the custom indicator and want to call on it with the EA"

You "call" the custom indicator code and ask it to hand you its values via the iCustom() call. It is not necessary to "incorporate" an indicator into your EA.

The indicator above has two indexes , named Resistance and Support in use. The iCustom call will reference index 0 or index 1, that is, 0 or 1, in the "mode"
parameter to get the values from the indicator. This indicator has no external inputs, so the " ,..., " part is not used.

"I am a little confused on what needs to go into all the places for the iCustom funciton."

That is why all the commands are defined in the documentation. Play around with code and find out how things work. Write tiny programs to explore
specific things you don't understand, until you do understand. Give yourself a year or so to become proficient if you are not coming in with existing
code skills.

"Also is this put in as Normalizedouble or double? "

Is what put in?

NormalizeDouble is necessary to limit the number of digits in the fractional part of decimal numbers before comparing them for equality. A second use is
to limit the number of digits in the fractional part of a calculated decimal number as a preparation step before placing it into one of the price fields of an
order to buy or sell.

 
, string name, ...,
Reason: