Push notifications not going through, what is wrong with attached function?

 

Good day, 

I want to be notified of any change in account balance so I made a function that is called on every tick and checks if there is any difference in account balance between consecutive ticks. 

The function is then suppose to send a push notification on mobile device but no notification is sent when I open random trades and close them so I cause a decrease in the account balance. 

See the code below. All variables are type double, and I have tested the push ID in tools>options>notifications to be working fine, even with the default trade notifications 

What am I doing wrong? or is there another simpler alternative? I do not want the default trade notifications because I am only interested in the change in account balance, at least for now

Thanks in advance for your help

//+------------------------------------------------------------------+
//| Account Balance Chnage                                           |
//| Sends a push notification for any change in the account balance  |
//+------------------------------------------------------------------+
void AccountBalanceChange()
{
   accountBalance = AccountBalance();
   if (AccountBalance() - accountBalance != 0) 
   {
      changeInAccountBal = AccountBalance() - accountBalance;
      percChangeInAccountBal = (changeInAccountBal/AccountBalance())*100; 
      if (changeInAccountBal > 0) SendNotification("Your account :"+AccountNumber()+" balance increased with: "+changeInAccountBal+", / :"+percChangeInAccountBal+"%");
      if (changeInAccountBal < 0) SendNotification("Your account :"+AccountNumber()+" balance decreased with: "+changeInAccountBal+", / :"+percChangeInAccountBal+"%");
      accountBalance = AccountBalance();
   }

}
 
   accountBalance = AccountBalance();
   if (AccountBalance() - accountBalance != 0) 

You make accountBalance to equal AccountBalance()

then check whether they are not equal.

That doesn't make sense.

 
Keith Watford:

You make accountBalance to equal AccountBalance()

then check whether they are not equal.

That doesn't make sense.

Thanks a lot Keith, I wrote ' accountBalance = AccountBalance();'  at the wrong place, now it's working fine

Reason: