So I added the last two lines (this is a snippet from the order management function)
if(OrderType()==0) // Type = Buy { if(Bid>=TakeProfitLevel) { RemoveObjects=true; OrderClose(OrderTicket(),Lots,TakeProfitLevel,Slippage,Green); if(OrdersTotal()!=0) Alert("Order ", OrderTicket(), " failed to close. Error:", GetLastError() ); }
Which resulted in a pop-up with error 129 (invalid price)
So I figured that I should've put 'Bid' or 'Ask' in the price-tab instead of 'TakeProfitLevel'
Thanks for pointing me in the right direction, but still letting me figure it out. I really learned some usefull stuff!
So I added the last two lines (this is a snippet from the order management function)
Which resulted in a pop-up with error 129 (invalid price)
So I figured that I should've put 'Bid' or 'Ask' in the price-tab instead of 'TakeProfitLevel'
Thanks for pointing me in the right direction, but still letting me figure it out. I really learned some usefull stuff!
with closing trades you can use instead of Bid or Ask also OrderClosePrice()
So I added the last two lines (this is a snippet from the order management function)
Which resulted in a pop-up with error 129 (invalid price)
So I figured that I should've put 'Bid' or 'Ask' in the price-tab instead of 'TakeProfitLevel'
Thanks for pointing me in the right direction, but still letting me figure it out. I really learned some usefull stuff!
You need to read this, actually read it and understand it, it's obvious from your code change that you didn't, you are still not checking the return value from the OrderClose() why would you check for an error if the OrderClose() has worked ?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hiya all,
So I had made this -for me - really handy EA. If you load it, you can chose from the four pending order types, and three lines are drawed on the screen: the Triggerline, TP and SL. As soon as the price gets triggered the order opens; the TP and SL can be changed realtime: The TP and SL-levels are determined from the height of the line (where they are on the y-axis).
Anyhow, I just switched brokers, but now my EA does not close orders anymore. The only difference with this broker, is that each symbol is followed by an 'm'. So EURUSDm instead of EURUSD, and USDJPYm instead of USdJPY, but this should't make a difference if I am correct. I do not know what it is, but maybe anyone of you is willing to help me. If so, I'd be really grateful!