Tutorial - Capture Modes
Tutorial - Capture Modes
Some capture methods require a Mid Point value that is supplied as an additional setting to the Color Indexes.
For example, if an indicator is signalling buy if greater than 50 and sell if less than 50 then the Mid Point value
should be set to 50.
Another setting that can be important to capture is Null Value. Null value is the value a color index buffer has
when the color is not being shown. Usually, it's fine to keep this set to AUTO. Auto will handle when the null
value is either 0 or special constant called EMPTY_VALUE (this is the official MetaTrader way of not showing a
color). Occasionally, though, an indicator developer may chose to use something like -1, in which case Null
Value would have to be set to -1 instead of AUTO.
If two color indexes are specified then will regard as buy signal if first color index is present (not null) or sell if
second color index is present. Color indexes need to be comma separated, e.g. 0,1 will signal buy if color index
0 is not null or sell if color index 1 is not null. This works for line color changes, histogram color changes and for
dots/arrows and the like, which is display used color index buffers. Note, some indicators use chart objects for
displaying arrows. This will show up in color index helper tool and will need something like OBJ:Arrow mentioned
in our library.
Some indicators may have multiple pairs of buy/sell color indexes then need to be checked. This can achieved
by simply listing them in pairs comma separated, e.g. buy1,sell1,buy2,sell2 etc. In this case, by default, will
check all supplied color indexes are not null for a given direction to be signalled. However, can set Mid Point to
number required for given direction if don't need all of them.
In MetaTrader 5 is quite common to see where a single color index gives buy/sell indication by say being value 1
for buy and value 2 for sell. In this situation supply the color index that gives the value and set Mid Point to the
buy:sell value, e.g. 1:2. If other values also give buy and sell then can supply these by comma separated, e.g.
if 1 or 3 is buy and 2 or 4 is sell then can set Mid Point to 1,3:2,4
Finally, can use ~ before Mid Point value to check color index before supplied one is not null. This can be useful
for MetaTrader 5 where (say) color index 0 is giving the price and index 1 is giving the color value, so want to
look at color given by index 1 but also check index 0 is valid (not null).
Indicators that give buy/sell by line crossing particular value can also be handled by DefaultBuySell. Just need to
supply the color index that gives then value and in Mid Point setting supply the value that gives the buy/sell
threshold, e.g. 0 or 50. So, if mid point 50 is supplied then buy will be when color index buffer is giving a value
above 50 and sell is when below 50.
For oversold/overbought you can supply this in the Mid Point setting as (say) 80/20 which will signal buy when
color index goes above 80 and sell when goes below for 20, e.g. for a breakout strategy. If supply 20/80 then
will signal buy will below 20 and signal sell when above 80, e.g for a reversal strategy.
Simply supply the color index buffers that give the values that are crossing each other, comma separated. The
line that is moving faster should be supplied second. For example, if a red line (color index 4) crossing a slower
yellow line (color index 5) then supply 5,4 for the color indexes setting - will give buy when red above yellow
and visa versa for sell.
If interested not just that the lines have crossed but also by how much then can set this in the Mid Point box. If
the difference between the value of the lines is greater than Mid Point then will signal. If wish to supply this
value in pips then add the letter p, e.g. setting Mid Point to 10p will require the lines to be separated by more
than 10 pips for signal.
Note, the indicators don't necessarily have to show two lines. If had histogram crossing a line then CrossBuySell
capture method will work as well, as the histogram is just represented by a color index buffer also.
A special color index buffer of -1 presents price. So, if interested in price crossing a line (say given by color
index 0) then color indexes needs to be set to 0,-1. If you are interested in candle close price crossing then the
Shift setting, which is also present when capturing indicators, should be set to 1 (closed candle), rather then 0
(live candle - current market price). Note, if interested in Heiken-Ashi close crossing then set color index to -2
instead of -1.
If interested in a line crossing upper and lower bands then three color indexes can be supplied to achieve that.
Supply the upper band color index followed by lower band index and then the index that gives the line that is
doing the crossing, again comma separated. Will normally signal buy when line crosses upper band and sell if
crosses lower band, e.g. break out strategy. If interested reversal strategy, e.g. signal sell when line crosses
upper band then set Mid Point to !. If interested in price crossing upper/lower bands then supply -1 as the color
index buffer to represent price.
If interested on checking not just lines have crossed but the crossed line has also reached a certain value then
can set this can be achieved by placing a tilde before the value in the Mid Point setting. For example, if
interested if green line crossed red for buy and that green value is above 15 then set the Color Indexes to the
green followed by red index and set the Mid Point to ~15. Note, for sell will check red crossed green and red
value is above 15.
If need to check a line or histogram that changes color for buy and sell and also that it has crossed another line
(color index) then this can be achieved by setting Color Indexes to the buy color followed by sell color followed
by line to have crossed and then set Mid Point to > to tell the system to check for this scenario. A good example
indicator of this is Waddah Attar Explosion.
Note, can also handle where buy and sell lines are always shown, so just want to check appropriate color (e.g.
greenBuy or redSell) has crossed a third color (e.g. white). An example indicator is MP Andean Oscillator.
Note, if need to do extra check that the third color index is not null then set Mid Point to ~ instead of >. If want
reversal i.e. signal sell rather than buy and visa versa then set Mid Point to !~
If not interested in buy/sell color being correct and just want to use whichever of the first two color indexes is
available (not null) then set Mid Point to ~~ or for reversal set to !~~
For indicators that have lines crossing each other and when need to check line is beyond those lines then this
can be achieved by setting the Color Index for the lines that are crossing followed by the color index of the line
that needs to be beyond this and then set Mid Point to ^. A good example of this is the Ichimoku indicator,
where two lines are used to show a 'cloud' and then a third line needs to be above this for buy or below for sell.
CrossBuySell With Four Color Indexes, e.g. Bollinger lines crossed other Bollinger
If interested in check two lines have crossed two other lines then this can be achieved by supplying the color
indexes for the slower upper and lower bands followed by the color indexes of the faster bands, i.e. supplying 4
color indexes comma separated. By default, i.e. Mid Point is blank, will check both lines have crossed with
reversal being achieved by setting Mid Point to !. However, if just interested in one line of faster bands have
crossed then set Mid Point to ^ or !^ for reversal.
CrossBuySell With Five Color Indexes, e.g. similar to 4 color indexes but also (say)
price crossed
If want something similar to the four color indexes of two bands crossing each other but also want to check
(say) the price has crossed also then this can be achieved by adding a 5th color index of -1 to represent price.
We added this for an indicator called 'Follow The Line PRO', which has three lines - a signal line crossing an
upper and lower line (band). However, those lines also changed color with green for buy and red for sell. This
unfortunately meant checking 6 color indexes, with 3 for green (buy) situation and another 3 for red (sell).
Those 6 color indexes should be supplied as buyUpper,buyLower,buySignal,sellUpper,sellLower,sellSignal.
Note, the maximum distance searched back is given by EA input Indi_maxBarsToSearch (number of
bars/candles). Can increase this if need be.
Note, the maximum distance searched back is given by EA input Indi_maxBarsToSearch (number of
bars/candles). Can increase this if need be.
If also want to check the extent of the slope that this too can be specified in the Mid Point setting, just put a /
before the value. If want to supply as pips rather than absolute value then add the letter p after the number.
This capture mode can be used with standard indicators, such as F:MovingAverage to check slope of the moving
average line, e.g. buy signal if line is sloping up.
If two color indexes are supplied then will check 2nd index is null for any trade signal. This is useful if a
secondary color index is being used (say) to display grey (no buy or sell), and need to check that this 'grey'
color is not shown.
OnCross also support two color indexes, where will use whichever is not null. This is useful to check Mid Point
against a line that changes color, via two color indexes, so will automatically use which color is visible (not null).
If two color indexes are supplied and Mid Point starts with <, e.g. <50, then will signal buy if first index goes
from above 50 to below 50 and signal sell if second color index does this. An example indicator is peak.mq4,
which has a green line that crosses below 15 for buy and a red line that crosses below 15 for sell, i.e. Mid Point
would be set to <15 and Color Index would be 0,1 to give green and red line, respectively.
Finally, OnCross supports three color indexes for line/price reaching upper or lower bands. Works similar to
CrossBuySell in this regard, except that it just signals when cross of bands happens. For reversal, i.e. when Mid
Point is set to !, it will signal when price/line crosses back under high band for sell and back above low band for
buy.
Note, if the value need to check changes color then can provide two color indexes in the Color Index setting,
separated by comma. The system will then automatically use the value from the index that is not null.
Finally, if want reversal signal when currency lines cross each other then set Mid Point to ! or if supplying a value
in Mid Point, i.e. for minimum difference, then use a negative value. Note, to do reversal on 6/3 Mid Point
setting then put 3/6 instead.