+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
 1 Attachment(s)    

Thread: How to add a magic number

  1. #1
    Member
    Join Date
    Jan 2009
    Posts
    32

    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,178

    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
    Member
    Join Date
    Dec 2008
    Posts
    35

    Default

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

    Rgds,
    Jdk

  4. #4
    Member
    Join Date
    Jan 2009
    Posts
    151

    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?
    PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!

  5. #5
    Member
    Join Date
    Nov 2008
    Posts
    257

    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

  6. #6
    Member
    Join Date
    Dec 2008
    Posts
    35

    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
    Member
    Join Date
    Dec 2008
    Posts
    35

    Default

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

    Rgds
    Jdk

  8. #8
    Member
    Join Date
    Jan 2009
    Posts
    151

    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.
    PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!

  9. #9
    Member
    Join Date
    Dec 2008
    Posts
    35

    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?

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Limit number of trading per day
    By jidonk in forum MQL programming
    Replies: 2
    Last Post: 04-23-2009, 14:42

Posting Permissions

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