MQL4 - automated forex trading   /  

Forum

How do using indicator in EA ?

Back to topics list To post a new topic, please log in or register

avatar
128
Mehmet 2008.06.17 22:48 

i have a sample indicators

//+------------------------------------------------------------------+
//| IndicatorNew.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
double sonuc=0.0;
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
double rest=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
if (rest>50) sonuc=1.5;
if (rest<50) sonuc=2.0;
if (rest==50) sonuc=3.25;



//----

//----
return(0);
}
//+------------------------------------------------------------------+

I have a EA.

//+------------------------------------------------------------------+
//| ExpertNew.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

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

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double deger=iCustom(NULL, 0, "IndicatorNew",13,1,0);
Print(deger);
//----

//----
return(0);
}
//+------------------------------------------------------------------+

i want to using indicator in my EA.

questions

1. How do change of codes Indicators.

2. How do change of codes Expert Advisor.

Thank You.

article

To Sleep, or Not to Sleep?

An alternative use of the Sleep() function in the realization of pauses between EA's actions is proposed. The approach under consideration allows a smart use of machine time.


avatar
1514
DxdCn 2008.06.18 05:10 

1 since MACD is indicators inside MT, so you can use these inside EA directory:

double rest=CD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
if (rest>50) sonuc=1.5;
if (rest<50) sonuc=2.0;
if (rest==50) sonuc=3.25;

2 double deger=iCustom(NULL, 0, "IndicatorNew",13,1,0); this is errors for this!!!!!, since parameter 13 has no menaing, parameter 1 is for one of databuffer, but no any buffer and no any parameter exist in your indicator "IndicatorNew", you only have a indicator file, but no any indicator data inside it, you should reference MTedit's help, and MQL4 language, and a lot of sample file on internet, atleast you shoul learn the samples bringed by MTself and try to modified them.

these two files only a sketch of file format of indicator and EA, but no useful contents in them.

Back to topics list  

To add comments, please log in or register