Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-09-2005, 05:07 PM
homicida homicida is offline
Junior Member
 
Join Date: Nov 2005
Posts: 14
homicida is on a distinguished road
iCustom function

hi there

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

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-10-2005, 12:42 AM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow The magic of iCustom() function.

Quote:
Originally Posted by homicida
hi there

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

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 homi,

Let’s assume we want to return the value of the indicator “Supertrend” of a specific bar using iCustom.

If we want to get the returned value of the Supertrend first line:
We can write this price of code inside start() function:

Code:
double val=iCustom(NULL, 0, "SuperTrend",0,0,pos);
Here val will hold the returned value of Supertrend indicator(first line).

If you want the returned value of the second line, we can write:

Code:
double val=iCustom(NULL, 0, "SuperTrend",0,1,pos);
This is a program which will use Supertrend indicator using iCustom:


Code:
#property copyright "Coders Guru"
#property link      "http://www.forex-tsd.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }


int start()
  {
   int    counted_bars=IndicatorCounted();
 
//---- check for possible errors
   if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if (counted_bars>0) counted_bars--;
   
   int pos=Bars-counted_bars;
   
     
 
   while(pos>=0)
     {
         ExtMapBuffer1[pos] = iCustom(NULL, 0, "SuperTrend",0,0,pos);
         ExtMapBuffer2[pos] = iCustom(NULL, 0, "SuperTrend",0,1,pos);

         pos--;
     }
     
     
     
//----
   return(0);
  }
//+------------------------------------------------------------------+
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-10-2005, 12:16 PM
homicida homicida is offline
Junior Member
 
Join Date: Nov 2005
Posts: 14
homicida is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-10-2005, 02:46 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Using iCustom to get the value of LSMA.

Quote:
Originally Posted by 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 LSMA using iCustom.

Note: I used LSMA in color (Lsma)

Code:
Alert(iCustom(NULL,0,"LSMA in Color",14,1500,0,0));
parmeter 1 :the symbol - NULL for 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 .
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-10-2005, 11:18 PM
homicida homicida is offline
Junior Member
 
Join Date: Nov 2005
Posts: 14
homicida is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-11-2005, 12:31 AM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Lightbulb 214783647 means there's an error!

Quote:
Originally Posted by 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.


PHP Code:
//+------------------------------------------------------------------+
//|                                                 iCustom_Demo.mq4 |
//|                                                    Coders' Guru. |
//|                                         http://www.forex-tsd.com |
//+------------------------------------------------------------------+
#property copyright "Coders Guru"
#property link      "http://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);
  }
//+------------------------------------------------------------------+ 
Attached Files
File Type: mq4 iCustom_Demo.mq4 (2.0 KB, 108 views)
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-11-2005, 11:22 PM
homicida homicida is offline
Junior Member
 
Join Date: Nov 2005
Posts: 14
homicida is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-11-2005, 11:35 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Unhappy Help me please!

Quote:
Originally Posted by 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)
Attached Images
File Type: jpg icustom.JPG (28.7 KB, 836 views)
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-12-2005, 12:50 AM
homicida homicida is offline
Junior Member
 
Join Date: Nov 2005
Posts: 14
homicida is on a distinguished road
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 11-12-2005, 12:55 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Unhappy

Quote:
Originally Posted by homicida
looks exactly like the results i got .

but what are that values?

greets homi
homi,

Line 1 Alert: is the value of the first buffer or LSMA (ExtMapBuffer1)
Line 2 Alert: is the value of the second buffer or LSMA (ExtMapBuffer2)
Line 3 Alert: is the value of the third buffer 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!
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
iCustom question .. yaniv_av Indicators - Metatrader 4 16 06-20-2008 04:37 PM
Easy iCustom and Alerts! codersguru Indicators - Metatrader 4 46 03-06-2008 04:25 AM
icustom maje Questions 24 12-05-2007 09:26 AM
I need help on creating an Icustom statement for my EA using this indicator as input! iscuba11 Expert Advisors - Metatrader 4 4 09-11-2006 07:18 PM
iCustom() problem billritz Indicators - Metatrader 4 5 08-23-2006 07:22 AM


All times are GMT. The time now is 02:36 AM.