Download MetaTrader 5

coding help

To add comments, please log in or register
Ma1991Lak7
20
Ma1991Lak7  
The robot I work on opens multiple deals about the same price, I want to stop repeating trades from the same point. For example, if the price of 1.200 opens only one transaction regardless of its type, and continues until the condition is met again and opens one deal at the new price.
Question 2: I want to determine the maximum spread not exceeding 2 cents to open transactions, I wrote the condition as follows without benefit if (MarketInfo (Symbol), MODE_SPREAD) P> MaxSpread && MaxSpread! = 0) return; How this problem is resolved. Please help me quickly and thank you very much
Keith Watford
Moderator
8293
Keith Watford  

We can't help you if you don't show the relevant code

MarketInfo( _Symbol, MODE_SPREAD)

returns the spread in points, not pips (necessarily) and not a decimal.
ionone
293
ionone  

Question 1 : just a simple bool variable that you set to true when you open an order and to false when the order is closed.

whroeder1
17122
whroeder1  
ionone: just a simple bool variable that you set to true when you open an order and to false when the order is closed.
EAs must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage (GV+flush or files) of ticket numbers required.
ThanhTran
10
ThanhTran  

i think this code can help you ^^

To add comments, please log in or register