ICustom function

 

hi there

first i must say really lots of helpfull info on the board here its great:D

next my question

how do i get the indicatorresult (or other variable) as a returnvalue if i call it with icustom ?

i tryed to analyze the code of some other indicators for that part but... theres no difference (or i missed it ).

so how does it work?

greets homi:)

 
 

hi and sorry

tj for answering:)

oh you missunderstund me

its my crapy english ...sorry!

normally i know how to call a indicator with icustom(),

but when i try to call LSMA trendindicator then it gives me back the value "1" all the time ,no madder what the trend really is now it returns allways one value.... "1".

so i thought that the 1 it returns is some kind of errorcheck that returns true or false.

but i need to know what the trend is and have to add some code to the indicator that gives me back the trendvalue not the errorcheckvalue.

and my question above means :what code to add to the indicator to get the trendvalue instead of errorcheck value back when i call it with icustom().

greets homi

 

Using iCustom to get the value of LSMA.

homicida:
tj for answering:)

oh you missunderstund me

its my crapy english ...sorry!

normally i know how to call a indicator with icustom(),

but when i try to call LSMA trendindicator then it gives me back the value "1" all the time ,no madder what the trend really is now it returns allways one value.... "1".

so i thought that the 1 it returns is some kind of errorcheck that returns true or false.

but i need to know what the trend is and have to add some code to the indicator that gives me back the trendvalue not the errorcheckvalue.

and my question above means :what code to add to the indicator to get the trendvalue instead of errorcheck value back when i call it with icustom().

greets homi

Hi homi,

I didn't misunderstand you. I gave you working example of iCustom.

Anyway. this is a line of code which will get the value of LSMAusing iCustom.

Note: I used LSMA in color ()

Alert(iCustom(NULL,0,"LSMA in Color",14,1500,0,0));

parmeter 1 :the symbol - NULLfor current symbol.

parmeter 2 : time frame - 0 for current time frame.

parmeter 3 : indicator name - here it's "LSMA in Color".

parmeter 4 : this is a setting for LSMA - Rperiod= 14.

parmeter 5 : this is a setting for LSMA - Draw4HowLongg= 1500.

parmeter 6 : the line number (range from 0 to 7) - usually used 0.

parmeter 7 : the working bar - 0 for the current bar.

Please try this line of code and tell me .

 

hi

i tested it ,your code works well.....

but that dosent fix the problem^^

i got the returnvalue like you said but its allways the same value no madder what the trend really is its 214783647 all the time.

i searched the value in the indicatorcode there are 3 buffers and the buffer that holds the 214783647 is the trend not the value that stored in it

like

if buffer1 holds the 214783647 means trend up,other 2 buffers holds then something like 174...

if buffer2 holds the 214783647 means trend down,other 2 buffers holds then something like 174...

could that cause the problem?

greets homi

 

214783647 means there's an error!

homicida:
hi

i tested it ,your code works well.....

but that dosent fix the problem^^

i got the returnvalue like you said but its allways the same value no madder what the trend really is its 214783647 all the time.

i searched the value in the indicatorcode there are 3 buffers and the buffer that holds the 214783647 is the trend not the value that stored in it

like

if buffer1 holds the 214783647 means trend up,other 2 buffers holds then something like 174...

if buffer2 holds the 214783647 means trend down,other 2 buffers holds then something like 174...

could that cause the problem?

greets homi

Hi homi,

I think there's an error in your iCustom call.

Anyway, here is the code which will call iCustom of LSMA to return the value of its 3 lines.

Note 1: The values of the 3 lines are the same because LSMA is color indicator (if you want to know more ask me)

Note 2: 214783647 is an error. I included in the demo example some lines of code which will return the same error to make it clear for you.

//+------------------------------------------------------------------+

//| iCustom_Demo.mq4 |

//| Coders' Guru. |

//| https://www.forex-tsd.com |

//+------------------------------------------------------------------+

#property copyright "Coders Guru"

#property link "https://www.forex-tsd.com"

#property indicator_chart_window

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted();

//----

Alert("Line3 on LSMA is: " + iCustom(NULL,0,"LSMA in Color",14,1500,2,0));

Alert("Line1 on LSMA is: " + iCustom(NULL,0,"LSMA in Color",14,1500,0,0));

Alert("Line2 on LSMA is: " + iCustom(NULL,0,"LSMA in Color",14,1500,1,0));

//Some mis-typed iCustom calls which will return:

//Wrong LSMA parameter

Alert("This is an error " + iCustom(NULL,0,"LSMA in Color",0,1500,0,0));

//Wrong line number

Alert("This is an error " + iCustom(NULL,0,"LSMA in Color",14,1500,3,0));

//Wrong Bar number

Alert("This is an error " + iCustom(NULL,0,"LSMA in Color",14,1500,3,counted_bars));

//----

return(0);

}

//+------------------------------------------------------------------+
Files:
 

hi again:D

okay im defeated by the indicator lol:)

i cant get it to work like i want

you say its an colorindicator what does that mean?

and the most important thing is how do i get the current state of it?

i allways get only wired number from it that looks like a rounded version of the closeprice in all three lines ,even with your unmodified demo ( indicator and demo).

what am i missing ?

how do i convert the output in a simple "green" "red" "yellow" string?

greets

stressed homi

 

Help me please!

homicida:
okay im defeated by the indicator lol:)

i cant get it to work like i want

you say its an colorindicator what does that mean?

and the most important thing is how do i get the current state of it?

i allways get only wired number from it that looks like a rounded version of the closeprice in all three lines ,even with your unmodified demo ( indicator and demo).

what am i missing ?

how do i convert the output in a simple "green" "red" "yellow" string?

greets

stressed homi

Hi stressed homi

Did you try the demo and still getting wrong numbers?

Could you tell me the Alerts you've got? that's what I've got (2 minutes ago)

Files:
icustom.jpg  29 kb
 

looks exactly like the results i got .

but what are that values?

greets homi

p.s

do any other have the brplem that strategybuilder isnt updating the charts?

 
homicida:
looks exactly like the results i got .

but what are that values?

greets homi

homi,

Line 1 Alert: is the value of the firstbuffer or LSMA (ExtMapBuffer1)

Line 2 Alert: is the value of the secondbuffer or LSMA (ExtMapBuffer2)

Line 3 Alert: is the value of the thirdbuffer or LSMA (ExtMapBuffer3)

Then I wrote three iCustoms' calls with intentionally wrong parameters to show you what probably be wrong in your iCustom's call.

Could you tell me exactly what do you want to do? Maybe I can help!

 

oh the only thing i want is to call it und get the current trend back.

like "1" for up "2" for down and "3" for side.

thats whats im trying to get done.

cause your code works right.

i know know my main problem is the lack of knowledege about the indicator

so i cant interpret the returnvalues in the right way.

but i cant find some info on for it.

greets homi

Reason: