Help needed with iCustom

Post Reply
K-Lander
Trader
Posts: 35
Joined: Thu Nov 17, 2011 9:03 pm
Location: Buenos Aires, Argentina

Help needed with iCustom

Post by K-Lander »

Hello all,
Maybe this is too basic but I am in my first steps as a wannabe coder, so bear with me... I am trying to call an indi from an EA, to no avail. I only have the ex4 file so I don´t know if this is even possible. I have no idea of the parameters the indi needs (no external ones though), so what I am doing is this:

I want to get the indi´s values of the last 8 bars and pick the highest and lowest values, so:

For (i=1;i<9;i++)
{
Indi = iCustom(NULL,0,"INDINAME", 1, i);
if (Indi > IndiHigh) IndiHigh = Indi;
if (Indi < IndiLow) IndiLow = Indi;
}

However, iCustom does not read the indi´s values. IndiHigh and IndiLow remain zeroed. As I said, I only have the indi´s ex4 file.

If this is not possible, I thought I may code an indi that reads in real time the ex4 output on the screen, a sort of mirror that can be called in turn by iCustom. Anyway, any help here will be greatly appreciated.

Thanks a lot,

K-Lander
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Help needed with iCustom

Post by gaheitman »

K-Lander wrote:Hello all,
Maybe this is too basic but I am in my first steps as a wannabe coder, so bear with me... I am trying to call an indi from an EA, to no avail. I only have the ex4 file so I don´t know if this is even possible. I have no idea of the parameters the indi needs (no external ones though), so what I am doing is this:

I want to get the indi´s values of the last 8 bars and pick the highest and lowest values, so:

For (i=1;i<9;i++)
{
Indi = iCustom(NULL,0,"INDINAME", 1, i);
if (Indi > IndiHigh) IndiHigh = Indi;
if (Indi < IndiLow) IndiLow = Indi;
}

However, iCustom does not read the indi´s values. IndiHigh and IndiLow remain zeroed. As I said, I only have the indi´s ex4 file.

If this is not possible, I thought I may code an indi that reads in real time the ex4 output on the screen, a sort of mirror that can be called in turn by iCustom. Anyway, any help here will be greatly appreciated.

Thanks a lot,

K-Lander


When you have the indicator on a chart does it appear with values in the data window? If so, you can get it with iCustom(). You'll probably want to call it with mode = 0, which will give you the first indicator buffer.

George
K-Lander
Trader
Posts: 35
Joined: Thu Nov 17, 2011 9:03 pm
Location: Buenos Aires, Argentina

Re: Help needed with iCustom

Post by K-Lander »

gaheitman wrote:
K-Lander wrote:Hello all,
Maybe this is too basic but I am in my first steps as a wannabe coder, so bear with me... I am trying to call an indi from an EA, to no avail. I only have the ex4 file so I don´t know if this is even possible. I have no idea of the parameters the indi needs (no external ones though), so what I am doing is this:

I want to get the indi´s values of the last 8 bars and pick the highest and lowest values, so:

For (i=1;i<9;i++)
{
Indi = iCustom(NULL,0,"INDINAME", 1, i);
if (Indi > IndiHigh) IndiHigh = Indi;
if (Indi < IndiLow) IndiLow = Indi;
}

However, iCustom does not read the indi´s values. IndiHigh and IndiLow remain zeroed. As I said, I only have the indi´s ex4 file.

If this is not possible, I thought I may code an indi that reads in real time the ex4 output on the screen, a sort of mirror that can be called in turn by iCustom. Anyway, any help here will be greatly appreciated.

Thanks a lot,

K-Lander


When you have the indicator on a chart does it appear with values in the data window? If so, you can get it with iCustom(). You'll probably want to call it with mode = 0, which will give you the first indicator buffer.

George


Hello George,
Yes, the indicator is on the chart and shows its current value on the upper left corner of the indi´s window, along with its continuous line. I tried with mode=0, yet nothing different happened.
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Help needed with iCustom

Post by gaheitman »

K-Lander wrote:
gaheitman wrote:
K-Lander wrote:Hello all,
Maybe this is too basic but I am in my first steps as a wannabe coder, so bear with me... I am trying to call an indi from an EA, to no avail. I only have the ex4 file so I don´t know if this is even possible. I have no idea of the parameters the indi needs (no external ones though), so what I am doing is this:

I want to get the indi´s values of the last 8 bars and pick the highest and lowest values, so:

For (i=1;i<9;i++)
{
Indi = iCustom(NULL,0,"INDINAME", 1, i);
if (Indi > IndiHigh) IndiHigh = Indi;
if (Indi < IndiLow) IndiLow = Indi;
}

However, iCustom does not read the indi´s values. IndiHigh and IndiLow remain zeroed. As I said, I only have the indi´s ex4 file.

