ICustom function - page 5

 

Ok, thank you, I'm going to have to read and re-read this a few times to get it and yes I do want it to only signal when BOTH lines go Blue or Red at the same time. What would the 'place Buy trade' code be then?

 
matrixebiz:
Ok, thank you, I'm going to have to read and re-read this a few times to get it and yes I do want it to only signal when BOTH lines go Blue or Red at the same time. What would the 'place Buy trade' code be then?

The term referring to this indicator would simply be to mention the boolean variable, e.g. "both_go_blue" as a term in the buy condition, and "both_go_red" as a term in the sell condition. To illustrate it'd look like:

if ( .... && both_go_blue && ... ) ....

Note that I've made assumptions regarding the indicator, namely that the each indication buffer either has "empty value" or a constant value, which is the same for the blue and red indications on the same line. If that assumption is wrong, the actual code needs to be a trifle more convoluted, but we'll take that bus when it comes.

 

Ok, thank you for your clear explanations. I should be able to get it now One last thing, how would I code it if I didn't only want to compare the Current and Previous bars but wanted to say "if signals agree within that last 2-4 bars then still create the BUY condition" no more than 4 bars difference of when the indicators agree with each other? That would change the whole coding logic of the EA, correct?

EDIT: also, what did I do to create a condition where the EA triggered a BUY when One indicator signaled and the other indicator didn't signal but was at least in agreement and going in the same direction, BUY trade was still triggered ??

 
matrixebiz:
Ok, thank you for your clear explanations. I should be able to get it now

One last thing, how would I code it if I didn't only want to compare the Current and Previous bars but wanted to say "if signals agree within that last 2-4 bars then still create the BUY condition" no more than 4 bars difference of when the indicators agree with each other? That would change the whole coding logic of the EA, correct?

Right; you can go about this in two ways: 1) with a stateful EA, which holds on to past readings for comparing with present readings, or 2) read off the indicator further into its past. I think the second approach is better, as it then makes for a more robust EA that can be restarted without worries. And performance-wise the approaches are roughly the same.

For (2), you would, or I would, use a code snippet to scan backwards for the transitions, e.g. like (in principle):

bool top_went_blue_in_5 = false;

for ( int i = 1; i < 6; i++ ) {

if ( iCustom( ...., 0, i ) != EMPTY_VALUE ) continue; // is blue

if ( iCustom( ...., 1, i ) != EMPTY_VALUE ) {

top_went_blue_in_5 = ( i > 1 ); // Red at i, and blue after

break;

}

}[/PHP]

EDIT: also, what did I do to create a condition where the EA triggered a BUY when One indicator signaled and the other indicator didn't signal but was at least in agreement and going in the same direction, BUY trade was still triggered ??

You are getting fancy ...

It involves a) to represent the "right direction" concept, and then have a disjunctive condition of the form:

if ( ( buy_signal_A && buy_direction_B ) || ( buy_signal_B && buy_direction_A ) ) ...

or, you might prefer a nested condition structure:

[PHP]if ( buy_signal_A || buy_signal_B ) {

if ( buy_direction_A && buy_direction_B ) {

...

}

}
 

Sending you an email

 

Matrix, could you help me where I can get the MTF CI indi? do you know where I can find the Stealth indies? Thank You

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
 

Matrixebiz, and Ralph,

If you want to use VQ for an EA, it has a 2 bar lag. I strongly suggest you see my work posted here:

https://www.mql5.com/en/forum/general

see Post 319.

Ralph, can you help me with any of my problems? I will appreciate it!

One here: https://www.mql5.com/en/forum/173219

Post 702.

Another here:

https://www.mql5.com/en/forum/173060 Post 986

Thanks,

Big Be

 

Custom Indicators

a leasson on how to make a sexy good looking indicators

MQL4 Language for Newbies. Custom Indicators (Part 2) - MQL4 Articles

 

How to get multiple values from custom indicators ?

Hi folks,

I need to get values from custom indicator using iCustom function, but it seems that iCustom can only get one return value.

If a custom indicator return more than one value, how can i get a certain value I need ?

For example, a pivot indicator will return 2 or more values of Support, Resistance ... so, how can i get each value in an indicator ?

Thanks In Advance

 

Normally read the amount of buffers in the indicator. If there are two buffers, then using iCustom address each buffer.

Example:

double Buff0=iCustom(NULL, 0, "Pivot",13,0,0);

double Buff1=iCustom(NULL, 0, "Pivot",13,1,0);

double Buff2=iCustom(NULL, 0, "Pivot",13,2,0);

If there is only two buffers in the indicator, buffer 0 normal relates to the indicator color that represents going up. Buffer 1 normal relates to the indicator buffer going down.

Also, if the indicator graphs various colors, you can open the indicator setup screen box on the platform and select color setup. Sometimes the buffer and color will be listed in order so you can see what buffer (and color) does what. The order may list #1, which is buffer 0, color green(or lime). and then #2, which is buffer 1, color red, and so on.

Hope this helps!

Reason: