Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


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
  #1 (permalink)  
Old 12-11-2006, 03:29 PM
pooshkin pooshkin is offline
Junior Member
 
Join Date: Oct 2006
Posts: 25
pooshkin is on a distinguished road
help me fix my ea

Hello
the idea is this :
only 1 trade per symbol allowed.
i use to do it like this:
int total = OrdersTotal();
if(total != 0 )
{
return(0); // dont trade
}
else
trade

but the problem is that i have other open position from manual trades\other EA
i need that the ea will open only 1 trade per symbol.

please help, thanks!
Attached Files
File Type: mq4 boo01.mq4 (5.2 KB, 12 views)

Last edited by pooshkin : 12-11-2006 at 03:32 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-11-2006, 04:57 PM
Maji Maji is offline
Senior Member
 
Join Date: Mar 2006
Posts: 787
Maji is on a distinguished road
Use MagicNumber to identify the trades placed by your EAs. Read up on Magicnumber by our gracious Coder's Guru and you will have a very good idea on what to do.

Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-11-2006, 05:13 PM
pooshkin pooshkin is offline
Junior Member
 
Join Date: Oct 2006
Posts: 25
pooshkin is on a distinguished road
where can i read about it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-11-2006, 05:27 PM
pooshkin pooshkin is offline
Junior Member
 
Join Date: Oct 2006
Posts: 25
pooshkin is on a distinguished road
ok, i have 666 as magic number to trades that open in the ea
is this code any good?
Code:
   if(OrderSelect(ticket, SELECT_BY_TICKET) == true) // open trades
   { 
   if(OrderMagicNumber() == 666){
   return(0);} // no trades
   }
else
trade
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-11-2006, 06:29 PM
Maji Maji is offline
Senior Member
 
Join Date: Mar 2006
Posts: 787
Maji is on a distinguished road
Again, do a search, I am sure you will find Coder's Guru's lessons. There is nothing better than learning how to do it right.

I am providing you with a subroutine that will count the number of trades for a given symbol and a given magicnumber. You can call that to find the number of trades, and if it is equal to or less than a certain number, you can place your trades.

PHP Code:
int CountTrades(int MagicNumber)
{
 
int count=0;
 
int trade;
 for(
trade=OrdersTotal()-1;trade>=0;trade--)
 {
  
OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
  
  if(
OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)
   continue;
   
  if(
OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)   
  if(
OrderType()==OP_BUY || OrderType()==OP_SELL)
   
count++;
 }
//for
 
return(count);

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 12-12-2006, 01:17 PM
pooshkin pooshkin is offline
Junior Member
 
Join Date: Oct 2006
Posts: 25
pooshkin is on a distinguished road
maji, thank you very much!!
I got it now.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

vB 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



All times are GMT. The time now is 08:55 AM.