Help to recognize color change with LSMA indicator

Fabio Butto
177
Fabio Butto  

Hi everybody,

I wrote the following code to get the indexes from the LSMA indicator on the current bar:

index0=iCustom(NULL,0,"LSMA in Color",34,1500,0,0);
index1=iCustom(NULL,0,"LSMA in Color",34,1500,1,0);
index2=iCustom(NULL,0,"LSMA in Color",34,1500,2,0);

but it always give me the same value for

index0=1

index1=1

index2=1

how I can recognize the color of the indicator on the current bar ?

Files:
okwh
1646
okwh  
index0 1 2 are int or double type ?
Fabio Butto
177
Fabio Butto  
DxdCn wrote >>
index0 1 2 are int or double type ?

index0 1 2 are int ;-0

Thanks in advance for your support

Fabio Butto
177
Fabio Butto  
Fabio wrote >>

index0 1 2 are int ;-0

Thanks in advance for your support

I tried to declare index0 1 2 as double i.s.o integer, but they give always the same value.

Thus I can't distinguish which color is it .

Please HELP !

Fabio Butto
177
Fabio Butto  
Fabio wrote >>

Hi everybody,

I wrote the following code to get the indexes from the LSMA indicator on the current bar:

index0=iCustom(NULL,0,"LSMA in Color",34,1500,0,0);
index1=iCustom(NULL,0,"LSMA in Color",34,1500,1,0);
index2=iCustom(NULL,0,"LSMA in Color",34,1500,2,0);

but it always give me the same value for

index0=1

index1=1

index2=1

how I can recognize the color of the indicator on the current bar ?

Please somebody help me . May be Phy ?

Ray
2646
Ray  

Your indicator has three indexes, for three colors.

Figure out which index corresponds to which color,

and when that index has a value in it which is near price for that bar,

that is your clue to the color.

Your index0/1/2 need to be type double.

You need to verify that your iCustom call is correctly formatted.

What you are doing "looks" ok, but you don't show all your code, so who knows.

Fabio Butto
177
Fabio Butto  
phy wrote >>

Your indicator has three indexes, for three colors.

Figure out which index corresponds to which color,

and when that index has a value in it which is near price for that bar,

that is your clue to the color.

Your index0/1/2 need to be type double.

You need to verify that your iCustom call is correctly formatted.

What you are doing "looks" ok, but you don't show all your code, so who knows.

Hi Phy

thanks for your support.

Hereafter it's my code:

bool difference_found=false;

double LSMA_index0,LSMA_index1,LSMA_index2;

LSMA_index0=iCustom(NULL,0,"LSMA in Color",34,1500,0,0);
LSMA_index1=iCustom(NULL,0,"LSMA in Color",34,1500,1,0);
LSMA_index2=iCustom(NULL,0,"LSMA in Color",34,1500,2,0);
if(LSMA_index0 != LSMA_index1 || LSMA_index1!=LSMA_index2 || LSMA_index0!=LSMA_index2)
{
difference_found=true;
}

string sComment;
sComment="";

sComment=sComment+"LSMA color0=" +LSMA_index0+"\n";
sComment=sComment+"LSMA color1=" +LSMA_index1+"\n";
sComment=sComment+"LSMA color2=" +LSMA_index2+"\n";
sComment=sComment+"Difference found=" +difference_found+"\n";
Comment(sComment);

but it never set difference_found = true ;-(

The value of LSMA_index0, LSMA_index1, LSMA_index2 are always the same . Like this I never can find out which color is it.

Once I could clear identify a color changing I would like to write an EA that buy when color changed from red->green or from yellow -> green and sell when the opposite occurs.

Can you please HELP me ?

Thanks in advance

Fabio

Ray
2646
Ray  
Why don't you just post your code, Why make us guess?
Also, you posted a different indicator than what you are calling in your snips.
Fabio Butto
177
Fabio Butto  
phy wrote >>

here is my code ;-)

Thanks again

Files:
lsma.mq4  3 kb
Fabio Butto
177
Fabio Butto  
Fabio wrote >>

here is my code ;-)

Thanks again

Sorry, you are right . I attch hereafter the indicator that i call

Files:
Ray
2646
Ray  
LSMA_index0=iCustom(NULL,0,"LSMA in Color",34,1500,0,0);
Please attach "LSMA in Color.mq4"