Page 1 of 2 12 LastLast
Results 1 to 10 of 11
 1 Attachment(s)    

Thread: How to add a magic number

  1. #1

    Default How to add a magic number

    thank you for your last replying.i runned two inpendent ea,which are same code, different parameter to different currency on one mt4,you know,and but they conflicted again,maybe my magic number is wrong,so how to write the code magic number.i am a new fish.hehe.
    Last edited by billsechen; 02-23-2009 at 14:55.

  2. #2
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by billsechen View Post
    thank you for your last replying.i runned two inpendent ea,which are same code, different parameter to different currency on one mt4,you know,and but they conflicted again,maybe my magic number is wrong,so how to write the code magic number.i am a new fish.hehe.
    Hi billsechen,

    After the "comment" into each OrderSend function :



    You replace the value 0 by this :

    Code:
    Magic
    Then search this line :
    Code:
    OrderSymbol()==Symbol()
    In-line after and for each occuration, you add that :

    Code:
     && OrderMagicNumber()==Magic
    Finally after the extern parameters, you add this :

    Code:
    extern int Magic=2009;

  3. #3

    Default

    How can I code to automatically use different Magic for different pairs? Thanks

    Rgds,
    Jdk

  4. #4

    Default

    Quote Originally Posted by jidonk View Post
    How can I code to automatically use different Magic for different pairs? Thanks

    Rgds,
    Jdk
    I'm not sure why you would need to do this.

    Can you explain a bit more?

  5. #5

    Default

    Quote Originally Posted by jidonk View Post
    How can I code to automatically use different Magic for different pairs? Thanks

    Rgds,
    Jdk
    automatic magic you can find in this ea
    Attached Files Attached Files

  6. #6

    Default

    Quote Originally Posted by jezzer1961 View Post
    I'm not sure why you would need to do this.

    Can you explain a bit more?
    I put my EA on many different pairs and I don't want to change the magic manually. If it coded on the EA would be much easier.

    Thanks & Regards Jezzer,
    Jdk

  7. #7

    Default

    Quote Originally Posted by przem81621 View Post
    automatic magic you can find in this ea
    Thank you very much

    Rgds
    Jdk

  8. #8

    Default

    Quote Originally Posted by jidonk View Post
    I put my EA on many different pairs and I don't want to change the magic manually. If it coded on the EA would be much easier.

    Thanks & Regards Jezzer,
    Jdk
    Jdk,

    I thought you might say that.

    You should, however, be able to use the same EA with the same magic number for multiple symbols without needing to change anything. Just as long as the orders are selected for processing by their symbol (which they should be).

    The only scenario where you would need a different magic number should be if you used the same EA on the same symbol but on different timeframes. Then you would need different magic numbers to ensure that the M5 instance didn't close trades from the M30 instance and vice-versa.

  9. #9

    Lightbulb

    Quote Originally Posted by jezzer1961 View Post
    Jdk,

    I thought you might say that.

    You should, however, be able to use the same EA with the same magic number for multiple symbols without needing to change anything. Just as long as the orders are selected for processing by their symbol (which they should be).

    The only scenario where you would need a different magic number should be if you used the same EA on the same symbol but on different timeframes. Then you would need different magic numbers to ensure that the M5 instance didn't close trades from the M30 instance and vice-versa.
    OK I got it now.
    As you mention it, I may try it on the different timeframe as well.

    Thanks for your help Jezzer. I have learn so many from you for the last view days. Hopefully I'll be a good coder as you are.

    Cheers
    Jdk

  10. #10
    Junior Member
    Join Date
    Nov 2009
    Posts
    3

    Default

    Quote Originally Posted by funyoo View Post
    After the "comment" into each OrderSend function :



    You replace the value 0 by this :

    Code:
    Magic
    What about the "0" in the ordermodify line?
    Code:
    OrderModify(OrderTicket(),OrderOpenPrice(),newSL,OrderTakeProfit(),0,Red);
    Should the 'Magic' ideally be added here as well?

Similar Threads

  1. MAGIC NUMBER
    By anchalsoni in forum MQL programming
    Replies: 0
    Last Post: 04-22-2013, 16:36
  2. I need to add magic number to this E.A
    By lifeplusbiz in forum MQL programming
    Replies: 0
    Last Post: 05-13-2011, 14:01
  3. magic number function missing
    By getting in forum Ideas for expert advisors
    Replies: 2
    Last Post: 11-03-2010, 02:18
  4. Limit number of trading per day
    By jidonk in forum MQL programming
    Replies: 2
    Last Post: 04-23-2009, 14:42

Tags for this Thread

add, automatic, change, color, how to, learn, magic, magic number, mt4, thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •