How I set the TP less than 5 pips? - page 2

 
ats:

orderclose at a price as script??? Or you mean manually?



I make EA doing it but it can also with script
 
Good idea! EA to close only one order and let the other orders open? Is it possible?
 
ats:
Good idea! EA to close only one order and let the other orders open? Is it possible?


it can it is just how do you open the trade it can with comment with magicnumber, if you make it that way an EA can recognize to close it or not to close it then there can't be a problem

 

I'm curious...

why are you using Excel to open your trades?

is it an EA in Excel? or just a system to open trades?

maybe you can have an EA inside MT4 to close your trades when you reached the 5pips. its simple and safer to do this inside MT4 instead of into Excel.

 

Is it correct? It should close one buy order or a sell order at a price! Thank you

 

Please use this to post code . . . it makes it easier to read.

 
extern double CloseforBuy=1.4;
extern double CloseforSell=1.3;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()

{
if(Bid>CloseforBuy)
{
for(int a=OrdersTotal()-1;a>=0;a--)
if(OrderSelect(a,SELECT_BY_POS, MODE_TRADES) )
//if(OrderSymbol()==Symbol())
OrderClose(OrderTicket(),OrderLots( ),OrderClosePrice(),1000,White);
Sleep(1);
//----

//----

}
if(Ask<CloseforSell)
{
for(int b=OrdersTotal()-1;b>=0;b--)
if(OrderSelect(b,SELECT_BY_POS, MODE_TRADES) )
//if(OrderSymbol()==Symbol())
OrderClose(OrderTicket(),OrderLots( ),OrderClosePrice(),1000,White);
Sleep(1);
//----

//----

}

return(0);
}
 
ats:

Is it correct? It should close one buy order or a sell order at a price! Thank you!

No . . .

Each of your conditional statements . . . .

if(Bid>CloseforBuy)

&

if(Ask<CloseforSell)

. . . . will allow the closing of ALL open orders regardless of symbol, Magic Number or type (Buy or Sell) . . . and once they are all closed there is a 1 milli second sleep.

 

Sleep was silly, I deleted! I know that it will close all open positions! I do not know how to programm it with the magic number to close one of the buys or one of the sells!

 
ats:

Sleep was silly, I deleted! I know that it will close all open positions! I do not know how to programm it with the magic number to close one of the buys or one of the sells!

You need to identify which Buy or Sell you want to close . . . you would use the Magic Number to differentiate between manually placed trades and trades placed by EAs . . . or to differentiate between trades placed on the same Symbol but different timeframes or to differentiate between trades placed by different EAs.