Jump to content

how to add mq4 code robot that was not magic number


Recommended Posts

Re: Please help me !

 

I've a robot that was not magic number. How to add this ? What's the mq4 code ?

 

At the beginning of your EA, add this line

 

int MagicNumber=112233; // any number you like

 

Then when you try to open trades, you must issue command like

 

ticket=OrderSend(Symbol(),BUY_OR_SELL,Lots,Price,Slippage,SL,TP,Comment,MagicNumber,OrderValidity,Color);

 

Now, each position opened has the magic number defined as above. So very time you refer to your position, you need to make sure it has the same MagicNumber by using

 

OrderMagicNumber()==MagicNumber as part of your expression.

 

eg . if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && (OrderMagicNumber()==MagicNumber))

 

Hope this helps...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...