ICustom function - page 4

 
TheRumpledOne:
If it's "junk", then why post it at all?

I had a similar thought....

 

One question about iCustom.

Can you explain and give some examples regarding the Line and Shift variables with iCustom commands?

Thank you

 
matrixebiz:
One question about iCustom.

Can you explain and give some examples regarding the Line and Shift variables with iCustom commands?

Thank you

iCustom - MQL4 Documentation

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).

Use MODE to tell your indicator what buffer you want. The support resistance indicators may use buffer 0 ( MODE=0 ) for resistance and buffer 1 ( MODE=1 ) for support.

SHIFT says to use the value from Bar(SHIFT) of the indicator called by iCustom.

Does that help?

 
TheRumpledOne:
iCustom - MQL4 Documentation

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).

Use MODE to tell your indicator what buffer you want. The support resistance indicators may use buffer 0 ( MODE=0 ) for resistance and buffer 1 ( MODE=1 ) for support.

SHIFT says to use the value from Bar(SHIFT) of the indicator called by iCustom.

Does that help?

Ok, I get Shift, will have to do more reading about Mode.

Do you code? I have this indicator that I call from my EA but not sure how to set it up properly. See pic.

it just has two lines and when Blue changes and lines up with the other line, Long signal is generated (Same idea with Red)

Tried a few different codes like the one I used with the VQ indicator;

double Entry1 = iCustom(NULL, 0, "VQ", 24, 30....., 0, 1);

double Entry2 = iCustom(NULL, 0, "VQ", 24, 30....., 0, 2);

double Up2 = iCustom(NULL, 0, "VQ", 24, 30....., 1, 2);

double Down2 = iCustom(NULL, 0, "VQ", 24, 30....., 2, 2);

Just not trading right.

Thanks

Files:
ci.jpg  66 kb
 
matrixebiz:
Ok, I get Shift, will have to do more reading about Mode.

Do you code? I have this indicator that I call from my EA but not sure how to set it up properly. See pic.

it just has two lines and when Blue changes and lines up with the other line, Long signal is generated (Same idea with Red)

Tried a few different codes like the one I used with the VQ indicator;

double Entry1 = iCustom(NULL, 0, "VQ", 24, 30....., 0, 1);

double Entry2 = iCustom(NULL, 0, "VQ", 24, 30....., 0, 2);

double Up2 = iCustom(NULL, 0, "VQ", 24, 30....., 1, 2);

double Down2 = iCustom(NULL, 0, "VQ", 24, 30....., 2, 2);

Just not trading right.

Thanks

If you are referring to the bottom indicator, which seems to be named "#MTF CI", then I think that possibly that indicator has 4 buffers: one each for the two colors of each line. You can bring up the Data Window (ctrl-D) to see which buffers the indicators have, as well as their indexes (the MODE argument to the iCustom call).

 
matrixebiz:
Ok, I get Shift, will have to do more reading about Mode.

Do you code?

Thanks

I have been known to code an indicator or 2 ( HUNDREDS ) in my time....LOL!

 
ralph.ronnquist:
If you are referring to the bottom indicator, which seems to be named "#MTF CI", then I think that possibly that indicator has 4 buffers: one each for the two colors of each line. You can bring up the Data Window (ctrl-D) to see which buffers the indicators have, as well as their indexes (the MODE argument to the iCustom call).

Yes, your right, how do I iCustom these and create the Trade?

For the other two (QQEA 4 buffers and VQ 2 buffers) which are working I use this;

double Entry1 = iCustom(NULL, 0, "VQ", Crash,TimeFrame,Length,Method,Smoothing,Filter,RealTime,Steady,Colors,Alerts,EmailON,SignalPrice,CountBars, 0, 1);

double Entry2 = iCustom(NULL, 0, "VQ", Crash,TimeFrame,Length,Method,Smoothing,Filter,RealTime,Steady,Colors,Alerts,EmailON,SignalPrice,CountBars, 0, 2);

double Up2 = iCustom(NULL, 0, "VQ", Crash,TimeFrame,Length,Method,Smoothing,Filter,RealTime,Steady,Colors,Alerts,EmailON,SignalPrice,CountBars, 1, 2);

double Down2 = iCustom(NULL, 0, "VQ", Crash,TimeFrame,Length,Method,Smoothing,Filter,RealTime,Steady,Colors,Alerts,EmailON,SignalPrice,CountBars, 2, 2);

double qqe0_0=iCustom(Symbol(),0,"QQEA",QQEA_SF,RSI_Period,DARFACTOR,0,1);

double qqe0_1=iCustom(Symbol(),0,"QQEA",QQEA_SF,RSI_Period,DARFACTOR,0,2);

double qqe1_0=iCustom(Symbol(),0,"QQEA",QQEA_SF,RSI_Period,DARFACTOR,1,1);

double qqe1_1=iCustom(Symbol(),0,"QQEA",QQEA_SF,RSI_Period,DARFACTOR,1,2);

//Buy

qqe0_0>qqe1_0 && qqe0_1Entry2 && ....

Thanks Ralph

Files:
data.jpg  24 kb
 
matrixebiz:
Yes, your right, how do I iCustom these and create the Trade?

For the other two (QQEA 4 buffers and VQ 2 buffers) which are working I use this;

double Entry1 = iCustom(NULL, 0, "VQ", Crash,TimeFrame,Length,Method,Smoothing,Filter,RealTime,Steady,Colors,Alerts,EmailON,SignalPrice,CountBars, 0, 1);

