Download MetaTrader 5

Detect and Place Stop Orders when Price touch a level

To add comments, please log in or register
Trade like successful traders - subscribe to their signals!
noname2 2016.01.12 19:57 

So i have been thinking many days on this Problem and don't know how to fix it, maybe someone have Idee for algorithm, i will be very thankful

Basically it's a Grid system, at Start it will open 2 level above with predefine Increment and 2 level under . Let say A for above and U for under , we have A1 , A2, and U1 U2. If price touch level A1 i want it to place order in U area , that's valid for A2 too . Vice versa for U1 U2, Order will be placed in A area. So i wrote some code like this :

for (i=1 ; i<=2 ; i++)
   if(Ask >= InitialPrice+(i*Increment*Point))
      //Do something

   if(Bid<= InitialPrice+(i*Increment*Point)))
     //Do something

Now the Problem is that logic is true whenever the Price is above that level and Order will be placed continuously . Can you suggest me how to block it so i will be excute only once ? Thanks so much

Doerk Hilger
Doerk Hilger 2016.01.12 23:32  
Simply loop all orders and check which one exists already? Of course it sends unlimited orders this way, what did you expect? :D
To add comments, please log in or register