order repeat? - page 2

 

very silly of me i just realised it actually quite simple actually lol... im using this code and its working to a certain extent...

 if (OrdersTotal()>10)
      {
      Alert("Open Orders");
      }
      
   if (OrdersTotal()<10)
      {
now for the bigger question. so far so good. it opens a max of 10 trades, however... its opening more than one trade at the same position. how do i make it open one position per ASK or BID price that ive set already and not put another position there until that position has taken a SL or TP? i think one option would be to have an orders total for every single position, but that would really slow down the EA and most likely crash MT4, which btw i have managed todo over 20 times. :)
 

Still not sure what your end result is so I'm guessing a bit...

The OrdersTotal() is simply a count of orders at the moment the script gets to that line. It will execute whatever is in the block if it is true. If one of your orders is triggered and then closes, and you have 9 orders left, this code, if run again would then open a further 10 orders...


To set up the 10 orders, you could use a loop and increment the entry price by a set amount up to a defined upper / lower limit.

https://book.mql4.com/operators/for


or you could manually set variables for each entry price and then have an order send for each entry price variable.

https://book.mql4.com/trading/orders



Is this grid / anti grid trading your trying to do? If so, there is some interesting stuff from 7bit here.

http://sites.google.com/site/prof7bit/snowball

With some very neat code at the end which is perhaps what your trying to achieve.


Hope that helps

V

 
thank youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu soooooooooo much!
 
nayef #:
thank youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu soooooooooo much!
Hello...I've been trying to write a code that I guess is similar to yours but I need it to repeat a given order till a specific  reached market price .Can you please help me ?