When Expert Run & Execute this code:
Example:
OrderClose(3432945,0.10,1.3445,1,CLR_NONE);
return(0);
this Form Show Again & Need 1 person to close order
How can i click close button of this form by code?!
I Wanna click close button by code at current point.
Is it probably because in Tools > Options > Expert Advisors you have selected "Allow live trading" AND "Ask manual confirmation" ?
Yes. Uncheck this option and confirmation won't appear.
it doesn't work its impossible
How can i close any order without this Dialog windows
I Wanna close position by code without any Human Plz Help me
With out this Window...
Disable "Ask manual confirmation" in the expert properties
1. MAKE A NEW SCRIPT AND ADD THE FOLLOWING CODE TO IT
2. SELECT THE CURRENTLY OPENED POSITION AND DOUBLE CLICK THE ABOVE SAVED SCRIPT, WHICH WILL APPEAR IN THE NAVIGATOR WINDOW (VIEW > NAVIGATOR)
3. THE SCRIPT WILL CONFIRM IF YOU REALLY WISH TO CLOSE THE SELECTED POSITION.
//+------------------------------------------------------------------+
//| close. mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net//"
#property show_confirm
//+------------------------------------------------------------------+
//| script "close first market order if it is first in the list" |
//+------------------------------------------------------------------+
int start()
{
bool result;
double price;
int cmd,error;
//----
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
{
cmd=OrderType();
//---- first order is buy or sell
if(cmd==OP_BUY || cmd==OP_SELL)
{
while(true)
{
if(cmd==OP_BUY) price=Bid;
else price=Ask;
result=OrderClose(OrderTicket(), OrderLots(), price, 3, CLR_NONE);
if(result!=TRUE) { error=GetLastError(); Print("LastError = ", error);
}
else error=0;
if(error==135) RefreshRates();
else break;
}
}
}
else Print( "Error when order select ", GetLastError());
//----
return(0);
}
//+------------------------------------------------------------------+
by this code u can click any Button in any location by SetCursorPosition
Example in C#:
[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
[Flags]
public enum MouseEventFlags
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
....
//Set cursor position
SetCursorPos(500, 480);
//Mouse Right Down and Mouse Right Up
mouse_event((uint)MouseEventFlags.LEFTDOWN, 0, 0, 0, 0);
mouse_event((uint)MouseEventFlags.LEFTUP, 0, 0, 0, 0);
---------------------------------------------------------------------
Note:
SetCursorPos(int X,int Y);
X: x of mouse Location for Click(in close button rectangle)
Y: Y of mouse Location for Click(in close button rectangle)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How can i close any order without this Dialog windows
I Wanna close position by code without any Human Plz Help me
With out this Window...