View Single Post
  #4 (permalink)  
Old 08-07-2006, 06:12 PM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 20,083
Blog Entries: 243
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Quote:
Originally Posted by rbowles
I did find some with the magicnumber. Can somebody give me a brief description of what that is and how it functions. Once I have that I think I can work with it.

Thanks,

Randy
My explanation is not good as I am not a coder.

But for example:

Code:
//Sell
   if (Order == SIGNAL_SELL ....

if(Total < 1) 
.....

Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
So every ticket it having magic number (some number let's say). Means that all the orders are opened with this number.
And then EA is trying to find the orders with the same numbers to modify, close with sl or with tp.

Code:
bool ExistPositions() {
	for (int i=0; i<OrdersTotal(); i++) {
		if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
			if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
				return(True);
I could not find EA without magic number in my computer. Even very old EAs without magic numbers as the settings are having it inside the code:

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-sl*Point,Ask+tp*Point,"qq-buy60",11603575,0,Blue);
}
Reply With Quote