ขอรบกวน Admin และ ท่านผู้รู้หน่อยครับ
คืออยากได้เสียงเตือนตอนมันปิดออเดอร์นะครับ
ขอความกรุณาด้วยครับ
//+------------------------------------------------------------------+
//| Exit Hedge.mq4 |
//| D_Diamond |
//|
http://expertfx.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "D_Diamond"
#property link "
http://expertfx.blogspot.com"
//---- input parameters
extern double Profit=60.0;
extern int Magic0=4875;
extern int Magic1=4875;
extern int Magic2=4875;
extern int Magic3=4875;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
double LastOpen,TotalProfit,FirstOpen;
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
TotalProfit=0;
LastOpen=0;
FirstOpen=0;
countOrder();
if ( TotalProfit >= Profit )
CloseOrder();
//----
Comment("TotalProfit = ",TotalProfit);
return(0);
}
//+------------------------------------------------------------------+
int countOrder()
{
int count;
int total = OrdersTotal();
for (int pos = 0; pos < total; pos++)
{
OrderSelect( pos, SELECT_BY_POS, MODE_TRADES );
if ( OrderMagicNumber() == Magic0 || OrderMagicNumber() == Magic1 || OrderMagicNumber() == Magic2 || OrderMagicNumber() == Magic3 )
{
count++;
LastOpen=OrderOpenPrice();
TotalProfit += OrderProfit() + OrderSwap() + OrderCommission();
if (count == 1) FirstOpen = OrderOpenPrice();
}
}
}
return(0);
//+------------------------------------------------------------------+
void CloseOrder() {
int l_ord_total_0 = OrdersTotal();
for (int l_ord_total_4 = l_ord_total_0; l_ord_total_4 >= 0; l_ord_total_4--) {
OrderSelect(l_ord_total_4, SELECT_BY_POS, MODE_TRADES);
if ( OrderMagicNumber() == Magic0 || OrderMagicNumber() == Magic1 || OrderMagicNumber() == Magic2 || OrderMagicNumber() == Magic3 )
{
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Blue);
else
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red);
}
}
}
//+------------------------------------------------------------------+