.: I need help again - IMPORTANT, NOT RESOLVED PROBLEM:. How to modify, lookup and close opened orders in MQL ?

 

I have the medium level in MQL programming but I would like to learn more in practice.


//||\\ Please do not reffer me to manuals and other topics. I have a specific issue which I would like to resolve. //||\\


For example we have 3 (three) opened orders:


[1st order1009]
Order=Sell
Symbol()=EUR/USD
OrderOpenPrice()=1.3755 //Bid
StopLoss=0 //on the interbanking carnet system
TakeProfit=0 //on the interbanking carnet system


[2nd order1010]

Order=Buy
Symbol()=EUR/CHF
OrderOpenPrice()=1.5510 //Ask
StopLoss=0 //on the interbanking carnet system
TakeProfit=0 //on the interbanking carnet system


[3rd order1011]
Order=Buy
Symbol()=USD/CAD
OrderOpenPrice()=1.1380 //Ask
StopLoss=0 //on the interbanking carnet system
TakeProfit=0 //on the interbanking carnet system



***** I would like write EA what will control current TakeProfit and StopLoss level for each opened order.

Expert Advisor should work as I described below for above axample opened orders: *****


[1st order1009]
Order=Sell

Symbol()=EUR/USD


If Ask of EURUSD <= OrderOpenPrice(1009)-20*Point

{ Modify order1009 and set StopLoss=(Ask-Current Spread+10*Point) }


If Bid of EURUSD >= OrderOpenPrice(1009)+20*Point

{ Close order1009 }




[2nd order1010]

Order=Buy
Symbol()=EUR/CHF

If Bid of EURCHF >= OrderOpenPrice(1010)+20*Point

{ Modify order1010 and set StopLoss=(Ask+Current Spread-10*Point) }


If Ask of EURCHF <= OrderOpenPrice(1010)-20*Point

{ Close order1010 }




[3rd order1011]

Order=Buy
Symbol()=USD/CAD

If Bid of USDCAD >= OrderOpenPrice(1011)+20*Point

{ Modify order1011 and set StopLoss=(Ask+Current Spread-10*Point) }


If Ask of USDCAD <= OrderOpenPrice(1011)-20*Point

{ Close order1011 }


My questions are:


1/. What variables should I define in MQL code to be able lookup opened orders and reffer to them? In this concrete case for those three opened orders?

2/. What code should I write in MQL code for proper modyfing and close opened orders? In this concrete case, for example for [2nd order1010]?

3/. What for is Sleep(5000) function and if should I use it in modyfing opened orders?

4/. Should I set RefreshRates() function before check each condition for modyfing/closing opened orders? Is it good idea?



Please for help. Thank you in advance.


Puncher

 

All positions, pending orders, and closed positions are available for lookup.

How many?

See OrdersTotal() and OrdersHistoryTotal()

How do I pick one to look at?

OrderSelect()

How do I see something, the stop loss, for example?

After selecting an order, OrderStopLoss() returns the stoploss

 
phy:

All positions, pending orders, and closed positions are available for lookup.

How many?

See OrdersTotal() and OrdersHistoryTotal()

How do I pick one to look at?

OrderSelect()

How do I see something, the stop loss, for example?

After selecting an order, OrderStopLoss() returns the stoploss

Ok, could you please reply me exactly on my four question what I have added not long ago above and send me the answer on my e-mail to bemowo@tlen.pl ?

I don't know how to use properly OrderSelect(), OrdersTotal() and OrderHistoryTotal() functions on mql code...

If you can I will be grateful to you...


Regards...

Reason: