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 Thread Tools Display Modes
  #11 (permalink)  
Old 11-05-2005, 05:28 PM
Alex.Piech.FinGeR's Avatar
Senior Member
 
Join Date: Oct 2005
Location: Germany
Posts: 305
Alex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud of
sorry im not understand
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 11-05-2005, 07:02 PM
Member
 
Join Date: Oct 2005
Posts: 34
yaniv_av is on a distinguished road
I'll try to explain myself :

Suppose I have 3 different systems:
system 1 works best on EUR/USD 1M chart.
system 2 works best on EUR/USD 5M chart.
system 3 works best on EUR/USD 1H chart.

Now I want my expert advisor to open 1 position per chart and no more. In other words, I want to open 1 position only for system 1, 1 position for system 2, and 1 to system 3.

The previous solution you wrote limit 1 position per symbol, and now I want to limit 1 position per chart type...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 11-06-2005, 12:20 PM
Alex.Piech.FinGeR's Avatar
Senior Member
 
Join Date: Oct 2005
Location: Germany
Posts: 305
Alex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud of
. In other words, I want to open 1 position only for system 1, 1 position for system 2, and 1 to system 3.

OK

then you work with MAGIC Number per system


Code:
#property copyright "system 1"
#property link	  ""
#define   MAGIC	01901

.
.
.

if ( ExistPosition() == False) {
OrderSend(Symbol(),op,Lots,pp,SLIPPAGE,ldStop,ldTake,lsComm,MAGIC,0,clOpen);   // MAGIC  =  system 1

}


// if  open 1 position only for system 1 MAGIC ?
bool ExistPosition() {
  bool Exist=False;
  for (int i=0; i<OrdersTotal(); i++) {
	if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
	  if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC)  Exist=True;
	}
  }
  return(Exist);
}

can you posting you systems ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 11-06-2005, 07:20 PM
Member
 
Join Date: Oct 2005
Posts: 34
yaniv_av is on a distinguished road
10x!

I don't have specific system. It was only an example.
I'm new to metaTrader and that was some basic question I had ...
As soon as I'll write something good' I'll upload it here for comments...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 03-22-2007, 11:57 AM
basza's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 141
basza is on a distinguished road
How to make ea trade once per candle?

I was wondering if there is a piece of code that I can add to an EA so that it only trades once per candle.

Thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 03-23-2007, 12:08 AM
Member
 
Join Date: Sep 2006
Posts: 68
ra300z is on a distinguished road
Quote:
Originally Posted by basza
I was wondering if there is a piece of code that I can add to an EA so that it only trades once per candle.

Thanks in advance
static datetime timeprev;


if(timeprev==Time[0]) {
return(0); //only execute on new bar
} else if (timeprev==0) {
timeprev=Time[0]; // do nothing if freshly added to chart
return(0);
} else {
timeprev=Time[0];
// bar processing here
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 03-23-2007, 12:35 AM
basza's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 141
basza is on a distinguished road
Quote:
Originally Posted by ra300z
static datetime timeprev;


if(timeprev==Time[0]) {
return(0); //only execute on new bar
} else if (timeprev==0) {
timeprev=Time[0]; // do nothing if freshly added to chart
return(0);
} else {
timeprev=Time[0];
// bar processing here
}
Thank you ra300z
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 05-29-2007, 05:21 AM
basza's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 141
basza is on a distinguished road
Display percentage target ?

Hello

I am trying to display a percentage target in the form of a comment within a ea.

I have this bit of code which displays the current balance as a comment:

"Percentage Target : " + AccountBalance()"\n"

At the start of the ea I have the following:

extern int ProfitPercentage=25;

Now what I want to do is : AccountBalance * ProfitPercentage and display the results. eg. $5675.69 * 25% = $1418.92 and display only $1418.69.

Thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 07-06-2007, 01:13 PM
Member
 
Join Date: Feb 2006
Location: malaysia
Posts: 44
dreamer is on a distinguished road
hi guyss....

1:how to make the EA to trade only one time persignal..( what i mean is the code)

for example ma cross EA... when the ma cross up and with target 20 pip it will closed but when the trend is continue it will try to open another trade since the fast ma still above slow ma.it only have to open another trade when the ma cross down.

fast ma > slow ma = need only one trade persignal

fast ma < slow ma = also need only one trade persignal

2:is there anyway to put time delay on the crossing? I only know pip seperation (whatever they call it) mean it will wait maybe 10-15 pip after the crossing the only open a trade.

just a newbie trying to learn mq4 language
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 07-06-2007, 01:48 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
one way would be to make the EA look at historical MA readings rather than the current ones. In principle it'd be:

PHP Code:
// Recognise past crossing (up or down)
if ( fastpast+) <= slowpast+) && fastpast ) > slowpast ) )
    
then cmd OP_BUY;
else if ( 
fastpast+) >= slowpast+) && fastpast ) < slowpast ) )
    
then cmd OP_SELL;
else return;
// If processing reaches this point, then a trade decision of either OP_BUY
// or OP_SELL has been made, due to recognising a supporting MA crossing
// at "past" number of bars in history.

// Limit to only one trade in a direction
static int last_trade = -1;
if ( 
last_trade == cmd ) return;
last_trade cmd;
// If processing reaches this point, then this processing is the first time
// that the supporting MA crossing is recognised. 
That would make a decision at the "past" number of bars following the bar where the crossing occurs, and only allow a trade the first time the crossing is detected.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
MT4 (Basic) Questions stepwise Metatrader 4 6 09-22-2008 02:22 AM
Basic Indicator Question waaustin Metatrader Programming 8 04-02-2008 02:54 PM
Need Help Understanding Basic MQL logic Emerald King Expert Advisors - Metatrader 4 7 02-27-2007 09:59 AM
Very basic coding help needed camisa Questions 1 05-08-2006 05:36 PM


All times are GMT. The time now is 02:07 PM.



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