Expert code...

 
I am having a bit of trouble with writing experts. When I read iCustom indicator values they do not match the same indicator that is plotted on the screen. Is there a trick to getting the correct values into the expert. Do I have to replicate the indicator as a fuction inside the expert? I have tried both iCustom and global variables without any luck.

Thanks,
Dan
 
I am having a bit of trouble with writing experts. When I read iCustom indicator values they do not match the same indicator that is plotted on the screen. Is there a trick to getting the correct values into the expert. Do I have to replicate the indicator as a fuction inside the expert? I have tried both iCustom and global variables without any luck.

Thanks,
Dan

Pay attention to ,...., field below.

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

Pay attention to A,B,C,D, in that field

double iCustom( string symbol, int timeframe, string name, A,B,C,D, int mode, int shift)

The A,B,C,D values must be same in the expert and indicator "extern" variables if you want same results.

The first "extern" variable in the indicator corresponds to "A"
The second "extern" variable in the indicator corresponds to "B"
The third "extern" variable in the indicator corresponds to "C"
The fourth "extern" variable in the indicator corresponds to "D"
.
.
 
Thank you for the reply...I will test it out this week.

Dan
 
Here is my test expert:
----------------------------
extern double A = 22;
extern double B = 7;
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
double TL00 = iCustom(NULL, 0, "custom_test_indicator",A,B,0,0);
Print(" Result: ", TL00);
return(0);
}
---------------------------
Here is the test indicator:
---------------------------
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Orange

extern double A;
extern double B;
double R;
double Array[];
int i;
int limit;
int counted_bars;

int init()
{
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexDrawBegin(0,0);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
IndicatorShortName("R");

SetIndexBuffer(0,Array);
SetIndexLabel(0,"R");

return(0);
}
int deinit()
{
return(0);
}
int start()
{
limit=Bars;
for(i=0; i <= limit; i++)
{
if (i == limit)
{
Print("i: ",i);
}
Array[i] = i;
}
return(0);
}
----------------------
output
2005.05.25 08:16 custom_test GBPUSD, M15: Result: 0
2005.05.25 08:16 custom_test_indicator GBPUSD, M15: i: 471
---------
Question: Why is the value of 471 returning from the iCustom as zero? Is it indexing one past the limit to end the loop and causing it to become zero?
 
What is Array[] size?
 
Size of Array is Bars.
 
How do You assign this size to your array?
 
Does this do it?

double Array[];
limit=Bars;
for(i=0; i <= limit; i++)
{
Array[i] = value;
}
 
double Array[] means array of zero size. You need to resize it or declare with size
double Array[1000];
 
double Array[] means array of zero size. You need to resize it or declare with size
double Array[1000];

But Slawa,
He is referring to the Array as a indicator Buffer 0.
You do not have to specify indicator Buffer size, do you?
 
Does this do it?

double Array[];
limit=Bars;
for(i=0; i <= limit; i++)
{
Array[i] = value;
}


What is your objective?
Why are you declaring extern A, B if they are not used in your indicator?
Reason: