Magic numbers

3 replies

jakehk

Subscriber, bbp_participant, community, 0 replies.

Visit profile

5 years ago #235569

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

 

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

5 years ago #235574

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

0

jakehk

Subscriber, bbp_participant, community, 0 replies.

Visit profile

5 years ago #235580

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

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

5 years ago #235594

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

0

Viewing 3 replies - 1 through 3 (of 3 total)