How would I enable my EA to send a notification only once to my iPhone when the else if (ClosePosition == false)
condition returns true (in other words, when my EA fails to close an EA-opened position). At the moment, it pings on every tick.
The ClosePosition
boolean for the OrderClose()
function returns true
when the EA successfully closes the position when the conditions specified are met. It returns ClosePosition == false
when the EA fails to close the position.
Here is my code so far
else if(ClosePosition == false)
{
int failedClosePosition = OrdersTotal()-1;
bool fail = OrderSelect(failedClosePosition,SELECT_BY_POS,MODE_TRADES);
if(fail == true)
{
SendNotification("Order Number #"+IntegerToString(OrderTicket(),10)+" has failed to close. Please refer to error code "+IntegerToString(GetLastError()));
}
}