please help me check code for checking ID account to use EA

 

hello, i want to check if account run ea must match with code then EA can run

for example code input ID 11111, i write code as below.
and then ID account if 12345 still run as normal. then I know below code is wrong. 

please help me correct it

long FixedAccountID = 11111;


int OnInit() 

{if (AccountInfoInteger(ACCOUNT_LOGIN) != FixedAccountID) 

    {

        Print("ID tài khoản không khớp. Robot sẽ dừng hoạt động.");

        ExpertRemove(); // Dừng robot

        return(INIT_FAILED); // Trả về lỗi khởi tạo

    }

 

When you post code please use the CODE button (Alt-S)!

Use the CODE button

 
Sergey Golubev #:

When you post code please use the CODE button (Alt-S)!

please help me revise with adding Magic_Number to open sell and open buy order
Adding SYMBOL and Magic Number to Position STOPLOSS AND TAKEPROFIT

//+------------------------------------------------------------------+
//|   position   stoploss  and  talke     profit                     |
//+------------------------------------------------------------------+

void stoploss_takeprofit()
{
   
    for (int i = 0; i < PositionsTotal(); i++)
    {
        ulong ticket = PositionGetTicket(i);
        double profit = PositionGetDouble(POSITION_PROFIT);
        
        if (profit>0 && profit > TakeProfit)
        {
            trade.PositionClose(ticket);
        }
        else if (profit < 0 && MathAbs(profit) > StopLoss)
        {
            trade.PositionClose(ticket);
        }
    }
}

//+------------------------------------------------------------------+
//|           SELL              POSITION                             |
//+------------------------------------------------------------------+


void sell_position(string line_name)
{
double bid=SymbolInfoDouble(_Symbol,SYMBOL_BID);
double line_price=ObjectGetDouble(0,line_name,OBJPROP_PRICE);
if(PositionsTotal()){
if(bid==line_price)
{
trade.Sell(lotsize,_Symbol,bid,0,0,"Galvin special EA");
}
else if((IsLastClosedOrderWinning()<0) && (bid==Distance_order*mypoint+line_price))
{
trade.Sell(lotsize* MultLot,_Symbol,bid,0,0,"Galvin special EA");
}
}
}
//+------------------------------------------------------------------+
//|           BUY               POSITION                             |
//+------------------------------------------------------------------+
void buy_position(string line_name)
{
double ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
double line_price=ObjectGetDouble(0,line_name,OBJPROP_PRICE);
if(PositionsTotal()<1){
if(ask==line_price)
{
trade.Buy(lotsize,_Symbol,ask,0,0,"Galvin special EA");
}
else if((IsLastClosedOrderWinning()<0) &&(ask==line_price+Distance_order*mypoint))
{
trade.Buy(lotsize*MultLot,_Symbol,ask,0,0,"Galvin special EA");
}

}
}