iCustom question

 

Hello everyone,

I need to get some Resistance, Pivot and Support lines values from a Fibonacci indicator. I have to read and store R1, R2, R3, Pivot, S1, S2 and S3.

The values are calculated once per day (at midnight) and are static for the whole day.

It should be easy to use the iCustom, but I can't figure out how precisely.

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

Parameters:

symbol - Symbol the data of which should be used to calculate indicator. NULL means current symbol.

timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.

name - Custom indicator compiled program name.

... - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator.

mode - Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions.

shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

 

For example for Pivot I write double Pivot = iCustom (NULL, 0, "Fibonacci",..., 0, 0),

Where NULL - the current symbol

0 -the current timeframe

"Fibonacci" -the string name of the indicator

"..."- parameters, but not sure how to set them and if I need to at all

0 -mode, the 1st piece of info I want to grab from the Indicator. I think Pivot is the first one as it appears in the objects list of the Indicator

0 -I am grabbing data from the current bar (although, the Pivot line is the same for all bars in the day)

 

Am I doing it correctly? I am getting some rubbish results...

I appreciate your thoughts.

R

 

What extern variables does the Indicator use ?

What buffers does it use ?

 
Good questions. I wonder where I can find the answers. I got the Fibo indicator already compiled. All I can view is the objects which is R, P and S lines and values..I don't know about the inputs. Fibo uses the previous days lows and highs...This is all I know at the moment...
 
Put the Indicator on a chart, look at it's buffers using the data Window (Ctrl + D) . . . of course if it draws lines using objects then iCustom won't help you . . . but you can get at the Objects parameters easily enough. The Externs are the settings you can change in the Indictors Inputs.
 

I have checked thoroughly and there are no Indicator Inputs anywhere to be found. This is different to the standard Mt4 indicators like RSI, for example, where the input parms are in the RSI properties menu. All I can get to in the indicator I have is the Objects list and horizontal lines names (S1, S2, etc.)...

Is there a chance to still grab the prices at which the lines are drawn?

 
Yep, you use the Object functions to get them . . .
 
Cheers, Raptor. I will check it out. It looks like what I need.
 

I have tired ObjestGet on a script and it worked quite good. All R, P and S values got captured. However, it returns 0 values when being used in an EA..

Here is the script:

================================================

int init()
{
return(0);
}
//-------------------------------------------------------------------------------------------------------------------
int start()
{
double Pivot = ObjectGet("Piviot level", OBJPROP_PRICE1);
double R1 = ObjectGet("Resistance 1", OBJPROP_PRICE1);
double R2 = ObjectGet("Resistance 2", OBJPROP_PRICE1);
double R3 = ObjectGet("Resistance 3", OBJPROP_PRICE1);
double S1 = ObjectGet("Support 1", OBJPROP_PRICE1);
double S2 = ObjectGet("Support 2", OBJPROP_PRICE1);
double S3 = ObjectGet("Support 3", OBJPROP_PRICE1);
Print ("Pivot is ", Pivot);
Print ("Resistance 1 is ", R1);
Print ("Resistance 2 is ", R2);
Print ("Resistance 3 is ", R3);
Print ("Support 1 is ", S1);
Print ("Support 2 is ", S2);
Print ("Support 3 ", S3);

return(0);
}

=====================================

I have plugged in this code in the start function, but helas...What could be the issue?

Another thing. Can I use this code in the init function?

Appreciating your help.

R

 
I don't see why there should be any difference between this code working in a script and an EA, perhaps the Objects were re-drawing while you tried to get their properties . . . you can use ObjectFind first.
 
Remember the object names must be EXACT. Case, spacing, etc. Make sure.
 
Finally, I have found the error. It was a stupid one and I don't even want to say what it is ;o). But you, guys, rock!
Reason: