Forex
Google
New signals service!

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

 
 
LinkBack Thread Tools
 
Old 02-04-2008, 02:56 PM
TheRumpledOne's Avatar
Banned
 
Join Date: Nov 2006
Posts: 802
TheRumpledOne is an unknown quantity at this point
Quote:
Originally Posted by matrixebiz View Post
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-04-2008, 10:31 PM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,174
matrixebiz is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist View Post
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;
Code:
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_1<=qqe1_1 && Up2==Down2 && Entry1>Entry2 && ....

Thanks Ralph
Attached Images
File Type: jpg data.JPG (23.5 KB, 234 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-04-2008, 11:30 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
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;
Code:
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_1<=qqe1_1 && Up2==Down2 && Entry1>Entry2 && ....

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-04-2008, 11:53 PM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,174
matrixebiz is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist View Post
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-05-2008, 12:32 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
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:
PHP Code:
double top_is_blue iCustom( ..., 0);
double top_was_blue iCustom( ..., 0);
double top_is_red    iCustom( ..., 1);
double top_was_red iCustom( ..., 1);
double bot_is_blue iCustom( ..., 2);
double bot_was_blue iCustom( ..., 2);
double bot_is_red    iCustom( ..., 3);
double bot_was_red iCustom( ..., 3); 
Then you can summarise them as follows:
PHP Code:
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".

Last edited by ralph.ronnquist; 02-05-2008 at 12:35 AM. Reason: revised variable names
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-05-2008, 12:39 AM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,174
matrixebiz is on a distinguished road
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-05-2008, 12:48 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-05-2008, 12:57 AM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,174
matrixebiz is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-05-2008, 01:51 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
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 16i++ ) {
    if ( 
iCustom( ...., 0) != EMPTY_VALUE ) continue; // is blue
    
if ( iCustom( ...., 1) != EMPTY_VALUE ) {
        
top_went_blue_in_5 = ( ); // 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:
PHP Code:
if ( ( buy_signal_A && buy_direction_B ) || ( buy_signal_B && buy_direction_A ) ) ... 
or, you might prefer a nested condition structure:
PHP Code:
if ( buy_signal_A || buy_signal_B ) {
    if ( 
buy_direction_A && buy_direction_B ) {
        ...
    }

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-05-2008, 01:52 AM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,174
matrixebiz is on a distinguished road
Sending you an email
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 

Bookmarks

Tags
icustom, icustom function
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy iCustom and Alerts! codersguru Indicators - Metatrader 4 50 09-18-2008 02:02 PM
iCustom question .. yaniv_av Indicators - Metatrader 4 16 06-20-2008 05:37 PM
icustom maje Questions 24 12-05-2007 10:26 AM
I need help on creating an Icustom statement for my EA using this indicator as input! iscuba11 Expert Advisors - Metatrader 4 4 09-11-2006 08:18 PM
iCustom() problem billritz Indicators - Metatrader 4 5 08-23-2006 08:22 AM


All times are GMT. The time now is 07:57 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.