If this is not possible, I thought I may code an indi that reads in real time the ex4 output on the screen, a sort of mirror that can be called in turn by iCustom. Anyway, any help here will be greatly appreciated.

Thanks a lot,

K-Lander


When you have the indicator on a chart does it appear with values in the data window? If so, you can get it with iCustom(). You'll probably want to call it with mode = 0, which will give you the first indicator buffer.

George


Hello George,
Yes, the indicator is on the chart and shows its current value on the upper left corner of the indi´s window, along with its continuous line. I tried with mode=0, yet nothing different happened.


Actually, I meant to look in the data window (Ctrl-D) and see what data is listed there. I'll need to see the code where you initialize the Indi[] array as well as have a copy of the indicator to see what's wrong. Feel free to post here or PM me.

George
K-Lander
Trader
Posts: 35
Joined: Thu Nov 17, 2011 9:03 pm
Location: Buenos Aires, Argentina

Re: Help needed with iCustom

Post by K-Lander »

Actually, I meant to look in the data window (Ctrl-D) and see what data is listed there. I'll need to see the code where you initialize the Indi[] array as well as have a copy of the indicator to see what's wrong. Feel free to post here or PM me.

George[/quote]

Sorry... Yes, the indi´s history appears in the data window.

Here I declare the variables. Maybe there is something related to the array missing?:


int Indi[8];
int IndiHigh, IndiLow;

For (i=1;i<9;i++)
{
Indi = iCustom(NULL,0,"INDINAME", 1, i);
if (Indi > IndiHigh) IndiHigh = Indi;
if (Indi < IndiLow) IndiLow = Indi;
}
You do not have the required permissions to view the files attached to this post.
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Help needed with iCustom

Post by gaheitman »

K-Lander wrote:
Sorry... Yes, the indi´s history appears in the data window.

Here I declare the variables. Maybe there is something related to the array missing?:


int Indi[8];
int IndiHigh, IndiLow;

For (i=1;i<9;i++)
{
Indi = iCustom(NULL,0,"INDINAME", 1, i);
if (Indi > IndiHigh) IndiHigh = Indi;
if (Indi < IndiLow) IndiLow = Indi;
}


Arrays are referenced from 0 to <array size> - 1. Also, you have to use the actual indicator name in the call to iCustom().... ;) You should see error messages in your expert tab in the terminal saying it cannot open the file.

The following code will scan the last 8 values and alert you with the high and low values.

Code: Select all

	int Indi[8];
	int IndiHigh, IndiLow;

	for (int i=0; i<8; i++)
	{
		Indi[i] = iCustom(NULL,0,"indi", 0, i);
                //I added this step since I don't know the proper range for the values
		if (i == 0) {
		   IndiHigh = Indi[i];
		   IndiLow = Indi[i];
		}
		if (Indi[i] > IndiHigh) IndiHigh = Indi[i];
		if (Indi[i] < IndiLow) IndiLow = Indi[i];
	}

	Alert("High = ",IndiHigh,"   Low = ",IndiLow);
George
garyfritz

Re: Help needed with iCustom

Post by garyfritz »

Unless you have other plans for the Indi[] values, there's no need to use an array. You're only using the latest value of the indicator. You could replace Indi with Indi and it would work the same.
K-Lander
Trader
Posts: 35
Joined: Thu Nov 17, 2011 9:03 pm
Location: Buenos Aires, Argentina

Re: Help needed with iCustom

Post by K-Lander »

gaheitman wrote:
K-Lander wrote:
Sorry... Yes, the indi´s history appears in the data window.

Here I declare the variables. Maybe there is something related to the array missing?:


int Indi[8];
int IndiHigh, IndiLow;

For (i=1;i<9;i++)
{
Indi = iCustom(NULL,0,"INDINAME", 1, i);
if (Indi > IndiHigh) IndiHigh = Indi;
if (Indi < IndiLow) IndiLow = Indi;
}


Arrays are referenced from 0 to <array size> - 1. Also, you have to use the actual indicator name in the call to iCustom().... ;) You should see error messages in your expert tab in the terminal saying it cannot open the file.

The following code will scan the last 8 values and alert you with the high and low values.

Code: Select all

	int Indi[8];
	int IndiHigh, IndiLow;

	for (int i=0; i<8; i++)
	{
		Indi[i] = iCustom(NULL,0,"indi", 0, i);
                //I added this step since I don't know the proper range for the values
		if (i == 0) {
		   IndiHigh = Indi[i];
		   IndiLow = Indi[i];
		}
		if (Indi[i] > IndiHigh) IndiHigh = Indi[i];
		if (Indi[i] < IndiLow) IndiLow = Indi[i];
	}

	Alert("High = ",IndiHigh,"   Low = ",IndiLow);
George
Hello George. It seems to be working fine now. I guess the problem was in the array management. The indi´s name was ok.

Thanks a bunch, really...

K
Post Reply

Return to “Coders Hangout”