Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
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;
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.
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?
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:
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".
Last edited by ralph.ronnquist; 02-05-2008 at 12:35 AM.
Reason: revised variable names
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?
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:
PHP Code:
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.
Last edited by ralph.ronnquist; 02-05-2008 at 12:55 AM.
Reason: added a caveat
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 ??
Last edited by matrixebiz; 02-05-2008 at 01:14 AM.
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):
PHP Code:
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;
}
}
Quote:
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: