'Close all'/'Open' tools - page 13

matrixebiz
1631
matrixebiz  

EA to close all orders

I've seen EA/Scripts that close all open orders but I'm looking for and EA to close all open orders at a specified time. Anyone have an EA like this?

or can someone show me what code to change on an EA that opens orders to add code to close and order.

Thank you

EDIT: if anyone has an EA that Opens an order at a specified time then closes the order at another time can someone post here please.

raffinoso
108
raffinoso  

Only Open at specified time

Hi matrixbiz

this EA open trades at specified time, but not close at specified time.

I'm looking for the same code ( close all orders at specified time ) to built in exist EA's.

May be this help

matrixebiz:
I've seen EA/Scripts that close all open orders but I'm looking for and EA to close all open orders at a specified time. Anyone have an EA like this?

or can someone show me what code to change on an EA that opens orders to add code to close and order.

Thank you

EDIT: if anyone has an EA that Opens an order at a specified time then closes the order at another time can someone post here please.
Files:
raffinoso
108
raffinoso  

Hi Coders

I'm still learning by copy and past, because I'm a totally newbie.

I need a function thats close all open trades at specified time.

I have try something.

Don't have any errors with compile. But with strategytester I have follow message:

Testgenerator: unmatched data error(volume limit 719 at 2008.03.27 12:30 exeeded

Testgenerator: unmatched data error(volume limit 135 at 2008.03.27 23:00 exeeded

Black thats the original code. That works

Blue thats what i i like to insert

Thanks for any help

//+-----------------------------------------------------------------------+

//| Check for close order conditions |

//+-----------------------------------------------------------------------+

void CheckForCloseConditions()

{

int ticket;

for(int i=0;i<OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;

if(OrderType()==OP_BUY)

{

if (GetSignal()==1)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);

return(0);

}

}

if(OrderType()==OP_SELL)

{

if (GetSignal()==2)

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);

return(0);

}

}

}

return(0);

}

//+-----------------------------------------------------------------------+

//| Check for close order conditions trailing |

//+-----------------------------------------------------------------------+

void CheckForCloseConditionsTrailing()

{

int ticket;

for(int i=0;i<OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!=MAGICMA_Trailing || OrderSymbol()!=Symbol()) continue;

if(OrderType()==OP_BUY)

{

if (GetSignal()==1)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);

return(0);

}

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

if(OrderType()==OP_SELL)

{

if (GetSignal()==2)

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);

return(0);

}

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(Point*TrailingStop))

{

if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Magenta);

return(0);

}

}

}

}

}

return(0);

}

//+-----------------------------------------------------------------------+

//| Start function |

//+-----------------------------------------------------------------------+

int start()

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//Close Open Orders by Time

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

if (UseCloseTime){

if (!(Hour()>=CloseTime && Hour()>=CloseTime)) {

Comment("Time for close trade has come !");

return(0);

} else Comment("");

}else Comment("");

{

int ticket;

for(int i=0;i<OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;

if(OrderType()==OP_BUY)

{

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);

return(0);

}

}

if(OrderType()==OP_SELL)

{

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);

return(0);

}

}

}

return(0);

}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//Close Open Trailing Orders by Time

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

if (UseCloseTime){

if (!(Hour()>=CloseTime && Hour()>=CloseTime)) {

Comment("Time for close trailing trade has come !");

return(0);

} else Comment("");

}else Comment("");

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) //break;

if(OrderMagicNumber()!=MAGICMA_Trailing || OrderSymbol()!=Symbol()) //continue;

if(OrderType()==OP_BUY)

{

// if (GetSignal()==1)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);

return(0);

}

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

if(OrderType()==OP_SELL)

{

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);

return(0);

}

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(Point*TrailingStop))

{

if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Magenta);

return(0);

}

}

}

}

}

return(0);

if(CalculateNumberOfOrders(Symbol())<1&&CalculateNumberOfOrdersTrailing(Symbol())<1)

CheckForOpenConditions();

else

{

CheckForCloseConditions();

CheckForCloseConditionsTrailing();

}

return(0);

}

matrixebiz
1631
matrixebiz  

How do you fix a "'CloseHour' - expression on global scope not allowed" error?

raffinoso
108
raffinoso  

Global variables?

hi matrixbiz

What's mean with "global scope"? The variables in begin of script to define the parameters of indicators ect?

See attached # 1EA_Test_Template. I need this to test function of scripts.

Let it run in strategytester and it works.

Open Ea with MetaEditor and activate the inactive script after int start()

Now compile and let it run in strategytester, the EA don't trade. See the error message in journal.

matrixebiz:
How do you fix a "'CloseHour' - expression on global scope not allowed" error?
Files:
BigBaloo
88
BigBaloo  

Scripts & Include file help

Dimicr:
They send orders very sure!

Do script & Include files need to be compiled?

If so, do they need the full works, or can they be treated the same as an exe file? (Down load/Close Metatrader/Re-open)

Thanks guys

BigBaloo
88
BigBaloo  

Help with this EA

Hi,

Any kind Coder like to add a Breakeven option to this Indicator?

Blessings, & kind thoughts always with you!

Thanks

Files:
Beno
1163
Beno  

I do not know the language that is on KimIV. site but I managed to find the right file to down load but when I compile it there is an error

'GetParent' - function is not defined C:\Program Files\Straighthold Trader\experts\e-CloseByPercentProfit.mq4 (180, 10)

Could some one please let him know or fix it if they have it

Linuxser
5921
Linuxser  
Sergey Golubev
Moderator
122849
Sergey Golubev  
Beno:
I do not know the language that is on KimIV. site but I managed to find the right file to down load but when I compile it there is an error

'GetParent' - function is not defined C:\Program Files\Straighthold Trader\experts\e-CloseByPercentProfit.mq4 (180, 10)

Could some one please let him know or fix it if they have it

Yes, the same with me.

May be it is the function which was removed from Metatrader? This EA was created in December 2007 so it is not old one ...

I have no idea sorry.