下载MetaTrader 5
要添加评论,请登录注册
了解如何在Linux上安装MetaTrader
gget
410
gget 2008.03.31 12:43 
For example

I use an indicator you recommended The "Impulse_macd.mq4"

Using the function "iCustom()" to get the data from indicator to an ea

I put two files recorded the data on both sides

But the data from the indicator producing and the data the ea got are very different !

I show you the results and the program below

Please help me !

Thank you in advance !!!


The ea program :

........

int IMACD_Timeframe=PERIOD_M1;
double SignalBuffer[4];
int bar;
for(bar = 1; bar <= 4; bar++)
SignalBuffer[bar-1] = iCustom(NULL,IMACD_Timeframe,"Impulse_MACD",MasterMA,SignalMA,MODE_SMA,bar-1);
FileWrite(GGhandle,"OpenTime ",TimeToStr(TimeCurrent()),"0= ",SignalBuffer[0]*10000,"1= ",SignalBuffer[1]*10000,"2= ",SignalBuffer[2]*10000,"3= ",SignalBuffer[3]*10000);
...........


The indicator :

//+------------------------------------------------------------------+
//| Cronex Impulse_MACD.mq4 |
//| Copyright ?2007, Cronex. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2008, Cronex"
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 SteelBlue
#property indicator_color2 DarkOrange

//---- indicator parameters
extern int MasterMA=34;
extern int SignalMA=9;
//---- indicator buffers

double MacdDivrBuffer[];
double SignalBuffer[];

double BTS_S0,BTS_S1;
int JJhandle; // 结果数据文件保存
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
JJhandle = FileOpen("JJResult.csv",FILE_CSV|FILE_WRITE,';');
//---- indicator buffers mapping
SetIndexBuffer(0,MacdDivrBuffer);
SetIndexBuffer(1,SignalBuffer);
//---- drawing settings

SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_LINE);

SetIndexEmptyValue(0,0) ;
IndicatorDigits(Digits+1);

//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Impulce MACD("+MasterMA+","+SignalMA+")");
SetIndexLabel(0,"Impulce MACD");
SetIndexLabel(1,"Signal");
//---- initialization done
return(0);
}
int deinit()
{
// Comment("");
FileClose(JJhandle);
// FileClose(JGhandle);
return(0);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double HiInd,LoInd,MasterInd;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
for(int i=0; i<limit; i++)
{
HiInd=iMA(NULL,0,MasterMA,0,MODE_SMMA,PRICE_HIGH,i);
LoInd=iMA(NULL,0,MasterMA,0,MODE_SMMA,PRICE_LOW,i);
MasterInd=iMA(NULL,0,MasterMA,0,MODE_LWMA,PRICE_WEIGHTED,i);

if(MasterInd>HiInd)
MacdDivrBuffer[i]=MasterInd-HiInd;

if(MasterInd<LoInd)
MacdDivrBuffer[i]=MasterInd-LoInd;
}
//---- signal line counted in the 2-nd buffer
for(i=0; i<limit; i++)
SignalBuffer[i]=iMAOnArray(MacdDivrBuffer,Bars,SignalMA,0,MODE_SMA,i);
//BTS_S0=SignalBuffer[0]*10000;
//BTS_S1=SignalBuffer[1]*10000;
FileWrite(JJhandle,"OpenTime ",TimeToStr(TimeCurrent()),"0= ",SignalBuffer[0]*10000,"1= ",SignalBuffer[1]*10000,"2= ",SignalBuffer[2]*10000,"3= ",SignalBuffer[3]*10000);

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








Rashid Umarov
管理员
6602
Rashid Umarov 2008.03.31 14:51  
There is an error in your EA or indicator. I did explain such kind of trouble somewhere in this forum. It will be better if you yourself will clear up.
gget
410
gget 2008.03.31 15:23  
Thank you for your reply

I knew you said "You must call function iCustom() with parameters in same order as indicator was written"

I have already followed your above instruction

To make variables in ea in same order like as indicator

.......

extern int MasterMA=34;
extern int SignalMA=9;

.........

You said "I did explain such kind of trouble somewhere in this forum"

Please tell me where could I find you said: the such kind of trouble ?

The http:// ???

Thank you very much !

Rashid Umarov
管理员
6602
Rashid Umarov 2008.03.31 20:09  
I can't find this topic right now. See for example Dear Mr. Rosh, Now the problem is .....
gget
410
gget 2008.03.31 20:47  
Rosh:
I can't find this topic right now. See for example Dear Mr. Rosh, Now the problem is .....
Mr. Rosh

The website you wrote is found: "The page you have requested does not exist"

(: (:

Rashid Umarov
管理员
6602
Rashid Umarov 2008.03.31 21:45  
Fixed
gget
410
gget 2008.04.02 09:35  
Rosh:
Fixed

I found what you said

And debug the error already


Thank you very much !!!

Rashid Umarov
管理员
6602
Rashid Umarov 2008.04.02 09:39  
You're welcome!
zky
4
zky 2008.04.02 19:26  

The function "IndicatorCounted()" can get a different data from indicator and ea

maybe,it's a bug in MQ

Rashid Umarov
管理员
6602
Rashid Umarov 2008.04.02 21:30  
Function IndicatorCounted() uses only for indicators but not expert advisor (EAs)!
zky
4
zky 2008.04.03 06:32  
Thanks!
/
要添加评论,请登录注册