Edit Your Comment
Help please for a custom Indicator
Mar 02, 2011 부터 멤버
게시물9
Mar 15, 2011 at 22:06
Mar 02, 2011 부터 멤버
게시물9
Hello
I wrote these lines of code and I would like to get it working properly .
I use it in an EA and it seems correct ...unfortunately messagge in journal says : cannot resize the array.
Can anybody please correct the bug or the syntax ?
Thanks
Giorgio
//+------------------------------------------------------------------+
//| Ratio.mq4 |
//| Copyright © 2010, Giorgio Guglielmo. |
//|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Giorgio Guglielmo."
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_minimum -800000
#property indicator_maximum 800000
//---- indicator parameters
extern int periodAv=25;
extern int period=5;
//---- indicator buffers
double GainBuffer[];//Gain
double RatioBuffer[];//Ratio
double ReturnBuffer[];//Return
double MyPlotBuffer[];
double AVMyPlotBuffer[];
double AV1MyPlotBuffer[];
double SmoothedAV1MyPlotBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(2);//controllare !!!!!
//---- drawing settings
IndicatorDigits(Digits+2);
//---- 6 indicator buffers mapping
//SetIndexBuffer(0,GainBuffer);//Gold
//SetIndexBuffer(1,RatioBuffer);//Silver
//SetIndexBuffer(2,ReturnBuffer);//Black
//SetIndexBuffer(3,MyPlotBuffer);//Green
SetIndexBuffer(0,AV1MyPlotBuffer);//Red
SetIndexBuffer(1,SmoothedAV1MyPlotBuffer);//Blue
//SetIndexStyle(0,DRAW_LINE);//Gold
//SetIndexStyle(1,DRAW_LINE);//Silver
//SetIndexStyle(2,DRAW_LINE);//Black
// SetIndexStyle(3,DRAW_LINE);//Green
// SetIndexStyle(4,DRAW_LINE);//Red
SetIndexStyle(0,DRAW_LINE);//Blue
SetIndexStyle(1,DRAW_LINE);//Blue
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Ratio("+period+","+periodAv+")");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| declare arrays |
//+------------------------------------------------------------------+
int start()
{
if(Bars0) counted_bars--;
usedBar=MathMax(period,periodAv);
count=Bars-counted_bars;
MaxBar=Bars-1-usedBar;
/****************************************************************/
newSize=iBars(NULL,0);
if(ArraySize(MyArray0)MaxBar)
{
count=MaxBar;
for(bar=Bars -1;bar>=MaxBar;bar--)
{
MyArray0[bar] = 0.0;
MyArray1[bar] = 0.0;
MyArray2[bar] = 0.0;
MyArray3[bar] = 0.0;
MyArray4[bar] = 0.0;
MyArray5[bar] = 0.0;
}
}
//******************************************************************************/
//*******************************************************************************/
for(i=count; i>=1; i--)
{
MyArray0[i] =(iClose(NULL,0,i)-iClose(NULL,0,period))*100/(iClose(NULL,0,period));
}
for( i=count; i>=1; i--)
{
GainBuffer[i]=MyArray0[i];
}
for( i=count; i>=1; i--)
{
MyArray1[i] = MathAbs(iMomentum(NULL,0,period,PRICE_CLOSE,i))/iATR(NULL,0,period,i);
}
//for(i=0; i=1; i--)
{
RatioBuffer[i]= iMAOnArray(MyArray1,Bars,period+periodAv,0,MODE_SMA,i);//divide for 10 ??
}
for( i=count; i>=1; i--)
{
MyArray2[i] =RatioBuffer[i] ;
}
// for( i=0; i=1; i--)
{
ReturnBuffer[i]=iMAOnArray(MyArray2,Bars,periodAv+period,0,MODE_SMA,i);
}
for( i=count; i>=1; i--)
{
MyArray4[i]=ReturnBuffer[i]*GainBuffer[i]*10;//multiply for 100
}
for( i=count; i>=1; i--)
{
MyPlotBuffer[i]=MyArray4[i];
}
for(i=count; i>=1; i--)
{
AV1MyPlotBuffer[i]=iMAOnArray(MyArray4,Bars,period,0,MODE_SMA,i);
}
for(i=count; i>=1; i--)
{
MyArray5[i]=AV1MyPlotBuffer[i]*0.9+MyArray4[i]*0.1;
}
for(i=count; i>=1; i--)
{
SmoothedAV1MyPlotBuffer[i]=iMAOnArray(MyArray5,Bars,period,0,MODE_SMA,i);
}
return(0);
}
//+------------------------------------------------------------------+
I wrote these lines of code and I would like to get it working properly .
I use it in an EA and it seems correct ...unfortunately messagge in journal says : cannot resize the array.
Can anybody please correct the bug or the syntax ?
Thanks
Giorgio
//+------------------------------------------------------------------+
//| Ratio.mq4 |
//| Copyright © 2010, Giorgio Guglielmo. |
//|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Giorgio Guglielmo."
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_minimum -800000
#property indicator_maximum 800000
//---- indicator parameters
extern int periodAv=25;
extern int period=5;
//---- indicator buffers
double GainBuffer[];//Gain
double RatioBuffer[];//Ratio
double ReturnBuffer[];//Return
double MyPlotBuffer[];
double AVMyPlotBuffer[];
double AV1MyPlotBuffer[];
double SmoothedAV1MyPlotBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(2);//controllare !!!!!
//---- drawing settings
IndicatorDigits(Digits+2);
//---- 6 indicator buffers mapping
//SetIndexBuffer(0,GainBuffer);//Gold
//SetIndexBuffer(1,RatioBuffer);//Silver
//SetIndexBuffer(2,ReturnBuffer);//Black
//SetIndexBuffer(3,MyPlotBuffer);//Green
SetIndexBuffer(0,AV1MyPlotBuffer);//Red
SetIndexBuffer(1,SmoothedAV1MyPlotBuffer);//Blue
//SetIndexStyle(0,DRAW_LINE);//Gold
//SetIndexStyle(1,DRAW_LINE);//Silver
//SetIndexStyle(2,DRAW_LINE);//Black
// SetIndexStyle(3,DRAW_LINE);//Green
// SetIndexStyle(4,DRAW_LINE);//Red
SetIndexStyle(0,DRAW_LINE);//Blue
SetIndexStyle(1,DRAW_LINE);//Blue
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Ratio("+period+","+periodAv+")");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| declare arrays |
//+------------------------------------------------------------------+
int start()
{
if(Bars0) counted_bars--;
usedBar=MathMax(period,periodAv);
count=Bars-counted_bars;
MaxBar=Bars-1-usedBar;
/****************************************************************/
newSize=iBars(NULL,0);
if(ArraySize(MyArray0)MaxBar)
{
count=MaxBar;
for(bar=Bars -1;bar>=MaxBar;bar--)
{
MyArray0[bar] = 0.0;
MyArray1[bar] = 0.0;
MyArray2[bar] = 0.0;
MyArray3[bar] = 0.0;
MyArray4[bar] = 0.0;
MyArray5[bar] = 0.0;
}
}
//******************************************************************************/
//*******************************************************************************/
for(i=count; i>=1; i--)
{
MyArray0[i] =(iClose(NULL,0,i)-iClose(NULL,0,period))*100/(iClose(NULL,0,period));
}
for( i=count; i>=1; i--)
{
GainBuffer[i]=MyArray0[i];
}
for( i=count; i>=1; i--)
{
MyArray1[i] = MathAbs(iMomentum(NULL,0,period,PRICE_CLOSE,i))/iATR(NULL,0,period,i);
}
//for(i=0; i=1; i--)
{
RatioBuffer[i]= iMAOnArray(MyArray1,Bars,period+periodAv,0,MODE_SMA,i);//divide for 10 ??
}
for( i=count; i>=1; i--)
{
MyArray2[i] =RatioBuffer[i] ;
}
// for( i=0; i=1; i--)
{
ReturnBuffer[i]=iMAOnArray(MyArray2,Bars,periodAv+period,0,MODE_SMA,i);
}
for( i=count; i>=1; i--)
{
MyArray4[i]=ReturnBuffer[i]*GainBuffer[i]*10;//multiply for 100
}
for( i=count; i>=1; i--)
{
MyPlotBuffer[i]=MyArray4[i];
}
for(i=count; i>=1; i--)
{
AV1MyPlotBuffer[i]=iMAOnArray(MyArray4,Bars,period,0,MODE_SMA,i);
}
for(i=count; i>=1; i--)
{
MyArray5[i]=AV1MyPlotBuffer[i]*0.9+MyArray4[i]*0.1;
}
for(i=count; i>=1; i--)
{
SmoothedAV1MyPlotBuffer[i]=iMAOnArray(MyArray5,Bars,period,0,MODE_SMA,i);
}
return(0);
}
//+------------------------------------------------------------------+
Aug 20, 2009 부터 멤버
게시물256
Mar 02, 2011 부터 멤버
게시물9
Jan 14, 2010 부터 멤버
게시물541
Mar 02, 2011 부터 멤버
게시물9
Mar 16, 2011 at 17:53
Mar 02, 2011 부터 멤버
게시물9
Hi
Unfortunately not yet
All suggests I had seems to me right but not solve the problem.
The strange thing is that the indicator as it is ....works in EA and is painted in separate window chart as well.
when I modify or check as you said ....the indicator is painted as a line == 0 and of course it does not work in EA
Thanks Giorgio
Unfortunately not yet
All suggests I had seems to me right but not solve the problem.
The strange thing is that the indicator as it is ....works in EA and is painted in separate window chart as well.
when I modify or check as you said ....the indicator is painted as a line == 0 and of course it does not work in EA
Thanks Giorgio
Mar 02, 2011 부터 멤버
게시물9
Jan 14, 2010 부터 멤버
게시물541
Mar 17, 2011 at 08:54
Jan 14, 2010 부터 멤버
게시물541
1448giorgio posted:
Hi
Unfortunately not yet
All suggests I had seems to me right but not solve the problem.
The strange thing is that the indicator as it is ....works in EA and is painted in separate window chart as well.
when I modify or check as you said ....the indicator is painted as a line == 0 and of course it does not work in EA
Thanks Giorgio
Have you tried debugging the issue? Print all variables and you'll quickly find the error.
Mar 02, 2011 부터 멤버
게시물9
Mar 17, 2011 at 11:10
Mar 02, 2011 부터 멤버
게시물9
Hello wilkinson
Yes I printed variables and reported values seem to be reported in right way .(message always : cannot resize array but EA reads values from indicator)
Any way as soon as I do not resize buffers .....buffers are all ==0 and EA does not work.
EA should read two buffers from this indicator
If this matter has be solved throught a fee I am ready to pay any coder willing to help to do the job ...I mean $50 throught PayPal as soon as work is done
Is it an adequate reward for this issue ?
Thanks Giorgio
Yes I printed variables and reported values seem to be reported in right way .(message always : cannot resize array but EA reads values from indicator)
Any way as soon as I do not resize buffers .....buffers are all ==0 and EA does not work.
EA should read two buffers from this indicator
If this matter has be solved throught a fee I am ready to pay any coder willing to help to do the job ...I mean $50 throught PayPal as soon as work is done
Is it an adequate reward for this issue ?
Thanks Giorgio
Mar 02, 2011 부터 멤버
게시물9

*상업적 사용 및 스팸은 허용되지 않으며 계정이 해지될 수 있습니다.
팁: 이미지/유튜브 URL을 게시하면 게시물에 자동으로 삽입됩니다!
팁: @기호를 입력하여 이 토론에 참여하는 사용자 이름을 자동으로 완성합니다.