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

Reply
 
LinkBack (2) Thread Tools Display Modes
  #1041 (permalink)  
Old 04-08-2008, 01:56 AM
Senior Member
 
Join Date: Oct 2007
Posts: 198
Dave137 is on a distinguished road
Question

What is an easy statement to check to see if 2 moving averages have crossed within 5 bars before the current bar?? Can anybody help me with this??

Dave


-OR-

How do you state 5 conditional statements?? If all 5 are acceptable, a buyvalue=1 is stated.

I do not know if this would work below??:
Can somebody comment on this as to whether it would work, if not, how should it be stated??

if(Condition1)
if(Condition2)
if(Condition3)
if(Condiition4)
if(Condition5)
{
buyvalue=1;
}

Dave

Last edited by Dave137; 04-08-2008 at 05:06 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1042 (permalink)  
Old 04-08-2008, 01:24 PM
Senior Member
 
Join Date: Feb 2006
Posts: 513
Michel is on a distinguished road
PHP Code:
if(Condition1)
if(
Condition2)
if(
Condition3)
if(
Condiition4)
if(
Condition5
{
buyvalue=1;

This is the most economical and fastest way to write multiconditional tests.
It's the fastest because if condition1 is not filled, condition 2, 3, ... are not evaluated, which is not the case if you put "&&" operator between them.
So begin with the most likely unfrequent condition.
So this will undoubtfully work.
Now, as you are often asking if something will work, the best is to try, its a good way to learn too.
Cheers.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1043 (permalink)  
Old 04-08-2008, 01:38 PM
Senior Member
 
Join Date: Feb 2006
Posts: 513
Michel is on a distinguished road
Quote:
Originally Posted by Dave137 View Post
What is an easy statement to check to see if 2 moving averages have crossed within 5 bars before the current bar?? Can anybody help me with this??
Dave
PHP Code:
ma1_0 iMA(....,0);
ma2_0 iMA(....,0);
ma1_5 iMA(....,5);
ma2_5 iMA(....,5);

if((
ma1_0 ma2_0) * (ma1_5 ma2_5) < 0cross true
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1044 (permalink)  
Old 04-11-2008, 10:39 AM
Junior Member
 
Join Date: Dec 2007
Posts: 13
amatrader is on a distinguished road
How do I...

Hi there,

Please can you show me if you will, how do I say:-

"if the previous position closed on candle "0" or candle "1", then do not open another position on that same candle." or, even if candle "0" meets the required conditions to open another position... if the previous position closed on that candle then prevent it from opening another position, wait for the conditions to be right again.

I can say it in english but I'm still a bit too new to mql4 it.

thanks

amatrader
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1045 (permalink)  
Old 04-11-2008, 11:36 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
You might use the following code snippet:
PHP Code:
bool last_order_closed_rather_recently false;
for ( 
int i OrdersHistoryTotal() - 1>= 0;i-- ) {
    if ( ! 
OrderSelectiSELECT_BY_POSMODE_HISTORY ) ) continue;
    if ( 
OrderCloseTime() >= Time] ) {
        
last_order_closed_rather_recently true;
        break;
    }

after which you have the bool variable "last_order_closed_rather_recently" telling whether there was an order closed after the opening of bar 1. Then somewhere you'd have:
PHP Code:
if ( last_order_closed_rather_recently ) return( ); 
before entering a new trade.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1046 (permalink)  
Old 04-11-2008, 04:29 PM
Junior Member
 
Join Date: Dec 2007
Posts: 13
amatrader is on a distinguished road
Smile

Thank you sir, much appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1047 (permalink)  
Old 04-16-2008, 11:37 AM
Senior Member
 
Join Date: Sep 2007
Location: Poland
Posts: 210
Pucio is on a distinguished road
Qestion for Coders

Hi

I wrote Alert but it only works when I open window with my indicator. It works only also when I jump beetwen charts windows, in other words when I jump between charts time levels. It seems that indicator can not count when whorks. How can I solve my problem ? Need help. Is it conected with Indicatorcounted ? Should I do something in parameter of Alert. How to do it ?

Should I use something like:

double

? = ObjectGetValueByShift(string name, int shift));

if (???????????)

Alert("Pattern on " + Symbol() + " " + Period());




Pucio

Last edited by Pucio; 04-16-2008 at 11:45 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1048 (permalink)  
Old 04-16-2008, 12:03 PM
Junior Member
 
Join Date: Jul 2006
Location: Spain
Posts: 18
Oidunno is on a distinguished road
Silly Question..

Anyone? Trying to create what must be the simplest indy of all time and screwing up..

Input: Last Tic Value of (1)Pair X and (2) Pair Y.
( both CDF "pairs" ..ie 3 letter symbols))

Output 1: Print onscreen X-Y
Output 2: Plot In Indicator window MA of X-Y..

.Dont ask...LoL
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1049 (permalink)  
Old 04-16-2008, 04:26 PM
Senior Member
 
Join Date: Sep 2007
Location: Poland
Posts: 210
Pucio is on a distinguished road
Alert once

Hi,

Please, could you write an example of the code where Alert is only once.

When an object shows up on the chart and you want to have Alert once.

Pucio
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1050 (permalink)  
Old 04-16-2008, 11:34 PM
Linuxser's Avatar
Moderator
 
Join Date: May 2006
Location: Helliconia (Winter)
Posts: 2,511
Blog Entries: 8
Linuxser has disabled reputation
Quote:
Originally Posted by Pucio View Post
Hi,

Please, could you write an example of the code where Alert is only once.

When an object shows up on the chart and you want to have Alert once.

Pucio
Maybe you could use this piece of code: How to alert only at candle close
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
histogram

Thread Tools
Display Modes

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 On
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
Posted By For Type Date
OzFx System:) - Page 639 This thread Refback 06-21-2008 09:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 11:46 AM


All times are GMT. The time now is 06:11 PM.



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