| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Close Orders From Shell Auto https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4146 |
Page 1 of 1 |
| Author: | DigitalCrypto [ Tue Mar 03, 2015 10:40 am ] |
| Post subject: | Close Orders From Shell Auto |
Hey guys, First of all I've not been coding in MQL for more than 2 weeks. So I am pretty sure I qualify as a newbie. Secondly I've been looking at example code all over the net and seeing great things but it wasn't until I google "Best EA template" that I came upon this fantastic website. I've been a long time lurker but this is my first time posting because I wanted to be a little smarter before looking dumb or asking a dumb question, which this may very well be, but I am going ahead and asking it anyway since I've been searching the forum and trying for hours without success to close this stupid order. I'm using the basic Shell Auto from Steve and all you great coders here (fantastic job!) And I've managed to create long positions based on my criteria to create a long entry with candle stops etc. But for the life of me I cannot figure out how to close an open order where the trade is going against me. The situation is simply this "If indicator indicates a long position take it. If indicator turns sour, close the open order" I've been back and forth through the code and I recall seeing if a Long or Short was taken that it won't look for trade opportunities because it is in one. And naturally that wouldn't make any logical sense. Also I tried following the CloseOrder on page 1 of the forum posting but I get an incorrect parameter count for CloseOrder(); On other EAs this is done like Code: Select all So this is what I basically have done: Code: Select all Code: Select all Now I have this condition: Code: Select all Could someone be kind enough to explain how to close an order without entering a new long or short position? I would be very greatful! Best regards, David |
|
| Author: | milanese [ Tue Mar 03, 2015 10:53 am ] |
| Post subject: | Close Orders From Shell Auto |
read there---> http://docs.mql4.com/trading/orderclose , how to use the OrderClose function a short code example from one of my EA's how to use the OrderClose: Code: Select all Tommaso |
|
| Author: | DigitalCrypto [ Tue Mar 03, 2015 11:17 am ] |
| Post subject: | Close Orders From Shell Auto |
Hello Tommaso! Thank you for the expert reply! I was able to close the order by RTFMing the official docs. I don't know why I wasn't getting it right there. Code: Select all bool LookForTradeClosure(int ticket) Is the only thing I see but I don't know if I want to be monkeying around in code that already works. If it ain't broken I don't need to fix it. Best regards, David |
|
| Author: | milanese [ Tue Mar 03, 2015 11:33 am ] |
| Post subject: | Close Orders From Shell Auto |
This you should call each tick so you embed in OnTick(), something like CheckOpenPositions(Symbol(),Magic): Code: Select all Tommaso |
|
| Author: | DigitalCrypto [ Tue Mar 03, 2015 12:08 pm ] |
| Post subject: | Close Orders From Shell Auto |
Tommaso, I don't know how to thank you. I knew there was something simple I was missing. OnTick() was it. I am still learning the MQL or CrapQL as Steve puts it. I have to smile at his frustration because I find myself frustrated sometimes too. I will give it a go and see how I make out. Again my deepest thanks! Best regards, David |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|