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
  #851 (permalink)  
Old 11-12-2007, 05:34 PM
Senior Member
 
Join Date: Feb 2006
Posts: 559
Michel is on a distinguished road
Quote:
Originally Posted by Sadly View Post
How do I express the following in MQL:-

if(boolean_condition_is_true AND (this_is_true OR that_is_true))

That is to say if boolean_condition is true AND (either this_is_true OR that_is_true) THEN do_something.

Anyone?
if(b1 && (b2 || b3))
{
do_something
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #852 (permalink)  
Old 11-13-2007, 02:08 PM
Sadly's Avatar
Senior Member
 
Join Date: Nov 2006
Posts: 260
Sadly is on a distinguished road
Thank you Michel. Using what you've suggested A *= + A does indeed give a positive sign ie: changes -A to +A.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #853 (permalink)  
Old 11-13-2007, 02:09 PM
Sadly's Avatar
Senior Member
 
Join Date: Nov 2006
Posts: 260
Sadly is on a distinguished road
Quote:
Originally Posted by Michel View Post
if(b1 && (b2 || b3))
{
do_something
}

Here;s what I am doing ...

Code:
	  if(Alarm_Reset && (stepSignalBuffer[shift] < Lwr_level || stepSignalBuffer[shift] > Upr_level ))
	  {
	  if(stepSignalBuffer[shift] < Lwr_level)
	     {
	     PlaySound("twank.wav");
	     }
	     else 
	     {
	     PlaySound("tick.wav"); 
	     }
	     
	  Alarm_Reset = false;
	  }
	  else
	  {
	  Alarm_Reset = true;
	  }
	  }
That is, if the alarm has been reset (to true) and either signalbuffer < lwr_level or signalbuffer > upr_level

Play one sound if the signalbuffer is below the lower level or another sound if above the upper level. Set the alarm to false (don't want another alarm going off if it's already the done.

else

Reset the alarm (ie: signalbuffer is outside of the lower_level and the upper_level)

Unfortunately that's not what's happening but at least I know that the code is correct and it's probably down to the logic.

Thank you again Michel.

EDIT: I've just commented stepSignalBuffer[shift] and it's value is always ZERO! I feel such an idiot.

Last edited by Sadly; 11-13-2007 at 02:47 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #854 (permalink)  
Old 11-13-2007, 05:51 PM
Senior Member
 
Join Date: Feb 2006
Posts: 559
Michel is on a distinguished road
Quote:
Originally Posted by Sadly View Post
Thank you Michel. Using what you've suggested A *= + A does indeed give a positive sign ie: changes -A to +A.
No, this is wrong, I said: A *= -1; not A *= +A;
This flipflop the sign; but if you need to have a positive number, use the MathAbs() function : A = MathAbs(A); Wathever is A , it will become positif.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #855 (permalink)  
Old 11-14-2007, 06:36 AM
BornToWin's Avatar
Junior Member
 
Join Date: Nov 2007
Posts: 26
BornToWin is on a distinguished road
Weekend test code

Hi guru,

Are there any server can feed price to give us chance test our code at Saturday and Sunday ?

I mean if there possible to make simulator server to give chance to test at weekend ?

This idea come because of :
1. While at workdays, we are seriously to watch our chart,
at that time, can't seriously type code.
2. We have more time at weekend, then we can seriously test our code atm.

Maybe some one can give me information about this idea ?

Best regards,

BornToWin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #856 (permalink)  
Old 11-14-2007, 08:17 AM
Sadly's Avatar
Senior Member
 
Join Date: Nov 2006
Posts: 260
Sadly is on a distinguished road
Quote:
Originally Posted by Michel View Post
No, this is wrong, I said: A *= -1; not A *= +A;
This flipflop the sign; but if you need to have a positive number, use the MathAbs() function : A = MathAbs(A); Wathever is A , it will become positif.
I was after trying t flipflip the sign which appeared to work. I tired the MathsAbs() function too and indeed the number is positive.

Thank you Michel, you have been a great help to me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #857 (permalink)  
Old 11-16-2007, 01:14 AM
Senior Member
 
Join Date: May 2007
Posts: 118
aurorau is on a distinguished road
Quote:
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- the last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- main loop
for(int i=0; i<limit; i++)
{
//---- ma_shift set to 0 because SetIndexShift called abowe
ExtBlueBuffer[i]=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i) ;
ExtRedBuffer[i]=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i );
ExtLimeBuffer[i]=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i) ;
}
//---- done
return(0);
}
Hi coders,

I try to go thorugh some MQL4 functions and bumped into this sample code as above. Could someone kindly explain:
1.)what's the reason of using "limit" variable there?
2.)I tried to run the sample code, which always returns value 2, what's the purpose of the "limit" value 2 in the for loop,
3.)which position bars does this for loop working on?

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #858 (permalink)  
Old 11-16-2007, 08:33 PM
Member
 
Join Date: May 2007
Posts: 40
derekz is on a distinguished road
search a simple ea

hi ... i search this simple ea

daily breakout EA with trailing stop and profit lock function.

Exist?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #859 (permalink)  
Old 11-17-2007, 04:53 AM
Senior Member
 
Join Date: Oct 2007
Posts: 224
Dave137 is on a distinguished road
Smile #property indicator question

What is the statement to code #property indicator as a line versus a dash (default)??

Simple question, but unknown answer at present!

Dave

Appreciate you answering this for me!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #860 (permalink)  
Old 11-17-2007, 09:48 AM
Junior Member
 
Join Date: Oct 2005
Posts: 12
postfin is on a distinguished road
icustom ! indicator -> ea

good morning, is a beginner of the language mq4, I would appreciate a help, I in advance thank!

the indicator has two variables:

bool TurnedUp = false
bool TurnedDown = false

how to use the function icustom in the EA, to read the values of TurnedUp and TurnedDown?


iCustom(Symbol(),"postfin",0,TurnedUp,0,0,0); ....
iCustom(Symbol(),"postfin",0,TurnedDown,0,0,0);


.....my probations, not working, possible because it deals with "bool" ??

part EA and error ..

//+------------------------------------------------------------------+
//| EXPERT BASIC CALCULATION |
//| START HERE |
//+------------------------------------------------------------------+


iCustom(Symbol(),"postfin",0,TurnedUp,0,0,0);
iCustom(Symbol(),"postfin",0,TurnedDown,0,0,0);

//EnterLong = TurnedUp;
// EnterShort = TurnedDown;




// EnterLong = true;
// if( TurnedUp == true ) EnterLong== true;
// EnterShort = TurnedDown;
//}
//if(icustom(Symbol(), "postfin","TurnedUp",0,0) == True && EnterLong== 1 )
//{



//+------------------------------------------------------------------+
//| EXPERT BASIC CALCULATION |
//| END HERE |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| YOU SHOULD NOT HAVE TO MODIFY ANYTHING BELOW THIS BOX |
//+------------------------------------------------------------------+

// ENTER LONG CONDITION
if(EnterLong == true && CountLongs(MagicNumber)== 0)
{
Attached Files
File Type: mq4 Patrick's Expert Template.mq4 (14.6 KB, 11 views)
File Type: mq4 BBANDS~1.MQ4 (5.7 KB, 5 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
histogram, forex, ZUP_v1.mq4

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 Off
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 10:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 12:46 PM


All times are GMT. The time now is 06:25 AM.



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