How to write the code to close positions

 

I have been having a lot of difficulty trying to write the code needed to close all of the positions I am in if a certain signal appears. Here is the code that I have within my method:       

string symbol = Symbol();

ulong deviation = ULONG_MAX;
      
if (PositionClose(symbol, deviation){
   Print("Position for symbol ", symbol, " closed successfully");
} else {
   Print("Error closing position for symbol ", symbol, ". Error code:", GetLastError());
}

I have been trying to fix this many times, but I cannot figure out a way how to make this work, and help would be greatly appreciated.