//+------------------------------------------------------------------+ //| ScanPositions.mqh | //| Copyright 2021, Nkondog Anselme Venceslas | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, Nkondog Anselme Venceslas" #property link "https://www.mql5.com" //Scan all positions to find the ones submitted by the EA //NOTE This function is defined as bool because we want to return true if it is successful and false if it fails bool ScanPositions() { //Scan all the orders, retrieving some of the details gTotalOpenOrders = OrdersTotal(); gTotalPositions = PositionsTotal(); gTotalBuyPositions = 0; gTotalSellPositions = 0; gTotalTransactions = gTotalOpenOrders+gTotalPositions; for(int i=0; igLastBarTraded || gLastBarTraded==NULL) gLastBarTraded=(datetime)PositionGetInteger(POSITION_TIME); } Print("Total positions ", gTotalPositions, " - Total buys ", gTotalBuyPositions, " - Total sells ", gTotalSellPositions); return true; }