double Entry2 = iCustom(NULL, 0, "VQ", Crash,TimeFrame,Length,Method,Smoothing,Filter,RealTime,Steady,Colors,Alerts,EmailON,SignalPrice,CountBars, 0, 2);

double Up2 = iCustom(NULL, 0, "VQ", Crash,TimeFrame,Length,Method,Smoothing,Filter,RealTime,Steady,Colors,Alerts,EmailON,SignalPrice,CountBars, 1, 2);

double Down2 = iCustom(NULL, 0, "VQ", Crash,TimeFrame,Length,Method,Smoothing,Filter,RealTime,Steady,Colors,Alerts,EmailON,SignalPrice,CountBars, 2, 2);

double qqe0_0=iCustom(Symbol(),0,"QQEA",QQEA_SF,RSI_Period,DARFACTOR,0,1);

double qqe0_1=iCustom(Symbol(),0,"QQEA",QQEA_SF,RSI_Period,DARFACTOR,0,2);

double qqe1_0=iCustom(Symbol(),0,"QQEA",QQEA_SF,RSI_Period,DARFACTOR,1,1);

double qqe1_1=iCustom(Symbol(),0,"QQEA",QQEA_SF,RSI_Period,DARFACTOR,1,2);

//Buy

qqe0_0>qqe1_0 && qqe0_1Entry2 && ....

Thanks Ralph

Generally, when you see an indicator line with multiple colors, then that is usually implemented by multiple buffers; one for each color. You can then work out the buffer indexes from the data window, where the top buffer has index 0, and increasing downwards. The buffer is plotted when it has a value (or if its a LINE drawing style, it needs two or more consecutive values to be plotted)

If you have the indicator source code, it's sometimes easier to peep into it, and learn the buffer indexes from the SetIndexBuffer function calls.

As a point on the side: an indicator may also plot "objects" onto the display, and those are not accessible via the iCustom call. Instead you'll need to know the "object name", and can the read off its properties.

Thus, you always need to be clear about which indicator buffer to read off, and use that index as the second last argument to iCustom.

For example, the use of the VQ indicator does not seem quite right, because (going by the source I've sighted), its buffers [1] and [2] are used for the green and red lines respectively, and there is never a case where they are both non-empty. I.e., "Up2==Down2" is always false, except when both are "empty", and that's when the VQ line is neither green nor red, but yellow.

Apart from that, I think you are doing things in the right way. One can discuss choice of variable names, of course, but that's academic. The way to go is to pick the values of interest using the iCustom call, then express the particular required value relationships in the trading conditions.

 
ralph.ronnquist:
Generally, when you see an indicator line with multiple colors, then that is usually implemented by multiple buffers; one for each color. You can then work out the buffer indexes from the data window, where the top buffer has index 0, and increasing downwards. The buffer is plotted when it has a value (or if its a LINE drawing style, it needs two or more consecutive values to be plotted)

If you have the indicator source code, it's sometimes easier to peep into it, and learn the buffer indexes from the SetIndexBuffer function calls.

As a point on the side: an indicator may also plot "objects" onto the display, and those are not accessible via the iCustom call. Instead you'll need to know the "object name", and can the read off its properties.

Thus, you always need to be clear about which indicator buffer to read off, and use that index as the second last argument to iCustom.

For example, the use of the VQ indicator does not seem quite right, because (going by the source I've sighted), its buffers [1] and [2] are used for the green and red lines respectively, and there is never a case where they are both non-empty. I.e., "Up2==Down2" is always false, except when both are "empty", and that's when the VQ line is neither green nor red, but yellow.

Apart from that, I think you are doing things in the right way. One can discuss choice of variable names, of course, but that's academic. The way to go is to pick the values of interest using the iCustom call, then express the particular required value relationships in the trading conditions.

Unfortunately I don't have the source for the three indicators I mentioned above. How would you write the code for these if I want them to check for a Buy or Sell condition ONLY at the precise moment they change color at the same time for each indicator ofcourse?

Thanks

 

Lack of source is not a problem. Let's focus on indicator window 2 in your image, which shows an indicator with 4 buffers. If you move the mouse left and right over the indicator, you can work out which buffer is used for which color.

Let me assume that the first buffer ([0]) is for the blue indication of the top line, the second buffer ([1]) is for the red indication of the top line, and likewise [2] and [3] are blue and red of the bottom line. You could then read off the indicator as follows:

double top_is_blue = iCustom( ..., 0, 1 );

double top_was_blue = iCustom( ..., 0, 2 );

double top_is_red = iCustom( ..., 1, 1 );

double top_was_red = iCustom( ..., 1, 2 );

double bot_is_blue = iCustom( ..., 2, 1 );

double bot_was_blue = iCustom( ..., 2, 2 );

double bot_is_red = iCustom( ..., 3, 1 );

double bot_was_red = iCustom( ..., 3, 2 );

[/PHP]

Then you can summarise them as follows:

[PHP]bool top_goes_blue = ( top_is_blue == top_was_red );

bool top_goes_red = ( top_is_red == top_was_blue );

bool bot_goes_blue = ( top_is_blue == top_was_red );

bool bot_goes_red = ( top_is_red == top_was_blue );

bool both_go_blue = ( top_goes_blue && bot_goes_blue );

bool both_go_red = ( top_goes_red && bot_goes_red );

How you do that depends on what you are looking for. Especially,

if you want to combine non-concurrent readings of the two lines, it might become more involved coding. For example, the boolean variable "both_go_blue" refers to concurrent readings of the two lines, and does not capture that "one line goes blue, and then other goes blue a little later".

Reason: