Not logged in
Viewing 4 posts - 1 through 4 (of 4 total)
  • #235569 |
    Participant
    2 Posts

    Hi, This is my first EA, so I apologize for my probably simple question.

    I am working on an EA that based on certain conditions takes either 2 long, or 2 short trades each hour.

    I am getting the following message in the journal  –

    order with magic number xxxxx already exists, can not open another one!

    Suggestions…..

    Thanks

     

    #235574
    tomas262
    Administrator
    1826 Posts

    Hello,

    if you want to open 2 simultaneous longs you need to assign each order a different magic number. This way you will avoid conflict

    #235580
    Participant
    2 Posts

    Thanks, I understand and have done that, but the issue is the next hour, I want the ea to open another 2 trades, and the following hour another 2 trades, regardless of if the previous trades are open or closed. if each new trade requires a new magic number, how can i get the EA to generate or assign its own magic number?

    Thanks

    #235594
    tomas262
    Administrator
    1826 Posts

    Hello,

    you need to work with Hour[0] (under Time values) to achieve this

    As soon as you open a trade save Hour[0] to a new variable like firstTradeHour = Hour[0]

    Then setup a new condition: if (Hour[0] = firstTradeHour + 1) then open another trade

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.