Limitation of open position ?

 

Hi,

I'm finishing my first EA based on MA cross (yes, one more...),

0 error, 0 alert,

it works but it opens all the positions it can till bankruptcy on the first signal

I want to be sure of the line to add to limit the action

- at the first tick of new bar

- at on one open position short or long

Thanks for your help

Lionel

 
leyoye1:

Hi,

I'm finishing my first EA based on MA cross (yes, one more...),

0 error, 0 alert,

it works but it opens all the positions it can till bankruptcy on the first signal

I want to be sure of the line to add to limit the action

- at the first tick of new bar

- at on one open position short or long

Thanks for your help

Lionel

make sure you specify a magic number in your order, and before checking your MA cross, do a check on the oper orders, if an order with your magic number is open, then exit the EA.

 
c0d3 wrote >>

make sure you specify a magic number in your order, and before checking your MA cross, do a check on the oper orders, if an order with your magic number is open, then exit the EA.

Thank you be-in-phase for your answer, you are right but I'm just looking for a function now.

cOd3 thank you too,

Could you precise me what's a magic number. I saw it often in all the others EA I red before but I cannot understand how it is used. and the MetaEditor explainations are not clear to me.

I will precise my question for other goodwill, I'm only looking for the function that will limit my EA to one open position, with an order sent only at first tick of the new bar after signal.

any sample is welcome as I now precisely what I'm looking for, my problem is to translate it in metaquote language

I'm sure there is a way to say

Maximim number of open position = 1

and

start trade at the first tick of new bar after signal

Lionel

Reason: